Skip to content

Commit

Permalink
Added test for multiple empty elements around a table while pasting it.
Browse files Browse the repository at this point in the history
  • Loading branch information
niegowski committed Jun 5, 2020
1 parent c253d51 commit 1c371f1
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions packages/ckeditor5-table/tests/tableclipboard-paste.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', `<p>&nbsp;</p><p>&nbsp;</p>${ table }<p>&nbsp;</p><br>` );
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 ] ),
Expand Down

0 comments on commit 1c371f1

Please sign in to comment.