@atlaskit/editor-plugin-table
Version:
Table plugin for the @atlaskit/editor
9 lines (8 loc) • 586 B
JavaScript
import { findCellRectClosestToPos } from '@atlaskit/editor-tables/utils';
import { getSelectionRect } from '@atlaskit/editor-tables/utils/get-selection-rect';
import { isSelectionType } from '@atlaskit/editor-tables/utils/is-selection-type';
/**
* 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`.
*/
export const getMenuSelectionRect = selection => isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);