Skip to content

Commit e0542d2

Browse files
committed
Merge branch 't/11897'
2 parents 89f4a31 + 9a3b014 commit e0542d2

File tree

3 files changed

+57
-8
lines changed

3 files changed

+57
-8
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CKEditor 4 Changelog
66
Fixed Issues:
77

88
* [#12110](http://dev.ckeditor.com/ticket/12110): Fixed: Editor crash after deleting a table. Thanks to [Alin Purcaru](https://github.com/mesmerizero)!
9+
* [#11897](http://dev.ckeditor.com/ticket/11897): Fixed: Enter key in an empty formatted list item, creates a new line instead of breaking the list. Thanks to [noam-si](https://github.com/noam-si)!
910

1011
## CKEditor 4.4.2
1112

plugins/enterkey/plugin.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
if ( atBlockStart && atBlockEnd ) {
5959
// Exit the list when we're inside an empty list item block. (#5376)
6060
if ( block && ( block.is( 'li' ) || block.getParent().is( 'li' ) ) ) {
61+
// Make sure to point to the li when dealing with empty list item.
62+
if ( !block.is( 'li' ) )
63+
block = block.getParent();
64+
6165
var blockParent = block.getParent(),
6266
blockGrandParent = blockParent.getParent(),
6367

@@ -175,17 +179,23 @@
175179

176180
block.remove();
177181
} else {
178-
// Use <div> block for ENTER_BR and ENTER_DIV.
179-
newBlock = doc.createElement( mode == CKEDITOR.ENTER_P ? 'p' : 'div' );
182+
// Original path block is the list item, create new block for the list item content.
183+
if ( path.block.is( 'li' ) ) {
184+
// Use <div> block for ENTER_BR and ENTER_DIV.
185+
newBlock = doc.createElement( mode == CKEDITOR.ENTER_P ? 'p' : 'div' );
180186

181-
if ( dirLoose )
182-
newBlock.setAttribute( 'dir', orgDir );
187+
if ( dirLoose )
188+
newBlock.setAttribute('dir', orgDir);
183189

184-
style && newBlock.setAttribute( 'style', style );
185-
className && newBlock.setAttribute( 'class', className );
190+
style && newBlock.setAttribute( 'style', style );
191+
className && newBlock.setAttribute( 'class', className );
186192

187-
// Move all the child nodes to the new block.
188-
block.moveChildren( newBlock );
193+
// Move all the child nodes to the new block.
194+
block.moveChildren( newBlock );
195+
}
196+
// The original path block is not a list item, just copy the block to out side of the list.
197+
else
198+
newBlock = path.block;
189199

190200
// If block is the first or last child of the parent
191201
// list, move it out of the list:

tests/plugins/enter/list.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,44 @@
514514
true, 'Direction should be preserved if different than cointainer\'s.', true );
515515
},
516516

517+
'test enterkey: leaves empty list item with h1 format': function() {
518+
assertEnter( 'enterP',
519+
'<ul>' +
520+
'<li>x</li>' +
521+
'<li><h1>^</h1></li>' +
522+
'<li>y</li>' +
523+
'</ul>',
524+
525+
'<ul>' +
526+
'<li>x</li>' +
527+
'</ul>' +
528+
'<h1>^&nbsp;</h1>' +
529+
'<ul>' +
530+
'<li>y</li>' +
531+
'</ul>',
532+
533+
true, 'List should be split and format preserved.', true );
534+
},
535+
536+
'test enterkey: leaves empty list item with a paragraph': function() {
537+
assertEnter( 'enterP',
538+
'<ul>' +
539+
'<li>x</li>' +
540+
'<li><p>^</p></li>' +
541+
'<li>y</li>' +
542+
'</ul>',
543+
544+
'<ul>' +
545+
'<li>x</li>' +
546+
'</ul>' +
547+
'<p>^&nbsp;</p>' +
548+
'<ul>' +
549+
'<li>y</li>' +
550+
'</ul>',
551+
552+
true, 'List should be split.', true );
553+
},
554+
517555
'test enterkey: force block: style (ENTER_BR)': function() {
518556
assertEnter( 'enterBR',
519557
'<ul>' +

0 commit comments

Comments
 (0)