I think this is related to the fix from #831788: Allow inserting links without selecting text/element. After updating my links without selected text come out as <a href="internal:node/27" link_text="Insecticides for Indoor Use">internal:node/27</a>
Here is the "new" insertLink function
/linkit/editors/cheditor/plugin.js
function insertLink(params, editor) {
this.fakeObj = false;
var link_text = params.link_text;
delete params.link_text;
var selection = editor.getSelection(),
ranges = selection.getRanges(),
element = null;
// Fill in all the relevant fields if there's already one link selected.
if (ranges.length == 1) {
var rangeRoot = ranges[0].getCommonAncestor(true);
element = rangeRoot.getAscendant('a', true);
if(element && element.getAttribute('href')) {
selection.selectElement(element);
}
else if((element = rangeRoot.getAscendant('img', true)) && element.getAttribute('_cke_real_element_type') && element.getAttribute('_cke_real_element_type') == 'anchor') {
this.fakeObj = element;
element = editor.restoreRealElement(this.fakeObj);
selection.selectElement(this.fakeObj);
}
else
element = null;
}
// Record down the selected element in the dialog.
this._.selectedElement = element;
if ( !this._.selectedElement ) {
// Create element if current selection is collapsed.
var selection = editor.getSelection(), ranges = selection.getRanges();
if ( ranges.length == 1 && ranges[0].collapsed ) {
var text = new CKEDITOR.dom.text( link_text, editor.document );
ranges[0].insertNode( text );
ranges[0].selectNodeContents( text );
selection.selectRanges( ranges );
}
// Insert into editor
var style = new CKEDITOR.style( { element : 'a', attributes : params } );
style.type = CKEDITOR.STYLE_INLINE;
style.apply( editor.document );
}
else {
// We're only editing an existing link, so just overwrite the attributes.
var element = this._.selectedElement;
// IE BUG: Setting the name attribute to an existing link doesn't work.
// Must re-create the link from weired syntax to workaround.
if (CKEDITOR.env.ie && params.name != element.getAttribute('name')) {
var newElement = new CKEDITOR.dom.element('<a name="' + CKEDITOR.tools.htmlEncode( params.name ) + '">', editor.document);
selection = editor.getSelection();
element.moveChildren(newElement);
element.copyAttributes(newElement, { name : 1 });
newElement.replace(element);
element = newElement;
selection.selectElement(element);
}
var removeAttributes = ['target', '_cke_pa_onclick', '_cke_saved_href', 'onclick', 'title', 'id', 'class', 'rel', 'accesskey'];
// Remove all attributes so we can update them
element.removeAttributes(removeAttributes);
// Set params from form
element.setAttributes(params);
if (this.fakeObj) {
editor.createFakeElement(element, 'cke_anchor', 'anchor').replace(this.fakeObj);
}
delete this._.selectedElement;
}
}
Comments
Comment #1
sense-designsubscribing
Comment #2
njbooher commentedI think this is related to the fix from #831788: Allow inserting links without selecting text/element. After updating my links without selected text come out as
<a href="internal:node/27" link_text="Insecticides for Indoor Use">internal:node/27</a>Comment #3
anonnjbooher, that right. I will take a look at this.
Comment #4
anonI have commited a fix for this.
Its only like 3 lines changed.
Here is the "new" insertLink function
/linkit/editors/cheditor/plugin.js
Comment #5
sense-designworks like a charm