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

Updated usages of new TableWalker API.

Kuba Niegowski 5 лет назад
Родитель
Сommit
433d33a655

+ 16 - 31
packages/ckeditor5-table/src/tableclipboard.js

@@ -205,7 +205,7 @@ export default class TableClipboard extends Plugin {
 				endColumn: Math.min( selectionWidth - 1, pasteWidth - 1 )
 				endColumn: Math.min( selectionWidth - 1, pasteWidth - 1 )
 			};
 			};
 
 
-			pastedTable = cropTableToDimensions( pastedTable, cropDimensions, writer, tableUtils );
+			pastedTable = cropTableToDimensions( pastedTable, cropDimensions, writer );
 
 
 			const pastedDimensions = {
 			const pastedDimensions = {
 				width: pasteWidth,
 				width: pasteWidth,
@@ -250,14 +250,16 @@ function replaceSelectedCellsWithPasted( pastedTable, pastedDimensions, selected
 	const selectedTableMap = [ ...new TableWalker( selectedTable, {
 	const selectedTableMap = [ ...new TableWalker( selectedTable, {
 		startRow: firstRowOfSelection,
 		startRow: firstRowOfSelection,
 		endRow: lastRowOfSelection,
 		endRow: lastRowOfSelection,
+		startColumn: firstColumnOfSelection,
+		endColumn: lastColumnOfSelection,
 		includeAllSlots: true
 		includeAllSlots: true
 	} ) ];
 	} ) ];
 
 
 	// Selection must be set to pasted cells (some might be removed or new created).
 	// Selection must be set to pasted cells (some might be removed or new created).
 	const cellsToSelect = [];
 	const cellsToSelect = [];
 
 
-	// Store previous cell in order to insert a new table cells after it (if required).
-	let previousCellInRow;
+	// Store next cell insert position.
+	let insertPosition;
 
 
 	// Content table replace cells algorithm iterates over a selected table fragment and:
 	// Content table replace cells algorithm iterates over a selected table fragment and:
 	//
 	//
@@ -265,19 +267,12 @@ function replaceSelectedCellsWithPasted( pastedTable, pastedDimensions, selected
 	// - Inserts cell from a pasted table for a matched slots.
 	// - Inserts cell from a pasted table for a matched slots.
 	//
 	//
 	// This ensures proper table geometry after the paste
 	// This ensures proper table geometry after the paste
-	for ( const { row, column, cell, isAnchor } of selectedTableMap ) {
-		if ( column === 0 ) {
-			previousCellInRow = null;
-		}
-
-		// Could use startColumn, endColumn. See: https://github.com/ckeditor/ckeditor5/issues/6785.
-		if ( column < firstColumnOfSelection || column > lastColumnOfSelection ) {
-			// Only update the previousCellInRow for non-spanned slots.
-			if ( isAnchor ) {
-				previousCellInRow = cell;
-			}
+	for ( const tableSlot of selectedTableMap ) {
+		const { row, column, cell, isAnchor } = tableSlot;
 
 
-			continue;
+		// Save the insert position for current row start.
+		if ( column === firstColumnOfSelection ) {
+			insertPosition = tableSlot.getPositionBefore();
 		}
 		}
 
 
 		// If the slot is occupied by a cell in a selected table - remove it.
 		// If the slot is occupied by a cell in a selected table - remove it.
@@ -305,17 +300,10 @@ function replaceSelectedCellsWithPasted( pastedTable, pastedDimensions, selected
 		// Trim the cell if it's row/col-spans would exceed selection area.
 		// Trim the cell if it's row/col-spans would exceed selection area.
 		trimTableCellIfNeeded( cellToInsert, row, column, lastRowOfSelection, lastColumnOfSelection, writer );
 		trimTableCellIfNeeded( cellToInsert, row, column, lastRowOfSelection, lastColumnOfSelection, writer );
 
 
-		let insertPosition;
-
-		if ( !previousCellInRow ) {
-			insertPosition = writer.createPositionAt( selectedTable.getChild( row ), 0 );
-		} else {
-			insertPosition = writer.createPositionAfter( previousCellInRow );
-		}
-
 		writer.insert( cellToInsert, insertPosition );
 		writer.insert( cellToInsert, insertPosition );
 		cellsToSelect.push( cellToInsert );
 		cellsToSelect.push( cellToInsert );
-		previousCellInRow = cellToInsert;
+
+		insertPosition = writer.createPositionAfter( cellToInsert );
 	}
 	}
 
 
 	writer.setSelection( cellsToSelect.map( cell => writer.createRangeOn( cell ) ) );
 	writer.setSelection( cellsToSelect.map( cell => writer.createRangeOn( cell ) ) );
@@ -511,14 +499,11 @@ function isAffectedBySelection( index, span, limit ) {
 //  3 |   |   |   |   |
 //  3 |   |   |   |   |
 //    +---+---+---+---+
 //    +---+---+---+---+
 function adjustLastRowIndex( table, rowIndexes, columnIndexes ) {
 function adjustLastRowIndex( table, rowIndexes, columnIndexes ) {
-	const tableIterator = new TableWalker( table, {
+	const lastRowMap = Array.from( new TableWalker( table, {
+		startColumn: columnIndexes.first,
+		endColumn: columnIndexes.last,
 		row: rowIndexes.last
 		row: rowIndexes.last
-	} );
-
-	const lastRowMap = Array.from( tableIterator ).filter( ( { column } ) => {
-		// Could use startColumn, endColumn. See: https://github.com/ckeditor/ckeditor5/issues/6785.
-		return columnIndexes.first <= column && column <= columnIndexes.last;
-	} );
+	} ) );
 
 
 	const everyCellHasSingleRowspan = lastRowMap.every( ( { cellHeight } ) => cellHeight === 1 );
 	const everyCellHasSingleRowspan = lastRowMap.every( ( { cellHeight } ) => cellHeight === 1 );
 
 

+ 1 - 1
packages/ckeditor5-table/src/tableselection.js

@@ -109,7 +109,7 @@ export default class TableSelection extends Plugin {
 				endColumn
 				endColumn
 			};
 			};
 
 
-			const table = cropTableToDimensions( sourceTable, cropDimensions, writer, this.editor.plugins.get( 'TableUtils' ) );
+			const table = cropTableToDimensions( sourceTable, cropDimensions, writer );
 
 
 			writer.insert( table, documentFragment, 0 );
 			writer.insert( table, documentFragment, 0 );
 
 

+ 4 - 8
packages/ckeditor5-table/src/tableselection/croptable.js

@@ -20,7 +20,7 @@ import TableWalker from '../tablewalker';
  *			endRow: 1,
  *			endRow: 1,
  *			startColumn: 3,
  *			startColumn: 3,
  *			endColumn: 3
  *			endColumn: 3
- *		}, tableUtils, writer );
+ *		}, writer );
  *
  *
  * Calling the code above for the table below:
  * Calling the code above for the table below:
  *
  *
@@ -44,10 +44,9 @@ import TableWalker from '../tablewalker';
  * @param {Number} cropDimensions.endRow
  * @param {Number} cropDimensions.endRow
  * @param {Number} cropDimensions.endColumn
  * @param {Number} cropDimensions.endColumn
  * @param {module:engine/model/writer~Writer} writer
  * @param {module:engine/model/writer~Writer} writer
- * @param {module:table/tableutils~TableUtils} tableUtils
  * @returns {module:engine/model/element~Element}
  * @returns {module:engine/model/element~Element}
  */
  */
-export function cropTableToDimensions( sourceTable, cropDimensions, writer, tableUtils ) {
+export function cropTableToDimensions( sourceTable, cropDimensions, writer ) {
 	const { startRow, startColumn, endRow, endColumn } = cropDimensions;
 	const { startRow, startColumn, endRow, endColumn } = cropDimensions;
 
 
 	// Create empty table with empty rows equal to crop height.
 	// Create empty table with empty rows equal to crop height.
@@ -61,19 +60,16 @@ export function cropTableToDimensions( sourceTable, cropDimensions, writer, tabl
 	const tableMap = [ ...new TableWalker( sourceTable, { startRow, endRow, startColumn, endColumn, includeAllSlots: true } ) ];
 	const tableMap = [ ...new TableWalker( sourceTable, { startRow, endRow, startColumn, endColumn, includeAllSlots: true } ) ];
 
 
 	// Iterate over source table slots (including empty - spanned - ones).
 	// Iterate over source table slots (including empty - spanned - ones).
-	for ( const { row: sourceRow, column: sourceColumn, cell: tableCell, isAnchor } of tableMap ) {
+	for ( const { row: sourceRow, column: sourceColumn, cell: tableCell, isAnchor, cellAnchorRow, cellAnchorColumn } of tableMap ) {
 		// Row index in cropped table.
 		// Row index in cropped table.
 		const rowInCroppedTable = sourceRow - startRow;
 		const rowInCroppedTable = sourceRow - startRow;
 		const row = croppedTable.getChild( rowInCroppedTable );
 		const row = croppedTable.getChild( rowInCroppedTable );
 
 
 		// For empty slots: fill the gap with empty table cell.
 		// For empty slots: fill the gap with empty table cell.
 		if ( !isAnchor ) {
 		if ( !isAnchor ) {
-			// TODO: Remove table utils usage. See: https://github.com/ckeditor/ckeditor5/issues/6785.
-			const { row: anchorRow, column: anchorColumn } = tableUtils.getCellLocation( tableCell );
-
 			// But fill the gap only if the spanning cell is anchored outside cropped area.
 			// But fill the gap only if the spanning cell is anchored outside cropped area.
 			// In the table from method jsdoc those cells are: "c" & "f".
 			// In the table from method jsdoc those cells are: "c" & "f".
-			if ( anchorRow < startRow || anchorColumn < startColumn ) {
+			if ( cellAnchorRow < startRow || cellAnchorColumn < startColumn ) {
 				createEmptyTableCell( writer, writer.createPositionAt( row, 'end' ) );
 				createEmptyTableCell( writer, writer.createPositionAt( row, 'end' ) );
 			}
 			}
 		}
 		}

+ 16 - 22
packages/ckeditor5-table/src/tableutils.js

@@ -246,35 +246,29 @@ export default class TableUtils extends Plugin {
 
 
 			const tableWalker = new TableWalker( table, { column: insertAt, includeAllSlots: true } );
 			const tableWalker = new TableWalker( table, { column: insertAt, includeAllSlots: true } );
 
 
-			for ( const { row, cell, cellIndex } of tableWalker ) {
+			for ( const tableSlot of tableWalker ) {
+				const { row, cell, cellAnchorColumn, cellAnchorRow, cellWidth, cellHeight } = tableSlot;
+
 				// When iterating over column the table walker outputs either:
 				// When iterating over column the table walker outputs either:
 				// - cells at given column index (cell "e" from method docs),
 				// - cells at given column index (cell "e" from method docs),
 				// - spanned columns (spanned cell from row between cells "g" and "h" - spanned by "e", only if `includeAllSlots: true`),
 				// - spanned columns (spanned cell from row between cells "g" and "h" - spanned by "e", only if `includeAllSlots: true`),
 				// - or a cell from the same row which spans over this column (cell "a").
 				// - or a cell from the same row which spans over this column (cell "a").
 
 
-				const rowspan = parseInt( cell.getAttribute( 'rowspan' ) || 1 );
-				const colspan = parseInt( cell.getAttribute( 'colspan' ) || 1 );
-
-				if ( cellIndex !== insertAt && colspan > 1 ) {
-					// If column is different than `insertAt`, it is a cell that spans over an inserted column (cell "a" & "i").
+				if ( cellAnchorColumn < insertAt ) {
+					// If cell is anchored in previous column, it is a cell that spans over an inserted column (cell "a" & "i").
 					// For such cells expand them by a number of columns inserted.
 					// For such cells expand them by a number of columns inserted.
-					writer.setAttribute( 'colspan', colspan + columnsToInsert, cell );
+					writer.setAttribute( 'colspan', cellWidth + columnsToInsert, cell );
 
 
-					// The `includeAllSlots` option will output the "empty"/spanned column so skip this row already.
-					tableWalker.skipRow( row );
+					// This cell will overlap cells in rows below so skip them (because of `includeAllSlots` option) - (cell "a")
+					const lastCellRow = cellAnchorRow + cellHeight - 1;
 
 
-					// This cell will overlap cells in rows below so skip them also (because of `includeAllSlots` option) - (cell "a")
-					if ( rowspan > 1 ) {
-						for ( let i = row + 1; i < row + rowspan; i++ ) {
-							tableWalker.skipRow( i );
-						}
+					for ( let i = row; i <= lastCellRow; i++ ) {
+						tableWalker.skipRow( i );
 					}
 					}
 				} else {
 				} else {
-					// It's either cell at this column index or spanned cell by a rowspanned cell from row above.
+					// It's either cell at this column index or spanned cell by a row-spanned cell from row above.
 					// In table above it's cell "e" and a spanned position from row below (empty cell between cells "g" and "h")
 					// In table above it's cell "e" and a spanned position from row below (empty cell between cells "g" and "h")
-					const insertPosition = writer.createPositionAt( table.getChild( row ), cellIndex );
-
-					createCells( columnsToInsert, writer, insertPosition );
+					createCells( columnsToInsert, writer, tableSlot.getPositionBefore() );
 				}
 				}
 			}
 			}
 		} );
 		} );
@@ -631,7 +625,9 @@ export default class TableUtils extends Plugin {
 					newCellsAttributes.colspan = colspan;
 					newCellsAttributes.colspan = colspan;
 				}
 				}
 
 
-				for ( const { column, row, cellIndex } of tableMap ) {
+				for ( const tableSlot of tableMap ) {
+					const { column, row } = tableSlot;
+
 					// As both newly created cells and the split cell might have rowspan,
 					// As both newly created cells and the split cell might have rowspan,
 					// the insertion of new cells must go to appropriate rows:
 					// the insertion of new cells must go to appropriate rows:
 					//
 					//
@@ -643,9 +639,7 @@ export default class TableUtils extends Plugin {
 					const isInEvenlySplitRow = ( row + splitCellRow + updatedSpan ) % newCellsSpan === 0;
 					const isInEvenlySplitRow = ( row + splitCellRow + updatedSpan ) % newCellsSpan === 0;
 
 
 					if ( isAfterSplitCell && isOnSameColumn && isInEvenlySplitRow ) {
 					if ( isAfterSplitCell && isOnSameColumn && isInEvenlySplitRow ) {
-						const position = writer.createPositionAt( table.getChild( row ), cellIndex );
-
-						createCells( 1, writer, position, newCellsAttributes );
+						createCells( 1, writer, tableSlot.getPositionBefore(), newCellsAttributes );
 					}
 					}
 				}
 				}
 			}
 			}

+ 37 - 24
packages/ckeditor5-table/src/tablewalker.js

@@ -92,7 +92,7 @@ export default class TableWalker {
 		 *
 		 *
 		 * @readonly
 		 * @readonly
 		 * @member {module:engine/model/element~Element}
 		 * @member {module:engine/model/element~Element}
-		 * @private
+		 * @protected
 		 */
 		 */
 		this._table = table;
 		this._table = table;
 
 
@@ -154,7 +154,7 @@ export default class TableWalker {
 		 * The current row index.
 		 * The current row index.
 		 *
 		 *
 		 * @member {Number}
 		 * @member {Number}
-		 * @private
+		 * @protected
 		 */
 		 */
 		this._row = 0;
 		this._row = 0;
 
 
@@ -162,7 +162,7 @@ export default class TableWalker {
 		 * The current column index.
 		 * The current column index.
 		 *
 		 *
 		 * @member {Number}
 		 * @member {Number}
-		 * @private
+		 * @protected
 		 */
 		 */
 		this._column = 0;
 		this._column = 0;
 
 
@@ -171,7 +171,7 @@ export default class TableWalker {
 		 * this represents the index of the next table cell.
 		 * this represents the index of the next table cell.
 		 *
 		 *
 		 * @member {Number}
 		 * @member {Number}
-		 * @private
+		 * @protected
 		 */
 		 */
 		this._cellIndex = 0;
 		this._cellIndex = 0;
 
 
@@ -320,13 +320,7 @@ export default class TableWalker {
 	_formatOutValue( cell, anchorRow = this._row, anchorColumn = this._column ) {
 	_formatOutValue( cell, anchorRow = this._row, anchorColumn = this._column ) {
 		return {
 		return {
 			done: false,
 			done: false,
-			value: new TableSlot( cell, {
-				row: this._row,
-				column: this._column,
-				anchorRow,
-				anchorColumn,
-				cellIndex: this._cellIndex
-			} )
+			value: new TableSlot( this, cell, anchorRow, anchorColumn )
 		};
 		};
 	}
 	}
 
 
@@ -414,16 +408,13 @@ class TableSlot {
 	/**
 	/**
 	 * Creates an instance of the table walker value.
 	 * Creates an instance of the table walker value.
 	 *
 	 *
-	 * @private
+	 * @protected
+	 * @param {module:table/tablewalker~TableWalker} tableWalker The table walker instance.
 	 * @param {module:engine/model/element~Element} cell The current table cell.
 	 * @param {module:engine/model/element~Element} cell The current table cell.
-	 * @param {Object} data
-	 * @param {Number} data.row The row index of a table slot.
-	 * @param {Number} data.column The column index of a table slot.
-	 * @param {Number} data.anchorRow The row index of a cell anchor slot.
-	 * @param {Number} data.anchorColumn The column index of a cell anchor slot.
-	 * @param {Number} data.cellIndex The index of the current cell in the parent row.
+	 * @param {Number} anchorRow The row index of a cell anchor slot.
+	 * @param {Number} anchorColumn The column index of a cell anchor slot.
 	 */
 	 */
-	constructor( cell, data ) {
+	constructor( tableWalker, cell, anchorRow, anchorColumn ) {
 		/**
 		/**
 		 * The current table cell.
 		 * The current table cell.
 		 *
 		 *
@@ -438,7 +429,7 @@ class TableSlot {
 		 * @readonly
 		 * @readonly
 		 * @member {Number}
 		 * @member {Number}
 		 */
 		 */
-		this.row = data.row;
+		this.row = tableWalker._row;
 
 
 		/**
 		/**
 		 * The column index of a table slot.
 		 * The column index of a table slot.
@@ -446,7 +437,7 @@ class TableSlot {
 		 * @readonly
 		 * @readonly
 		 * @member {Number}
 		 * @member {Number}
 		 */
 		 */
-		this.column = data.column;
+		this.column = tableWalker._column;
 
 
 		/**
 		/**
 		 * The row index of a cell anchor slot.
 		 * The row index of a cell anchor slot.
@@ -454,7 +445,7 @@ class TableSlot {
 		 * @readonly
 		 * @readonly
 		 * @member {Number}
 		 * @member {Number}
 		 */
 		 */
-		this.cellAnchorRow = data.anchorRow;
+		this.cellAnchorRow = anchorRow;
 
 
 		/**
 		/**
 		 * The column index of a cell anchor slot.
 		 * The column index of a cell anchor slot.
@@ -462,15 +453,25 @@ class TableSlot {
 		 * @readonly
 		 * @readonly
 		 * @member {Number}
 		 * @member {Number}
 		 */
 		 */
-		this.cellAnchorColumn = data.anchorColumn;
+		this.cellAnchorColumn = anchorColumn;
 
 
 		/**
 		/**
 		 * The index of the current cell in the parent row.
 		 * The index of the current cell in the parent row.
 		 *
 		 *
 		 * @readonly
 		 * @readonly
 		 * @member {Number}
 		 * @member {Number}
+		 * @private
 		 */
 		 */
-		this.cellIndex = data.cellIndex;
+		this._cellIndex = tableWalker._cellIndex;
+
+		/**
+		 * The table element.
+		 *
+		 * @readonly
+		 * @member {module:engine/model/element~Element}
+		 * @private
+		 */
+		this._table = tableWalker._table;
 	}
 	}
 
 
 	/**
 	/**
@@ -503,7 +504,19 @@ class TableSlot {
 		return parseInt( this.cell.getAttribute( 'rowspan' ) || 1 );
 		return parseInt( this.cell.getAttribute( 'rowspan' ) || 1 );
 	}
 	}
 
 
+	/**
+	 * Returns the {@link module:engine/model/position~Position} before the table slot.
+	 *
+	 * @returns {module:engine/model/position~Position}
+	 */
+	getPositionBefore() {
+		const model = this._table.root.document.model;
+
+		return model.createPositionAt( this._table.getChild( this.row ), this._cellIndex );
+	}
+
 	// @if CK_DEBUG // get isSpanned() { throw new CKEditorError( 'tablewalker-improper-api-usage', this ); }
 	// @if CK_DEBUG // get isSpanned() { throw new CKEditorError( 'tablewalker-improper-api-usage', this ); }
 	// @if CK_DEBUG // get colspan() { throw new CKEditorError( 'tablewalker-improper-api-usage', this ); }
 	// @if CK_DEBUG // get colspan() { throw new CKEditorError( 'tablewalker-improper-api-usage', this ); }
 	// @if CK_DEBUG // get rowspan() { throw new CKEditorError( 'tablewalker-improper-api-usage', this ); }
 	// @if CK_DEBUG // get rowspan() { throw new CKEditorError( 'tablewalker-improper-api-usage', this ); }
+	// @if CK_DEBUG // get cellIndex() { throw new CKEditorError( 'tablewalker-improper-api-usage', this ); }
 }
 }

+ 4 - 5
packages/ckeditor5-table/src/utils.js

@@ -322,16 +322,15 @@ export function splitHorizontally( tableCell, splitRow, writer ) {
 
 
 	let columnIndex;
 	let columnIndex;
 
 
-	for ( const { row, column, cell, cellIndex } of tableMap ) {
+	for ( const tableSlot of tableMap ) {
+		const { row, column, cell } = tableSlot;
+
 		if ( cell === tableCell && columnIndex === undefined ) {
 		if ( cell === tableCell && columnIndex === undefined ) {
 			columnIndex = column;
 			columnIndex = column;
 		}
 		}
 
 
 		if ( columnIndex !== undefined && columnIndex === column && row === endRow ) {
 		if ( columnIndex !== undefined && columnIndex === column && row === endRow ) {
-			const tableRow = table.getChild( row );
-			const tableCellPosition = writer.createPositionAt( tableRow, cellIndex );
-
-			createEmptyTableCell( writer, tableCellPosition, newCellAttributes );
+			createEmptyTableCell( writer, tableSlot.getPositionBefore(), newCellAttributes );
 		}
 		}
 	}
 	}
 
 

+ 1 - 1
packages/ckeditor5-table/tests/tableclipboard-paste.js

@@ -1421,7 +1421,7 @@ describe( 'table clipboard', () => {
 					] );
 					] );
 				} );
 				} );
 
 
-				it( 'handles pasting table that has cell with colspan (multiple ending rows in the selection are spanned)', () => {
+				it( 'handles pasting table that has cell with rowspan (multiple ending rows in the selection are spanned)', () => {
 					// +----+----+----+
 					// +----+----+----+
 					// | 00 | 01 | 02 |
 					// | 00 | 01 | 02 |
 					// +----+    +    +
 					// +----+    +    +

+ 7 - 0
packages/ckeditor5-table/tests/tableutils.js

@@ -481,6 +481,13 @@ describe( 'TableUtils', () => {
 		} );
 		} );
 
 
 		it( 'should skip row & column spanned cells', () => {
 		it( 'should skip row & column spanned cells', () => {
+			// +----+----+----+
+			// | 00      | 02 |
+			// +         +----+
+			// |         | 12 |
+			// +----+----+----+
+			// | 20 | 21 | 22 |
+			// +----+----+----+
 			setData( model, modelTable( [
 			setData( model, modelTable( [
 				[ { colspan: 2, rowspan: 2, contents: '00[]' }, '02' ],
 				[ { colspan: 2, rowspan: 2, contents: '00[]' }, '02' ],
 				[ '12' ],
 				[ '12' ],

+ 17 - 11
packages/ckeditor5-table/tests/tablewalker.js

@@ -31,22 +31,28 @@ describe( 'TableWalker', () => {
 		setData( model, modelTable( tableData ) );
 		setData( model, modelTable( tableData ) );
 
 
 		const walker = new TableWalker( root.getChild( 0 ), options );
 		const walker = new TableWalker( root.getChild( 0 ), options );
+
 		if ( skip !== undefined ) {
 		if ( skip !== undefined ) {
 			walker.skipRow( skip );
 			walker.skipRow( skip );
 		}
 		}
+
 		const result = [ ...walker ];
 		const result = [ ...walker ];
 
 
-		const formattedResult = result.map( ( { cell, row, column, isAnchor, cellWidth, cellHeight, cellIndex, ...anchor } ) => ( {
-			row,
-			column,
-			data: cell && cell.getChild( 0 ).getChild( 0 ).data,
-			index: cellIndex,
-			...( anchor.cellAnchorRow != row ? { anchorRow: anchor.cellAnchorRow } : null ),
-			...( anchor.cellAnchorColumn != column ? { anchorColumn: anchor.cellAnchorColumn } : null ),
-			...( isAnchor ? { isAnchor } : null ),
-			...( cellWidth > 1 ? { width: cellWidth } : null ),
-			...( cellHeight > 1 ? { height: cellHeight } : null )
-		} ) );
+		const formattedResult = result.map( tableSlot => {
+			const { cell, row, column, isAnchor, cellWidth, cellHeight, cellAnchorRow, cellAnchorColumn } = tableSlot;
+
+			return {
+				row,
+				column,
+				data: cell && cell.getChild( 0 ).getChild( 0 ).data,
+				index: tableSlot.getPositionBefore().offset,
+				...( cellAnchorRow != row ? { anchorRow: cellAnchorRow } : null ),
+				...( cellAnchorColumn != column ? { anchorColumn: cellAnchorColumn } : null ),
+				...( isAnchor ? { isAnchor } : null ),
+				...( cellWidth > 1 ? { width: cellWidth } : null ),
+				...( cellHeight > 1 ? { height: cellHeight } : null )
+			};
+		} );
 
 
 		expect( formattedResult ).to.deep.equal( expected );
 		expect( formattedResult ).to.deep.equal( expected );
 	}
 	}