Commit 7aab8b26 authored by anon's avatar anon

Fixed #1915086: Inserting link not working in IE9 and below when making text...

Fixed #1915086: Inserting link not working in IE9 and below when making text selection (with ckeditor 4)
parent 35cbe495
......@@ -134,13 +134,12 @@
if (!linkitCache.selectedElement) {
// We have not selected any link element so lets create a new one.
var ranges = selection.getRanges( true );
if (ranges.length == 1 && ranges[0].collapsed) {
var content = (Drupal.linkitCache.link_tmp_title) ? Drupal.linkitCache.link_tmp_title : data.path;
var text = new CKEDITOR.dom.text(content, editor.document);
ranges[0].insertNode(text);
ranges[0].selectNodeContents(text);
selection.selectRanges(ranges);
var range = selection.getRanges(1)[0];
if (range.collapsed) {
var content = (Drupal.settings.linkit.currentInstance.linkContent) ? Drupal.settings.linkit.currentInstance.linkContent : data.path;
var text = new CKEDITOR.dom.text(content , editor.document );
range.insertNode(text);
range.selectNodeContents(text);
}
// Delete all attributes that are empty.
......@@ -151,7 +150,8 @@
// Apply style.
var style = new CKEDITOR.style({element : 'a', attributes : data.attributes});
style.type = CKEDITOR.STYLE_INLINE;
style.apply(editor.document);
style.applyToRange(range);
range.select();
}
else {
// We are editing an existing link, so just overwrite the attributes.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment