Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#842] Fix for indention list troubles #872

Merged
merged 5 commits into from
Sep 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Fixed Issues:
* [#704](https://github.com/ckeditor/ckeditor-dev/issues/704): [Edge] Fixed: Using `Ctrl/Cmd + Z` breaks widgets structure.
* [#591](https://github.com/ckeditor/ckeditor-dev/issues/591): Fixed: Column is inserted in a wrong order inside table if any cell has a vertical split.
* [#787](https://github.com/ckeditor/ckeditor-dev/issues/787): Fixed: Using cut inside nested table does not cut selected content.
* [#842](https://github.com/ckeditor/ckeditor-dev/issues/842): Fixed: List style not restored when toggling list indent level in [Indent List](http://ckeditor.com/addon/indentlist) plugin.

## CKEditor 4.7.3

Expand Down
10 changes: 10 additions & 0 deletions plugins/indentlist/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@
// Make sure the newly created sublist get a brand-new element of the same type. (http://dev.ckeditor.com/ticket/5372)
if ( indentOffset > 0 ) {
var listRoot = listArray[ i ].parent;

// Find previous list item which has the same indention offset as the new indention offset
// of current item to copy its root tag (so the proper list-style-type is used) (#842).
for ( var j = i - 1; j >= 0; j-- ) {
if ( listArray[ j ].indent === indentOffset ) {
listRoot = listArray[ j ].parent;
break;
}
}

listArray[ i ].parent = new CKEDITOR.dom.element( listRoot.getName(), listRoot.getDocument() );
}
}
Expand Down
32 changes: 32 additions & 0 deletions tests/plugins/indentlist/indentlist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* bender-tags: editor */
/* bender-ckeditor-plugins: toolbar,indentlist,list,wysiwygarea */
/* bender-ui: collapsed */

( function() {
'use strict';

bender.editor = true;

bender.test( {
'test indention keeps proper list tags': function() {
var bot = this.editorBot;

bot.setHtmlWithSelection( '<ul><li>foo</li><li>bar<ol><li>111</li></ol><li>[222</li><li>333]</li></li><li>baz</li></ul>' );
bot.execCommand( 'indent' );

assert.beautified.html( '<ul><li>foo</li><li>bar<ol><li>111</li><li>222</li><li>333</li></ol></li><li>baz</li></ul>', bot.getData() );
},

'test outdent and indent get proper list tags': function() {
var bot = this.editorBot;

bot.setHtmlWithSelection( '<ol><li>foo</li><li>bar<ul><li>111</li><li>2^22</li><li>333</li></ul></li><li>baz</li></ol>' );

bot.execCommand( 'outdent' );
assert.beautified.html( '<ol><li>foo</li><li>bar<ul><li>111</li></ul></li><li>222<ul><li>333</li></ul></li><li>baz</li></ol>', bot.getData() );

bot.execCommand( 'indent' );
assert.beautified.html( '<ol><li>foo</li><li>bar<ul><li>111</li><li>222<ul><li>333</li></ul></li></ul></li><li>baz</li></ol>', bot.getData() );
}
} );
} )();
7 changes: 7 additions & 0 deletions tests/plugins/indentlist/manual/keepcorrectlisttag.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<textarea name="" id="editor" cols="30" rows="10">
<ol><li>one</li><li>two<ul><li>111</li><li>222</li><li>333</li></ul></li><li>three</li></ol>
</textarea>

<script>
CKEDITOR.replace( 'editor' );
</script>
14 changes: 14 additions & 0 deletions tests/plugins/indentlist/manual/keepcorrectlisttag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@bender-tags: 4.8.0, 842, bug
@bender-ui: collapsed
@bender-ckeditor-plugins: toolbar, wysiwygarea, list, indentlist

----

1. Put caret in paragraph with `333`.
1. Use `Decrease indent` button to move list item to the left.
1. Use `Increase indent` button to move list item to the right.

**Expected:** List item with `333` has circle as a list bullet.

**Unexpected:** List item with `333` has number as a list bullet.