Skip to content
Permalink
Browse files

Merge branch 't/13409'

  • Loading branch information
Reinmar committed Jul 22, 2015
2 parents e3ee229 + 592bc94 commit 03c33295ff5bae105e63bea21cfb1c53007e9fef
@@ -23,6 +23,7 @@ Fixed Issues:
* [#13494](http://dev.ckeditor.com/ticket/13494): Fixed: Error thrown in toolbar configurator if plugin requirements are unsatisfied.
* [#11376](http://dev.ckeditor.com/ticket/11376): [IE11] Fixed: Loss of text when pasting bullet lists from Microsoft Word.
* [#13387](http://dev.ckeditor.com/ticket/13387): [Edge] Fixed: "Permission denied" error thrown while loading the editor with developer tools open.
* [#13409](http://dev.ckeditor.com/ticket/13409): Fixed: List elements incorrectly merged when pressing *Backspace* or *Delete*.

## CKEditor 4.5.1

@@ -945,7 +945,6 @@
}

} else {

var next, nextLine;

li = path.contains( 'li' );
@@ -977,12 +976,79 @@
isAtEnd = 2;
}


if ( isAtEnd && next ) {
// Put cursor range there.
nextLine = range.clone();
nextLine.moveToElementEditStart( next );

// #13409
// For the following case and similar
//
// <ul>
// <li>
// <p><a href="#one"><em>x^</em></a></p>
// <ul>
// <li><span>y</span></li>
// </ul>
// </li>
// </ul>
if ( isAtEnd == 1 ) {
// Move the cursor to <em> if attached to "x" text node.
cursor.optimize();

// Abort if the range is attached directly in <li>, like
//
// <ul>
// <li>
// x^
// <ul>
// <li><span>y</span></li>
// </ul>
// </li>
// </ul>
if ( !cursor.startContainer.equals( li ) ) {
var node = cursor.startContainer,
farthestInlineAscendant;

// Find <a>, which is farthest from <em> but still inline element.
while ( node.is( CKEDITOR.dtd.$inline ) ) {
farthestInlineAscendant = node;
node = node.getParent();
}

// Move the range so it does not contain inline elements.
// It prevents <span> from being included in <em>.
//
// <ul>
// <li>
// <p><a href="#one"><em>x</em></a>^</p>
// <ul>
// <li><span>y</span></li>
// </ul>
// </li>
// </ul>
//
// so instead of
//
// <ul>
// <li>
// <p><a href="#one"><em>x^<span>y</span></em></a></p>
// </li>
// </ul>
//
// pressing DELETE produces
//
// <ul>
// <li>
// <p><a href="#one"><em>x</em></a>^<span>y</span></p>
// </li>
// </ul>
if ( farthestInlineAscendant ) {
cursor.moveToPosition( farthestInlineAscendant, CKEDITOR.POSITION_AFTER_END );
}
}
}

// Moving `cursor` and `next line` only when at the end literally (#12729).
if ( isAtEnd == 2 ) {
cursor.moveToPosition( cursor.endPath().block, CKEDITOR.POSITION_BEFORE_END );
@@ -347,6 +347,81 @@ <h1>2.1</h1>
<li><a href="#one"><span>one</span></a>^<a href="#two">two</a>@</li>
</ul>
</textarea>
<!-- #13409 -->
<textarea id="join_list17_del">
<ul>
<li>
<a href="#one">x^</a>
<ul>
<li><span>y</span></li>
</ul>
</li>
</ul>
=>
<ul>
<li><a href="#one">x</a>^<span>y</span>@</li>
</ul>
</textarea>
<!-- #13409 -->
<textarea id="join_list18_del">
<ul>
<li>
<a href="#one"><strong>x^</strong></a>
<ul>
<li><span><em>y</em></span></li>
</ul>
</li>
</ul>
=>
<ul>
<li><a href="#one"><strong>x</strong></a>^<span><em>y</em></span>@</li>
</ul>
</textarea>
<!-- #13409 -->
<textarea id="join_list19_del">
<ul>
<li>
<p><a href="#one"><strong>x^</strong></a></p>
<ul>
<li><span><em>y</em></span></li>
</ul>
</li>
</ul>
=>
<ul>
<li><p><a href="#one"><strong>x</strong></a>^<span><em>y</em></span>@</p></li>
</ul>
</textarea>
<!-- #13409 -->
<textarea id="join_list20_del">
<ul>
<li>
x^
<ul>
<li><span><em>y</em></span></li>
</ul>
</li>
</ul>
=>
<ul>
<li>x^<span><em>y</em></span>@@</li>
</ul>
</textarea>
<!-- #13409 -->
<textarea id="join_list21_del">
<ul>
<li>
<blockquote>x^</blockquote>
<ul>
<li><span><em>y</em></span></li>
</ul>
</li>
</ul>
=>
<ul>
<li><blockquote>x^<span><em>y</em></span></blockquote></li>
</ul>
</textarea>

<textarea id="outdent_list">
<ol>
@@ -81,6 +81,11 @@ addTests( 'test del join list items', 'join_list13_del', DEL );
addTests( 'test del join list items', 'join_list14_del', DEL );
addTests( 'test del join list items', 'join_list15_del', DEL, undefined, assertNotNestedAnchors );
addTests( 'test del join list items', 'join_list16_del', DEL, undefined, assertNotNestedAnchors );
addTests( 'test del join list items', 'join_list17_del', DEL );
addTests( 'test del join list items', 'join_list18_del', DEL );
addTests( 'test del join list items', 'join_list19_del', DEL );
addTests( 'test del join list items', 'join_list20_del', DEL );
addTests( 'test del join list items', 'join_list21_del', DEL );

addTests( 'test del join with next list item', 'merge_next_list', DEL );
addTests( 'test del join with next list item', 'merge_next_list2', DEL );
@@ -4,11 +4,15 @@

----

Test merging lists items (and blocks around) with <kbd>backspace</kbd>/<kbd>delete</kbd> in both editors.
Test merging lists items and blocks around lists using <kbd>backspace</kbd>/<kbd>delete</kbd> in both editors.

Notes:

* Contents of one block should not be inserted into inline elements in the second block, but next to them (link should not be nested into `em` and vice versa).
* Contents of one block should not be inserted into inline elements in the second block, but next to them. For example:
* place caret at the end of the first list item,
* press <kbd>delete</kbd>,
* **expected:** `<li><a>foo</a><em>foo</em></li>`.
* **bad:** `<li><a>foo<em>foo</em></a></li>`.
* When trying to merge the first list item with a block outside it, it's:
* expected that selection moves, but structure does not change (that's due to the nested list).
* [BR mode] known that on FF and IE11 caret is rendered inside list even though it's in the previous line.

0 comments on commit 03c3329

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