Skip to content

Commit

Permalink
Merge branch 't/12796'
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Jasiun committed Feb 2, 2015
2 parents ee2210a + dee909a commit 6a8dc27
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Expand Up @@ -3,6 +3,10 @@ CKEditor 4 Changelog

## CKEditor 4.4.8

Fixed Issues:

* [#12796](http://dev.ckeditor.com/ticket/12796): Fixed: [Indent List](http://ckeditor.com/addon/indentlist) plugin unwraps parent li elements.

Other Changes:

* [#12844](http://dev.ckeditor.com/ticket/12844): Upgraded the [testing environment](http://docs.ckeditor.com/#!/guide/dev_tests) to [Bender.js](https://github.com/benderjs/benderjs) `0.2.*`.
Expand Down
11 changes: 8 additions & 3 deletions plugins/indentlist/plugin.js
Expand Up @@ -232,11 +232,16 @@
range;

while ( ( range = iterator.getNextRange() ) ) {
var rangeRoot = range.getCommonAncestor(),
nearestListBlock = rangeRoot;
var nearestListBlock = range.getCommonAncestor();

while ( nearestListBlock && !( nearestListBlock.type == CKEDITOR.NODE_ELEMENT && context[ nearestListBlock.getName() ] ) )
while ( nearestListBlock && !( nearestListBlock.type == CKEDITOR.NODE_ELEMENT && context[ nearestListBlock.getName() ] ) ) {
// Avoid having plugin propagate to parent of editor in inline mode by canceling the indentation. (#12796)
if ( editor.editable().equals( nearestListBlock ) ) {
nearestListBlock = false;
break;
}
nearestListBlock = nearestListBlock.getParent();
}

// Avoid having selection boundaries out of the list.
// <ul><li>[...</li></ul><p>...]</p> => <ul><li>[...]</li></ul><p>...</p>
Expand Down
5 changes: 5 additions & 0 deletions tests/plugins/indentlist/editorinlist.html
@@ -0,0 +1,5 @@
<ul>
<li id="outerListItem">
<div contenteditable="true" id="editor1"></div>
</li>
</ul>
72 changes: 72 additions & 0 deletions tests/plugins/indentlist/editorinlist.js
@@ -0,0 +1,72 @@
/* bender-tags: editor,unit */
/* bender-ckeditor-plugins: toolbar,floatingspace,list,indentlist */

CKEDITOR.disableAutoInline = true;

bender.editor = {
creator: 'inline',
name: 'editor1'
};

bender.test( {
'test outdent does not unwrap parent li with multiple lists and both lists selected': function() {
var bot = this.editorBot,
editor = bot.editor;

editor.focus();
bender.tools.selection.setWithHtml( editor, '<ul><li>[1</li></ul><ol><li>2]</li></ol>' );

var originalEditable = editor.editable(),
originalEditableParent = originalEditable.getParent();

bot.execCommand( 'outdent' );

var body = CKEDITOR.document.getBody();
assert.isTrue( body.contains( originalEditableParent ), 'editable\'s parent was not removed from the body element' );
assert.areSame( originalEditableParent, originalEditable.getParent(), 'editable\'s parent did not change' );

// It is not necessarily the most expected result (I would expect both lists to be outdented),
// but this is how the algorithm works in an iframed editor at the moment.
assert.areSame( '<p>1</p><ol><li>2</li></ol>', editor.getData(), 'the first of the selected lists was outdented' );
},

'test outdent does not unwrap parent li with multiple lists and one list selected': function() {
var bot = this.editorBot,
editor = bot.editor;

editor.focus();
bender.tools.selection.setWithHtml( editor, '<ul><li>[1]</li></ul><ol><li>2</li></ol>' );

var originalEditable = editor.editable(),
originalEditableParent = originalEditable.getParent();

bot.execCommand( 'outdent' );

var body = CKEDITOR.document.getBody();
assert.isTrue( body.contains( originalEditableParent ), 'editable\'s parent was not removed from the body element' );
assert.areSame( originalEditableParent, originalEditable.getParent(), 'editable\'s parent did not change' );

// It is not necessarily the most expected result (I would expect both lists to be outdented),
// but this is how the algorithm works in an iframed editor at the moment.
assert.areSame( '<p>1</p><ol><li>2</li></ol>', editor.getData(), 'the first of the selected lists was outdented' );
},

'test outdent does not unwrap parent li with a single list': function() {
var bot = this.editorBot,
editor = bot.editor;

editor.focus();
bender.tools.selection.setWithHtml( editor, '<ul><li>[1]</li></ul>' );

var originalEditable = editor.editable(),
originalEditableParent = originalEditable.getParent();

bot.execCommand( 'outdent' );

var body = CKEDITOR.document.getBody();
assert.isTrue( body.contains( originalEditableParent ), 'editable\'s parent was not removed from the body element' );
assert.areSame( originalEditableParent, originalEditable.getParent(), 'editable\'s parent did not change' );

assert.areSame( '<p>1</p>', editor.getData(), 'the first of the selected lists was outdented' );
}
} );

0 comments on commit 6a8dc27

Please sign in to comment.