@atlaskit/editor-plugin-table
Version:
Table plugin for the @atlaskit/editor
19 lines (18 loc) • 869 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getMenuSelectionRect = void 0;
var _utils = require("@atlaskit/editor-tables/utils");
var _fg = require("@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`.
*/
var getMenuSelectionRect = exports.getMenuSelectionRect = function getMenuSelectionRect(selection) {
if (!(0, _fg.fg)('platform_editor_table_cell_menu_update')) {
return (0, _utils.getSelectionRect)(selection);
}
return (0, _utils.isSelectionType)(selection, 'cell') ? (0, _utils.getSelectionRect)(selection) : (0, _utils.findCellRectClosestToPos)(selection.$from);
};