Skip to content
Permalink
Browse files

Merge branch 't/13599b'

  • Loading branch information...
pjasiun committed Aug 20, 2015
2 parents 89d54d8 + e7b615f commit 06362a8715809f23d439986a122b87a37eef2e13
@@ -6,6 +6,7 @@ CKEditor 4 Changelog
Fixed Issues:

* [#13142](http://dev.ckeditor.com/ticket/13142): [Edge] Fixed: CTRL+A, backspace results in an empty div.
* [#13599](http://dev.ckeditor.com/ticket/13599): Fixed: Cross-editor D&D of inline widget ends up in error/artifacts.

## CKEditor 4.5.3

@@ -1287,7 +1287,9 @@
// Create a dataTransfer object and save it globally.
editable.attachListener( editor, 'dragstart', function( evt ) {
clipboard.initDragDataTransfer( evt, editor );
}, null, null, 2 );

editable.attachListener( editor, 'dragstart', function() {
// Save drag range globally for cross editor D&D.
var dragRange = clipboard.dragRange = editor.getSelection().getRanges()[ 0 ];

@@ -1296,7 +1298,7 @@
clipboard.dragStartContainerChildCount = dragRange ? getContainerChildCount( dragRange.startContainer ) : null;
clipboard.dragEndContainerChildCount = dragRange ? getContainerChildCount( dragRange.endContainer ) : null;
}
}, null, null, 2 );
}, null, null, 100 );

// -------------- DRAGEND --------------
// Clean up on dragend.
@@ -2372,10 +2372,17 @@
editor.on( 'drop', function( evt ) {
var dataTransfer = evt.data.dataTransfer,
id = dataTransfer.getData( 'cke/widget-id' ),
transferType = dataTransfer.getTransferType( editor ),
dragRange = editor.createRange(),
sourceWidget;

if ( id === '' || dataTransfer.getTransferType( editor ) != CKEDITOR.DATA_TRANSFER_INTERNAL ) {
// Disable cross-editor drag & drop for widgets - #13599.
if ( id !== '' && transferType === CKEDITOR.DATA_TRANSFER_CROSS_EDITORS ) {
evt.cancel();
return;
}

if ( id === '' || transferType != CKEDITOR.DATA_TRANSFER_INTERNAL ) {
return;
}

@@ -39,4 +39,4 @@ Drop scenarios:

**Note:** internal D&D is the most complex operation because editor have to handle two ranges at the same time.

**Note:** that block widget D&D works only internally in one editor.
**Note:** that widget (both block and inline) D&D works only internally in one editor.
@@ -303,6 +303,40 @@
} );
},

'test drop - cross-editor drop': function() {
var editor = this.editor;

this.editorBot.setData( '<p class="x">foo</p><p><b>x<span data-widget="testwidget" id="w1">foo</span>x</b></p>', function() {
var evt = { data: bender.tools.mockDropEvent() },
range = editor.createRange(),
dropCalled = false,
dropNotCancelled = false;

CKEDITOR.plugins.clipboard.initDragDataTransfer( evt );
evt.data.dataTransfer.setData( 'cke/widget-id', getWidgetById( editor, 'w1' ).id );

// Not really a cross-editor drop. We're just making it appear so.
evt.data.dataTransfer.sourceEditor = {};

range.setStart( editor.document.findOne( '.x' ).getFirst(), 1 );
range.collapse( true );
evt.data.testRange = range;

editor.once( 'drop', function() {
dropCalled = true;
}, null, null, 1 );

editor.once( 'drop', function() {
dropNotCancelled = true;
}, null, null, 999 );

drop( editor, evt.data, range );

assert.areSame( true, dropCalled, 'the drop event should have been called' );
assert.areSame( false, dropNotCancelled, 'the drop event should have been cancelled' );
} );
},

'test drop - wrong widget id': function() {
var editor = this.editor;

0 comments on commit 06362a8

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