@atlaskit/editor-plugin-table
Version:
Table plugin for the @atlaskit/editor
11 lines (10 loc) • 626 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 var getMenuSelectionRect = function getMenuSelectionRect(selection) {
return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
};