8
0
Pārlūkot izejas kodu

Revert use of simple attributeToAttribute converter.

Maciej Gołaszewski 5 gadi atpakaļ
vecāks
revīzija
803b68019d
1 mainītis faili ar 10 papildinājumiem un 27 dzēšanām
  1. 10 27
      packages/ckeditor5-indent/src/indentblock.js

+ 10 - 27
packages/ckeditor5-indent/src/indentblock.js

@@ -102,34 +102,17 @@ export default class IndentBlock extends Plugin {
 		const locale = this.editor.locale;
 		const marginProperty = locale.contentLanguageDirection === 'rtl' ? 'margin-right' : 'margin-left';
 
-		conversion.for( 'upcast' ).add( dispatcher => dispatcher.on( 'element', ( evt, data, conversionApi ) => {
-			const element = data.viewItem;
-
-			if ( !element.hasStyle( marginProperty ) ) {
-				return;
-			}
-
-			// Try to consume appropriate values from consumable values list.
-			if ( !testStyle( marginProperty ) && !testStyle( 'margin' ) ) {
-				return;
-			}
-
-			if ( !data.modelRange ) {
-				data = Object.assign( data, conversionApi.convertChildren( data.viewItem, data.modelCursor ) );
-			}
-
-			const items = Array.from( data.modelRange.getItems() );
-			const node = items.shift();
-
-			if ( conversionApi.schema.checkAttribute( node, 'blockIndent' ) ) {
-				conversionApi.writer.setAttribute( 'blockIndent', element.getNormalizedStyle( marginProperty ), node );
-				conversionApi.consumable.consume( data.viewItem, { styles: marginProperty } );
-			}
-
-			function testStyle( styleName ) {
-				return conversionApi.consumable.test( data.viewItem, { styles: styleName } );
+		conversion.for( 'upcast' ).attributeToAttribute( {
+			view: {
+				styles: {
+					[ marginProperty ]: /[\s\S]+/
+				}
+			},
+			model: {
+				key: 'blockIndent',
+				value: viewElement => viewElement.getStyle( marginProperty )
 			}
-		} ) );
+		} );
 
 		conversion.for( 'downcast' ).attributeToAttribute( {
 			model: 'blockIndent',