UNPKG

@atlaskit/editor-plugin-table

Version:

Table plugin for the @atlaskit/editor

14 lines (13 loc) 724 B
import { findCellRectClosestToPos, getSelectionRect, isSelectionType } from '@atlaskit/editor-tables/utils'; import { fg } from '@atlaskit/platform-feature-flags/fg'; /** * Resolve the table `Rect` for the current selection. Falls back to the closest cell's rect * for a `TextSelection` (cell menu), where `getSelectionRect` returns `undefined`. Gated: * with the gate off this behaves exactly like `getSelectionRect`. */ export var getMenuSelectionRect = function getMenuSelectionRect(selection) { if (!fg('platform_editor_table_cell_menu_update')) { return getSelectionRect(selection); } return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from); };