Skip to content

Commit

Permalink
Merge branch 't/13640b'
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Jasiun committed Aug 20, 2015
2 parents 06362a8 + 2a2fc7f commit b98d8b9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 26 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -7,6 +7,7 @@ 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.
* [#13453](http://dev.ckeditor.com/ticket/13453): Fixed: Drag&drop whole selected content cause error.

## CKEditor 4.5.3

Expand Down
40 changes: 17 additions & 23 deletions plugins/clipboard/plugin.js
Expand Up @@ -1755,34 +1755,28 @@
dropInsideDragRange =
// Must check endNode because dragRange could be collapsed in some edge cases (simulated DnD).
endNode &&
startNode.getPosition( dropNode ) == CKEDITOR.POSITION_PRECEDING &&
endNode.getPosition( dropNode ) == CKEDITOR.POSITION_FOLLOWING;
( startNode.getPosition( dropNode ) & CKEDITOR.POSITION_PRECEDING ) &&
( endNode.getPosition( dropNode ) & CKEDITOR.POSITION_FOLLOWING );

// If the drop range happens to be inside drag range change it's position to the beginning of the drag range.
if ( dropInsideDragRange ) {
// When we normally drag and drop, the selection is changed to dropRange,
// so here we simulate the same behavior.
editor.getSelection().selectRanges( [ dropRange ] );

// Remove bookmark spans.
startNode.remove();
endNode.remove();
dropNode.remove();
// We only change position of bookmark span that is connected with dropBookmark.
// dropRange will be overwritten and set to the dropBookmark later.
dropNode.insertBefore( startNode );
}
else {
// Drop range is outside drag range.
// No we can safely delete content for the drag range...
dragRange = editor.createRange();
dragRange.moveToBookmark( dragBookmark );
editable.extractHtmlFromRange( dragRange, 1 );

// ...and paste content into the drop position.
dropRange = editor.createRange();
dropRange.moveToBookmark( dropBookmark );
// No we can safely delete content for the drag range...
dragRange = editor.createRange();
dragRange.moveToBookmark( dragBookmark );
editable.extractHtmlFromRange( dragRange, 1 );

// We do not select drop range, because of may be in the place we can not set the selection
// (e.g. between blocks, in case of block widget D&D). We put range to the paste event instead.
firePasteEvents( editor, { dataTransfer: dataTransfer, method: 'drop', range: dropRange }, 1 );
}
// ...and paste content into the drop position.
dropRange = editor.createRange();
dropRange.moveToBookmark( dropBookmark );

// We do not select drop range, because of may be in the place we can not set the selection
// (e.g. between blocks, in case of block widget D&D). We put range to the paste event instead.
firePasteEvents( editor, { dataTransfer: dataTransfer, method: 'drop', range: dropRange }, 1 );

editor.fire( 'unlockSnapshot' );
},
Expand Down
2 changes: 1 addition & 1 deletion tests/tickets/13453/1.md
@@ -1,4 +1,4 @@
@bender-tags: 4.5.3, tc, 13453
@bender-tags: 4.5.3, 4.5.4, tc, 13453
@bender-ui: collapsed
@bender-ckeditor-plugins: wysiwygarea, toolbar, elementspath, justify, clipboard, floatingspace, sourcearea, htmlwriter, link

Expand Down
4 changes: 2 additions & 2 deletions tests/tickets/13465/1.md
@@ -1,9 +1,9 @@
@bender-ui: collapsed
@bender-tags: 4.5.3, tc, widget, 13465
@bender-ckeditor-plugins: wysiwygarea, toolbar, placeholder
@bender-ckeditor-plugins: wysiwygarea, toolbar, placeholder, sourcearea

1. Drag the placeholder after or before itself.

Expected: Nothing should happen. Placeholder should be left untouched.

Unexpected: Placeholder is lost. Error is thrown.
Unexpected: Placeholder is lost. Error is thrown.

0 comments on commit b98d8b9

Please sign in to comment.