瀏覽代碼

Add information about content table replacing goals.

Maciej Gołaszewski 5 年之前
父節點
當前提交
afde3cfaf2
共有 1 個文件被更改,包括 12 次插入6 次删除
  1. 12 6
      packages/ckeditor5-table/src/tableclipboard.js

+ 12 - 6
packages/ckeditor5-table/src/tableclipboard.js

@@ -166,18 +166,24 @@ export default class TableClipboard extends Plugin {
 			// Content table to which we insert a table.
 			const contentTable = findAncestor( 'table', selectedTableCells[ 0 ] );
 
-			// Selection must be set to pasted cells (some might be removed or new created).
-			const cellsToSelect = [];
-
-			// Store previous cell in order to insert a new table cells after it if required.
-			let previousCellInRow;
-
 			const tableMap = [ ...new TableWalker( contentTable, {
 				startRow: firstRowOfSelection,
 				endRow: lastRowOfSelection,
 				includeSpanned: true
 			} ) ];
 
+			// Selection must be set to pasted cells (some might be removed or new created).
+			const cellsToSelect = [];
+
+			// Store previous cell in order to insert a new table cells after it if required.
+			let previousCellInRow;
+
+			// Content table replace cells algorithm iterates over a selected table fragment and:
+			//
+			// - Removes existing table cells at current slot (location).
+			// - Inserts cell from a pasted table for a matched slots.
+			//
+			// This ensures proper table geometry after the paste
 			for ( const { row, column, cell, isSpanned } of tableMap ) {
 				if ( column === 0 ) {
 					previousCellInRow = null;