Skip to content
Permalink
Browse files

Merge branch 't/11384'

  • Loading branch information...
Reinmar committed Jun 16, 2014
2 parents 6c83319 + 34cefb8 commit 4d28beb8a7b567c93167355c79f47f4bb3b3316d
Showing with 74 additions and 0 deletions.
  1. +1 −0 CHANGES.md
  2. +9 −0 plugins/clipboard/plugin.js
  3. +64 −0 tests/tickets/11384/1.js
@@ -34,6 +34,7 @@ Fixed Issues:
* [#11753](http://dev.ckeditor.com/ticket/11753): Fixed: Wrong [`checkDirty()`](http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-checkDirty) value after focusing or blurring widget.
* [#11830](http://dev.ckeditor.com/ticket/11830): Fixed: Impossible to pass some arguments to [CKBuilder](https://github.com/ckeditor/ckbuilder) when using `/dev/builder/build.sh` script.
* [#11945](http://dev.ckeditor.com/ticket/11945): Fixed: Forms plugin should not change core method.
* [#11384](http://dev.ckeditor.com/ticket/11384): [IE9+] Fixed: `IndexSizeError` thrown when pasting into non empty selection anchored in one text node.

## CKEditor 4.4.1

@@ -670,6 +670,15 @@
var sel = editor.getSelection();
var bms = sel.createBookmarks();

// #11384. On IE9+ we use native selectionchange (i.e. editor#selectionCheck) to cache the most
// recent selection which we then lock on editable blur. See selection.js for more info.
// selectionchange fired before getClipboardDataByPastebin() cached selection
// before creating bookmark (cached selection will be invalid, because bookmarks modified the DOM),
// so we need to fire selectionchange one more time, to store current seleciton.
// Selection will be locked when we focus pastebin.
if ( CKEDITOR.env.ie )
sel.root.fire( 'selectionchange' );

// Create container to paste into.
// For rich content we prefer to use "body" since it holds
// the least possibility to be splitted by pasted content, while this may
@@ -0,0 +1,64 @@
/* bender-tags: editor,unit,clipboard */
/* bender-ckeditor-plugins: toolbar,clipboard */

( function() {
'use strict';

bender.test( {
'async:init': function() {
var that = this;

bender.tools.setUpEditors( {
inline: {
name: 'inline',
creator: 'inline'
}
}, function( editors, bots ) {
that.editors = editors;
that.editorBots = bots;

that.callback();
} );
},

'test paste into a non-empty range': function() {
var editor = this.editors.inline;

this.editorBots.inline.setData( '<p>1234567890</p>', function() {
var sel = editor.getSelection(),
paragraph = editor.editable().getFirst(),
textNode = paragraph.getFirst(),
editable = editor.editable(),
itThrew = false;

// Set seleciton 12[345678]90.
var rng = editor.createRange();
rng.setStart( textNode, 2 );
rng.setEnd( textNode, 8 );
sel.selectRanges( [ rng ] );

var origSelectRanges = CKEDITOR.dom.selection.prototype.selectRanges,
revert = bender.tools.replaceMethod( CKEDITOR.dom.selection.prototype, 'selectRanges', function( ranges ) {
try {
origSelectRanges.call( this, ranges );
} catch ( e ) {
itThrew = true;
throw e;
}
} );

editor.on( 'afterPaste', function() {
resume( function() {
revert();
assert.isFalse( itThrew, 'selectRanges has not thrown an error' );
} )
} );

// Ensure async.
wait( function() {
bender.tools.emulatePaste( editor, '<p>abc</p>' );
} );
} );
}
} );
} )();

0 comments on commit 4d28beb

Please sign in to comment.
You can’t perform that action at this time.