Skip to content

Commit

Permalink
Fix for 523 - works better but doesn't work exactly the same as the '…
Browse files Browse the repository at this point in the history
…link' button
  • Loading branch information
JohnSmith-LT committed Jun 6, 2016
1 parent 7cec2b6 commit 58f390a
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion editor/js/vendor/ckeditor/plugins/xotlink/dialogs/xotlink.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,31 @@ if (!CKEDITOR.ui.dialog.button.prototype.toggle) {
}
}

//http://ckeditor.com/forums/CKEditor-3.x/getSelection-getNative-returns-object-Object
CKEDITOR.editor.prototype.getSelectedHtml = function()
{
var selection = this.getSelection();
if( selection )
{
var bookmarks = selection.createBookmarks(),
range = selection.getRanges()[ 0 ],
fragment = range.clone().cloneContents();

selection.selectBookmarks( bookmarks );

var retval = "",
childList = fragment.getChildren(),
childCount = childList.count();
for ( var i = 0; i < childCount; i++ )
{
var child = childList.getItem( i );
retval += ( child.getOuterHtml?
child.getOuterHtml() : child.getText() );
}
return retval;
}
};

// Our dialog definition.
CKEDITOR.dialog.add('xotlinkDialog', function(editor) {

Expand Down Expand Up @@ -83,7 +108,7 @@ CKEDITOR.dialog.add('xotlinkDialog', function(editor) {
// Create a new <a> element if it does not exist
if (!element || element.getName() != 'a') {
element = editor.document.createElement('a');
element.setHtml(selection.getSelectedText());
element.setHtml(editor.getSelectedHtml());
// Flag the insertion mode for later use
this.insertMode = true; // We've had to create a new <a> tag
}
Expand Down

0 comments on commit 58f390a

Please sign in to comment.