浏览代码

Add docs to getRowIndexes() helper function.

Maciej Gołaszewski 5 年之前
父节点
当前提交
3e185654c9
共有 1 个文件被更改,包括 14 次插入3 次删除
  1. 14 3
      packages/ckeditor5-table/src/utils.js

+ 14 - 3
packages/ckeditor5-table/src/utils.js

@@ -137,9 +137,20 @@ export function getSelectionAffectedTableCells( selection ) {
 	return getTableCellsContainingSelection( selection );
 }
 
-// Returns a helper object with first and last row index contained in given `referenceCells`.
-export function getRowIndexes( referenceCells ) {
-	const allIndexesSorted = referenceCells.map( cell => cell.parent.index ).sort();
+/**
+ * Returns a helper object with `first` and `last` row index contained in given `tableCells`.
+ *
+ *		const selectedTableCells = getSelectedTableCells( editor.model.document.selection );
+ *
+ *		const { first, last } = getRowIndexes( selectedTableCells );
+ *
+ *		console.log( `Selected rows ${ first } to ${ last }` );
+ *
+ * @package {Array.<module:engine/model/element~Element>}
+ * @returns {Object} Returns an object with `first` and `last` table row indexes.
+ */
+export function getRowIndexes( tableCells ) {
+	const allIndexesSorted = tableCells.map( cell => cell.parent.index ).sort();
 
 	return {
 		first: allIndexesSorted[ 0 ],