8
0
Просмотр исходного кода

TableProperties alignment conversion must consume attributes.

Maciej Gołaszewski 6 лет назад
Родитель
Сommit
b786aeccc9

+ 5 - 0
packages/ckeditor5-table/src/tableproperties/tablepropertiesediting.js

@@ -149,10 +149,15 @@ function enableAlignmentProperty( schema, conversion ) {
 				value: viewElement => viewElement.getAttribute( 'align' )
 				value: viewElement => viewElement.getAttribute( 'align' )
 			}
 			}
 		} );
 		} );
+
 	conversion.for( 'downcast' ).add( dispatcher => dispatcher.on( 'attribute:alignment:table', ( evt, data, conversionApi ) => {
 	conversion.for( 'downcast' ).add( dispatcher => dispatcher.on( 'attribute:alignment:table', ( evt, data, conversionApi ) => {
 		const { item, attributeNewValue } = data;
 		const { item, attributeNewValue } = data;
 		const { mapper, writer } = conversionApi;
 		const { mapper, writer } = conversionApi;
 
 
+		if ( !conversionApi.consumable.consume( data.item, evt.name ) ) {
+			return;
+		}
+
 		const table = [ ...mapper.toViewElement( item ).getChildren() ].find( child => child.is( 'table' ) );
 		const table = [ ...mapper.toViewElement( item ).getChildren() ].find( child => child.is( 'table' ) );
 
 
 		if ( !attributeNewValue ) {
 		if ( !attributeNewValue ) {

+ 9 - 0
packages/ckeditor5-table/tests/tableproperties/tablepropertiesediting.js

@@ -658,6 +658,15 @@ describe( 'table properties', () => {
 					table = createEmptyTable();
 					table = createEmptyTable();
 				} );
 				} );
 
 
+				it( 'should consume converted item', () => {
+					editor.conversion.for( 'downcast' )
+						.add( dispatcher => dispatcher.on( 'attribute:alignment:table', ( evt, data, conversionApi ) => {
+							expect( conversionApi.consumable.consume( data.item, evt.name ) ).to.be.false;
+						} ) );
+
+					model.change( writer => writer.setAttribute( 'alignment', 'right', table ) );
+				} );
+
 				it( 'should downcast right alignment', () => {
 				it( 'should downcast right alignment', () => {
 					model.change( writer => writer.setAttribute( 'alignment', 'right', table ) );
 					model.change( writer => writer.setAttribute( 'alignment', 'right', table ) );