Skip to content

Commit

Permalink
Merge branch 't/9552'
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Nov 5, 2012
2 parents d8c53c1 + b1f343e commit 6dc63a1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
3 changes: 3 additions & 0 deletions core/selection.js
Expand Up @@ -571,12 +571,15 @@
* Select this range as the only one with {@link CKEDITOR.dom.selection#selectRanges}.
*
* @method
* @returns {CKEDITOR.dom.selection}
* @member CKEDITOR.dom.range
*/
CKEDITOR.dom.range.prototype.select = function() {
var sel = this.root instanceof CKEDITOR.editable ? this.root.editor.getSelection() : new CKEDITOR.dom.selection( this.root );

sel.selectRanges( [ this ] );

return sel;
};

/**
Expand Down
20 changes: 14 additions & 6 deletions plugins/clipboard/plugin.js
Expand Up @@ -708,15 +708,23 @@
// Temporarily move selection to the pastebin.
isEditingHost && pastebin.focus();
var range = new CKEDITOR.dom.range( pastebin );
range.setStartAt( pastebin, CKEDITOR.POSITION_AFTER_START );
range.setEndAt( pastebin, CKEDITOR.POSITION_BEFORE_END );
range.select();
range.selectNodeContents( pastebin );
var sel = range.select();

// If non-native paste is executed, IE will open security alert and blur editable.
// Editable will then lock selection inside itself and after accepting security alert
// this selection will be restored. We overwrite stored selection, so it's restored
// in pastebin. (#9552)
if ( CKEDITOR.env.ie ) {
var blurListener = editable.once( 'blur', function( evt ) {
editor.lockSelection( sel );
} );
}

// Wait a while and grab the pasted contents.
setTimeout( function() {

// Cancel the locked selection.
editor.unlockSelection();
// Blur will be fired only on non-native paste. In other case manually remove listener.
blurListener && blurListener.removeListener();

// Restore properly the document focus. (#8849)
if ( CKEDITOR.env.ie )
Expand Down

0 comments on commit 6dc63a1

Please sign in to comment.