};
}
+ function getSelectedLink(editor) {
+ var selection = editor.getSelection();
+ var selectedElement = selection.getSelectedElement();
+ if (selectedElement && selectedElement.is('a')) {
+ return selectedElement;
+ }
+
+ var range = selection.getRanges(true)[0];
+
+ if (range) {
+ range.shrink(CKEDITOR.SHRINK_TEXT);
+ return editor.elementPath(range.getCommonAncestor()).contains('a', 1);
+ }
+ return null;
+ }
+
CKEDITOR.plugins.add('drupallink', {
icons: 'drupallink,drupalunlink',
hidpi: true,
range.selectNodeContents(text);
}
- var style = new CKEDITOR.style({ element: 'a', attributes: returnValues.attributes });
+ var style = new CKEDITOR.style({
+ element: 'a',
+ attributes: returnValues.attributes
+ });
style.type = CKEDITOR.STYLE_INLINE;
style.applyToRange(range);
range.select();
}
}),
exec: function exec(editor) {
- var style = new CKEDITOR.style({ element: 'a', type: CKEDITOR.STYLE_INLINE, alwaysRemoveElement: 1 });
+ var style = new CKEDITOR.style({
+ element: 'a',
+ type: CKEDITOR.STYLE_INLINE,
+ alwaysRemoveElement: 1
+ });
editor.removeStyle(style);
},
refresh: function refresh(editor, path) {
var menu = {};
if (anchor.getAttribute('href') && anchor.getChildCount()) {
- menu = { link: CKEDITOR.TRISTATE_OFF, unlink: CKEDITOR.TRISTATE_OFF };
+ menu = {
+ link: CKEDITOR.TRISTATE_OFF,
+ unlink: CKEDITOR.TRISTATE_OFF
+ };
}
return menu;
});
}
});
- function getSelectedLink(editor) {
- var selection = editor.getSelection();
- var selectedElement = selection.getSelectedElement();
- if (selectedElement && selectedElement.is('a')) {
- return selectedElement;
- }
-
- var range = selection.getRanges(true)[0];
-
- if (range) {
- range.shrink(CKEDITOR.SHRINK_TEXT);
- return editor.elementPath(range.getCommonAncestor()).contains('a', 1);
- }
- return null;
- }
-
CKEDITOR.plugins.drupallink = {
parseLinkAttributes: parseAttributes,
getLinkAttributes: getAttributes