ソースを参照

Move private method to the bottom of a file.

Maciej Gołaszewski 6 年 前
コミット
6242981bcf
1 ファイル変更9 行追加6 行削除
  1. 9 6
      packages/ckeditor5-table/src/commands/utils.js

+ 9 - 6
packages/ckeditor5-table/src/commands/utils.js

@@ -29,12 +29,6 @@ export function findAncestor( parentName, positionOrElement ) {
 	}
 }
 
-function getSelectedTableCell( firstPosition ) {
-	const isTableCellSelected = firstPosition.nodeAfter && firstPosition.nodeAfter.is( 'tableCell' );
-
-	return isTableCellSelected ? firstPosition.nodeAfter : findAncestor( 'tableCell', firstPosition );
-}
-
 /**
  * Returns a first selected table cell from a multi-cell or in-cell selection.
  *
@@ -142,3 +136,12 @@ export function addDefaultUnitToNumericValue( value, defaultUnit ) {
 
 	return `${ numericValue }${ defaultUnit }`;
 }
+
+// Returns a table cell for two scenarios:
+// 1. Selection is on table cell (position is before table cell).
+// 2. Selection is inside a table cell (position is inside as well).
+function getSelectedTableCell( position ) {
+	const isTableCellSelected = position.nodeAfter && position.nodeAfter.is( 'tableCell' );
+
+	return isTableCellSelected ? position.nodeAfter : findAncestor( 'tableCell', position );
+}