Răsfoiți Sursa

Changed: IndentCommand should fix list type when item is indented.

Szymon Cofalik 8 ani în urmă
părinte
comite
f2a15c7660

+ 3 - 3
packages/ckeditor5-list/src/indentcommand.js

@@ -68,7 +68,7 @@ export default class IndentCommand extends Command {
 
 			// We need to be sure to keep model in correct state after each small change, because converters
 			// bases on that state and assumes that model is correct.
-			// Because of that, if the command outdented items, we will outdent them starting from the last item, as
+			// Because of that, if the command outdents items, we will outdent them starting from the last item, as
 			// it is safer.
 			if ( this._indentBy < 0 ) {
 				itemsToChange = itemsToChange.reverse();
@@ -87,8 +87,8 @@ export default class IndentCommand extends Command {
 				}
 				// If indent is >= 0, change the attribute value.
 				else {
-					// If indent is > 0 and the item was outdented, check whether list item's type should not be fixed.
-					if ( indent > 0 && this._indentBy < 0 ) {
+					// If indent is > 0 check whether list item's type should not be fixed.
+					if ( indent > 0 ) {
 						// First, find previous sibling with same indent.
 						let prev = item.previousSibling;
 

+ 24 - 1
packages/ckeditor5-list/tests/indentcommand.js

@@ -130,6 +130,29 @@ describe( 'IndentCommand', () => {
 					'<listItem indent="0" type="bulleted">g</listItem>'
 				);
 			} );
+
+			it( 'should fix list type when item is intended if needed', () => {
+				setData(
+					doc,
+					'<listItem indent="0" type="bulleted">a</listItem>' +
+					'<listItem indent="1" type="bulleted">b</listItem>' +
+					'<listItem indent="2" type="numbered">c</listItem>' +
+					'<listItem indent="1" type="bulleted">d</listItem>'
+				);
+
+				doc.selection.setRanges( [ new Range(
+					new Position( root.getChild( 3 ), [ 0 ] )
+				) ] );
+
+				command._doExecute();
+
+				expect( getData( doc, { withoutSelection: true } ) ).to.equal(
+					'<listItem indent="0" type="bulleted">a</listItem>' +
+					'<listItem indent="1" type="bulleted">b</listItem>' +
+					'<listItem indent="2" type="numbered">c</listItem>' +
+					'<listItem indent="2" type="numbered">d</listItem>'
+				);
+			} );
 		} );
 	} );
 
@@ -234,7 +257,7 @@ describe( 'IndentCommand', () => {
 				);
 			} );
 
-			it( 'should fix list type if item is outdented', () => {
+			it( 'should fix list type when item is outdented if needed', () => {
 				setData(
 					doc,
 					'<listItem indent="0" type="bulleted">a</listItem>' +