|
|
@@ -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 );
|
|
|
+}
|