diff --git a/CHANGES.md b/CHANGES.md
index 0b616319bac..b21a6a28da9 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -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.*`.
diff --git a/plugins/indentlist/plugin.js b/plugins/indentlist/plugin.js
index 3c0a7bd23b3..9e80a4459e7 100644
--- a/plugins/indentlist/plugin.js
+++ b/plugins/indentlist/plugin.js
@@ -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.
//
...]
=> ...
diff --git a/tests/plugins/indentlist/editorinlist.html b/tests/plugins/indentlist/editorinlist.html
new file mode 100644
index 00000000000..582d6ce18db
--- /dev/null
+++ b/tests/plugins/indentlist/editorinlist.html
@@ -0,0 +1,5 @@
+
\ No newline at end of file
diff --git a/tests/plugins/indentlist/editorinlist.js b/tests/plugins/indentlist/editorinlist.js
new file mode 100644
index 00000000000..be79a39fe1a
--- /dev/null
+++ b/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, '- 2]
' );
+
+ 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( '1
- 2
', 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, '- 2
' );
+
+ 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( '1
- 2
', 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, '' );
+
+ 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( '1
', editor.getData(), 'the first of the selected lists was outdented' );
+ }
+} );