4
4
*/
5
5
6
6
import ModelTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/modeltesteditor' ;
7
- import { setData , getData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model' ;
7
+ import { getData , setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model' ;
8
8
import { upcastElementToElement } from '@ckeditor/ckeditor5-engine/src/conversion/upcast-converters' ;
9
9
10
10
import MergeCellCommand from '../../src/commands/mergecellcommand' ;
@@ -483,6 +483,17 @@ describe( 'MergeCellCommand', () => {
483
483
expect ( command . value ) . to . equal ( root . getNodeByPath ( [ 0 , 0 , 0 ] ) ) ;
484
484
} ) ;
485
485
486
+ it ( 'should be set to mergeable cell in rows with spanned cells' , ( ) => {
487
+ setData ( model , modelTable ( [
488
+ [ { rowspan : 3 , contents : '00' } , '11' , '12' , '13' ] ,
489
+ [ { rowspan : 2 , contents : '21' } , '22' , '23' ] ,
490
+ [ '32' , { rowspan : 2 , contents : '33[]' } ] ,
491
+ [ { colspan : 2 , contents : '40' } , '42' ]
492
+ ] ) ) ;
493
+
494
+ expect ( command . value ) . to . equal ( root . getNodeByPath ( [ 0 , 1 , 2 ] ) ) ;
495
+ } ) ;
496
+
486
497
it ( 'should be undefined if in a cell that potential mergeable cell has different rowspan' , ( ) => {
487
498
setData ( model , modelTable ( [
488
499
[ { colspan : 2 , contents : '00' } , '02' ] ,
@@ -500,10 +511,10 @@ describe( 'MergeCellCommand', () => {
500
511
} ) ;
501
512
502
513
describe ( 'execute()' , ( ) => {
503
- it ( 'should merge table cells ' , ( ) => {
514
+ it ( 'should merge table cells' , ( ) => {
504
515
setData ( model , modelTable ( [
505
516
[ '00' , '01' ] ,
506
- [ '10' , '11[] ' ]
517
+ [ '10' , '[]11 ' ]
507
518
] ) ) ;
508
519
509
520
command . execute ( ) ;
@@ -513,6 +524,24 @@ describe( 'MergeCellCommand', () => {
513
524
[ '10' ]
514
525
] ) ) ;
515
526
} ) ;
527
+
528
+ it ( 'should properly merge cells in rows with spaned cells' , ( ) => {
529
+ setData ( model , modelTable ( [
530
+ [ { rowspan : 3 , contents : '00' } , '11' , '12' , '13' ] ,
531
+ [ { rowspan : 2 , contents : '21' } , '22' , '23' ] ,
532
+ [ '32' , { rowspan : 2 , contents : '33[]' } ] ,
533
+ [ { colspan : 2 , contents : '40' } , '42' ]
534
+ ] ) ) ;
535
+
536
+ command . execute ( ) ;
537
+
538
+ expect ( formatTable ( getData ( model ) ) ) . to . equal ( formattedModelTable ( [
539
+ [ { rowspan : 3 , contents : '00' } , '11' , '12' , '13' ] ,
540
+ [ { rowspan : 2 , contents : '21' } , '22' , { rowspan : 3 , contents : '[2333]' } ] ,
541
+ [ '32' ] ,
542
+ [ { colspan : 2 , contents : '40' } , '42' ]
543
+ ] ) ) ;
544
+ } ) ;
516
545
} ) ;
517
546
} ) ;
518
547
} ) ;
0 commit comments