8
0
Просмотр исходного кода

Add column/row tests for simple paste scenarios.

Maciej Gołaszewski 5 лет назад
Родитель
Сommit
f6e0c2fae9

+ 1 - 0
packages/ckeditor5-table/src/tableclipboard.js

@@ -152,6 +152,7 @@ export default class TableClipboard extends Plugin {
 						}
 					}
 				} );
+
 				return;
 			}
 

+ 54 - 0
packages/ckeditor5-table/tests/tableclipboard.js

@@ -496,6 +496,7 @@ describe( 'table clipboard', () => {
 						[ '20', '21', 'aa', 'ab' ],
 						[ '30', '31', 'ba', 'bb' ]
 					] ) );
+
 					assertSelectedCells( model, [
 						[ 0, 0, 0, 0 ],
 						[ 0, 0, 0, 0 ],
@@ -521,6 +522,7 @@ describe( 'table clipboard', () => {
 						[ '20', 'ba', 'bb', '23' ],
 						[ '30', '31', '32', '33' ]
 					] ) );
+
 					assertSelectedCells( model, [
 						[ 0, 0, 0, 0 ],
 						[ 0, 1, 1, 0 ],
@@ -529,6 +531,57 @@ describe( 'table clipboard', () => {
 					] );
 				} );
 
+				it( 'inserts simple row to a simple row fragment - in the middle of a table', () => {
+					tableSelection._setCellSelection(
+						modelRoot.getNodeByPath( [ 0, 1, 1 ] ),
+						modelRoot.getNodeByPath( [ 0, 1, 2 ] )
+					);
+
+					pasteTable( [
+						[ 'aa', 'ab' ]
+					] );
+
+					assertEqualMarkup( getModelData( model, { withoutSelection: true } ), modelTable( [
+						[ '00', '01', '02', '03' ],
+						[ '10', 'aa', 'ab', '13' ],
+						[ '20', '21', '22', '23' ],
+						[ '30', '31', '32', '33' ]
+					] ) );
+
+					assertSelectedCells( model, [
+						[ 0, 0, 0, 0 ],
+						[ 0, 1, 1, 0 ],
+						[ 0, 0, 0, 0 ],
+						[ 0, 0, 0, 0 ]
+					] );
+				} );
+
+				it( 'inserts simple column to a simple column fragment - in the middle of a table', () => {
+					tableSelection._setCellSelection(
+						modelRoot.getNodeByPath( [ 0, 1, 1 ] ),
+						modelRoot.getNodeByPath( [ 0, 2, 1 ] )
+					);
+
+					pasteTable( [
+						[ 'aa' ],
+						[ 'ba' ]
+					] );
+
+					assertEqualMarkup( getModelData( model, { withoutSelection: true } ), modelTable( [
+						[ '00', '01', '02', '03' ],
+						[ '10', 'aa', '12', '13' ],
+						[ '20', 'ba', '22', '23' ],
+						[ '30', '31', '32', '33' ]
+					] ) );
+
+					assertSelectedCells( model, [
+						[ 0, 0, 0, 0 ],
+						[ 0, 1, 0, 0 ],
+						[ 0, 1, 0, 0 ],
+						[ 0, 0, 0, 0 ]
+					] );
+				} );
+
 				it( 'inserts simple table to a simple table fragment - whole table selected', () => {
 					tableSelection._setCellSelection(
 						modelRoot.getNodeByPath( [ 0, 0, 0 ] ),
@@ -548,6 +601,7 @@ describe( 'table clipboard', () => {
 						[ 'ca', 'cb', 'cc', 'cd' ],
 						[ 'da', 'db', 'dc', 'dd' ]
 					] ) );
+
 					assertSelectedCells( model, [
 						[ 1, 1, 1, 1 ],
 						[ 1, 1, 1, 1 ],