|
|
@@ -11,58 +11,60 @@ import RemoveColumnCommand from '../../src/commands/removecolumncommand';
|
|
|
import { downcastInsertTable } from '../../src/converters/downcast';
|
|
|
import upcastTable from '../../src/converters/upcasttable';
|
|
|
import { formatTable, formattedModelTable, modelTable } from '../_utils/utils';
|
|
|
+import TableUtils from '../../src/tableutils';
|
|
|
|
|
|
describe( 'RemoveColumnCommand', () => {
|
|
|
let editor, model, command;
|
|
|
|
|
|
beforeEach( () => {
|
|
|
- return ModelTestEditor.create()
|
|
|
- .then( newEditor => {
|
|
|
- editor = newEditor;
|
|
|
- model = editor.model;
|
|
|
- command = new RemoveColumnCommand( editor );
|
|
|
-
|
|
|
- const conversion = editor.conversion;
|
|
|
- const schema = model.schema;
|
|
|
-
|
|
|
- schema.register( 'table', {
|
|
|
- allowWhere: '$block',
|
|
|
- allowAttributes: [ 'headingRows', 'headingColumns' ],
|
|
|
- isBlock: true,
|
|
|
- isObject: true
|
|
|
- } );
|
|
|
-
|
|
|
- schema.register( 'tableRow', {
|
|
|
- allowIn: 'table',
|
|
|
- allowAttributes: [],
|
|
|
- isBlock: true,
|
|
|
- isLimit: true
|
|
|
- } );
|
|
|
-
|
|
|
- schema.register( 'tableCell', {
|
|
|
- allowIn: 'tableRow',
|
|
|
- allowContentOf: '$block',
|
|
|
- allowAttributes: [ 'colspan', 'rowspan' ],
|
|
|
- isBlock: true,
|
|
|
- isLimit: true
|
|
|
- } );
|
|
|
-
|
|
|
- model.schema.register( 'p', { inheritAllFrom: '$block' } );
|
|
|
-
|
|
|
- // Table conversion.
|
|
|
- conversion.for( 'upcast' ).add( upcastTable() );
|
|
|
- conversion.for( 'downcast' ).add( downcastInsertTable() );
|
|
|
-
|
|
|
- // Table row upcast only since downcast conversion is done in `downcastTable()`.
|
|
|
- conversion.for( 'upcast' ).add( upcastElementToElement( { model: 'tableRow', view: 'tr' } ) );
|
|
|
-
|
|
|
- // Table cell conversion.
|
|
|
- conversion.for( 'upcast' ).add( upcastElementToElement( { model: 'tableCell', view: 'td' } ) );
|
|
|
- conversion.for( 'upcast' ).add( upcastElementToElement( { model: 'tableCell', view: 'th' } ) );
|
|
|
-
|
|
|
- conversion.attributeToAttribute( { model: 'colspan', view: 'colspan' } );
|
|
|
- conversion.attributeToAttribute( { model: 'rowspan', view: 'rowspan' } );
|
|
|
+ return ModelTestEditor.create( {
|
|
|
+ plugins: [ TableUtils ]
|
|
|
+ } ).then( newEditor => {
|
|
|
+ editor = newEditor;
|
|
|
+ model = editor.model;
|
|
|
+ command = new RemoveColumnCommand( editor );
|
|
|
+
|
|
|
+ const conversion = editor.conversion;
|
|
|
+ const schema = model.schema;
|
|
|
+
|
|
|
+ schema.register( 'table', {
|
|
|
+ allowWhere: '$block',
|
|
|
+ allowAttributes: [ 'headingRows', 'headingColumns' ],
|
|
|
+ isBlock: true,
|
|
|
+ isObject: true
|
|
|
} );
|
|
|
+
|
|
|
+ schema.register( 'tableRow', {
|
|
|
+ allowIn: 'table',
|
|
|
+ allowAttributes: [],
|
|
|
+ isBlock: true,
|
|
|
+ isLimit: true
|
|
|
+ } );
|
|
|
+
|
|
|
+ schema.register( 'tableCell', {
|
|
|
+ allowIn: 'tableRow',
|
|
|
+ allowContentOf: '$block',
|
|
|
+ allowAttributes: [ 'colspan', 'rowspan' ],
|
|
|
+ isBlock: true,
|
|
|
+ isLimit: true
|
|
|
+ } );
|
|
|
+
|
|
|
+ model.schema.register( 'p', { inheritAllFrom: '$block' } );
|
|
|
+
|
|
|
+ // Table conversion.
|
|
|
+ conversion.for( 'upcast' ).add( upcastTable() );
|
|
|
+ conversion.for( 'downcast' ).add( downcastInsertTable() );
|
|
|
+
|
|
|
+ // Table row upcast only since downcast conversion is done in `downcastTable()`.
|
|
|
+ conversion.for( 'upcast' ).add( upcastElementToElement( { model: 'tableRow', view: 'tr' } ) );
|
|
|
+
|
|
|
+ // Table cell conversion.
|
|
|
+ conversion.for( 'upcast' ).add( upcastElementToElement( { model: 'tableCell', view: 'td' } ) );
|
|
|
+ conversion.for( 'upcast' ).add( upcastElementToElement( { model: 'tableCell', view: 'th' } ) );
|
|
|
+
|
|
|
+ conversion.attributeToAttribute( { model: 'colspan', view: 'colspan' } );
|
|
|
+ conversion.attributeToAttribute( { model: 'rowspan', view: 'rowspan' } );
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
afterEach( () => {
|
|
|
@@ -166,7 +168,7 @@ describe( 'RemoveColumnCommand', () => {
|
|
|
] ) );
|
|
|
} );
|
|
|
|
|
|
- it( 'should move colspaned cells to row below removing it\'s column', () => {
|
|
|
+ it( 'should decrease colspan of cells that are on removed column', () => {
|
|
|
setData( model, modelTable( [
|
|
|
[ { colspan: 3, contents: '[]00' }, '03' ],
|
|
|
[ { colspan: 2, contents: '10' }, '13' ],
|