Skip to content

Commit

Permalink
Merge branch 't/11982b'
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Jasiun committed Feb 24, 2015
2 parents 85c20b8 + 82c8871 commit 0db52ce
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -8,6 +8,7 @@ Fixed Issues:
* [#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)!
* [#12796](http://dev.ckeditor.com/ticket/12796): Fixed: [Indent List](http://ckeditor.com/addon/indentlist) plugin unwraps parent li elements.
* [#12885](http://dev.ckeditor.com/ticket/12885): Added missing getData parameter documentation.
* [#11982](http://dev.ckeditor.com/ticket/11982): Bullet added in wrong position after *enter* key pressed in nested list.

Other Changes:

Expand Down
49 changes: 28 additions & 21 deletions plugins/enterkey/plugin.js
Expand Up @@ -112,29 +112,36 @@
// </li> => </li>
// </ul> => </ul>

if ( firstChild || lastChild )
block[ firstChild ? 'insertBefore' : 'insertAfter' ]( blockGrandParent );
if ( firstChild || lastChild ) {

// If the empty block is neither first nor last child
// then split the list and the block as an element
// of outer list.
//
// => <ul>
// => <li>
// <ul> => <ul>
// <li> => <li>x</li>
// <ul> => </ul>
// <li>x</li> => </li>
// <li>^</li> => <li>^</li>
// <li>y</li> => <li>
// </ul> => <ul>
// </li> => <li>y</li>
// </ul> => </ul>
// => </li>
// => </ul>

else
// If it's only child, we don't want to keep perent ul anymore.
if ( firstChild && lastChild ) {
blockParent.remove();
}

block[lastChild ? 'insertAfter' : 'insertBefore']( blockGrandParent );

// If the empty block is neither first nor last child
// then split the list and the block as an element
// of outer list.
//
// => <ul>
// => <li>
// <ul> => <ul>
// <li> => <li>x</li>
// <ul> => </ul>
// <li>x</li> => </li>
// <li>^</li> => <li>^</li>
// <li>y</li> => <li>
// </ul> => <ul>
// </li> => <li>y</li>
// </ul> => </ul>
// => </li>
// => </ul>

} else {
block.breakParent( blockGrandParent );
}
}

else if ( !needsBlock ) {
Expand Down
1 change: 1 addition & 0 deletions tests/plugins/enter/enterkey.js
Expand Up @@ -256,6 +256,7 @@
'test shift+enter key - end of block': se( 'editor', '<p>foobar{}</p>', '<p>foobar<br />^@</p>' ),
'test shift+enter key - before br': se( 'editor', '<p>foo{}<br />bar</p>', '<p>foo<br />^<br />bar@</p>' ),
'test shift+enter key - after br': se( 'editor', '<p>foo<br />{}bar</p>', '<p>foo<br /><br />^bar@</p>' ),

// #11947
'test shift+enter key - end of block, inside inline element followed by bogus br':
se( 'editor', '<p><em>foo{}</em><br /></p>', '<p><em>foo<br />^</em><br /></p>' ),
Expand Down
45 changes: 45 additions & 0 deletions tests/plugins/enter/list.js
Expand Up @@ -599,6 +599,51 @@
'</div>',

true, 'Dir change forces block.', true );
},
// #11982
'test enterkey: nested empty list': function() {
assertEnter( 'enterP',
'<ul>' +
'<li>' +
'foo' +
'<ul>' +
'<li>^</li>' +
'</ul>' +
'</li>' +
'</ul>',

'<ul>' +
'<li>foo</li>' +
'<li>^&nbsp;</li>' +
'</ul>',

true, 'New item should be added to the list.', true );
},

// #11982
'test enterkey: nested list with empty item': function() {
assertEnter( 'enterP',
'<ul>' +
'<li>' +
'foo' +
'<ul>' +
'<li>bar</li>' +
'<li>^</li>' +
'</ul>' +
'</li>' +
'</ul>',

'<ul>' +
'<li>' +
'foo' +
'<ul>' +
'<li>bar</li>' +
'</ul>' +
'</li>' +
'<li>^&nbsp;</li>' +
'</ul>',

true, 'New item should be added to the list.', true );
}
};
} )();
28 changes: 28 additions & 0 deletions tests/plugins/enter/manual/nestedlist.html
@@ -0,0 +1,28 @@
<div id="editor">
<ul>
<li>If something frightens you irrationally, do it often.</li>
<li>The only way you are going to have success is to have lots of failures first.</li>
<li>Fail often but do not forget the Lesson.</li>
<ul>
<li></li>
</ul>
</ul>

<ul>
<li>one</li>
<ul>
<li>two</li>
<ul>
<li>three</li>
<ul>
<li></li>
</ul>
</ul>
</ul>
</ul>

</div>

<script>
CKEDITOR.replace( 'editor', { height: 400 } );
</script>
17 changes: 17 additions & 0 deletions tests/plugins/enter/manual/nestedlist.md
@@ -0,0 +1,17 @@
@bender-tags: 4.5.0, tc
@bender-ui: collapsed
@bender-ckeditor-plugins: wysiwygarea, toolbar, enterkey, htmlwriter, list, sourcearea

----

1. Put caret at the last nested item (empty one) in the first list.
4. Press `enter` key.

**Expected:** Last bullet should outdent.

----

1. Put caret at the most nested element in the second list.
2. Press enter few times.

**Expected:** Each `enter` key press should lead to outdent list one level.

0 comments on commit 0db52ce

Please sign in to comment.