@atlaskit/editor-plugin-table 22.4.7 → 22.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/pm-plugins/commands/split-cell.js +18 -1
  3. package/dist/cjs/pm-plugins/transforms/merge.js +5 -2
  4. package/dist/cjs/ui/FloatingContextualButton/index.js +5 -0
  5. package/dist/cjs/ui/FloatingContextualMenu/CellMenuPopup.js +104 -0
  6. package/dist/cjs/ui/FloatingContextualMenu/index.js +13 -2
  7. package/dist/cjs/ui/FloatingDragMenu/index.js +7 -2
  8. package/dist/cjs/ui/TableMenu/cell/getCellMenuComponents.js +70 -0
  9. package/dist/cjs/ui/TableMenu/cell/items/MergeCellsItem.js +33 -0
  10. package/dist/cjs/ui/TableMenu/cell/items/SplitCellItem.js +33 -0
  11. package/dist/cjs/ui/TableMenu/cell/keys.js +40 -0
  12. package/dist/cjs/ui/TableMenu/column/getColumnMenuComponents.js +4 -11
  13. package/dist/cjs/ui/TableMenu/column/items/ColumnBackgroundSection.js +25 -0
  14. package/dist/cjs/ui/TableMenu/column/items/ColumnToggleSection.js +24 -0
  15. package/dist/cjs/ui/TableMenu/column/items/DistributeColumnsItem.js +10 -0
  16. package/dist/cjs/ui/TableMenu/column/items/HeaderColumnToggleItem.js +17 -1
  17. package/dist/cjs/ui/TableMenu/column/items/MoveColumnRightItem.js +2 -6
  18. package/dist/cjs/ui/TableMenu/column/items/SortDecreasingItem.js +3 -1
  19. package/dist/cjs/ui/TableMenu/column/items/SortIncreasingItem.js +3 -1
  20. package/dist/cjs/ui/TableMenu/row/getRowMenuComponents.js +0 -7
  21. package/dist/cjs/ui/TableMenu/row/items/HeaderRowToggleItem.js +9 -0
  22. package/dist/cjs/ui/TableMenu/row/items/MoveRowDownItem.js +10 -0
  23. package/dist/cjs/ui/TableMenu/row/items/MoveRowUpItem.js +10 -0
  24. package/dist/cjs/ui/TableMenu/shared/TableMenu.js +53 -3
  25. package/dist/cjs/ui/TableMenu/shared/TableMenuContext.js +13 -0
  26. package/dist/cjs/ui/TableMenu/shared/consts.js +3 -2
  27. package/dist/cjs/ui/TableMenu/shared/getSharedItems.js +28 -19
  28. package/dist/cjs/ui/TableMenu/shared/getTableMenuComponents.js +2 -1
  29. package/dist/cjs/ui/event-handlers.js +6 -1
  30. package/dist/es2019/pm-plugins/commands/split-cell.js +17 -1
  31. package/dist/es2019/pm-plugins/transforms/merge.js +4 -4
  32. package/dist/es2019/ui/FloatingContextualButton/index.js +5 -0
  33. package/dist/es2019/ui/FloatingContextualMenu/CellMenuPopup.js +100 -0
  34. package/dist/es2019/ui/FloatingContextualMenu/index.js +13 -3
  35. package/dist/es2019/ui/FloatingDragMenu/index.js +7 -2
  36. package/dist/es2019/ui/TableMenu/cell/getCellMenuComponents.js +53 -0
  37. package/dist/es2019/ui/TableMenu/cell/items/MergeCellsItem.js +26 -0
  38. package/dist/es2019/ui/TableMenu/cell/items/SplitCellItem.js +26 -0
  39. package/dist/es2019/ui/TableMenu/cell/keys.js +42 -0
  40. package/dist/es2019/ui/TableMenu/column/getColumnMenuComponents.js +4 -12
  41. package/dist/es2019/ui/TableMenu/column/items/ColumnBackgroundSection.js +20 -0
  42. package/dist/es2019/ui/TableMenu/column/items/ColumnToggleSection.js +19 -0
  43. package/dist/es2019/ui/TableMenu/column/items/DistributeColumnsItem.js +11 -0
  44. package/dist/es2019/ui/TableMenu/column/items/HeaderColumnToggleItem.js +15 -0
  45. package/dist/es2019/ui/TableMenu/column/items/MoveColumnRightItem.js +3 -5
  46. package/dist/es2019/ui/TableMenu/column/items/SortDecreasingItem.js +3 -1
  47. package/dist/es2019/ui/TableMenu/column/items/SortIncreasingItem.js +3 -1
  48. package/dist/es2019/ui/TableMenu/row/getRowMenuComponents.js +0 -8
  49. package/dist/es2019/ui/TableMenu/row/items/HeaderRowToggleItem.js +8 -0
  50. package/dist/es2019/ui/TableMenu/row/items/MoveRowDownItem.js +8 -0
  51. package/dist/es2019/ui/TableMenu/row/items/MoveRowUpItem.js +8 -0
  52. package/dist/es2019/ui/TableMenu/shared/TableMenu.js +51 -3
  53. package/dist/es2019/ui/TableMenu/shared/TableMenuContext.js +4 -0
  54. package/dist/es2019/ui/TableMenu/shared/consts.js +2 -1
  55. package/dist/es2019/ui/TableMenu/shared/getSharedItems.js +9 -0
  56. package/dist/es2019/ui/TableMenu/shared/getTableMenuComponents.js +2 -1
  57. package/dist/es2019/ui/event-handlers.js +4 -1
  58. package/dist/esm/pm-plugins/commands/split-cell.js +17 -1
  59. package/dist/esm/pm-plugins/transforms/merge.js +4 -2
  60. package/dist/esm/ui/FloatingContextualButton/index.js +5 -0
  61. package/dist/esm/ui/FloatingContextualMenu/CellMenuPopup.js +96 -0
  62. package/dist/esm/ui/FloatingContextualMenu/index.js +13 -3
  63. package/dist/esm/ui/FloatingDragMenu/index.js +7 -2
  64. package/dist/esm/ui/TableMenu/cell/getCellMenuComponents.js +63 -0
  65. package/dist/esm/ui/TableMenu/cell/items/MergeCellsItem.js +27 -0
  66. package/dist/esm/ui/TableMenu/cell/items/SplitCellItem.js +27 -0
  67. package/dist/esm/ui/TableMenu/cell/keys.js +34 -0
  68. package/dist/esm/ui/TableMenu/column/getColumnMenuComponents.js +4 -12
  69. package/dist/esm/ui/TableMenu/column/items/ColumnBackgroundSection.js +19 -0
  70. package/dist/esm/ui/TableMenu/column/items/ColumnToggleSection.js +18 -0
  71. package/dist/esm/ui/TableMenu/column/items/DistributeColumnsItem.js +11 -0
  72. package/dist/esm/ui/TableMenu/column/items/HeaderColumnToggleItem.js +17 -0
  73. package/dist/esm/ui/TableMenu/column/items/MoveColumnRightItem.js +3 -7
  74. package/dist/esm/ui/TableMenu/column/items/SortDecreasingItem.js +3 -1
  75. package/dist/esm/ui/TableMenu/column/items/SortIncreasingItem.js +3 -1
  76. package/dist/esm/ui/TableMenu/row/getRowMenuComponents.js +0 -8
  77. package/dist/esm/ui/TableMenu/row/items/HeaderRowToggleItem.js +10 -0
  78. package/dist/esm/ui/TableMenu/row/items/MoveRowDownItem.js +10 -0
  79. package/dist/esm/ui/TableMenu/row/items/MoveRowUpItem.js +10 -0
  80. package/dist/esm/ui/TableMenu/shared/TableMenu.js +52 -3
  81. package/dist/esm/ui/TableMenu/shared/TableMenuContext.js +6 -0
  82. package/dist/esm/ui/TableMenu/shared/consts.js +2 -1
  83. package/dist/esm/ui/TableMenu/shared/getSharedItems.js +9 -0
  84. package/dist/esm/ui/TableMenu/shared/getTableMenuComponents.js +2 -1
  85. package/dist/esm/ui/event-handlers.js +6 -1
  86. package/dist/types/pm-plugins/commands/split-cell.d.ts +2 -0
  87. package/dist/types/pm-plugins/transforms/merge.d.ts +2 -0
  88. package/dist/types/ui/FloatingContextualMenu/CellMenuPopup.d.ts +12 -0
  89. package/dist/types/ui/TableMenu/cell/getCellMenuComponents.d.ts +2 -0
  90. package/dist/types/ui/TableMenu/cell/items/MergeCellsItem.d.ts +2 -0
  91. package/dist/types/ui/TableMenu/cell/items/SplitCellItem.d.ts +2 -0
  92. package/dist/types/ui/TableMenu/cell/keys.d.ts +9 -0
  93. package/dist/types/ui/TableMenu/column/getColumnMenuComponents.d.ts +0 -7
  94. package/dist/types/ui/TableMenu/column/items/ColumnBackgroundSection.d.ts +10 -0
  95. package/dist/types/ui/TableMenu/column/items/ColumnToggleSection.d.ts +9 -0
  96. package/dist/types/ui/TableMenu/column/items/DistributeColumnsItem.d.ts +1 -1
  97. package/dist/types/ui/TableMenu/column/items/HeaderColumnToggleItem.d.ts +11 -1
  98. package/dist/types/ui/TableMenu/row/getRowMenuComponents.d.ts +0 -7
  99. package/dist/types/ui/TableMenu/row/items/HeaderRowToggleItem.d.ts +1 -1
  100. package/dist/types/ui/TableMenu/row/items/MoveRowDownItem.d.ts +1 -1
  101. package/dist/types/ui/TableMenu/row/items/MoveRowUpItem.d.ts +1 -1
  102. package/dist/types/ui/TableMenu/shared/TableMenu.d.ts +3 -1
  103. package/dist/types/ui/TableMenu/shared/TableMenuContext.d.ts +14 -0
  104. package/dist/types/ui/TableMenu/shared/consts.d.ts +1 -0
  105. package/dist/types-ts4.5/pm-plugins/commands/split-cell.d.ts +2 -0
  106. package/dist/types-ts4.5/pm-plugins/transforms/merge.d.ts +2 -0
  107. package/dist/types-ts4.5/ui/FloatingContextualMenu/CellMenuPopup.d.ts +12 -0
  108. package/dist/types-ts4.5/ui/TableMenu/cell/getCellMenuComponents.d.ts +2 -0
  109. package/dist/types-ts4.5/ui/TableMenu/cell/items/MergeCellsItem.d.ts +2 -0
  110. package/dist/types-ts4.5/ui/TableMenu/cell/items/SplitCellItem.d.ts +2 -0
  111. package/dist/types-ts4.5/ui/TableMenu/cell/keys.d.ts +9 -0
  112. package/dist/types-ts4.5/ui/TableMenu/column/getColumnMenuComponents.d.ts +0 -7
  113. package/dist/types-ts4.5/ui/TableMenu/column/items/ColumnBackgroundSection.d.ts +10 -0
  114. package/dist/types-ts4.5/ui/TableMenu/column/items/ColumnToggleSection.d.ts +9 -0
  115. package/dist/types-ts4.5/ui/TableMenu/column/items/DistributeColumnsItem.d.ts +1 -1
  116. package/dist/types-ts4.5/ui/TableMenu/column/items/HeaderColumnToggleItem.d.ts +11 -1
  117. package/dist/types-ts4.5/ui/TableMenu/row/getRowMenuComponents.d.ts +0 -7
  118. package/dist/types-ts4.5/ui/TableMenu/row/items/HeaderRowToggleItem.d.ts +1 -1
  119. package/dist/types-ts4.5/ui/TableMenu/row/items/MoveRowDownItem.d.ts +1 -1
  120. package/dist/types-ts4.5/ui/TableMenu/row/items/MoveRowUpItem.d.ts +1 -1
  121. package/dist/types-ts4.5/ui/TableMenu/shared/TableMenu.d.ts +3 -1
  122. package/dist/types-ts4.5/ui/TableMenu/shared/TableMenuContext.d.ts +14 -0
  123. package/dist/types-ts4.5/ui/TableMenu/shared/consts.d.ts +1 -0
  124. package/package.json +5 -5
@@ -0,0 +1,42 @@
1
+ import { BACKGROUND_COLOR_ITEM, CLEAR_CELLS_ITEM } from '../shared/keys';
2
+
3
+ // --- Menu surface ---
4
+
5
+ export const CELL_MENU = {
6
+ type: 'menu',
7
+ key: 'cell-contextual-menu'
8
+ };
9
+
10
+ // --- Sections ---
11
+
12
+ export const CELL_ACTION_SECTION = {
13
+ type: 'menu-section',
14
+ key: 'cell-action-section'
15
+ };
16
+ export const CELL_DANGER_SECTION = {
17
+ type: 'menu-section',
18
+ key: 'cell-danger-section'
19
+ };
20
+ export const CELL_MENU_RANK = {
21
+ [CELL_ACTION_SECTION.key]: 100,
22
+ [CELL_DANGER_SECTION.key]: 200
23
+ };
24
+ export const MERGE_CELLS_ITEM = {
25
+ type: 'menu-item',
26
+ key: 'merge-cells'
27
+ };
28
+ export const SPLIT_CELL_ITEM = {
29
+ type: 'menu-item',
30
+ key: 'split-cell'
31
+ };
32
+
33
+ // --- Item ranks within their sections ---
34
+
35
+ export const CELL_ACTION_SECTION_RANK = {
36
+ [BACKGROUND_COLOR_ITEM.key]: 100,
37
+ [MERGE_CELLS_ITEM.key]: 200,
38
+ [SPLIT_CELL_ITEM.key]: 300
39
+ };
40
+ export const CELL_DANGER_SECTION_RANK = {
41
+ [CLEAR_CELLS_ITEM.key]: 100
42
+ };
@@ -2,6 +2,8 @@ import React from 'react';
2
2
  import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
3
3
  import { AddColumnLeftItem } from './items/AddColumnLeftItem';
4
4
  import { AddColumnRightItem } from './items/AddColumnRightItem';
5
+ import { ColumnBackgroundSection } from './items/ColumnBackgroundSection';
6
+ import { ColumnToggleSection } from './items/ColumnToggleSection';
5
7
  import { DeleteColumnItem } from './items/DeleteColumnItem';
6
8
  import { DistributeColumnsItem } from './items/DistributeColumnsItem';
7
9
  import { HeaderColumnToggleItem } from './items/HeaderColumnToggleItem';
@@ -9,14 +11,6 @@ import { MoveColumnRightItem } from './items/MoveColumnRightItem';
9
11
  import { SortDecreasingItem } from './items/SortDecreasingItem';
10
12
  import { SortIncreasingItem } from './items/SortIncreasingItem';
11
13
  import { COLUMN_MENU, COLUMN_TOGGLE_SECTION, COLUMN_BACKGROUND_SECTION, COLUMN_SORT_SECTION, COLUMN_ADD_SECTION, COLUMN_DANGER_SECTION, COLUMN_SECTION_RANK, HEADER_COLUMN_TOGGLE_ITEM, SORT_INCREASING_ITEM, SORT_DECREASING_ITEM, ADD_COLUMN_LEFT_ITEM, ADD_COLUMN_RIGHT_ITEM, MOVE_COLUMN_RIGHT_ITEM, DISTRIBUTE_COLUMNS_ITEM, DELETE_COLUMN_ITEM, COLUMN_TOGGLE_SECTION_RANK, COLUMN_SORT_SECTION_RANK, COLUMN_ADD_SECTION_RANK, COLUMN_DANGER_SECTION_RANK } from './keys';
12
-
13
- /**
14
- * Returns the RegisterComponent[] array defining the column menu surface.
15
- *
16
- * This is a **UI-only stub** — all items are always visible with no conditional
17
- * logic and no wired actions. Functional behaviour (actions, conditional visibility)
18
- * will be connected in follow-up tickets.
19
- */
20
14
  export const getColumnMenuComponents = () => [
21
15
  // --- Menu surface ---
22
16
  {
@@ -32,7 +26,7 @@ export const getColumnMenuComponents = () => [
32
26
  key: COLUMN_MENU.key,
33
27
  rank: COLUMN_SECTION_RANK[COLUMN_TOGGLE_SECTION.key]
34
28
  }],
35
- component: props => /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, props.children)
29
+ component: props => /*#__PURE__*/React.createElement(ColumnToggleSection, null, props.children)
36
30
  }, {
37
31
  type: HEADER_COLUMN_TOGGLE_ITEM.type,
38
32
  key: HEADER_COLUMN_TOGGLE_ITEM.key,
@@ -52,9 +46,7 @@ export const getColumnMenuComponents = () => [
52
46
  key: COLUMN_MENU.key,
53
47
  rank: COLUMN_SECTION_RANK[COLUMN_BACKGROUND_SECTION.key]
54
48
  }],
55
- component: props => /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
56
- hasSeparator: true
57
- }, props.children)
49
+ component: props => /*#__PURE__*/React.createElement(ColumnBackgroundSection, null, props.children)
58
50
  },
59
51
  // --- Sort section ---
60
52
  {
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
3
+ import { useTableMenuContext } from '../../shared/TableMenuContext';
4
+ import { shouldShowHeaderColumnToggle } from './HeaderColumnToggleItem';
5
+
6
+ /**
7
+ * Background section sits directly below `ColumnToggleSection`. Its separator
8
+ * exists only to divide it from the toggle section; when the toggle section
9
+ * is hidden, the separator must drop too so we don't render a stray rule at
10
+ * the very top of the menu.
11
+ */
12
+ export const ColumnBackgroundSection = ({
13
+ children
14
+ }) => {
15
+ const tableMenuContext = useTableMenuContext();
16
+ const hasSeparator = shouldShowHeaderColumnToggle(tableMenuContext);
17
+ return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
18
+ hasSeparator: hasSeparator
19
+ }, children);
20
+ };
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
3
+ import { useTableMenuContext } from '../../shared/TableMenuContext';
4
+ import { shouldShowHeaderColumnToggle } from './HeaderColumnToggleItem';
5
+
6
+ /**
7
+ * The toggle section currently contains only the Header column toggle. When
8
+ * that item is hidden, the whole section disappears so we don't render an
9
+ * empty wrapper (and so the section below can drop its leading separator).
10
+ */
11
+ export const ColumnToggleSection = ({
12
+ children
13
+ }) => {
14
+ const tableMenuContext = useTableMenuContext();
15
+ if (!shouldShowHeaderColumnToggle(tableMenuContext)) {
16
+ return null;
17
+ }
18
+ return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, children);
19
+ };
@@ -2,10 +2,21 @@ import React from 'react';
2
2
  import { useIntl } from 'react-intl';
3
3
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
4
4
  import { TableColumnsDistributeIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
5
+ import { useTableMenuContext } from '../../shared/TableMenuContext';
6
+
7
+ /** Distribute columns is only visible when more than one column is selected. */
8
+ const shouldShowDistributeColumns = tableMenuContext => {
9
+ var _tableMenuContext$sel;
10
+ return ((_tableMenuContext$sel = tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedColumnCount) !== null && _tableMenuContext$sel !== void 0 ? _tableMenuContext$sel : 0) > 1;
11
+ };
5
12
  export const DistributeColumnsItem = () => {
13
+ const tableMenuContext = useTableMenuContext();
6
14
  const {
7
15
  formatMessage
8
16
  } = useIntl();
17
+ if (!shouldShowDistributeColumns(tableMenuContext)) {
18
+ return null;
19
+ }
9
20
  return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
10
21
  elemBefore: /*#__PURE__*/React.createElement(TableColumnsDistributeIcon, {
11
22
  color: "currentColor",
@@ -3,11 +3,26 @@ import { useIntl } from 'react-intl';
3
3
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
4
4
  import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
5
5
  import Toggle from '@atlaskit/toggle';
6
+ import { useTableMenuContext } from '../../shared/TableMenuContext';
7
+
8
+ /**
9
+ * Header column toggle is only visible when the first column is the entire
10
+ * selection.
11
+ *
12
+ * Exported so `ColumnToggleSection` (which can become empty) and
13
+ * `ColumnBackgroundSection` (which drops its leading separator alongside)
14
+ * can stay in lockstep with this rule without redefining it.
15
+ */
16
+ export const shouldShowHeaderColumnToggle = tableMenuContext => (tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isFirstColumn) === true && tableMenuContext.selectedColumnCount === 1;
6
17
  export const HeaderColumnToggleItem = () => {
18
+ const tableMenuContext = useTableMenuContext();
7
19
  const {
8
20
  formatMessage
9
21
  } = useIntl();
10
22
  const label = formatMessage(messages.headerColumn);
23
+ if (!shouldShowHeaderColumnToggle(tableMenuContext)) {
24
+ return null;
25
+ }
11
26
  return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
12
27
  elemAfter: /*#__PURE__*/React.createElement(Toggle, {
13
28
  label: label,
@@ -1,12 +1,10 @@
1
1
  import React from 'react';
2
2
  import { useIntl } from 'react-intl';
3
- import { moveColumnRight, moveColumnRightOld, tooltip } from '@atlaskit/editor-common/keymaps';
3
+ import { moveColumnRight, tooltip } from '@atlaskit/editor-common/keymaps';
4
4
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
5
5
  import { TableColumnMoveRightIcon, ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
6
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
- const getMoveColumnRightShortcut = () => tooltip(expValEquals('editor-a11y-fy26-keyboard-move-row-column', 'isEnabled', true) ? moveColumnRight : moveColumnRightOld);
8
6
  export const MoveColumnRightItem = () => {
9
- var _getMoveColumnRightSh;
7
+ var _tooltip;
10
8
  const {
11
9
  formatMessage
12
10
  } = useIntl();
@@ -17,7 +15,7 @@ export const MoveColumnRightItem = () => {
17
15
  size: "small"
18
16
  }),
19
17
  elemAfter: /*#__PURE__*/React.createElement(ToolbarKeyboardShortcutHint, {
20
- shortcut: (_getMoveColumnRightSh = getMoveColumnRightShortcut()) !== null && _getMoveColumnRightSh !== void 0 ? _getMoveColumnRightSh : ''
18
+ shortcut: (_tooltip = tooltip(moveColumnRight)) !== null && _tooltip !== void 0 ? _tooltip : ''
21
19
  })
22
20
  }, formatMessage(messages.moveColumnRight, {
23
21
  0: 1
@@ -2,12 +2,14 @@ import React from 'react';
2
2
  import { useIntl } from 'react-intl';
3
3
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
4
4
  import { ArrowDownIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
5
+ import { useTableMenuContext } from '../../shared/TableMenuContext';
5
6
  export const SortDecreasingItem = () => {
7
+ const tableMenuContext = useTableMenuContext();
6
8
  const {
7
9
  formatMessage
8
10
  } = useIntl();
9
11
  return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
10
- isDisabled: true,
12
+ isDisabled: Boolean(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.hasMergedCellsInTable),
11
13
  elemBefore: /*#__PURE__*/React.createElement(ArrowDownIcon, {
12
14
  color: "currentColor",
13
15
  label: "",
@@ -2,12 +2,14 @@ import React from 'react';
2
2
  import { useIntl } from 'react-intl';
3
3
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
4
4
  import { ArrowUpIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
5
+ import { useTableMenuContext } from '../../shared/TableMenuContext';
5
6
  export const SortIncreasingItem = () => {
7
+ const tableMenuContext = useTableMenuContext();
6
8
  const {
7
9
  formatMessage
8
10
  } = useIntl();
9
11
  return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
10
- isDisabled: true,
12
+ isDisabled: Boolean(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.hasMergedCellsInTable),
11
13
  elemBefore: /*#__PURE__*/React.createElement(ArrowUpIcon, {
12
14
  color: "currentColor",
13
15
  label: "",
@@ -8,14 +8,6 @@ import { MoveRowDownItem } from './items/MoveRowDownItem';
8
8
  import { MoveRowUpItem } from './items/MoveRowUpItem';
9
9
  import { NumberedRowsToggleItem } from './items/NumberedRowsToggleItem';
10
10
  import { ROW_MENU, ROW_TOGGLE_SECTION, ROW_BACKGROUND_SECTION, ROW_ADD_SECTION, ROW_DANGER_SECTION, ROW_MENU_SECTION_RANK, HEADER_ROW_TOGGLE_ITEM, NUMBERED_ROWS_TOGGLE_ITEM, ADD_ROW_ABOVE_ITEM, ADD_ROW_BELOW_ITEM, MOVE_ROW_UP_ITEM, MOVE_ROW_DOWN_ITEM, DELETE_ROW_ITEM, ROW_TOGGLE_SECTION_RANK, ROW_ADD_SECTION_RANK, ROW_DANGER_SECTION_RANK } from './keys';
11
-
12
- /**
13
- * Returns the RegisterComponent[] array defining the row menu surface.
14
- *
15
- * This is a **UI-only stub** — all items are always visible with no conditional
16
- * logic and no wired actions. Functional behaviour (actions, conditional visibility)
17
- * will be connected in follow-up tickets.
18
- */
19
11
  export const getRowMenuComponents = () => [
20
12
  // --- Menu surface ---
21
13
  {
@@ -3,11 +3,19 @@ import { useIntl } from 'react-intl';
3
3
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
4
4
  import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
5
5
  import Toggle from '@atlaskit/toggle';
6
+ import { useTableMenuContext } from '../../shared/TableMenuContext';
7
+
8
+ /** Header row toggle is only visible when the first row is the entire selection. */
9
+ const shouldShowHeaderRowToggle = tableMenuContext => (tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isFirstRow) === true && tableMenuContext.selectedRowCount === 1;
6
10
  export const HeaderRowToggleItem = () => {
11
+ const tableMenuContext = useTableMenuContext();
7
12
  const {
8
13
  formatMessage
9
14
  } = useIntl();
10
15
  const label = formatMessage(messages.headerRow);
16
+ if (!shouldShowHeaderRowToggle(tableMenuContext)) {
17
+ return null;
18
+ }
11
19
  return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
12
20
  elemAfter: /*#__PURE__*/React.createElement(Toggle, {
13
21
  label: label,
@@ -4,12 +4,20 @@ import { moveRowDown, moveRowDownOld, tooltip } from '@atlaskit/editor-common/ke
4
4
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
5
5
  import { TableRowMoveDownIcon, ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
6
6
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
+ import { useTableMenuContext } from '../../shared/TableMenuContext';
7
8
  const getMoveRowDownShortcut = () => tooltip(expValEquals('editor-a11y-fy26-keyboard-move-row-column', 'isEnabled', true) ? moveRowDown : moveRowDownOld);
9
+
10
+ /** Move row down is hidden when the selection includes the last row (cannot move further down). */
11
+ const shouldShowMoveRowDown = tableMenuContext => !(tableMenuContext !== null && tableMenuContext !== void 0 && tableMenuContext.isLastRow);
8
12
  export const MoveRowDownItem = () => {
9
13
  var _getMoveRowDownShortc;
14
+ const tableMenuContext = useTableMenuContext();
10
15
  const {
11
16
  formatMessage
12
17
  } = useIntl();
18
+ if (!shouldShowMoveRowDown(tableMenuContext)) {
19
+ return null;
20
+ }
13
21
  return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
14
22
  elemBefore: /*#__PURE__*/React.createElement(TableRowMoveDownIcon, {
15
23
  color: "currentColor",
@@ -4,12 +4,20 @@ import { moveRowUp, moveRowUpOld, tooltip } from '@atlaskit/editor-common/keymap
4
4
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
5
5
  import { TableRowMoveUpIcon, ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
6
6
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
+ import { useTableMenuContext } from '../../shared/TableMenuContext';
7
8
  const getMoveRowUpShortcut = () => tooltip(expValEquals('editor-a11y-fy26-keyboard-move-row-column', 'isEnabled', true) ? moveRowUp : moveRowUpOld);
9
+
10
+ /** Move row up is hidden when the selection includes row 0 (cannot move further up). */
11
+ const shouldShowMoveRowUp = tableMenuContext => !(tableMenuContext !== null && tableMenuContext !== void 0 && tableMenuContext.isFirstRow);
8
12
  export const MoveRowUpItem = () => {
9
13
  var _getMoveRowUpShortcut;
14
+ const tableMenuContext = useTableMenuContext();
10
15
  const {
11
16
  formatMessage
12
17
  } = useIntl();
18
+ if (!shouldShowMoveRowUp(tableMenuContext)) {
19
+ return null;
20
+ }
13
21
  return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
14
22
  elemBefore: /*#__PURE__*/React.createElement(TableRowMoveUpIcon, {
15
23
  color: "currentColor",
@@ -2,27 +2,75 @@
2
2
  import "./TableMenu.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React, { memo, useMemo } from 'react';
5
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
6
+ import { EditorToolbarProvider } from '@atlaskit/editor-common/toolbar';
7
+ import { TableMap } from '@atlaskit/editor-tables/table-map';
8
+ import { getSelectionRect } from '@atlaskit/editor-tables/utils';
5
9
  import { SurfaceRenderer } from '@atlaskit/editor-ui-control-model';
6
10
  import { Box } from '@atlaskit/primitives/compiled';
11
+ import { canSplitCellSelection } from '../../../pm-plugins/commands/split-cell';
12
+ import { canMergeCellSelection } from '../../../pm-plugins/transforms/merge';
13
+ import { TableMenuProvider } from './TableMenuContext';
7
14
  const tableMenuContainerStyles = {
8
15
  container: "_2rko1qi0 _1reo15vq _18m915vq _1bsb1178 _16qs130s _bfhk1bhr"
9
16
  };
17
+ const EMPTY_CONTEXT = {};
10
18
  export const TableMenu = /*#__PURE__*/memo(({
11
19
  api,
20
+ editorView,
12
21
  surface
13
22
  }) => {
14
23
  const components = useMemo(() => {
15
24
  var _api$uiControlRegistr, _api$uiControlRegistr2;
16
25
  return (_api$uiControlRegistr = api === null || api === void 0 ? void 0 : (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(surface.key)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [];
17
26
  }, [api, surface.key]);
27
+ const {
28
+ tableNode,
29
+ selection
30
+ } = useSharedPluginStateWithSelector(api !== null && api !== void 0 ? api : undefined, ['table', 'selection'], states => {
31
+ var _states$tableState, _states$selectionStat;
32
+ return {
33
+ tableNode: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : _states$tableState.tableNode,
34
+ selection: (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection
35
+ };
36
+ });
37
+ const tableMenuContext = useMemo(() => {
38
+ if (!selection || !tableNode) {
39
+ return EMPTY_CONTEXT;
40
+ }
41
+ const tableMap = TableMap.get(tableNode);
42
+ const selectionRect = getSelectionRect(selection);
43
+ const cellOps = {
44
+ canMergeCells: canMergeCellSelection(selection),
45
+ canSplitCell: canSplitCellSelection(selection),
46
+ hasMergedCellsInTable: tableMap.hasMergedCells()
47
+ };
48
+ if (!selectionRect) {
49
+ return cellOps;
50
+ }
51
+ return {
52
+ ...cellOps,
53
+ isFirstRow: selectionRect.top === 0,
54
+ isLastRow: selectionRect.bottom === tableMap.height,
55
+ selectedRowCount: selectionRect.bottom - selectionRect.top,
56
+ isFirstColumn: selectionRect.left === 0,
57
+ isLastColumn: selectionRect.right === tableMap.width,
58
+ selectedColumnCount: selectionRect.right - selectionRect.left
59
+ };
60
+ }, [selection, tableNode]);
18
61
  if (components.length === 0) {
19
62
  return null;
20
63
  }
21
- return /*#__PURE__*/React.createElement(Box, {
64
+ return /*#__PURE__*/React.createElement(EditorToolbarProvider, {
65
+ editorView: editorView !== null && editorView !== void 0 ? editorView : null
66
+ }, /*#__PURE__*/React.createElement(TableMenuProvider, {
67
+ value: tableMenuContext
68
+ }, /*#__PURE__*/React.createElement(Box, {
22
69
  xcss: tableMenuContainerStyles.container,
23
70
  testId: surface.key
24
71
  }, /*#__PURE__*/React.createElement(SurfaceRenderer, {
25
72
  surface: surface,
26
73
  components: components
27
- }));
28
- });
74
+ }))));
75
+ });
76
+ TableMenu.displayName = 'TableMenu';
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ const TableMenuContext = /*#__PURE__*/React.createContext(undefined);
3
+ export const TableMenuProvider = TableMenuContext.Provider;
4
+ export const useTableMenuContext = () => React.useContext(TableMenuContext);
@@ -1 +1,2 @@
1
- export const TABLE_MENU_WIDTH = 280;
1
+ export const TABLE_MENU_WIDTH = 280;
2
+ export const TABLE_MENU_SELECTOR = '[data-testid="column-handle-menu"], [data-testid="row-handle-menu"], [data-toolbar-nested-dropdown-menu]';
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { CELL_ACTION_SECTION, CELL_DANGER_SECTION, CELL_ACTION_SECTION_RANK, CELL_DANGER_SECTION_RANK } from '../cell/keys';
2
3
  import { COLUMN_BACKGROUND_SECTION, COLUMN_DANGER_SECTION, COLUMN_BACKGROUND_SECTION_RANK, COLUMN_DANGER_SECTION_RANK } from '../column/keys';
3
4
  import { ROW_BACKGROUND_SECTION, ROW_DANGER_SECTION, ROW_BACKGROUND_SECTION_RANK, ROW_DANGER_SECTION_RANK } from '../row/keys';
4
5
  import { BackgroundColorItem } from './items/BackgroundColorItem';
@@ -15,6 +16,10 @@ export const getSharedItems = () => [{
15
16
  type: COLUMN_BACKGROUND_SECTION.type,
16
17
  key: COLUMN_BACKGROUND_SECTION.key,
17
18
  rank: COLUMN_BACKGROUND_SECTION_RANK[BACKGROUND_COLOR_ITEM.key]
19
+ }, {
20
+ type: CELL_ACTION_SECTION.type,
21
+ key: CELL_ACTION_SECTION.key,
22
+ rank: CELL_ACTION_SECTION_RANK[BACKGROUND_COLOR_ITEM.key]
18
23
  }],
19
24
  component: () => /*#__PURE__*/React.createElement(BackgroundColorItem, null)
20
25
  }, {
@@ -28,6 +33,10 @@ export const getSharedItems = () => [{
28
33
  type: COLUMN_DANGER_SECTION.type,
29
34
  key: COLUMN_DANGER_SECTION.key,
30
35
  rank: COLUMN_DANGER_SECTION_RANK[CLEAR_CELLS_ITEM.key]
36
+ }, {
37
+ type: CELL_DANGER_SECTION.type,
38
+ key: CELL_DANGER_SECTION.key,
39
+ rank: CELL_DANGER_SECTION_RANK[CLEAR_CELLS_ITEM.key]
31
40
  }],
32
41
  component: () => /*#__PURE__*/React.createElement(ClearCellsItem, null)
33
42
  }];
@@ -1,4 +1,5 @@
1
+ import { getCellMenuComponents } from '../cell/getCellMenuComponents';
1
2
  import { getColumnMenuComponents } from '../column/getColumnMenuComponents';
2
3
  import { getRowMenuComponents } from '../row/getRowMenuComponents';
3
4
  import { getSharedItems } from './getSharedItems';
4
- export const getTableMenuComponents = () => [...getRowMenuComponents(), ...getColumnMenuComponents(), ...getSharedItems()];
5
+ export const getTableMenuComponents = () => [...getRowMenuComponents(), ...getColumnMenuComponents(), ...getCellMenuComponents(), ...getSharedItems()];
@@ -8,6 +8,7 @@ import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/u
8
8
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
9
9
  import { TableMap } from '@atlaskit/editor-tables/table-map';
10
10
  import { cellAround, findCellRectClosestToPos, findTable, getSelectionRect, removeTable } from '@atlaskit/editor-tables/utils';
11
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
11
12
  import { addResizeHandleDecorations, clearHoverSelection, hideInsertColumnOrRowButton, hideResizeHandleLine, hoverCell, hoverColumns, selectColumn, setEditorFocus, setTableHovered, showInsertColumnButton, showInsertRowButton, showResizeHandleLine } from '../pm-plugins/commands';
12
13
  import { getPluginState as getDragDropPluginState } from '../pm-plugins/drag-and-drop/plugin-factory';
13
14
  import { getPluginState } from '../pm-plugins/plugin-factory';
@@ -19,11 +20,13 @@ import { convertHTMLCellIndexToColumnIndex, getColumnIndexMappedToColumnIndexInF
19
20
  import { getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, hasResizeHandler, isCell, isColumnControlsDecorations, isCornerButton, isDragColumnFloatingInsertDot, isDragCornerButton, isDragRowFloatingInsertDot, isInsertRowButton, isResizeHandleDecoration, isRowControlsButton, isTableContainerOrWrapper, isTableControlsButton } from '../pm-plugins/utils/dom';
20
21
  import { getAllowAddColumnCustomStep } from '../pm-plugins/utils/get-allow-add-column-custom-step';
21
22
  import { TableCssClassName as ClassName, RESIZE_HANDLE_AREA_DECORATION_GAP } from '../types';
23
+ import { TABLE_MENU_SELECTOR } from './TableMenu/shared/consts';
22
24
  const isFocusingCalendar = event => event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.getAttribute('aria-label') === 'calendar';
23
25
  const isFocusingModal = event => event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('[role="dialog"]');
24
26
  const isFocusingFloatingToolbar = event => event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('[role="toolbar"]');
25
27
  const isFocusingDragHandles = event => event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('button') && event.relatedTarget.getAttribute('draggable') === 'true';
26
28
  const isFocusingDragHandlesClickableZone = event => event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('button') && event.relatedTarget.classList.contains(ClassName.DRAG_HANDLE_BUTTON_CLICKABLE_ZONE);
29
+ const isFocusingTableMenu = event => expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) && event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && Boolean(event.relatedTarget.closest(TABLE_MENU_SELECTOR));
27
30
  export const handleBlur = (view, event) => {
28
31
  const {
29
32
  state,
@@ -31,7 +34,7 @@ export const handleBlur = (view, event) => {
31
34
  } = view;
32
35
  // IE version check for ED-4665
33
36
  // Calendar focus check for ED-10466
34
- if (getBrowserInfo().ie_version !== 11 && !isFocusingCalendar(event) && !isFocusingModal(event) && !isFocusingFloatingToolbar(event) && !isFocusingDragHandles(event) && !isFocusingDragHandlesClickableZone(event)) {
37
+ if (getBrowserInfo().ie_version !== 11 && !isFocusingCalendar(event) && !isFocusingModal(event) && !isFocusingFloatingToolbar(event) && !isFocusingDragHandles(event) && !isFocusingDragHandlesClickableZone(event) && !isFocusingTableMenu(event)) {
35
38
  setEditorFocus(false)(state, dispatch);
36
39
  }
37
40
  event.preventDefault();
@@ -1,5 +1,21 @@
1
- import { splitCellWithType } from '@atlaskit/editor-tables/utils';
1
+ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
2
+ import { cellWrapping, splitCellWithType } from '@atlaskit/editor-tables/utils';
2
3
  import { getPluginState } from '../plugin-factory';
4
+ export var canSplitCellSelection = function canSplitCellSelection(selection) {
5
+ var cellNode;
6
+ if (!(selection instanceof CellSelection)) {
7
+ cellNode = cellWrapping(selection.$from);
8
+ if (!cellNode) {
9
+ return false;
10
+ }
11
+ } else {
12
+ if (selection.$anchorCell.pos !== selection.$headCell.pos) {
13
+ return false;
14
+ }
15
+ cellNode = selection.$anchorCell.nodeAfter;
16
+ }
17
+ return Boolean(cellNode && (cellNode.attrs.colspan !== 1 || cellNode.attrs.rowspan !== 1));
18
+ };
3
19
 
4
20
  /**
5
21
  * We need to split cell keeping the right type of cell given current table configuration.
@@ -113,8 +113,7 @@ export function mergeCells(tr) {
113
113
  }
114
114
  return tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable).setSelection(Selection.near(tr.doc.resolve((mergedCellPos || 0) + table.start)));
115
115
  }
116
- export function canMergeCells(tr) {
117
- var selection = tr.selection;
116
+ export function canMergeCellSelection(selection) {
118
117
  if (!(selection instanceof CellSelection) || selection.$anchorCell.pos === selection.$headCell.pos) {
119
118
  return false;
120
119
  }
@@ -129,6 +128,9 @@ export function canMergeCells(tr) {
129
128
  }
130
129
  return true;
131
130
  }
131
+ export function canMergeCells(tr) {
132
+ return canMergeCellSelection(tr.selection);
133
+ }
132
134
  function isEmptyCell(cell) {
133
135
  var content = cell.content;
134
136
  return content.childCount === 1 && content.firstChild && content.firstChild.isTextblock && content.firstChild.childCount === 0;
@@ -46,6 +46,11 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
46
46
  var handleClick = function handleClick() {
47
47
  var state = editorView.state,
48
48
  dispatch = editorView.dispatch;
49
+ if (expValEquals('platform_editor_table_menu_updates', 'isEnabled', true)) {
50
+ toggleContextualMenu()(state, dispatch);
51
+ return;
52
+ }
53
+
49
54
  // Clicking outside the dropdown handles toggling the menu closed
50
55
  // (otherwise these two toggles combat each other).
51
56
  // In the event a user clicks the chevron button again
@@ -0,0 +1,96 @@
1
+ import React, { useCallback, useEffect, useRef } from 'react';
2
+ import { bind } from 'bind-event-listener';
3
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
+ import { UserIntentPopupWrapper } from '@atlaskit/editor-common/user-intent';
5
+ import { setFocusToCellMenu, toggleContextualMenu } from '../../pm-plugins/commands';
6
+ import { TableCssClassName as ClassName } from '../../types';
7
+ import { CELL_MENU } from '../TableMenu/cell/keys';
8
+ import { TableMenu } from '../TableMenu/shared/TableMenu';
9
+ export var CellMenuPopup = function CellMenuPopup(_ref) {
10
+ var api = _ref.api,
11
+ editorView = _ref.editorView,
12
+ isCellMenuOpenByKeyboard = _ref.isCellMenuOpenByKeyboard,
13
+ isOpen = _ref.isOpen,
14
+ targetCellRef = _ref.targetCellRef;
15
+ var tableMenuRef = useRef(null);
16
+ var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['userIntent'], function (states) {
17
+ var _states$userIntentSta;
18
+ return {
19
+ currentUserIntent: (_states$userIntentSta = states.userIntentState) === null || _states$userIntentSta === void 0 ? void 0 : _states$userIntentSta.currentUserIntent
20
+ };
21
+ }),
22
+ currentUserIntent = _useSharedPluginState.currentUserIntent;
23
+ var closeCellMenu = useCallback(function () {
24
+ var state = editorView.state,
25
+ dispatch = editorView.dispatch,
26
+ dom = editorView.dom;
27
+ toggleContextualMenu()(state, dispatch);
28
+ if (isCellMenuOpenByKeyboard) {
29
+ setFocusToCellMenu(false)(state, dispatch);
30
+ dom.focus();
31
+ }
32
+ }, [editorView, isCellMenuOpenByKeyboard]);
33
+ useEffect(function () {
34
+ if (!isOpen || currentUserIntent !== 'tableDragMenuPopupOpen') {
35
+ return;
36
+ }
37
+ closeCellMenu();
38
+ }, [closeCellMenu, currentUserIntent, isOpen]);
39
+ useEffect(function () {
40
+ if (!isOpen) {
41
+ return;
42
+ }
43
+ if (!(targetCellRef instanceof HTMLElement)) {
44
+ return;
45
+ }
46
+ var ownerDocument = targetCellRef.ownerDocument;
47
+ var handlePointerDown = function handlePointerDown(event) {
48
+ var _tableMenuRef$current;
49
+ var target = event.target;
50
+ if (!(target instanceof Node)) {
51
+ return;
52
+ }
53
+ if ((_tableMenuRef$current = tableMenuRef.current) !== null && _tableMenuRef$current !== void 0 && _tableMenuRef$current.contains(target)) {
54
+ return;
55
+ }
56
+ var cellMenuButton = ownerDocument.querySelector(".".concat(ClassName.CONTEXTUAL_MENU_BUTTON));
57
+ if (cellMenuButton !== null && cellMenuButton !== void 0 && cellMenuButton.contains(target)) {
58
+ return;
59
+ }
60
+ closeCellMenu();
61
+ };
62
+ var handleKeyDown = function handleKeyDown(event) {
63
+ if (event.key === 'Escape') {
64
+ closeCellMenu();
65
+ }
66
+ };
67
+ var unbindPointerDown = bind(ownerDocument, {
68
+ type: 'pointerdown',
69
+ listener: handlePointerDown,
70
+ options: {
71
+ capture: true
72
+ }
73
+ });
74
+ var unbindKeyDown = bind(ownerDocument, {
75
+ type: 'keydown',
76
+ listener: handleKeyDown,
77
+ options: {
78
+ capture: true
79
+ }
80
+ });
81
+ return function () {
82
+ unbindPointerDown();
83
+ unbindKeyDown();
84
+ };
85
+ }, [closeCellMenu, isOpen, targetCellRef]);
86
+ return /*#__PURE__*/React.createElement(UserIntentPopupWrapper, {
87
+ api: api,
88
+ userIntent: "tableContextualMenuPopupOpen"
89
+ }, /*#__PURE__*/React.createElement("div", {
90
+ ref: tableMenuRef
91
+ }, /*#__PURE__*/React.createElement(TableMenu, {
92
+ api: api,
93
+ editorView: editorView,
94
+ surface: CELL_MENU
95
+ })));
96
+ };