Explorar el Código

Support mixed nested list in list normalization.

Maciej Gołaszewski hace 6 años
padre
commit
bbdad71292

+ 5 - 9
packages/ckeditor5-list/src/converters.js

@@ -392,20 +392,16 @@ function getIndentModifier( listItem, conversionStore ) {
 	// Ensure proper conversion store value.
 	conversionStore.indentModifiers = conversionStore.indentModifiers || new WeakMap();
 
-	const viewItem = listItem.parent;
+	const list = listItem.parent;
 
-	// View
-	if ( !viewItem || !viewItem.parent ) {
+	if ( !list || !list.parent ) {
 		return 0;
 	}
 
-	const parent = viewItem.parent;
-	const parentName = parent && parent.name;
-
 	let modifier = 0;
 
-	if ( parentName == 'ul' ) {
-		const previousSibling = viewItem.previousSibling;
+	if ( list.parent.is( 'ol' ) || list.parent.is( 'ul' ) ) {
+		const previousSibling = list.previousSibling;
 
 		if ( previousSibling ) {
 			if ( previousSibling.is( 'li' ) ) {
@@ -417,7 +413,7 @@ function getIndentModifier( listItem, conversionStore ) {
 	}
 
 	// Update the stored modifiers info.
-	conversionStore.indentModifiers.set( viewItem, modifier );
+	conversionStore.indentModifiers.set( list, modifier );
 
 	return modifier;
 }

+ 51 - 0
packages/ckeditor5-list/tests/listediting.js

@@ -1302,6 +1302,17 @@ describe( 'ListEditing', () => {
 					'</ul>'
 				);
 
+				test( 'fixing list - ul in ol',
+					'<ol>' +
+						'<ul>' +
+							'<li>1.1</li>' +
+						'</ul>' +
+					'</ol>',
+					'<ul>' +
+					'<li>1.1</li>' +
+					'</ul>'
+				);
+
 				test( 'fixing list - ul in ul (prev is li)',
 					'<ul>' +
 						'<li>1</li>' +
@@ -1333,6 +1344,21 @@ describe( 'ListEditing', () => {
 					'</ul>'
 				);
 
+				test( 'fixing list - ul in deeply nested ul/ol',
+					'<ol>' +
+						'<ul>' +
+							'<ol>' +
+								'<ul>' +
+									'<li>2.1</li>' +
+								'</ul>' +
+							'</ol>' +
+						'</ul>' +
+					'</ol>',
+					'<ul>' +
+					'<li>2.1</li>' +
+					'</ul>'
+				);
+
 				test( 'fixing list - ul in deeply nested ul',
 					'<ul>' +
 						'<li>A' +
@@ -1357,6 +1383,31 @@ describe( 'ListEditing', () => {
 					'</li>' +
 					'</ul>'
 				);
+
+				test( 'fixing list - ul in deeply nested ul/ol',
+					'<ul>' +
+						'<li>A' +
+							'<ol>' +
+								'<ul>' +
+									'<ol>' +
+										'<ul>' +
+											'<li>B</li>' +
+										'</ul>' +
+									'</ol>' +
+								'</ul>' +
+								'<li>C</li>' +
+							'</ol>' +
+						'</li>' +
+					'</ul>',
+					'<ul>' +
+						'<li>A' +
+						'<ul>' +
+							'<li>B</li>' +
+							'<li>C</li>' +
+						'</ul>' +
+						'</li>' +
+					'</ul>'
+				);
 			} );
 
 			test( 'fixing list - ul in ul',