ソースを参照

Use single batch to modify table.

Maciej Gołaszewski 5 年 前
コミット
4ec76addce
1 ファイル変更8 行追加2 行削除
  1. 8 2
      packages/ckeditor5-table/src/commands/removerowcommand.js

+ 8 - 2
packages/ckeditor5-table/src/commands/removerowcommand.js

@@ -60,7 +60,10 @@ export default class RemoveRowCommand extends Command {
 
 		const columnIndexToFocus = this.editor.plugins.get( 'TableUtils' ).getCellLocation( firstCell ).column;
 
-		model.change( writer => {
+		// Use single batch to modify table in steps but in one undo step.
+		const batch = model.createBatch();
+
+		model.enqueueChange( batch, writer => {
 			// This prevents the "model-selection-range-intersects" error, caused by removing row selected cells.
 			writer.setSelection( writer.createSelection( table, 'on' ) );
 
@@ -68,9 +71,12 @@ export default class RemoveRowCommand extends Command {
 
 			this.editor.plugins.get( 'TableUtils' ).removeRows( table, {
 				at: removedRowIndexes.first,
-				rows: rowsToRemove
+				rows: rowsToRemove,
+				batch
 			} );
+		} );
 
+		model.enqueueChange( batch, writer => {
 			const cellToFocus = getCellToFocus( table, removedRowIndexes.first, columnIndexToFocus );
 
 			writer.setSelection( writer.createPositionAt( cellToFocus, 0 ) );