Selaa lähdekoodia

Remove to margin left/right from table alignment converters.

Maciej Gołaszewski 5 vuotta sitten
vanhempi
commit
5d9e804e5c

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

@@ -26,7 +26,6 @@ import TableWidthCommand from './commands/tablewidthcommand';
 import TableHeightCommand from './commands/tableheightcommand';
 import TableAlignmentCommand from './commands/tablealignmentcommand';
 
-// RegExp used for matching margin style in converters.
 const ALIGN_VALUES_REG_EXP = /^(left|right)$/;
 
 /**
@@ -127,14 +126,12 @@ function enableAlignmentProperty( schema, conversion ) {
 				left: {
 					key: 'style',
 					value: {
-						'margin-left': '0',
 						float: 'left'
 					}
 				},
 				right: {
 					key: 'style',
 					value: {
-						'margin-right': '0',
 						float: 'right'
 					}
 				}

+ 4 - 4
packages/ckeditor5-table/tests/tableproperties/commands/tablealignmentcommand.js

@@ -102,7 +102,7 @@ describe( 'table properties', () => {
 
 						command.execute( { value: 'right' } );
 
-						assertTableStyle( editor, null, 'float:right;margin-right:0;' );
+						assertTableStyle( editor, null, 'float:right;' );
 					} );
 
 					it( 'should change selected table alignment to a passed value', () => {
@@ -110,7 +110,7 @@ describe( 'table properties', () => {
 
 						command.execute( { value: 'right' } );
 
-						assertTableStyle( editor, null, 'float:right;margin-right:0;' );
+						assertTableStyle( editor, null, 'float:right;' );
 					} );
 
 					it( 'should remove alignment from a selected table if no value is passed', () => {
@@ -128,7 +128,7 @@ describe( 'table properties', () => {
 
 						command.execute( { value: 'right' } );
 
-						assertTableStyle( editor, null, 'float:right;margin-right:0;' );
+						assertTableStyle( editor, null, 'float:right;' );
 					} );
 
 					it( 'should change selected table alignment to a passed value', () => {
@@ -136,7 +136,7 @@ describe( 'table properties', () => {
 
 						command.execute( { value: 'right' } );
 
-						assertTableStyle( editor, null, 'float:right;margin-right:0;' );
+						assertTableStyle( editor, null, 'float:right;' );
 					} );
 
 					it( 'should remove alignment from a selected table if no value is passed', () => {

+ 12 - 19
packages/ckeditor5-table/tests/tableproperties/tablepropertiesediting.js

@@ -768,27 +768,20 @@ describe( 'table properties', () => {
 			} );
 
 			describe( 'upcast conversion', () => {
-				it( 'should upcast style="float:right;margin-right:0" to right value', () => {
-					editor.setData( '<table style="float:right;margin-right:0"><tr><td>foo</td></tr></table>' );
+				it( 'should upcast style="float:right" to right value', () => {
+					editor.setData( '<table style="float:right"><tr><td>foo</td></tr></table>' );
 					const table = model.document.getRoot().getNodeByPath( [ 0 ] );
 
 					expect( table.getAttribute( 'alignment' ) ).to.equal( 'right' );
 				} );
 
-				it( 'should upcast style="margin-left:0;float:left;" to left value', () => {
-					editor.setData( '<table style="margin-left:0;float:left;"><tr><td>foo</td></tr></table>' );
+				it( 'should upcast style="float:left;" to left value', () => {
+					editor.setData( '<table style="float:left;"><tr><td>foo</td></tr></table>' );
 					const table = model.document.getRoot().getNodeByPath( [ 0 ] );
 
 					expect( table.getAttribute( 'alignment' ) ).to.equal( 'left' );
 				} );
 
-				it( 'should not upcast style="float:right;margin-right:23px" to right value (non-zero margin)', () => {
-					editor.setData( '<table style="float:right;margin-right:23px"><tr><td>foo</td></tr></table>' );
-					const table = model.document.getRoot().getNodeByPath( [ 0 ] );
-
-					expect( table.hasAttribute( 'alignment' ) ).to.be.false;
-				} );
-
 				it( 'should upcast align=right attribute', () => {
 					editor.setData( '<table align="right"><tr><td>foo</td></tr></table>' );
 					const table = model.document.getRoot().getNodeByPath( [ 0 ] );
@@ -848,13 +841,13 @@ describe( 'table properties', () => {
 				it( 'should downcast "right" alignment', () => {
 					model.change( writer => writer.setAttribute( 'alignment', 'right', table ) );
 
-					assertTableStyle( editor, null, 'float:right;margin-right:0;' );
+					assertTableStyle( editor, null, 'float:right;' );
 				} );
 
 				it( 'should downcast "left" alignment', () => {
 					model.change( writer => writer.setAttribute( 'alignment', 'left', table ) );
 
-					assertTableStyle( editor, null, 'float:left;margin-left:0;' );
+					assertTableStyle( editor, null, 'float:left;' );
 				} );
 
 				it( 'should not downcast "center" alignment', () => {
@@ -866,27 +859,27 @@ describe( 'table properties', () => {
 				it( 'should downcast changed alignment (left -> right)', () => {
 					model.change( writer => writer.setAttribute( 'alignment', 'left', table ) );
 
-					assertTableStyle( editor, null, 'float:left;margin-left:0;' );
+					assertTableStyle( editor, null, 'float:left;' );
 
 					model.change( writer => writer.setAttribute( 'alignment', 'right', table ) );
 
-					assertTableStyle( editor, null, 'float:right;margin-right:0;' );
+					assertTableStyle( editor, null, 'float:right;' );
 				} );
 
 				it( 'should downcast changed alignment (right -> left)', () => {
 					model.change( writer => writer.setAttribute( 'alignment', 'right', table ) );
 
-					assertTableStyle( editor, null, 'float:right;margin-right:0;' );
+					assertTableStyle( editor, null, 'float:right;' );
 
 					model.change( writer => writer.setAttribute( 'alignment', 'left', table ) );
 
-					assertTableStyle( editor, null, 'float:left;margin-left:0;' );
+					assertTableStyle( editor, null, 'float:left;' );
 				} );
 
 				it( 'should downcast removed alignment (from left)', () => {
 					model.change( writer => writer.setAttribute( 'alignment', 'left', table ) );
 
-					assertTableStyle( editor, null, 'float:left;margin-left:0;' );
+					assertTableStyle( editor, null, 'float:left;' );
 
 					model.change( writer => writer.removeAttribute( 'alignment', table ) );
 
@@ -896,7 +889,7 @@ describe( 'table properties', () => {
 				it( 'should downcast removed alignment (from right)', () => {
 					model.change( writer => writer.setAttribute( 'alignment', 'right', table ) );
 
-					assertTableStyle( editor, null, 'float:right;margin-right:0;' );
+					assertTableStyle( editor, null, 'float:right;' );
 
 					model.change( writer => writer.removeAttribute( 'alignment', table ) );