|
|
@@ -234,6 +234,66 @@ describe( 'table selection', () => {
|
|
|
preventDefault: sinon.spy()
|
|
|
} );
|
|
|
} );
|
|
|
+
|
|
|
+ it( 'should fix selected table to a selection rectangle (hardcore case)', done => {
|
|
|
+ // This test check how previous simple rules run together (mixed prepending and trimming).
|
|
|
+ // In the example below a selection is set from cell "32" to "88"
|
|
|
+ //
|
|
|
+ // Input table: Copied table:
|
|
|
+ //
|
|
|
+ // +----+----+----+----+----+----+----+----+----+
|
|
|
+ // | 11 | 12 | 13 | 14 | 15 | 17 | 18 | 19 |
|
|
|
+ // +----+----+ +----+ +----+----+----+
|
|
|
+ // | 21 | 22 | | 24 | | 27 | 28 | 29 |
|
|
|
+ // +----+----+ +----+ +----+----+----+ +----+----+----+---------+----+----+
|
|
|
+ // | 31 | 32 | | 34 | | 37 | | 32 | | 34 | | | 37 | |
|
|
|
+ // +----+----+ +----+ +----+----+----+ +----+----+----+----+----+----+----+
|
|
|
+ // | 41 | 42 | | 44 | | 47 | 48 | | 42 | | 44 | | | 47 | 48 |
|
|
|
+ // +----+----+----+----+ +----+----+----+ +----+----+----+----+----+----+----+
|
|
|
+ // | 51 | | 57 | 58 | 59 | | | | | | | 57 | 58 |
|
|
|
+ // +----+----+----+----+ +----+----+----+ ==> +----+----+----+----+----+----+----+
|
|
|
+ // | 61 | 62 | 63 | 64 | | 67 | 68 | 69 | | 62 | 63 | 64 | | | 67 | 68 |
|
|
|
+ // +----+----+----+----+----+----+ +----+----+ +----+----+----+----+----+----+----+
|
|
|
+ // | 71 | 72 | 75 | 76 | | 78 | 79 | | 72 | | | 75 | 76 | | 78 |
|
|
|
+ // +----+----+----+----+----+----+ +----+----+ +----+----+----+----+----+----+----+
|
|
|
+ // | 81 | 82 | 83 | 84 | 85 | 86 | | 88 | 89 | | 82 | 83 | 84 | 85 | 86 | | 88 |
|
|
|
+ // +----+ +----+----+----+----+ +----+----+ +----+----+----+----+----+----+----+
|
|
|
+ // | 91 | | 93 | 94 | 95 | 96 | | 98 | 99 |
|
|
|
+ // +----+----+----+----+----+----+----+----+----+
|
|
|
+ //
|
|
|
+ setModelData( model, modelTable( [
|
|
|
+ [ '11', '12', { contents: '13', rowspan: 4 }, '14', { contents: '15', colspan: 2, rowspan: 7 }, '17', '18', '19' ],
|
|
|
+ [ '21', '22', '24', '27', '28', '29' ],
|
|
|
+ [ '31', '32', '34', { contents: '37', colspan: 3 } ],
|
|
|
+ [ '41', '42', '44', '47', { contents: '48', colspan: 2 } ],
|
|
|
+ [ { contents: '51', colspan: 4 }, '57', '58', '59' ],
|
|
|
+ [ '61', '62', '63', '64', { contents: '67', rowspan: 4 }, '68', '69' ],
|
|
|
+ [ '71', { contents: '72', colspan: 3 }, '78', '79' ],
|
|
|
+ [ '81', { contents: '82', rowspan: 2 }, '83', '84', '85', '86', '88', '89' ],
|
|
|
+ [ '91', '93', '94', '95', '96', '98', '99' ]
|
|
|
+ ] ) );
|
|
|
+
|
|
|
+ tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 2, 1 ] ) );
|
|
|
+ tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 7, 6 ] ) );
|
|
|
+
|
|
|
+ viewDocument.on( 'clipboardOutput', ( evt, data ) => {
|
|
|
+ expect( stringifyView( data.content ) ).to.equal( viewTable( [
|
|
|
+ [ '32', '', '34', '', '', { contents: '37', colspan: 2 } ],
|
|
|
+ [ '42', '', '44', '', '', '47', '48' ],
|
|
|
+ [ '', '', '', '', '', '57', '58' ],
|
|
|
+ [ '62', '63', '64', '', '', { contents: '67', rowspan: 3 }, '68' ],
|
|
|
+ [ { contents: '72', colspan: 3 }, '', '', '', '78' ],
|
|
|
+ [ '82', '83', '84', '85', '86', '88' ]
|
|
|
+ ] ) );
|
|
|
+
|
|
|
+ done();
|
|
|
+ } );
|
|
|
+
|
|
|
+ viewDocument.fire( 'copy', {
|
|
|
+ dataTransfer: createDataTransfer(),
|
|
|
+ preventDefault: sinon.spy()
|
|
|
+ } );
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
describe( 'cut', () => {
|