| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637 |
- /**
- * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */
- import ModelTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/modeltesteditor';
- import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
- import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
- import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
- import TableEditing from '../src/tableediting';
- import { modelTable } from './_utils/utils';
- import TableWalker from '../src/tablewalker';
- describe( 'TableWalker', () => {
- let editor, model, doc, root;
- beforeEach( () => {
- return ModelTestEditor.create( { plugins: [ Paragraph, TableEditing ] } )
- .then( newEditor => {
- editor = newEditor;
- model = editor.model;
- doc = model.document;
- root = doc.getRoot( 'main' );
- } );
- } );
- function testWalker( tableData, expected, options, skip ) {
- setData( model, modelTable( tableData ) );
- const walker = new TableWalker( root.getChild( 0 ), options );
- if ( skip !== undefined ) {
- walker.skipRow( skip );
- }
- const result = [ ...walker ];
- const formattedResult = result.map( tableSlot => {
- const { cell, row, column, isAnchor, cellWidth, cellHeight, cellAnchorRow, cellAnchorColumn } = tableSlot;
- return {
- row,
- column,
- data: cell && cell.getChild( 0 ).getChild( 0 ).data,
- index: tableSlot.getPositionBefore().offset,
- ...( cellAnchorRow != row ? { anchorRow: cellAnchorRow } : null ),
- ...( cellAnchorColumn != column ? { anchorColumn: cellAnchorColumn } : null ),
- ...( isAnchor ? { isAnchor } : null ),
- ...( cellWidth > 1 ? { width: cellWidth } : null ),
- ...( cellHeight > 1 ? { height: cellHeight } : null )
- };
- } );
- expect( formattedResult ).to.deep.equal( expected );
- }
- it( 'should iterate over a table', () => {
- // +----+----+
- // | 00 | 01 |
- // +----+----+
- // | 10 | 11 |
- // +----+----+
- testWalker( [
- [ '00', '01' ],
- [ '10', '11' ]
- ], [
- { row: 0, column: 0, index: 0, data: '00', isAnchor: true },
- { row: 0, column: 1, index: 1, data: '01', isAnchor: true },
- { row: 1, column: 0, index: 0, data: '10', isAnchor: true },
- { row: 1, column: 1, index: 1, data: '11', isAnchor: true }
- ] );
- } );
- it( 'should properly output column indexes of a table that has col-spans', () => {
- // +----+----+----+
- // | 00 | 13 |
- // +----+----+----+
- testWalker( [
- [ { colspan: 2, contents: '00' }, '13' ]
- ], [
- { row: 0, column: 0, index: 0, data: '00', isAnchor: true, width: 2 },
- { row: 0, column: 2, index: 1, data: '13', isAnchor: true }
- ] );
- } );
- it( 'should properly output column indexes of a table that has row-spans', () => {
- // +----+----+----+
- // | 00 | 02 |
- // + +----+
- // | | 12 |
- // + +----+
- // | | 22 |
- // +----+----+----+
- // | 30 | 31 | 32 |
- // +----+----+----+
- testWalker( [
- [ { colspan: 2, rowspan: 3, contents: '00' }, '02' ],
- [ '12' ],
- [ '22' ],
- [ '30', '31', '32' ]
- ], [
- { row: 0, column: 0, index: 0, data: '00', isAnchor: true, width: 2, height: 3 },
- { row: 0, column: 2, index: 1, data: '02', isAnchor: true },
- { row: 1, column: 2, index: 0, data: '12', isAnchor: true },
- { row: 2, column: 2, index: 0, data: '22', isAnchor: true },
- { row: 3, column: 0, index: 0, data: '30', isAnchor: true },
- { row: 3, column: 1, index: 1, data: '31', isAnchor: true },
- { row: 3, column: 2, index: 2, data: '32', isAnchor: true }
- ] );
- } );
- it( 'should properly output column indexes of a table that has multiple row-spans', () => {
- // +----+----+----+
- // | 11 | 12 | 13 |
- // + +----+----+
- // | | 22 | 23 |
- // + + +----+
- // | | | 33 |
- // +----+----+----+
- // | 41 | 42 | 43 |
- // +----+----+----+
- testWalker( [
- [ { rowspan: 3, contents: '11' }, '12', '13' ],
- [ { rowspan: 2, contents: '22' }, '23' ],
- [ '33' ],
- [ '41', '42', '43' ]
- ], [
- { row: 0, column: 0, index: 0, data: '11', isAnchor: true, height: 3 },
- { row: 0, column: 1, index: 1, data: '12', isAnchor: true },
- { row: 0, column: 2, index: 2, data: '13', isAnchor: true },
- { row: 1, column: 1, index: 0, data: '22', isAnchor: true, height: 2 },
- { row: 1, column: 2, index: 1, data: '23', isAnchor: true },
- { row: 2, column: 2, index: 0, data: '33', isAnchor: true },
- { row: 3, column: 0, index: 0, data: '41', isAnchor: true },
- { row: 3, column: 1, index: 1, data: '42', isAnchor: true },
- { row: 3, column: 2, index: 2, data: '43', isAnchor: true }
- ] );
- } );
- describe( 'option.startRow', () => {
- it( 'should start iterating from given row but with cell spans properly calculated', () => {
- // +----+----+----+
- // | 11 | 13 |
- // + +----+
- // | | 23 |
- // + +----+
- // | | 33 |
- // +----+----+----+
- // | 41 | 42 | 43 |
- // +----+----+----+
- testWalker( [
- [ { colspan: 2, rowspan: 3, contents: '11' }, '13' ],
- [ '23' ],
- [ '33' ],
- [ '41', '42', '43' ]
- ], [
- { row: 2, column: 2, index: 0, data: '33', isAnchor: true },
- { row: 3, column: 0, index: 0, data: '41', isAnchor: true },
- { row: 3, column: 1, index: 1, data: '42', isAnchor: true },
- { row: 3, column: 2, index: 2, data: '43', isAnchor: true }
- ], { startRow: 2 } );
- } );
- it( 'should start iterating from given row, includeAllSlots = true', () => {
- // +----+----+----+
- // | 11 | 13 |
- // + +----+
- // | | 23 |
- // + +----+
- // | | 33 |
- // +----+----+----+
- // | 41 | 42 | 43 |
- // +----+----+----+
- testWalker( [
- [ { colspan: 2, rowspan: 3, contents: '11' }, '13' ],
- [ '23' ],
- [ '33' ],
- [ '41', '42', '43' ]
- ], [
- { row: 2, column: 0, index: 0, data: '11', width: 2, height: 3, anchorRow: 0 },
- { row: 2, column: 1, index: 0, data: '11', width: 2, height: 3, anchorRow: 0, anchorColumn: 0 },
- { row: 2, column: 2, index: 0, data: '33', isAnchor: true },
- { row: 3, column: 0, index: 0, data: '41', isAnchor: true },
- { row: 3, column: 1, index: 1, data: '42', isAnchor: true },
- { row: 3, column: 2, index: 2, data: '43', isAnchor: true }
- ], { startRow: 2, includeAllSlots: true } );
- } );
- } );
- describe( 'option.endRow', () => {
- it( 'should stop iterating after given row but with cell spans properly calculated', () => {
- // +----+----+----+
- // | 11 | 13 |
- // + +----+
- // | | 23 |
- // + +----+
- // | | 33 |
- // +----+----+----+
- // | 41 | 42 | 43 |
- // +----+----+----+
- testWalker( [
- [ { colspan: 2, rowspan: 3, contents: '11' }, '13' ],
- [ '23' ],
- [ '33' ],
- [ '41', '42', '43' ]
- ], [
- { row: 0, column: 0, index: 0, data: '11', isAnchor: true, width: 2, height: 3 },
- { row: 0, column: 2, index: 1, data: '13', isAnchor: true },
- { row: 1, column: 2, index: 0, data: '23', isAnchor: true },
- { row: 2, column: 2, index: 0, data: '33', isAnchor: true }
- ], { endRow: 2 } );
- } );
- it( 'should iterate over given row only', () => {
- // +----+----+----+
- // | 11 | 13 |
- // + +----+
- // | | 23 |
- // + +----+
- // | | 33 |
- // +----+----+----+
- // | 41 | 42 | 43 |
- // +----+----+----+
- testWalker( [
- [ { colspan: 2, rowspan: 3, contents: '11' }, '13' ],
- [ '23' ],
- [ '33' ],
- [ '41', '42', '43' ]
- ], [
- { row: 0, column: 0, index: 0, data: '11', isAnchor: true, width: 2, height: 3 },
- { row: 0, column: 2, index: 1, data: '13', isAnchor: true }
- ], { endRow: 0 } );
- } );
- it( 'should stop iterating after given row, includeAllSlots = true', () => {
- // +----+----+----+
- // | 11 | 13 |
- // + +----+
- // | | 23 |
- // + +----+
- // | | 33 |
- // +----+----+----+
- // | 41 | 42 | 43 |
- // +----+----+----+
- testWalker( [
- [ { colspan: 2, rowspan: 3, contents: '11' }, '13' ],
- [ '23' ],
- [ '33' ],
- [ '41', '42', '43' ]
- ], [
- { row: 0, column: 0, index: 0, data: '11', width: 2, height: 3, isAnchor: true },
- { row: 0, column: 1, index: 0, data: '11', width: 2, height: 3, anchorColumn: 0 },
- { row: 0, column: 2, index: 1, data: '13', isAnchor: true },
- { row: 1, column: 0, index: 0, data: '11', width: 2, height: 3, anchorRow: 0 },
- { row: 1, column: 1, index: 0, data: '11', width: 2, height: 3, anchorRow: 0, anchorColumn: 0 },
- { row: 1, column: 2, index: 0, data: '23', isAnchor: true }
- ], { endRow: 1, includeAllSlots: true } );
- } );
- } );
- describe( 'options.row', () => {
- it( 'should iterate given row', () => {
- // +----+----+----+
- // | 00 | 02 |
- // + +----+
- // | | 12 |
- // + +----+
- // | | 22 |
- // +----+----+----+
- // | 30 | 31 | 32 |
- // +----+----+----+
- testWalker( [
- [ { colspan: 2, rowspan: 3, contents: '00' }, '02' ],
- [ '12' ],
- [ '22' ],
- [ '30', '31', '32' ]
- ], [
- { row: 1, column: 2, index: 0, data: '12', isAnchor: true }
- ], { row: 1 } );
- } );
- it( 'should iterate given row, includeAllSlots = true', () => {
- // +----+----+----+
- // | 00 | 02 |
- // + +----+
- // | | 12 |
- // + +----+
- // | | 22 |
- // +----+----+----+
- // | 30 | 31 | 32 |
- // +----+----+----+
- testWalker( [
- [ { colspan: 2, rowspan: 3, contents: '00' }, '02' ],
- [ '12' ],
- [ '22' ],
- [ '30', '31', '32' ]
- ], [
- { row: 1, column: 0, index: 0, data: '00', width: 2, height: 3, anchorRow: 0 },
- { row: 1, column: 1, index: 0, data: '00', width: 2, height: 3, anchorRow: 0, anchorColumn: 0 },
- { row: 1, column: 2, index: 0, data: '12', isAnchor: true }
- ], { row: 1, includeAllSlots: true } );
- } );
- } );
- describe( 'options.startColumn', () => {
- it( 'should not return the slots before startColumn', () => {
- // +----+----+----+
- // | 00 | 02 |
- // + +----+
- // | | 12 |
- // + +----+
- // | | 22 |
- // +----+----+----+
- // | 30 | 31 | 32 |
- // +----+----+----+
- testWalker( [
- [ { colspan: 2, rowspan: 3, contents: '00' }, '02' ],
- [ '12' ],
- [ '22' ],
- [ '30', '31', '32' ]
- ], [
- { row: 0, column: 2, index: 1, data: '02', isAnchor: true },
- { row: 1, column: 2, index: 0, data: '12', isAnchor: true },
- { row: 2, column: 2, index: 0, data: '22', isAnchor: true },
- { row: 3, column: 1, index: 1, data: '31', isAnchor: true },
- { row: 3, column: 2, index: 2, data: '32', isAnchor: true }
- ], { startColumn: 1 } );
- } );
- it( 'should not return the slots before startColumn, includeAllSlots = true', () => {
- // +----+----+----+
- // | 00 | 02 |
- // + +----+
- // | | 12 |
- // + +----+
- // | | 22 |
- // +----+----+----+
- // | 30 | 31 | 32 |
- // +----+----+----+
- testWalker( [
- [ { colspan: 2, rowspan: 3, contents: '00' }, '02' ],
- [ '12' ],
- [ '22' ],
- [ '30', '31', '32' ]
- ], [
- { row: 0, column: 1, index: 0, data: '00', width: 2, height: 3, anchorColumn: 0 },
- { row: 0, column: 2, index: 1, data: '02', isAnchor: true },
- { row: 1, column: 1, index: 0, data: '00', width: 2, height: 3, anchorColumn: 0, anchorRow: 0 },
- { row: 1, column: 2, index: 0, data: '12', isAnchor: true },
- { row: 2, column: 1, index: 0, data: '00', width: 2, height: 3, anchorColumn: 0, anchorRow: 0 },
- { row: 2, column: 2, index: 0, data: '22', isAnchor: true },
- { row: 3, column: 1, index: 1, data: '31', isAnchor: true },
- { row: 3, column: 2, index: 2, data: '32', isAnchor: true }
- ], { startColumn: 1, includeAllSlots: true } );
- } );
- } );
- describe( 'options.endColumn', () => {
- it( 'should not return the slots after endColumn', () => {
- // +----+----+----+
- // | 00 | 02 |
- // + +----+
- // | | 12 |
- // + +----+
- // | | 22 |
- // +----+----+----+
- // | 30 | 31 | 32 |
- // +----+----+----+
- testWalker( [
- [ { colspan: 2, rowspan: 3, contents: '00' }, '02' ],
- [ '12' ],
- [ '22' ],
- [ '30', '31', '32' ]
- ], [
- { row: 0, column: 0, index: 0, data: '00', isAnchor: true, width: 2, height: 3 },
- { row: 3, column: 0, index: 0, data: '30', isAnchor: true },
- { row: 3, column: 1, index: 1, data: '31', isAnchor: true }
- ], { endColumn: 1 } );
- } );
- it( 'should not return the slots after endColumn, includeAllSlots = true', () => {
- // +----+----+----+
- // | 00 | 02 |
- // + +----+
- // | | 12 |
- // + +----+
- // | | 22 |
- // +----+----+----+
- // | 30 | 31 | 32 |
- // +----+----+----+
- testWalker( [
- [ { colspan: 2, rowspan: 3, contents: '00' }, '02' ],
- [ '12' ],
- [ '22' ],
- [ '30', '31', '32' ]
- ], [
- { row: 0, column: 0, index: 0, data: '00', width: 2, height: 3, isAnchor: true },
- { row: 0, column: 1, index: 0, data: '00', width: 2, height: 3, anchorColumn: 0 },
- { row: 1, column: 0, index: 0, data: '00', width: 2, height: 3, anchorRow: 0 },
- { row: 1, column: 1, index: 0, data: '00', width: 2, height: 3, anchorColumn: 0, anchorRow: 0 },
- { row: 2, column: 0, index: 0, data: '00', width: 2, height: 3, anchorRow: 0 },
- { row: 2, column: 1, index: 0, data: '00', width: 2, height: 3, anchorColumn: 0, anchorRow: 0 },
- { row: 3, column: 0, index: 0, data: '30', isAnchor: true },
- { row: 3, column: 1, index: 1, data: '31', isAnchor: true }
- ], { endColumn: 1, includeAllSlots: true } );
- } );
- } );
- describe( 'options.column', () => {
- it( 'should return the slots from given column', () => {
- // +----+----+----+
- // | 00 | 02 |
- // + +----+
- // | | 12 |
- // + +----+
- // | | 22 |
- // +----+----+----+
- // | 30 | 31 | 32 |
- // +----+----+----+
- testWalker( [
- [ { colspan: 2, rowspan: 3, contents: '00' }, '02' ],
- [ '12' ],
- [ '22' ],
- [ '30', '31', '32' ]
- ], [
- { row: 3, column: 1, index: 1, data: '31', isAnchor: true }
- ], { column: 1 } );
- } );
- it( 'should return the slots from given column, includeAllSlots = true', () => {
- // +----+----+----+
- // | 00 | 02 |
- // + +----+
- // | | 12 |
- // + +----+
- // | | 22 |
- // +----+----+----+
- // | 30 | 31 | 32 |
- // +----+----+----+
- testWalker( [
- [ { colspan: 2, rowspan: 3, contents: '00' }, '02' ],
- [ '12' ],
- [ '22' ],
- [ '30', '31', '32' ]
- ], [
- { row: 0, column: 1, index: 0, data: '00', width: 2, height: 3, anchorColumn: 0 },
- { row: 1, column: 1, index: 0, data: '00', width: 2, height: 3, anchorColumn: 0, anchorRow: 0 },
- { row: 2, column: 1, index: 0, data: '00', width: 2, height: 3, anchorColumn: 0, anchorRow: 0 },
- { row: 3, column: 1, index: 1, data: '31', isAnchor: true }
- ], { column: 1, includeAllSlots: true } );
- } );
- } );
- describe( 'option.includeAllSlots', () => {
- it( 'should output spanned cells at the end of a table', () => {
- // +----+----+
- // | 00 | 01 |
- // +----+ +
- // | 10 | |
- // +----+----+
- testWalker( [
- [ '00', { rowspan: 2, contents: '01' } ],
- [ '10' ]
- ], [
- { row: 0, column: 0, index: 0, data: '00', isAnchor: true },
- { row: 0, column: 1, index: 1, data: '01', isAnchor: true, height: 2 },
- { row: 1, column: 0, index: 0, data: '10', isAnchor: true },
- { row: 1, column: 1, index: 1, data: '01', anchorRow: 0, height: 2 }
- ], { includeAllSlots: true } );
- } );
- it( 'should output spanned cells', () => {
- // +----+----+----+
- // | 00 | 02 |
- // + +----+
- // | | 12 |
- // + +----+
- // | | 22 |
- // +----+----+----+
- // | 30 | 31 |
- // +----+----+----+
- testWalker( [
- [ { colspan: 2, rowspan: 3, contents: '00' }, '02' ],
- [ '12' ],
- [ '22' ],
- [ '30', { colspan: 2, contents: '31' } ]
- ], [
- { row: 0, column: 0, index: 0, data: '00', width: 2, height: 3, isAnchor: true },
- { row: 0, column: 1, index: 0, data: '00', width: 2, height: 3, anchorColumn: 0 },
- { row: 0, column: 2, index: 1, data: '02', isAnchor: true },
- { row: 1, column: 0, index: 0, data: '00', width: 2, height: 3, anchorRow: 0 },
- { row: 1, column: 1, index: 0, data: '00', width: 2, height: 3, anchorRow: 0, anchorColumn: 0 },
- { row: 1, column: 2, index: 0, data: '12', isAnchor: true },
- { row: 2, column: 0, index: 0, data: '00', width: 2, height: 3, anchorRow: 0 },
- { row: 2, column: 1, index: 0, data: '00', width: 2, height: 3, anchorRow: 0, anchorColumn: 0 },
- { row: 2, column: 2, index: 0, data: '22', isAnchor: true },
- { row: 3, column: 0, index: 0, data: '30', isAnchor: true },
- { row: 3, column: 1, index: 1, data: '31', width: 2, isAnchor: true },
- { row: 3, column: 2, index: 1, data: '31', width: 2, anchorColumn: 1 }
- ], { includeAllSlots: true } );
- } );
- it( 'should output rowspanned cells at the end of a table row', () => {
- // +----+----+
- // | 00 | 01 |
- // +----+ +
- // | 10 | |
- // +----+----+
- testWalker( [
- [ '00', { rowspan: 2, contents: '01' } ],
- [ '10' ]
- ], [
- { row: 0, column: 0, index: 0, data: '00', isAnchor: true },
- { row: 0, column: 1, index: 1, data: '01', isAnchor: true, height: 2 },
- { row: 1, column: 0, index: 0, data: '10', isAnchor: true },
- { row: 1, column: 1, index: 1, data: '01', anchorRow: 0, height: 2 }
- ], { includeAllSlots: true } );
- } );
- it( 'should work with startRow & endRow options', () => {
- // +----+----+----+
- // | 00 | 02 |
- // + +----+
- // | | 12 |
- // + +----+
- // | | 22 |
- // +----+----+----+
- // | 30 | 31 | 32 |
- // +----+----+----+
- testWalker( [
- [ { colspan: 2, rowspan: 3, contents: '00' }, '02' ],
- [ '12' ],
- [ '22' ],
- [ '30', '31', '32' ]
- ], [
- { row: 1, column: 0, index: 0, data: '00', anchorRow: 0, width: 2, height: 3 },
- { row: 1, column: 1, index: 0, data: '00', anchorRow: 0, width: 2, height: 3, anchorColumn: 0 },
- { row: 1, column: 2, index: 0, data: '12', isAnchor: true },
- { row: 2, column: 0, index: 0, data: '00', anchorRow: 0, width: 2, height: 3 },
- { row: 2, column: 1, index: 0, data: '00', anchorRow: 0, width: 2, height: 3, anchorColumn: 0 },
- { row: 2, column: 2, index: 0, data: '22', isAnchor: true }
- ], { includeAllSlots: true, startRow: 1, endRow: 2 } );
- } );
- it( 'should output row-spanned cells at the end of a table row with startRow & endRow options', () => {
- // +----+----+
- // | 00 | 01 |
- // +----+ +
- // | 10 | |
- // +----+----+
- // | 20 | 21 |
- // +----+----+
- testWalker( [
- [ '00', { rowspan: 2, contents: '01' } ],
- [ '10' ],
- [ '20', '21' ]
- ], [
- { row: 0, column: 0, index: 0, data: '00', isAnchor: true },
- { row: 0, column: 1, index: 1, data: '01', isAnchor: true, height: 2 },
- { row: 1, column: 0, index: 0, data: '10', isAnchor: true },
- { row: 1, column: 1, index: 1, data: '01', anchorRow: 0, height: 2 }
- ], { startRow: 0, endRow: 1, includeAllSlots: true } );
- } );
- } );
- describe( '#skipRow()', () => {
- it( 'should skip row', () => {
- // +----+----+----+
- // | 00 | 02 |
- // + +----+
- // | | 12 |
- // + +----+
- // | | 22 |
- // +----+----+----+
- // | 30 | 31 | 32 |
- // +----+----+----+
- testWalker( [
- [ { colspan: 2, rowspan: 3, contents: '00' }, '02' ],
- [ '12' ],
- [ '22' ],
- [ '30', '31', '32' ]
- ], [
- { row: 0, column: 0, index: 0, data: '00', isAnchor: true, width: 2, height: 3 },
- { row: 0, column: 2, index: 1, data: '02', isAnchor: true },
- { row: 2, column: 2, index: 0, data: '22', isAnchor: true },
- { row: 3, column: 0, index: 0, data: '30', isAnchor: true },
- { row: 3, column: 1, index: 1, data: '31', isAnchor: true },
- { row: 3, column: 2, index: 2, data: '32', isAnchor: true }
- ], {}, 1 );
- } );
- it( 'should skip row, includeAllSlots = true', () => {
- // +----+----+----+
- // | 00 | 02 |
- // + +----+
- // | | 12 |
- // + +----+
- // | | 22 |
- // +----+----+----+
- // | 30 | 31 | 32 |
- // +----+----+----+
- testWalker( [
- [ { colspan: 2, rowspan: 3, contents: '00' }, '02' ],
- [ '12' ],
- [ '22' ],
- [ '30', '31', '32' ]
- ], [
- { row: 0, column: 0, index: 0, data: '00', width: 2, height: 3, isAnchor: true },
- { row: 0, column: 1, index: 0, data: '00', width: 2, height: 3, anchorColumn: 0 },
- { row: 0, column: 2, index: 1, data: '02', isAnchor: true },
- { row: 2, column: 0, index: 0, data: '00', width: 2, height: 3, anchorRow: 0 },
- { row: 2, column: 1, index: 0, data: '00', width: 2, height: 3, anchorRow: 0, anchorColumn: 0 },
- { row: 2, column: 2, index: 0, data: '22', isAnchor: true },
- { row: 3, column: 0, index: 0, data: '30', isAnchor: true },
- { row: 3, column: 1, index: 1, data: '31', isAnchor: true },
- { row: 3, column: 2, index: 2, data: '32', isAnchor: true }
- ], { includeAllSlots: true }, 1 );
- } );
- } );
- it( 'should throw error if walker value old api used', () => {
- setData( model, modelTable( [
- [ 'a' ]
- ] ) );
- const walker = new TableWalker( root.getChild( 0 ) );
- const { value } = walker.next();
- expect( () => value.isSpanned ).to.throw( CKEditorError, 'tablewalker-improper-api-usage' );
- expect( () => value.colspan ).to.throw( CKEditorError, 'tablewalker-improper-api-usage' );
- expect( () => value.rowspan ).to.throw( CKEditorError, 'tablewalker-improper-api-usage' );
- expect( () => value.cellIndex ).to.throw( CKEditorError, 'tablewalker-improper-api-usage' );
- } );
- } );
|