Kamil Piechaczek 5 yıl önce
ebeveyn
işleme
7c93510981

+ 0 - 37
packages/ckeditor5-list/src/liststyleediting.js

@@ -111,43 +111,6 @@ function upcastListItemStyle() {
 // @returns {Function}
 function downcastListStyleAttribute() {
 	return dispatcher => {
-		// TODO: The idea seems to be OK. Unfortunately, it does not work.
-		// 	dispatcher.on( 'insert:listItem', ( evt, data, conversionApi ) => {
-		// 		const modelItem = data.item;
-		//
-		// 		// Do not update anything for "todo" `listItem`.
-		// 		if ( modelItem.getAttribute( 'listType' ) === 'todo' ) {
-		// 			return;
-		// 		}
-		//
-		// 		// Also, no changes are required if the style is already defined.
-		// 		if ( modelItem.hasAttribute( 'listStyle' ) ) {
-		// 			return;
-		// 		}
-		//
-		// 		const nextElement = getSiblingListItem( modelItem.nextSibling, {
-		// 			sameIndent: true,
-		// 			listIndent: modelItem.getAttribute( 'listIndent' ),
-		// 			direction: 'forward'
-		// 		} );
-		//
-		// 		const previousElement = getSiblingListItem( modelItem.previousSibling, {
-		// 			sameIndent: true,
-		// 			listIndent: modelItem.getAttribute( 'listIndent' ),
-		// 			direction: 'backward'
-		// 		} );
-		//
-		// 		if ( nextElement ) {
-		// 			// Insert at the beginning of the list.
-		// 			conversionApi.writer.setAttribute( 'listStyle', nextElement.getAttribute( 'listStyle' ), modelItem );
-		// 		} else if ( previousElement ) {
-		// 			// Insert at the end of the list.
-		// 			conversionApi.writer.setAttribute( 'listStyle', previousElement.getAttribute( 'listStyle' ), modelItem );
-		// 		}
-		//
-		// 		// We don't need to check whether `previousElement` or `nextElement` and `modelItem` belong to the same list.
-		// 	}, { priority: 'low' } );
-
 		dispatcher.on( 'attribute:listStyle:listItem', ( evt, data, conversionApi ) => {
 			const viewWriter = conversionApi.writer;
 			const currentElement = data.item;

+ 59 - 56
packages/ckeditor5-list/tests/liststyleediting.js

@@ -126,14 +126,14 @@ describe( 'ListStyleEditing', () => {
 
 				expect( editor.getData() ).to.equal(
 					'<ul style="list-style-type:circle;">' +
-					'<li>Foo 1' +
-					'<ul style="list-style-type:disc;">' +
-					'<li>Bar 1</li>' +
-					'<li>Bar 2</li>' +
-					'</ul>' +
-					'</li>' +
-					'<li>Foo 2</li>' +
-					'<li>Foo 3</li>' +
+						'<li>Foo 1' +
+							'<ul style="list-style-type:disc;">' +
+								'<li>Bar 1</li>' +
+								'<li>Bar 2</li>' +
+							'</ul>' +
+						'</li>' +
+						'<li>Foo 2</li>' +
+						'<li>Foo 3</li>' +
 					'</ul>'
 				);
 			} );
@@ -149,14 +149,14 @@ describe( 'ListStyleEditing', () => {
 
 				expect( editor.getData() ).to.equal(
 					'<ol style="list-style-type:decimal-leading-zero;">' +
-					'<li>Foo 1' +
-					'<ol style="list-style-type:lower-latin;">' +
-					'<li>Bar 1</li>' +
-					'<li>Bar 2</li>' +
-					'</ol>' +
-					'</li>' +
-					'<li>Foo 2</li>' +
-					'<li>Foo 3</li>' +
+						'<li>Foo 1' +
+							'<ol style="list-style-type:lower-latin;">' +
+								'<li>Bar 1</li>' +
+								'<li>Bar 2</li>' +
+							'</ol>' +
+						'</li>' +
+						'<li>Foo 2</li>' +
+						'<li>Foo 3</li>' +
 					'</ol>'
 				);
 			} );
@@ -172,14 +172,14 @@ describe( 'ListStyleEditing', () => {
 
 				expect( editor.getData() ).to.equal(
 					'<ul style="list-style-type:square;">' +
-					'<li>Foo 1' +
-					'<ol style="list-style-type:lower-roman;">' +
-					'<li>Bar 1</li>' +
-					'<li>Bar 2</li>' +
-					'</ol>' +
-					'</li>' +
-					'<li>Foo 2</li>' +
-					'<li>Foo 3</li>' +
+						'<li>Foo 1' +
+							'<ol style="list-style-type:lower-roman;">' +
+								'<li>Bar 1</li>' +
+								'<li>Bar 2</li>' +
+							'</ol>' +
+						'</li>' +
+						'<li>Foo 2</li>' +
+						'<li>Foo 3</li>' +
 					'</ul>'
 				);
 			} );
@@ -194,13 +194,13 @@ describe( 'ListStyleEditing', () => {
 
 				expect( editor.getData() ).to.equal(
 					'<ol style="list-style-type:decimal;">' +
-					'<li>Foo 1</li>' +
-					'<li>Foo 2' +
-					'<ol style="list-style-type:decimal;">' +
-					'<li>Bar 1</li>' +
-					'<li>Bar 2</li>' +
-					'</ol>' +
-					'</li>' +
+						'<li>Foo 1</li>' +
+						'<li>Foo 2' +
+							'<ol style="list-style-type:decimal;">' +
+								'<li>Bar 1</li>' +
+								'<li>Bar 2</li>' +
+							'</ol>' +
+						'</li>' +
 					'</ol>'
 				);
 			} );
@@ -215,12 +215,12 @@ describe( 'ListStyleEditing', () => {
 
 				expect( editor.getData() ).to.equal(
 					'<ol style="list-style-type:decimal;">' +
-					'<li>Foo 1</li>' +
-					'<li>Foo 2</li>' +
+						'<li>Foo 1</li>' +
+						'<li>Foo 2</li>' +
 					'</ol>' +
 					'<ul style="list-style-type:disc;">' +
-					'<li>Bar 1</li>' +
-					'<li>Bar 2</li>' +
+						'<li>Bar 1</li>' +
+						'<li>Bar 2</li>' +
 					'</ul>'
 				);
 			} );
@@ -235,12 +235,12 @@ describe( 'ListStyleEditing', () => {
 
 				expect( editor.getData() ).to.equal(
 					'<ul style="list-style-type:disc;">' +
-					'<li>Foo 1</li>' +
-					'<li>Foo 2</li>' +
+						'<li>Foo 1</li>' +
+						'<li>Foo 2</li>' +
 					'</ul>' +
 					'<ul style="list-style-type:circle;">' +
-					'<li>Bar 1</li>' +
-					'<li>Bar 2</li>' +
+						'<li>Bar 1</li>' +
+						'<li>Bar 2</li>' +
 					'</ul>'
 				);
 			} );
@@ -300,14 +300,14 @@ describe( 'ListStyleEditing', () => {
 			it( 'should convert nested and mixed lists', () => {
 				editor.setData(
 					'<ol style="list-style-type:upper-alpha;">' +
-					'<li>OL 1</li>' +
-					'<li>OL 2' +
-					'<ul style="list-style-type:circle;">' +
-					'<li>UL 1</li>' +
-					'<li>UL 2</li>' +
-					'</ul>' +
-					'</li>' +
-					'<li>OL 3</li>' +
+						'<li>OL 1</li>' +
+						'<li>OL 2' +
+							'<ul style="list-style-type:circle;">' +
+								'<li>UL 1</li>' +
+								'<li>UL 2</li>' +
+							'</ul>' +
+						'</li>' +
+						'<li>OL 3</li>' +
 					'</ol>'
 				);
 
@@ -323,7 +323,10 @@ describe( 'ListStyleEditing', () => {
 			it( 'should convert when the list is in the middle of the content', () => {
 				editor.setData(
 					'<p>Paragraph.</p>' +
-					'<ol style="list-style-type:upper-alpha;"><li>Foo</li><li>Bar</li></ol>' +
+					'<ol style="list-style-type:upper-alpha;">' +
+						'<li>Foo</li>' +
+						'<li>Bar</li>' +
+					'</ol>' +
 					'<p>Paragraph.</p>'
 				);
 
@@ -374,14 +377,14 @@ describe( 'ListStyleEditing', () => {
 
 				expect( getViewData( view, { withoutSelection: true } ) ).to.equal(
 					'<ul style="list-style-type:circle">' +
-					'<li>Foo 1' +
-					'<ul style="list-style-type:disc">' +
-					'<li>Bar 1</li>' +
-					'<li>Bar 2</li>' +
-					'</ul>' +
-					'</li>' +
-					'<li>Foo 2</li>' +
-					'<li>Foo 3</li>' +
+						'<li>Foo 1' +
+							'<ul style="list-style-type:disc">' +
+								'<li>Bar 1</li>' +
+								'<li>Bar 2</li>' +
+							'</ul>' +
+						'</li>' +
+						'<li>Foo 2</li>' +
+						'<li>Foo 3</li>' +
 					'</ul>'
 				);
 			} );