Skip to content

Commit 0db52ce

Browse files
author
Piotr Jasiun
committed
Merge branch 't/11982b'
2 parents 85c20b8 + 82c8871 commit 0db52ce

File tree

6 files changed

+120
-21
lines changed

6 files changed

+120
-21
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Fixed Issues:
88
* [#12899](http://dev.ckeditor.com/ticket/12899): Fixed: Corrected wrong tag ending for horizontal box definition in [dialogui](http://ckeditor.com/addon/dialogui) plugin. Thanks to [mizafish](https://github.com/mizafish)!
99
* [#12796](http://dev.ckeditor.com/ticket/12796): Fixed: [Indent List](http://ckeditor.com/addon/indentlist) plugin unwraps parent li elements.
1010
* [#12885](http://dev.ckeditor.com/ticket/12885): Added missing getData parameter documentation.
11+
* [#11982](http://dev.ckeditor.com/ticket/11982): Bullet added in wrong position after *enter* key pressed in nested list.
1112

1213
Other Changes:
1314

plugins/enterkey/plugin.js

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -112,29 +112,36 @@
112112
// </li> => </li>
113113
// </ul> => </ul>
114114

115-
if ( firstChild || lastChild )
116-
block[ firstChild ? 'insertBefore' : 'insertAfter' ]( blockGrandParent );
115+
if ( firstChild || lastChild ) {
117116

118-
// If the empty block is neither first nor last child
119-
// then split the list and the block as an element
120-
// of outer list.
121-
//
122-
// => <ul>
123-
// => <li>
124-
// <ul> => <ul>
125-
// <li> => <li>x</li>
126-
// <ul> => </ul>
127-
// <li>x</li> => </li>
128-
// <li>^</li> => <li>^</li>
129-
// <li>y</li> => <li>
130-
// </ul> => <ul>
131-
// </li> => <li>y</li>
132-
// </ul> => </ul>
133-
// => </li>
134-
// => </ul>
135-
136-
else
117+
// If it's only child, we don't want to keep perent ul anymore.
118+
if ( firstChild && lastChild ) {
119+
blockParent.remove();
120+
}
121+
122+
block[lastChild ? 'insertAfter' : 'insertBefore']( blockGrandParent );
123+
124+
// If the empty block is neither first nor last child
125+
// then split the list and the block as an element
126+
// of outer list.
127+
//
128+
// => <ul>
129+
// => <li>
130+
// <ul> => <ul>
131+
// <li> => <li>x</li>
132+
// <ul> => </ul>
133+
// <li>x</li> => </li>
134+
// <li>^</li> => <li>^</li>
135+
// <li>y</li> => <li>
136+
// </ul> => <ul>
137+
// </li> => <li>y</li>
138+
// </ul> => </ul>
139+
// => </li>
140+
// => </ul>
141+
142+
} else {
137143
block.breakParent( blockGrandParent );
144+
}
138145
}
139146

140147
else if ( !needsBlock ) {

tests/plugins/enter/enterkey.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@
256256
'test shift+enter key - end of block': se( 'editor', '<p>foobar{}</p>', '<p>foobar<br />^@</p>' ),
257257
'test shift+enter key - before br': se( 'editor', '<p>foo{}<br />bar</p>', '<p>foo<br />^<br />bar@</p>' ),
258258
'test shift+enter key - after br': se( 'editor', '<p>foo<br />{}bar</p>', '<p>foo<br /><br />^bar@</p>' ),
259+
259260
// #11947
260261
'test shift+enter key - end of block, inside inline element followed by bogus br':
261262
se( 'editor', '<p><em>foo{}</em><br /></p>', '<p><em>foo<br />^</em><br /></p>' ),

tests/plugins/enter/list.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,51 @@
599599
'</div>',
600600

601601
true, 'Dir change forces block.', true );
602+
},
603+
// #11982
604+
'test enterkey: nested empty list': function() {
605+
assertEnter( 'enterP',
606+
'<ul>' +
607+
'<li>' +
608+
'foo' +
609+
'<ul>' +
610+
'<li>^</li>' +
611+
'</ul>' +
612+
'</li>' +
613+
'</ul>',
614+
615+
'<ul>' +
616+
'<li>foo</li>' +
617+
'<li>^&nbsp;</li>' +
618+
'</ul>',
619+
620+
true, 'New item should be added to the list.', true );
621+
},
622+
623+
// #11982
624+
'test enterkey: nested list with empty item': function() {
625+
assertEnter( 'enterP',
626+
'<ul>' +
627+
'<li>' +
628+
'foo' +
629+
'<ul>' +
630+
'<li>bar</li>' +
631+
'<li>^</li>' +
632+
'</ul>' +
633+
'</li>' +
634+
'</ul>',
635+
636+
'<ul>' +
637+
'<li>' +
638+
'foo' +
639+
'<ul>' +
640+
'<li>bar</li>' +
641+
'</ul>' +
642+
'</li>' +
643+
'<li>^&nbsp;</li>' +
644+
'</ul>',
645+
646+
true, 'New item should be added to the list.', true );
602647
}
603648
};
604649
} )();
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<div id="editor">
2+
<ul>
3+
<li>If something frightens you irrationally, do it often.</li>
4+
<li>The only way you are going to have success is to have lots of failures first.</li>
5+
<li>Fail often but do not forget the Lesson.</li>
6+
<ul>
7+
<li></li>
8+
</ul>
9+
</ul>
10+
11+
<ul>
12+
<li>one</li>
13+
<ul>
14+
<li>two</li>
15+
<ul>
16+
<li>three</li>
17+
<ul>
18+
<li></li>
19+
</ul>
20+
</ul>
21+
</ul>
22+
</ul>
23+
24+
</div>
25+
26+
<script>
27+
CKEDITOR.replace( 'editor', { height: 400 } );
28+
</script>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@bender-tags: 4.5.0, tc
2+
@bender-ui: collapsed
3+
@bender-ckeditor-plugins: wysiwygarea, toolbar, enterkey, htmlwriter, list, sourcearea
4+
5+
----
6+
7+
1. Put caret at the last nested item (empty one) in the first list.
8+
4. Press `enter` key.
9+
10+
**Expected:** Last bullet should outdent.
11+
12+
----
13+
14+
1. Put caret at the most nested element in the second list.
15+
2. Press enter few times.
16+
17+
**Expected:** Each `enter` key press should lead to outdent list one level.

0 commit comments

Comments
 (0)