Kaynağa Gözat

Remove cropTableToSelection() util method.

Maciej Gołaszewski 5 yıl önce
ebeveyn
işleme
507f0de19a

+ 16 - 6
packages/ckeditor5-table/src/tableselection.js

@@ -13,12 +13,9 @@ import first from '@ckeditor/ckeditor5-utils/src/first';
 import TableWalker from './tablewalker';
 import TableWalker from './tablewalker';
 import TableUtils from './tableutils';
 import TableUtils from './tableutils';
 import MouseEventsObserver from './tableselection/mouseeventsobserver';
 import MouseEventsObserver from './tableselection/mouseeventsobserver';
-import {
-	getSelectedTableCells,
-	getTableCellsContainingSelection
-} from './utils';
+import { getColumnIndexes, getRowIndexes, getSelectedTableCells, getTableCellsContainingSelection } from './utils';
 import { findAncestor } from './commands/utils';
 import { findAncestor } from './commands/utils';
-import { cropTableToSelection } from './tableselection/croptable';
+import { cropTableToDimensions } from './tableselection/croptable';
 
 
 import '../theme/tableselection.css';
 import '../theme/tableselection.css';
 
 
@@ -99,7 +96,20 @@ export default class TableSelection extends Plugin {
 
 
 		return this.editor.model.change( writer => {
 		return this.editor.model.change( writer => {
 			const documentFragment = writer.createDocumentFragment();
 			const documentFragment = writer.createDocumentFragment();
-			const table = cropTableToSelection( selectedCells, writer, this.editor.plugins.get( 'TableUtils' ) );
+
+			const { first: startColumn, last: endColumn } = getColumnIndexes( selectedCells );
+			const { first: startRow, last: endRow } = getRowIndexes( selectedCells );
+
+			const sourceTable = findAncestor( 'table', selectedCells[ 0 ] );
+
+			const cropDimensions = {
+				startRow,
+				startColumn,
+				endRow,
+				endColumn
+			};
+
+			const table = cropTableToDimensions( sourceTable, cropDimensions, writer, this.editor.plugins.get( 'TableUtils' ) );
 
 
 			writer.insert( table, documentFragment, 0 );
 			writer.insert( table, documentFragment, 0 );
 
 

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

@@ -7,9 +7,8 @@
  * @module table/tableselection/croptable
  * @module table/tableselection/croptable
  */
  */
 
 
-import { createEmptyTableCell, findAncestor, updateNumericAttribute } from '../commands/utils';
+import { createEmptyTableCell, updateNumericAttribute } from '../commands/utils';
 import TableWalker from '../tablewalker';
 import TableWalker from '../tablewalker';
-import { getColumnIndexes, getRowIndexes } from '../utils';
 
 
 /**
 /**
  * Returns a cropped table according to given dimensions.
  * Returns a cropped table according to given dimensions.
@@ -97,40 +96,6 @@ export function cropTableToDimensions( sourceTable, cropDimensions, writer, tabl
 	return croppedTable;
 	return croppedTable;
 }
 }
 
 
-/**
- * Returns a cropped table from the selected table cells.
- *
- * This function is to be used with the table selection.
- *
- *		tableSelection.setCellSelection( startCell, endCell );
- *
- *		const croppedTable = cropTable( tableSelection.getSelectedTableCells(), tableUtils, writer );
- *
- * **Note**: This function is also used by {@link module:table/tableselection~TableSelection#getSelectionAsFragment}.
- *
- * @param {Iterable.<module:engine/model/element~Element>} selectedTableCellsIterator
- * @param {module:engine/model/writer~Writer} writer
- * @param {module:table/tableutils~TableUtils} tableUtils
- * @returns {module:engine/model/element~Element}
- */
-export function cropTableToSelection( selectedTableCellsIterator, writer, tableUtils ) {
-	const selectedTableCells = Array.from( selectedTableCellsIterator );
-
-	const { first: startColumn, last: endColumn } = getColumnIndexes( selectedTableCells );
-	const { first: startRow, last: endRow } = getRowIndexes( selectedTableCells );
-
-	const sourceTable = findAncestor( 'table', selectedTableCells[ 0 ] );
-
-	const cropDimensions = {
-		startRow,
-		startColumn,
-		endRow,
-		endColumn
-	};
-
-	return cropTableToDimensions( sourceTable, cropDimensions, writer, tableUtils );
-}
-
 // Adjusts table cell dimensions to not exceed limit row and column.
 // Adjusts table cell dimensions to not exceed limit row and column.
 //
 //
 // If table cell span to a column (or row) that is after a limit column (or row) trim colspan (or rowspan)
 // If table cell span to a column (or row) that is after a limit column (or row) trim colspan (or rowspan)