Explorar el Código

Apply suggestions from code review

Co-authored-by: Maciej <jodator@jodator.net>
Kuba Niegowski hace 5 años
padre
commit
3d4bbc0bc4

+ 1 - 1
packages/ckeditor5-table/src/commands/mergecellcommand.js

@@ -109,7 +109,7 @@ export default class MergeCellCommand extends Command {
 			if ( !removedTableCellRow.childCount ) {
 				const tableUtils = this.editor.plugins.get( 'TableUtils' );
 
-				tableUtils.removeRows( table, { at: table.getChildIndex( removedTableCellRow ), batch: writer.batch } );
+				tableUtils.removeRows( table, { at: removedTableCellRow.index, batch: writer.batch } );
 			}
 		} );
 	}

+ 1 - 1
packages/ckeditor5-table/src/commands/mergecellscommand.js

@@ -65,7 +65,7 @@ export default class MergeCellsCommand extends Command {
 				mergeTableCells( tableCell, firstTableCell, writer );
 
 				if ( !tableRow.childCount ) {
-					emptyRows.push( table.getChildIndex( tableRow ) );
+					emptyRows.push( tableRow.index );
 				}
 			}
 

+ 4 - 3
packages/ckeditor5-table/src/tableutils.js

@@ -290,8 +290,8 @@ export default class TableUtils extends Plugin {
 		const batch = options.batch || 'default';
 
 		model.enqueueChange( batch, writer => {
-			// Removing rows from table requires most calculations to be done prior to changing table structure.
-			// Preparations must be done in enqueueChange callback to use the current table structure.
+			// Removing rows from the table require that most calculations to be done prior to changing table structure.
+			// Preparations must be done in the same enqueueChange callback to use the current table structure.
 
 			// 1. Preparation - get row-spanned cells that have to be modified after removing rows.
 			const { cellsToMove, cellsToTrim } = getCellsToMoveAndTrimOnRemoveRow( table, first, last );
@@ -758,7 +758,8 @@ function adjustHeadingColumns( table, removedColumnIndexes, writer ) {
 // Calculates a new heading rows value for removing rows from heading section.
 function updateHeadingRows( table, first, last, model, batch ) {
 	// Must be done after the changes in table structure (removing rows).
-	// Otherwise the downcast converter for headingRows attribute will fail. ckeditor/ckeditor5#6391.
+	// Otherwise the downcast converter for headingRows attribute will fail.
+	// See https://github.com/ckeditor/ckeditor5/issues/6391.
 	//
 	// Must be completely wrapped in enqueueChange to get the current table state (after applying other enqueued changes).
 	model.enqueueChange( batch, writer => {