|
|
@@ -8,9 +8,10 @@ import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
|
|
|
|
|
|
import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
|
|
|
|
|
|
-import { assertTableCellStyle, modelTable, setTableCellWithObjectAttributes } from '../../_utils/utils';
|
|
|
+import { assertTableCellStyle, modelTable, setTableCellWithObjectAttributes, viewTable } from '../../_utils/utils';
|
|
|
import TableCellPropertiesEditing from '../../../src/tablecellproperties/tablecellpropertiesediting';
|
|
|
import TableCellBorderColorCommand from '../../../src/tablecellproperties/commands/tablecellbordercolorcommand';
|
|
|
+import { assertEqualMarkup } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
|
|
|
|
|
|
describe( 'table cell properties', () => {
|
|
|
describe( 'commands', () => {
|
|
|
@@ -54,6 +55,17 @@ describe( 'table cell properties', () => {
|
|
|
expect( command.isEnabled ).to.be.true;
|
|
|
} );
|
|
|
} );
|
|
|
+
|
|
|
+ describe( 'multi-cell selection', () => {
|
|
|
+ it( 'should be true if the selection contains some table cells', () => {
|
|
|
+ setData( model, modelTable( [
|
|
|
+ [ { contents: '00', isSelected: true }, '01' ],
|
|
|
+ [ '10', { contents: '11', isSelected: true } ]
|
|
|
+ ] ) );
|
|
|
+
|
|
|
+ expect( command.isEnabled ).to.be.true;
|
|
|
+ } );
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
describe( 'value', () => {
|
|
|
@@ -109,6 +121,68 @@ describe( 'table cell properties', () => {
|
|
|
expect( command.value ).to.equal( 'blue' );
|
|
|
} );
|
|
|
} );
|
|
|
+
|
|
|
+ describe( 'multi-cell selection', () => {
|
|
|
+ it( 'should be undefined if no table cells have the "borderColor" property', () => {
|
|
|
+ setData( model, modelTable( [
|
|
|
+ [
|
|
|
+ { contents: '00', isSelected: true },
|
|
|
+ { contents: '01', isSelected: true }
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ '10',
|
|
|
+ { contents: '11', isSelected: true }
|
|
|
+ ]
|
|
|
+ ] ) );
|
|
|
+
|
|
|
+ expect( command.value ).to.be.undefined;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be undefined if only some table cells have the "borderColor" property', () => {
|
|
|
+ setData( model, modelTable( [
|
|
|
+ [
|
|
|
+ { contents: '00', isSelected: true, borderColor: '#f00' },
|
|
|
+ { contents: '01', isSelected: true }
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ '10',
|
|
|
+ { contents: '11', isSelected: true, borderColor: '#f00' }
|
|
|
+ ]
|
|
|
+ ] ) );
|
|
|
+
|
|
|
+ expect( command.value ).to.be.undefined;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be undefined if one of selected table cells has a different "borderColor" property value', () => {
|
|
|
+ setData( model, modelTable( [
|
|
|
+ [
|
|
|
+ { contents: '00', isSelected: true, borderColor: '#f00' },
|
|
|
+ { contents: '01', isSelected: true, borderColor: 'pink' }
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ '10',
|
|
|
+ { contents: '11', isSelected: true, borderColor: '#f00' }
|
|
|
+ ]
|
|
|
+ ] ) );
|
|
|
+
|
|
|
+ expect( command.value ).to.be.undefined;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be set if all table cells have the same "borderColor" property value', () => {
|
|
|
+ setData( model, modelTable( [
|
|
|
+ [
|
|
|
+ { contents: '00', isSelected: true, borderColor: '#f00' },
|
|
|
+ { contents: '01', isSelected: true, borderColor: '#f00' }
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ '10',
|
|
|
+ { contents: '11', isSelected: true, borderColor: '#f00' }
|
|
|
+ ]
|
|
|
+ ] ) );
|
|
|
+
|
|
|
+ expect( command.value ).to.equal( '#f00' );
|
|
|
+ } );
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
describe( 'execute()', () => {
|
|
|
@@ -172,6 +246,38 @@ describe( 'table cell properties', () => {
|
|
|
assertTableCellStyle( editor, '' );
|
|
|
} );
|
|
|
} );
|
|
|
+
|
|
|
+ describe( 'multi-cell selection', () => {
|
|
|
+ beforeEach( () => {
|
|
|
+ setData( model, modelTable( [
|
|
|
+ [ { contents: '00', isSelected: true }, '01' ],
|
|
|
+ [ '10', { contents: '11', isSelected: true } ]
|
|
|
+ ] ) );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should set the "borderColor" attribute value of selected table cells', () => {
|
|
|
+ command.execute( { value: '#f00' } );
|
|
|
+
|
|
|
+ assertEqualMarkup( editor.getData(), viewTable( [
|
|
|
+ [ { contents: '00', style: 'border-bottom:#f00;border-left:#f00;border-right:#f00;border-top:#f00;' }, '01' ],
|
|
|
+ [ '10', { contents: '11', style: 'border-bottom:#f00;border-left:#f00;border-right:#f00;border-top:#f00;' } ]
|
|
|
+ ] ) );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should remove "borderColor" from the selected table cell if no value is passed', () => {
|
|
|
+ setData( model, modelTable( [
|
|
|
+ [ { contents: '00', isSelected: true, borderColor: '#f00' }, '01' ],
|
|
|
+ [ '10', { contents: '11', isSelected: true, borderColor: '#f00' } ]
|
|
|
+ ] ) );
|
|
|
+
|
|
|
+ command.execute();
|
|
|
+
|
|
|
+ assertEqualMarkup( editor.getData(), viewTable( [
|
|
|
+ [ '00', '01' ],
|
|
|
+ [ '10', '11' ]
|
|
|
+ ] ) );
|
|
|
+ } );
|
|
|
+ } );
|
|
|
} );
|
|
|
} );
|
|
|
} );
|