Skip to content

Commit

Permalink
Merge branch 't/13465b'
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Aug 10, 2015
2 parents 9bbeddb + 48d9a75 commit b32d85d
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -12,6 +12,7 @@ Fixed Issues:
* [#13386](http://dev.ckeditor.com/ticket/13386): [Edge] Fixed: Issues with selecting and editing images.
* [#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.
* [#13453](http://dev.ckeditor.com/ticket/13453): Fixed: Drag&drop of a whole content of the editor throws an error.
* [#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.

Other Changes:

Expand Down
25 changes: 24 additions & 1 deletion core/editable.js
Expand Up @@ -744,7 +744,13 @@
var path = range.startPath();

// <p><b>^</b></p> is empty block.
if ( range.checkStartOfBlock() && range.checkEndOfBlock() && path.block && !range.root.equals( path.block ) ) {
if (
range.checkStartOfBlock() &&
range.checkEndOfBlock() &&
path.block &&
!range.root.equals( path.block ) &&
// Do not remove a block with bookmarks. (#13465)
!hasBookmarks( path.block ) ) {
range.moveToPosition( path.block, CKEDITOR.POSITION_BEFORE_START );
path.block.remove();
}
Expand Down Expand Up @@ -1405,6 +1411,23 @@
};
}

function hasBookmarks( element ) {
// We use getElementsByTag() instead of find() to retain compatibility with IE quirks mode.
var potentialBookmarks = element.getElementsByTag( 'span' ),
i = 0,
child;

if ( potentialBookmarks ) {
while ( ( child = potentialBookmarks.getItem( i++ ) ) ) {
if ( !isNotBookmark( child ) ) {
return true;
}
}
}

return false;
}

// Check if the entire table/list contents is selected.
function getSelectedTableList( sel ) {
var selected,
Expand Down
14 changes: 12 additions & 2 deletions tests/core/editable/getextracthtmlfromrange.js
@@ -1,4 +1,4 @@
/* bender-tags: editor,unit,range */
/* bender-tags: editor,unit,range,13465 */

( function() {
'use strict';
Expand Down Expand Up @@ -369,7 +369,17 @@
[ '<p>a</p><p>[<b>b</b>]</p><p>c</p>', '<b>b</b>', '<p>a</p><p>c</p>' ],
[ '<p>a</p><p><b>[b]</b></p><p>c</p>', '<b>b</b>', '<p>a</p><p>c</p>' ],
[ '<p>a[b]c</p>', 'b', '<p>ac</p>' ],
[ '<table><tbody><tr><td>{a</td><td>b}</td></tr></tbody></table>', '<table><tbody><tr><td>a</td><td>b</td></tr></tbody></table>', '' ]
[ '<table><tbody><tr><td>{a</td><td>b}</td></tr></tbody></table>', '<table><tbody><tr><td>a</td><td>b</td></tr></tbody></table>', '' ],
// #13465
[
'<p>[<span>foo</span>]<span data-cke-bookmark="1">&nbsp;</span></p>',
'<span>foo</span>',
'<p><span data-cke-bookmark="1">&nbsp;</span></p>'
],
// #13465
[ '<p>a</p><p><span class="foo">{b}</span></p><p>c</p>', '<span class="foo">b</span>', '<p>a</p><p>c</p>' ],
// #13465
[ '<p>a</p><p><b>{b}</b><span class="foo"></span></p><p>c</p>', '<b>b</b>', '<p>a</p><p>c</p>' ]
]
}, 'inline', 1 );

Expand Down
7 changes: 7 additions & 0 deletions tests/tickets/13465/1.html
@@ -0,0 +1,7 @@
<div id="editor">
<p>[[foobar]]</p>
</div>

<script>
CKEDITOR.replace( 'editor' );
</script>
9 changes: 9 additions & 0 deletions tests/tickets/13465/1.md
@@ -0,0 +1,9 @@
@bender-ui: collapsed
@bender-tags: 4.5.3, tc, widget, 13465
@bender-ckeditor-plugins: wysiwygarea, toolbar, placeholder

1. Drag the placeholder after or before itself.

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

Unexpected: Placeholder is lost. Error is thrown.

0 comments on commit b32d85d

Please sign in to comment.