|
|
@@ -219,6 +219,26 @@ describe( 'table properties', () => {
|
|
|
table = createEmptyTable();
|
|
|
} );
|
|
|
|
|
|
+ it( 'should consume converted item borderColor attribute', () => {
|
|
|
+ editor.conversion.for( 'downcast' )
|
|
|
+ .add( dispatcher => dispatcher.on( 'attribute:borderColor:table', ( evt, data, conversionApi ) => {
|
|
|
+ expect( conversionApi.consumable.consume( data.item, evt.name ) ).to.be.false;
|
|
|
+ } ) );
|
|
|
+
|
|
|
+ model.change( writer => writer.setAttribute( 'borderColor', '#f00', table ) );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be overridable', () => {
|
|
|
+ editor.conversion.for( 'downcast' )
|
|
|
+ .add( dispatcher => dispatcher.on( 'attribute:borderColor:table', ( evt, data, conversionApi ) => {
|
|
|
+ conversionApi.consumable.consume( data.item, evt.name );
|
|
|
+ }, { priority: 'high' } ) );
|
|
|
+
|
|
|
+ model.change( writer => writer.setAttribute( 'borderColor', '#f00', table ) );
|
|
|
+
|
|
|
+ assertTableStyle( editor, '' );
|
|
|
+ } );
|
|
|
+
|
|
|
it( 'should downcast borderColor attribute (same top, right, bottom, left)', () => {
|
|
|
model.change( writer => writer.setAttribute( 'borderColor', {
|
|
|
top: '#f00',
|
|
|
@@ -246,6 +266,26 @@ describe( 'table properties', () => {
|
|
|
);
|
|
|
} );
|
|
|
|
|
|
+ it( 'should consume converted item borderStyle attribute', () => {
|
|
|
+ editor.conversion.for( 'downcast' )
|
|
|
+ .add( dispatcher => dispatcher.on( 'attribute:borderStyle:table', ( evt, data, conversionApi ) => {
|
|
|
+ expect( conversionApi.consumable.consume( data.item, evt.name ) ).to.be.false;
|
|
|
+ } ) );
|
|
|
+
|
|
|
+ model.change( writer => writer.setAttribute( 'borderStyle', 'solid', table ) );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be overridable', () => {
|
|
|
+ editor.conversion.for( 'downcast' )
|
|
|
+ .add( dispatcher => dispatcher.on( 'attribute:borderStyle:table', ( evt, data, conversionApi ) => {
|
|
|
+ conversionApi.consumable.consume( data.item, evt.name );
|
|
|
+ }, { priority: 'high' } ) );
|
|
|
+
|
|
|
+ model.change( writer => writer.setAttribute( 'borderStyle', 'solid', table ) );
|
|
|
+
|
|
|
+ assertTableStyle( editor, '' );
|
|
|
+ } );
|
|
|
+
|
|
|
it( 'should downcast borderStyle attribute (same top, right, bottom, left)', () => {
|
|
|
model.change( writer => writer.setAttribute( 'borderStyle', {
|
|
|
top: 'solid',
|
|
|
@@ -268,6 +308,26 @@ describe( 'table properties', () => {
|
|
|
assertTableStyle( editor, 'border-bottom:dotted;border-left:dashed;border-right:ridge;border-top:solid;' );
|
|
|
} );
|
|
|
|
|
|
+ it( 'should consume converted item borderWidth attribute', () => {
|
|
|
+ editor.conversion.for( 'downcast' )
|
|
|
+ .add( dispatcher => dispatcher.on( 'attribute:borderWidth:table', ( evt, data, conversionApi ) => {
|
|
|
+ expect( conversionApi.consumable.consume( data.item, evt.name ) ).to.be.false;
|
|
|
+ } ) );
|
|
|
+
|
|
|
+ model.change( writer => writer.setAttribute( 'borderWidth', '2px', table ) );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be overridable', () => {
|
|
|
+ editor.conversion.for( 'downcast' )
|
|
|
+ .add( dispatcher => dispatcher.on( 'attribute:borderWidth:table', ( evt, data, conversionApi ) => {
|
|
|
+ conversionApi.consumable.consume( data.item, evt.name );
|
|
|
+ }, { priority: 'high' } ) );
|
|
|
+
|
|
|
+ model.change( writer => writer.setAttribute( 'borderWidth', '2px', table ) );
|
|
|
+
|
|
|
+ assertTableStyle( editor, '' );
|
|
|
+ } );
|
|
|
+
|
|
|
it( 'should downcast borderWidth attribute (same top, right, bottom, left)', () => {
|
|
|
model.change( writer => writer.setAttribute( 'borderWidth', {
|
|
|
top: '42px',
|
|
|
@@ -515,6 +575,26 @@ describe( 'table properties', () => {
|
|
|
table = createEmptyTable();
|
|
|
} );
|
|
|
|
|
|
+ it( 'should consume converted item', () => {
|
|
|
+ editor.conversion.for( 'downcast' )
|
|
|
+ .add( dispatcher => dispatcher.on( 'attribute:backgroundColor:table', ( evt, data, conversionApi ) => {
|
|
|
+ expect( conversionApi.consumable.consume( data.item, evt.name ) ).to.be.false;
|
|
|
+ } ) );
|
|
|
+
|
|
|
+ model.change( writer => writer.setAttribute( 'backgroundColor', '#f00', table ) );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be overridable', () => {
|
|
|
+ editor.conversion.for( 'downcast' )
|
|
|
+ .add( dispatcher => dispatcher.on( 'attribute:backgroundColor:table', ( evt, data, conversionApi ) => {
|
|
|
+ conversionApi.consumable.consume( data.item, evt.name );
|
|
|
+ }, { priority: 'high' } ) );
|
|
|
+
|
|
|
+ model.change( writer => writer.setAttribute( 'backgroundColor', '#f00', table ) );
|
|
|
+
|
|
|
+ assertTableStyle( editor, '' );
|
|
|
+ } );
|
|
|
+
|
|
|
it( 'should downcast backgroundColor', () => {
|
|
|
model.change( writer => writer.setAttribute( 'backgroundColor', '#f00', table ) );
|
|
|
|
|
|
@@ -569,6 +649,26 @@ describe( 'table properties', () => {
|
|
|
table = createEmptyTable();
|
|
|
} );
|
|
|
|
|
|
+ it( 'should consume converted item', () => {
|
|
|
+ editor.conversion.for( 'downcast' )
|
|
|
+ .add( dispatcher => dispatcher.on( 'attribute:width:table', ( evt, data, conversionApi ) => {
|
|
|
+ expect( conversionApi.consumable.consume( data.item, evt.name ) ).to.be.false;
|
|
|
+ } ) );
|
|
|
+
|
|
|
+ model.change( writer => writer.setAttribute( 'width', '400px', table ) );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be overridable', () => {
|
|
|
+ editor.conversion.for( 'downcast' )
|
|
|
+ .add( dispatcher => dispatcher.on( 'attribute:width:table', ( evt, data, conversionApi ) => {
|
|
|
+ conversionApi.consumable.consume( data.item, evt.name );
|
|
|
+ }, { priority: 'high' } ) );
|
|
|
+
|
|
|
+ model.change( writer => writer.setAttribute( 'width', '400px', table ) );
|
|
|
+
|
|
|
+ assertTableStyle( editor, '' );
|
|
|
+ } );
|
|
|
+
|
|
|
it( 'should downcast width', () => {
|
|
|
model.change( writer => writer.setAttribute( 'width', '1337px', table ) );
|
|
|
|
|
|
@@ -646,6 +746,26 @@ describe( 'table properties', () => {
|
|
|
|
|
|
assertTableStyle( editor, null, 'height:1410em;' );
|
|
|
} );
|
|
|
+
|
|
|
+ it( 'should consume converted item', () => {
|
|
|
+ editor.conversion.for( 'downcast' )
|
|
|
+ .add( dispatcher => dispatcher.on( 'attribute:height:table', ( evt, data, conversionApi ) => {
|
|
|
+ expect( conversionApi.consumable.consume( data.item, evt.name ) ).to.be.false;
|
|
|
+ } ) );
|
|
|
+
|
|
|
+ model.change( writer => writer.setAttribute( 'height', '400px', table ) );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be overridable', () => {
|
|
|
+ editor.conversion.for( 'downcast' )
|
|
|
+ .add( dispatcher => dispatcher.on( 'attribute:height:table', ( evt, data, conversionApi ) => {
|
|
|
+ conversionApi.consumable.consume( data.item, evt.name );
|
|
|
+ }, { priority: 'high' } ) );
|
|
|
+
|
|
|
+ model.change( writer => writer.setAttribute( 'height', '400px', table ) );
|
|
|
+
|
|
|
+ assertTableStyle( editor, '' );
|
|
|
+ } );
|
|
|
} );
|
|
|
} );
|
|
|
|
|
|
@@ -655,48 +775,20 @@ describe( 'table properties', () => {
|
|
|
} );
|
|
|
|
|
|
describe( 'upcast conversion', () => {
|
|
|
- it( 'should upcast style="margin-left:auto;margin-right:0" to right value', () => {
|
|
|
- editor.setData( '<table style="margin-left:auto;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;margin-right:auto" to left value', () => {
|
|
|
- editor.setData( '<table style="margin-left:0;margin-right:auto"><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 upcast style="margin-left:auto;margin-right:auto" to center value', () => {
|
|
|
- editor.setData( '<table style="margin-left:auto;margin-right:auto"><tr><td>foo</td></tr></table>' );
|
|
|
- const table = model.document.getRoot().getNodeByPath( [ 0 ] );
|
|
|
-
|
|
|
- expect( table.getAttribute( 'alignment' ) ).to.equal( 'center' );
|
|
|
- } );
|
|
|
-
|
|
|
- it( 'should upcast style="margin-left:auto;margin-right:0pt" to right value', () => {
|
|
|
- editor.setData( '<table style="margin-left:auto;margin-right:0pt"><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:auto;margin-right:0%" to right value', () => {
|
|
|
- editor.setData( '<table style="margin-left:auto;margin-right:0%"><tr><td>foo</td></tr></table>' );
|
|
|
- const table = model.document.getRoot().getNodeByPath( [ 0 ] );
|
|
|
-
|
|
|
- expect( table.getAttribute( 'alignment' ) ).to.equal( 'right' );
|
|
|
- } );
|
|
|
-
|
|
|
- it( 'should not upcast style="margin-left:auto;margin-right:0.23pt" to right value', () => {
|
|
|
- editor.setData( '<table style="margin-left:auto;margin-right:0.23pt"><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 ] );
|
|
|
@@ -711,11 +803,11 @@ describe( 'table properties', () => {
|
|
|
expect( table.getAttribute( 'alignment' ) ).to.equal( 'left' );
|
|
|
} );
|
|
|
|
|
|
- it( 'should upcast align=center attribute', () => {
|
|
|
+ it( 'should discard align=center attribute', () => {
|
|
|
editor.setData( '<table align="center"><tr><td>foo</td></tr></table>' );
|
|
|
const table = model.document.getRoot().getNodeByPath( [ 0 ] );
|
|
|
|
|
|
- expect( table.getAttribute( 'alignment' ) ).to.equal( 'center' );
|
|
|
+ expect( table.getAttribute( 'alignment' ) ).to.be.undefined;
|
|
|
} );
|
|
|
|
|
|
it( 'should discard align=justify attribute', () => {
|
|
|
@@ -733,38 +825,78 @@ describe( 'table properties', () => {
|
|
|
table = createEmptyTable();
|
|
|
} );
|
|
|
|
|
|
- it( 'should downcast right alignment', () => {
|
|
|
+ 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 be overridable', () => {
|
|
|
+ editor.conversion.for( 'downcast' )
|
|
|
+ .add( dispatcher => dispatcher.on( 'attribute:alignment:table', ( evt, data, conversionApi ) => {
|
|
|
+ conversionApi.consumable.consume( data.item, evt.name );
|
|
|
+ }, { priority: 'highest' } ) );
|
|
|
|
|
|
- assertTableStyle( editor, 'margin-left:auto;margin-right:0;' );
|
|
|
+ model.change( writer => writer.setAttribute( 'alignment', 'right', table ) );
|
|
|
+
|
|
|
+ assertTableStyle( editor, '' );
|
|
|
} );
|
|
|
|
|
|
- it( 'should downcast left alignment', () => {
|
|
|
+ it( 'should downcast "right" alignment', () => {
|
|
|
+ model.change( writer => writer.setAttribute( 'alignment', 'right', table ) );
|
|
|
+
|
|
|
+ assertTableStyle( editor, null, 'float:right;' );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should downcast "left" alignment', () => {
|
|
|
model.change( writer => writer.setAttribute( 'alignment', 'left', table ) );
|
|
|
|
|
|
- assertTableStyle( editor, 'margin-left:0;margin-right:auto;' );
|
|
|
+ assertTableStyle( editor, null, 'float:left;' );
|
|
|
} );
|
|
|
|
|
|
- it( 'should downcast centered alignment', () => {
|
|
|
+ it( 'should not downcast "center" alignment', () => {
|
|
|
model.change( writer => writer.setAttribute( 'alignment', 'center', table ) );
|
|
|
|
|
|
- assertTableStyle( editor, 'margin-left:auto;margin-right:auto;' );
|
|
|
+ assertTableStyle( editor, null, null );
|
|
|
} );
|
|
|
|
|
|
- it( 'should downcast changed alignment', () => {
|
|
|
- model.change( writer => writer.setAttribute( 'alignment', 'center', table ) );
|
|
|
+ it( 'should downcast changed alignment (left -> right)', () => {
|
|
|
+ model.change( writer => writer.setAttribute( 'alignment', 'left', table ) );
|
|
|
|
|
|
- assertTableStyle( editor, 'margin-left:auto;margin-right:auto;' );
|
|
|
+ assertTableStyle( editor, null, 'float:left;' );
|
|
|
|
|
|
model.change( writer => writer.setAttribute( 'alignment', 'right', table ) );
|
|
|
|
|
|
- assertTableStyle( editor, 'margin-left:auto;margin-right:0;' );
|
|
|
+ assertTableStyle( editor, null, 'float:right;' );
|
|
|
} );
|
|
|
|
|
|
- it( 'should downcast removed alignment', () => {
|
|
|
- model.change( writer => writer.setAttribute( 'alignment', 'center', table ) );
|
|
|
+ it( 'should downcast changed alignment (right -> left)', () => {
|
|
|
+ model.change( writer => writer.setAttribute( 'alignment', 'right', table ) );
|
|
|
+
|
|
|
+ assertTableStyle( editor, null, 'float:right;' );
|
|
|
+
|
|
|
+ model.change( writer => writer.setAttribute( 'alignment', 'left', table ) );
|
|
|
+
|
|
|
+ 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;' );
|
|
|
+
|
|
|
+ model.change( writer => writer.removeAttribute( 'alignment', table ) );
|
|
|
+
|
|
|
+ assertTableStyle( editor );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should downcast removed alignment (from right)', () => {
|
|
|
+ model.change( writer => writer.setAttribute( 'alignment', 'right', table ) );
|
|
|
|
|
|
- assertTableStyle( editor, 'margin-left:auto;margin-right:auto;' );
|
|
|
+ assertTableStyle( editor, null, 'float:right;' );
|
|
|
|
|
|
model.change( writer => writer.removeAttribute( 'alignment', table ) );
|
|
|
|