|
|
@@ -853,8 +853,7 @@ describe( 'table clipboard', () => {
|
|
|
/* eslint-enable no-multi-spaces */
|
|
|
} );
|
|
|
|
|
|
- // TODO: Skipped case - should allow pasting but no tools to compare areas (like in MergeCellsCommand).
|
|
|
- it.skip( 'handles pasting table that has cell with colspan (last row in selection is spanned)', () => {
|
|
|
+ it( 'handles pasting table that has cell with colspan (last row in selection is spanned)', () => {
|
|
|
// +----+----+----+----+
|
|
|
// | 00 | 01 | 02 | 03 |
|
|
|
// +----+----+----+----+
|
|
|
@@ -871,6 +870,7 @@ describe( 'table clipboard', () => {
|
|
|
[ '30', '31', '32', '33' ]
|
|
|
] ) );
|
|
|
|
|
|
+ // Select 02 -> 10 (selection 3x3)
|
|
|
tableSelection.setCellSelection(
|
|
|
modelRoot.getNodeByPath( [ 0, 0, 2 ] ),
|
|
|
modelRoot.getNodeByPath( [ 0, 1, 0 ] )
|
|
|
@@ -896,6 +896,50 @@ describe( 'table clipboard', () => {
|
|
|
[ 0, 0, 0, 0 ]
|
|
|
] );
|
|
|
} );
|
|
|
+
|
|
|
+ it( 'handles pasting table that has cell with colspan (last column in selection is spanned)', () => {
|
|
|
+ // +----+----+----+----+
|
|
|
+ // | 00 | 01 | 03 |
|
|
|
+ // +----+----+----+----+
|
|
|
+ // | 10 | 11 | 13 |
|
|
|
+ // +----+ +----+
|
|
|
+ // | 20 | | 23 |
|
|
|
+ // +----+----+----+----+
|
|
|
+ // | 30 | 31 | 32 | 33 |
|
|
|
+ // +----+----+----+----+
|
|
|
+ setModelData( model, modelTable( [
|
|
|
+ [ '00', { contents: '01', colspan: 2 }, '03' ],
|
|
|
+ [ '10', { contents: '11', colspan: 2, rowspan: 2 }, '13' ],
|
|
|
+ [ '20', '23' ],
|
|
|
+ [ '30', '31', '32', '33' ]
|
|
|
+ ] ) );
|
|
|
+
|
|
|
+ // Select 20 -> 01 (selection 3x3)
|
|
|
+ tableSelection.setCellSelection(
|
|
|
+ modelRoot.getNodeByPath( [ 0, 2, 0 ] ),
|
|
|
+ modelRoot.getNodeByPath( [ 0, 0, 1 ] )
|
|
|
+ );
|
|
|
+
|
|
|
+ pasteTable( [
|
|
|
+ [ 'aa', 'ab', 'ac' ],
|
|
|
+ [ 'ba', 'bb', 'bc' ],
|
|
|
+ [ 'ca', 'cb', 'cc' ]
|
|
|
+ ] );
|
|
|
+
|
|
|
+ assertEqualMarkup( getModelData( model, { withoutSelection: true } ), modelTable( [
|
|
|
+ [ 'aa', 'ab', 'ac', '03' ],
|
|
|
+ [ 'ba', 'bb', 'bc', '13' ],
|
|
|
+ [ 'ca', 'cb', 'cc', '23' ],
|
|
|
+ [ '30', '31', '32', '33' ]
|
|
|
+ ] ) );
|
|
|
+
|
|
|
+ assertSelectedCells( model, [
|
|
|
+ [ 1, 1, 1, 0 ],
|
|
|
+ [ 1, 1, 1, 0 ],
|
|
|
+ [ 1, 1, 1, 0 ],
|
|
|
+ [ 0, 0, 0, 0 ]
|
|
|
+ ] );
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
describe( 'content and paste tables have spans', () => {
|
|
|
@@ -1047,8 +1091,7 @@ describe( 'table clipboard', () => {
|
|
|
/* eslint-enable no-multi-spaces */
|
|
|
} );
|
|
|
|
|
|
- // TODO: Skipped case - should allow pasting but no tools to compare areas (like in MergeCellsCommand).
|
|
|
- it.skip( 'handles pasting table that has cell with colspan (last row in selection is spanned)', () => {
|
|
|
+ it( 'handles pasting table that has cell with colspan (last row in selection is spanned)', () => {
|
|
|
// +----+----+----+----+
|
|
|
// | 00 | 01 | 02 | 03 |
|
|
|
// +----+----+----+----+
|
|
|
@@ -1065,6 +1108,7 @@ describe( 'table clipboard', () => {
|
|
|
[ '30', '31', '32', '33' ]
|
|
|
] ) );
|
|
|
|
|
|
+ // Select 02 -> 10 (selection 3x3)
|
|
|
tableSelection.setCellSelection(
|
|
|
modelRoot.getNodeByPath( [ 0, 0, 2 ] ),
|
|
|
modelRoot.getNodeByPath( [ 0, 1, 0 ] )
|
|
|
@@ -1084,17 +1128,70 @@ describe( 'table clipboard', () => {
|
|
|
] );
|
|
|
|
|
|
assertEqualMarkup( getModelData( model, { withoutSelection: true } ), modelTable( [
|
|
|
- [ '00', '01', '02', '03' ],
|
|
|
- [ '10', { colspan: 2, contents: 'aa' }, '13' ],
|
|
|
- [ '20', 'ba', 'bb', '23' ],
|
|
|
+ [ 'aa', 'ab', 'ac', '03' ],
|
|
|
+ [ { contents: 'ba', colspan: 2, rowspan: 2 }, 'bc', '13' ],
|
|
|
+ [ 'cc', '23' ],
|
|
|
[ '30', '31', '32', '33' ]
|
|
|
] ) );
|
|
|
|
|
|
/* eslint-disable no-multi-spaces */
|
|
|
assertSelectedCells( model, [
|
|
|
- [ 0, 0, 0, 0 ],
|
|
|
- [ 0, 1, 0 ],
|
|
|
- [ 0, 1, 1, 0 ],
|
|
|
+ [ 1, 1, 1, 0 ],
|
|
|
+ [ 1, 1, 0 ],
|
|
|
+ [ 1, 0 ],
|
|
|
+ [ 0, 0, 0, 0 ]
|
|
|
+ ] );
|
|
|
+ /* eslint-enable no-multi-spaces */
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'handles pasting table that has cell with colspan (last column in selection is spanned)', () => {
|
|
|
+ // +----+----+----+----+
|
|
|
+ // | 00 | 01 | 03 |
|
|
|
+ // +----+----+----+----+
|
|
|
+ // | 10 | 11 | 13 |
|
|
|
+ // +----+ +----+
|
|
|
+ // | 20 | | 23 |
|
|
|
+ // +----+----+----+----+
|
|
|
+ // | 30 | 31 | 32 | 33 |
|
|
|
+ // +----+----+----+----+
|
|
|
+ setModelData( model, modelTable( [
|
|
|
+ [ '00', { contents: '01', colspan: 2 }, '03' ],
|
|
|
+ [ '10', { contents: '11', colspan: 2, rowspan: 2 }, '13' ],
|
|
|
+ [ '20', '23' ],
|
|
|
+ [ '30', '31', '32', '33' ]
|
|
|
+ ] ) );
|
|
|
+
|
|
|
+ // Select 20 -> 01 (selection 3x3)
|
|
|
+ tableSelection.setCellSelection(
|
|
|
+ modelRoot.getNodeByPath( [ 0, 2, 0 ] ),
|
|
|
+ modelRoot.getNodeByPath( [ 0, 0, 1 ] )
|
|
|
+ );
|
|
|
+
|
|
|
+ // +----+----+----+
|
|
|
+ // | aa | ab | ac |
|
|
|
+ // +----+----+----+
|
|
|
+ // | ba | bc |
|
|
|
+ // + +----+
|
|
|
+ // | | cc |
|
|
|
+ // +----+----+----+
|
|
|
+ pasteTable( [
|
|
|
+ [ 'aa', 'ab', 'ac' ],
|
|
|
+ [ { contents: 'ba', colspan: 2, rowspan: 2 }, 'bc' ],
|
|
|
+ [ 'cc' ]
|
|
|
+ ] );
|
|
|
+
|
|
|
+ assertEqualMarkup( getModelData( model, { withoutSelection: true } ), modelTable( [
|
|
|
+ [ 'aa', 'ab', 'ac', '03' ],
|
|
|
+ [ { contents: 'ba', colspan: 2, rowspan: 2 }, 'bc', '13' ],
|
|
|
+ [ 'cc', '23' ],
|
|
|
+ [ '30', '31', '32', '33' ]
|
|
|
+ ] ) );
|
|
|
+
|
|
|
+ /* eslint-disable no-multi-spaces */
|
|
|
+ assertSelectedCells( model, [
|
|
|
+ [ 1, 1, 1, 0 ],
|
|
|
+ [ 1, 1, 0 ],
|
|
|
+ [ 1, 0 ],
|
|
|
[ 0, 0, 0, 0 ]
|
|
|
] );
|
|
|
/* eslint-enable no-multi-spaces */
|