From 1c371f1b9418191946d71e268a6a18467bd14fed Mon Sep 17 00:00:00 2001 From: Kuba Niegowski Date: Fri, 5 Jun 2020 11:42:24 +0200 Subject: [PATCH] Added test for multiple empty elements around a table while pasting it. --- .../tests/tableclipboard-paste.js | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/packages/ckeditor5-table/tests/tableclipboard-paste.js b/packages/ckeditor5-table/tests/tableclipboard-paste.js index bc5dc379720..b14e9335204 100644 --- a/packages/ckeditor5-table/tests/tableclipboard-paste.js +++ b/packages/ckeditor5-table/tests/tableclipboard-paste.js @@ -359,6 +359,33 @@ describe( 'table clipboard', () => { ] ) ); } ); + it( 'should alter model.insertContent if mixed content is pasted (p + p + table + p + br)', () => { + tableSelection.setCellSelection( + modelRoot.getNodeByPath( [ 0, 0, 0 ] ), + modelRoot.getNodeByPath( [ 0, 1, 1 ] ) + ); + + const table = viewTable( [ + [ 'aa', 'ab' ], + [ 'ba', 'bb' ] + ] ); + + const data = { + dataTransfer: createDataTransfer(), + preventDefault: sinon.spy(), + stopPropagation: sinon.spy() + }; + data.dataTransfer.setData( 'text/html', `

 

 

${ table }

 


` ); + viewDocument.fire( 'paste', data ); + + assertEqualMarkup( getModelData( model, { withoutSelection: true } ), modelTable( [ + [ 'aa', 'ab', '02', '03' ], + [ 'ba', 'bb', '12', '13' ], + [ '20', '21', '22', '23' ], + [ '30', '31', '32', '33' ] + ] ) ); + } ); + it( 'should not alter model.insertContent if element other than a table is passed directly', () => { tableSelection.setCellSelection( modelRoot.getNodeByPath( [ 0, 0, 0 ] ),