Skip to content

Commit b32d85d

Browse files
committed
Merge branch 't/13465b'
2 parents 9bbeddb + 48d9a75 commit b32d85d

File tree

5 files changed

+53
-3
lines changed

5 files changed

+53
-3
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Fixed Issues:
1212
* [#13386](http://dev.ckeditor.com/ticket/13386): [Edge] Fixed: Issues with selecting and editing images.
1313
* [#13568](http://dev.ckeditor.com/ticket/13568): Fixed: Method [`editor.getSelectedHtml()`](http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-getSelectedHtml) returns invalid results for entire content selection.
1414
* [#13453](http://dev.ckeditor.com/ticket/13453): Fixed: Drag&drop of a whole content of the editor throws an error.
15+
* [#13465](http://dev.ckeditor.com/ticket/13465): Fixed: Error is thrown and widget is lost when drag&drop if it is the only content of the editor.
1516

1617
Other Changes:
1718

core/editable.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,13 @@
744744
var path = range.startPath();
745745

746746
// <p><b>^</b></p> is empty block.
747-
if ( range.checkStartOfBlock() && range.checkEndOfBlock() && path.block && !range.root.equals( path.block ) ) {
747+
if (
748+
range.checkStartOfBlock() &&
749+
range.checkEndOfBlock() &&
750+
path.block &&
751+
!range.root.equals( path.block ) &&
752+
// Do not remove a block with bookmarks. (#13465)
753+
!hasBookmarks( path.block ) ) {
748754
range.moveToPosition( path.block, CKEDITOR.POSITION_BEFORE_START );
749755
path.block.remove();
750756
}
@@ -1405,6 +1411,23 @@
14051411
};
14061412
}
14071413

1414+
function hasBookmarks( element ) {
1415+
// We use getElementsByTag() instead of find() to retain compatibility with IE quirks mode.
1416+
var potentialBookmarks = element.getElementsByTag( 'span' ),
1417+
i = 0,
1418+
child;
1419+
1420+
if ( potentialBookmarks ) {
1421+
while ( ( child = potentialBookmarks.getItem( i++ ) ) ) {
1422+
if ( !isNotBookmark( child ) ) {
1423+
return true;
1424+
}
1425+
}
1426+
}
1427+
1428+
return false;
1429+
}
1430+
14081431
// Check if the entire table/list contents is selected.
14091432
function getSelectedTableList( sel ) {
14101433
var selected,

tests/core/editable/getextracthtmlfromrange.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* bender-tags: editor,unit,range */
1+
/* bender-tags: editor,unit,range,13465 */
22

33
( function() {
44
'use strict';
@@ -369,7 +369,17 @@
369369
[ '<p>a</p><p>[<b>b</b>]</p><p>c</p>', '<b>b</b>', '<p>a</p><p>c</p>' ],
370370
[ '<p>a</p><p><b>[b]</b></p><p>c</p>', '<b>b</b>', '<p>a</p><p>c</p>' ],
371371
[ '<p>a[b]c</p>', 'b', '<p>ac</p>' ],
372-
[ '<table><tbody><tr><td>{a</td><td>b}</td></tr></tbody></table>', '<table><tbody><tr><td>a</td><td>b</td></tr></tbody></table>', '' ]
372+
[ '<table><tbody><tr><td>{a</td><td>b}</td></tr></tbody></table>', '<table><tbody><tr><td>a</td><td>b</td></tr></tbody></table>', '' ],
373+
// #13465
374+
[
375+
'<p>[<span>foo</span>]<span data-cke-bookmark="1">&nbsp;</span></p>',
376+
'<span>foo</span>',
377+
'<p><span data-cke-bookmark="1">&nbsp;</span></p>'
378+
],
379+
// #13465
380+
[ '<p>a</p><p><span class="foo">{b}</span></p><p>c</p>', '<span class="foo">b</span>', '<p>a</p><p>c</p>' ],
381+
// #13465
382+
[ '<p>a</p><p><b>{b}</b><span class="foo"></span></p><p>c</p>', '<b>b</b>', '<p>a</p><p>c</p>' ]
373383
]
374384
}, 'inline', 1 );
375385

tests/tickets/13465/1.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div id="editor">
2+
<p>[[foobar]]</p>
3+
</div>
4+
5+
<script>
6+
CKEDITOR.replace( 'editor' );
7+
</script>

tests/tickets/13465/1.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@bender-ui: collapsed
2+
@bender-tags: 4.5.3, tc, widget, 13465
3+
@bender-ckeditor-plugins: wysiwygarea, toolbar, placeholder
4+
5+
1. Drag the placeholder after or before itself.
6+
7+
Expected: Nothing should happen. Placeholder should be left untouched.
8+
9+
Unexpected: Placeholder is lost. Error is thrown.

0 commit comments

Comments
 (0)