@atlaskit/editor-plugin-table 23.3.3 → 23.3.5

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 (111) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/cjs/pm-plugins/commands/active-table-menu.js +19 -8
  3. package/dist/cjs/pm-plugins/commands/commands-with-analytics.js +9 -49
  4. package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +1 -1
  5. package/dist/cjs/pm-plugins/handlers.js +1 -1
  6. package/dist/cjs/pm-plugins/main.js +4 -1
  7. package/dist/cjs/ui/ContentComponent.js +11 -1
  8. package/dist/cjs/ui/FloatingContextualButton/index.js +2 -2
  9. package/dist/cjs/ui/FloatingContextualMenu/CellMenuPopup.js +2 -2
  10. package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +6 -2
  11. package/dist/cjs/ui/FloatingDragMenu/index.js +10 -38
  12. package/dist/cjs/ui/FloatingTableMenu/index.js +175 -0
  13. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +43 -11
  14. package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +57 -26
  15. package/dist/cjs/ui/TableMenu/cell/items/MergeCellsItem.js +1 -1
  16. package/dist/cjs/ui/TableMenu/cell/items/SplitCellItem.js +1 -1
  17. package/dist/cjs/ui/TableMenu/cell/items/VerticalAlignDropdownItem.js +1 -1
  18. package/dist/cjs/ui/TableMenu/column/items/AddColumnLeftItem.js +1 -1
  19. package/dist/cjs/ui/TableMenu/column/items/AddColumnRightItem.js +1 -1
  20. package/dist/cjs/ui/TableMenu/column/items/DeleteColumnItem.js +1 -1
  21. package/dist/cjs/ui/TableMenu/column/items/DistributeColumnsItem.js +1 -1
  22. package/dist/cjs/ui/TableMenu/column/items/MoveColumnLeftItem.js +1 -1
  23. package/dist/cjs/ui/TableMenu/column/items/MoveColumnRightItem.js +1 -1
  24. package/dist/cjs/ui/TableMenu/column/items/SortDecreasingItem.js +1 -1
  25. package/dist/cjs/ui/TableMenu/column/items/SortIncreasingItem.js +1 -1
  26. package/dist/cjs/ui/TableMenu/row/items/AddRowAboveItem.js +1 -1
  27. package/dist/cjs/ui/TableMenu/row/items/AddRowBelowItem.js +1 -1
  28. package/dist/cjs/ui/TableMenu/row/items/DeleteRowItem.js +1 -1
  29. package/dist/cjs/ui/TableMenu/row/items/MoveRowDownItem.js +1 -1
  30. package/dist/cjs/ui/TableMenu/row/items/MoveRowUpItem.js +1 -1
  31. package/dist/cjs/ui/TableMenu/shared/TableMenu.js +8 -8
  32. package/dist/cjs/ui/TableMenu/shared/consts.js +1 -1
  33. package/dist/cjs/ui/TableMenu/shared/items/BackgroundColorItem.js +1 -1
  34. package/dist/cjs/ui/TableMenu/shared/items/ClearCellsItem.js +1 -1
  35. package/dist/es2019/pm-plugins/commands/active-table-menu.js +19 -8
  36. package/dist/es2019/pm-plugins/commands/commands-with-analytics.js +0 -39
  37. package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +1 -1
  38. package/dist/es2019/pm-plugins/handlers.js +1 -1
  39. package/dist/es2019/pm-plugins/main.js +3 -0
  40. package/dist/es2019/ui/ContentComponent.js +11 -1
  41. package/dist/es2019/ui/FloatingContextualButton/index.js +2 -2
  42. package/dist/es2019/ui/FloatingContextualMenu/CellMenuPopup.js +2 -2
  43. package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +6 -2
  44. package/dist/es2019/ui/FloatingDragMenu/index.js +11 -40
  45. package/dist/es2019/ui/FloatingTableMenu/index.js +165 -0
  46. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +41 -7
  47. package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +40 -7
  48. package/dist/es2019/ui/TableMenu/cell/items/MergeCellsItem.js +1 -1
  49. package/dist/es2019/ui/TableMenu/cell/items/SplitCellItem.js +1 -1
  50. package/dist/es2019/ui/TableMenu/cell/items/VerticalAlignDropdownItem.js +1 -1
  51. package/dist/es2019/ui/TableMenu/column/items/AddColumnLeftItem.js +1 -1
  52. package/dist/es2019/ui/TableMenu/column/items/AddColumnRightItem.js +1 -1
  53. package/dist/es2019/ui/TableMenu/column/items/DeleteColumnItem.js +1 -1
  54. package/dist/es2019/ui/TableMenu/column/items/DistributeColumnsItem.js +1 -1
  55. package/dist/es2019/ui/TableMenu/column/items/MoveColumnLeftItem.js +1 -1
  56. package/dist/es2019/ui/TableMenu/column/items/MoveColumnRightItem.js +1 -1
  57. package/dist/es2019/ui/TableMenu/column/items/SortDecreasingItem.js +1 -1
  58. package/dist/es2019/ui/TableMenu/column/items/SortIncreasingItem.js +1 -1
  59. package/dist/es2019/ui/TableMenu/row/items/AddRowAboveItem.js +1 -1
  60. package/dist/es2019/ui/TableMenu/row/items/AddRowBelowItem.js +1 -1
  61. package/dist/es2019/ui/TableMenu/row/items/DeleteRowItem.js +1 -1
  62. package/dist/es2019/ui/TableMenu/row/items/MoveRowDownItem.js +1 -1
  63. package/dist/es2019/ui/TableMenu/row/items/MoveRowUpItem.js +1 -1
  64. package/dist/es2019/ui/TableMenu/shared/TableMenu.js +8 -8
  65. package/dist/es2019/ui/TableMenu/shared/consts.js +1 -1
  66. package/dist/es2019/ui/TableMenu/shared/items/BackgroundColorItem.js +1 -1
  67. package/dist/es2019/ui/TableMenu/shared/items/ClearCellsItem.js +1 -1
  68. package/dist/esm/pm-plugins/commands/active-table-menu.js +19 -8
  69. package/dist/esm/pm-plugins/commands/commands-with-analytics.js +8 -48
  70. package/dist/esm/pm-plugins/drag-and-drop/plugin.js +1 -1
  71. package/dist/esm/pm-plugins/handlers.js +1 -1
  72. package/dist/esm/pm-plugins/main.js +4 -1
  73. package/dist/esm/ui/ContentComponent.js +11 -1
  74. package/dist/esm/ui/FloatingContextualButton/index.js +2 -2
  75. package/dist/esm/ui/FloatingContextualMenu/CellMenuPopup.js +2 -2
  76. package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +8 -2
  77. package/dist/esm/ui/FloatingDragMenu/index.js +11 -39
  78. package/dist/esm/ui/FloatingTableMenu/index.js +167 -0
  79. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +42 -10
  80. package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +56 -25
  81. package/dist/esm/ui/TableMenu/cell/items/MergeCellsItem.js +1 -1
  82. package/dist/esm/ui/TableMenu/cell/items/SplitCellItem.js +1 -1
  83. package/dist/esm/ui/TableMenu/cell/items/VerticalAlignDropdownItem.js +1 -1
  84. package/dist/esm/ui/TableMenu/column/items/AddColumnLeftItem.js +1 -1
  85. package/dist/esm/ui/TableMenu/column/items/AddColumnRightItem.js +1 -1
  86. package/dist/esm/ui/TableMenu/column/items/DeleteColumnItem.js +1 -1
  87. package/dist/esm/ui/TableMenu/column/items/DistributeColumnsItem.js +1 -1
  88. package/dist/esm/ui/TableMenu/column/items/MoveColumnLeftItem.js +1 -1
  89. package/dist/esm/ui/TableMenu/column/items/MoveColumnRightItem.js +1 -1
  90. package/dist/esm/ui/TableMenu/column/items/SortDecreasingItem.js +1 -1
  91. package/dist/esm/ui/TableMenu/column/items/SortIncreasingItem.js +1 -1
  92. package/dist/esm/ui/TableMenu/row/items/AddRowAboveItem.js +1 -1
  93. package/dist/esm/ui/TableMenu/row/items/AddRowBelowItem.js +1 -1
  94. package/dist/esm/ui/TableMenu/row/items/DeleteRowItem.js +1 -1
  95. package/dist/esm/ui/TableMenu/row/items/MoveRowDownItem.js +1 -1
  96. package/dist/esm/ui/TableMenu/row/items/MoveRowUpItem.js +1 -1
  97. package/dist/esm/ui/TableMenu/shared/TableMenu.js +8 -8
  98. package/dist/esm/ui/TableMenu/shared/consts.js +1 -1
  99. package/dist/esm/ui/TableMenu/shared/items/BackgroundColorItem.js +1 -1
  100. package/dist/esm/ui/TableMenu/shared/items/ClearCellsItem.js +1 -1
  101. package/dist/types/pm-plugins/commands/active-table-menu.d.ts +3 -3
  102. package/dist/types/pm-plugins/commands/commands-with-analytics.d.ts +1 -3
  103. package/dist/types/ui/FloatingContextualMenu/ContextualMenu.d.ts +0 -4
  104. package/dist/types/ui/FloatingTableMenu/index.d.ts +23 -0
  105. package/dist/types/ui/TableMenu/shared/consts.d.ts +1 -1
  106. package/dist/types-ts4.5/pm-plugins/commands/active-table-menu.d.ts +3 -3
  107. package/dist/types-ts4.5/pm-plugins/commands/commands-with-analytics.d.ts +1 -3
  108. package/dist/types-ts4.5/ui/FloatingContextualMenu/ContextualMenu.d.ts +0 -4
  109. package/dist/types-ts4.5/ui/FloatingTableMenu/index.d.ts +23 -0
  110. package/dist/types-ts4.5/ui/TableMenu/shared/consts.d.ts +1 -1
  111. package/package.json +3 -3
@@ -29,7 +29,7 @@ export const SortIncreasingItem = ({
29
29
  return;
30
30
  }
31
31
  sortColumnWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(INPUT_METHOD.TABLE_CONTEXT_MENU, columnIndex, SortOrder.ASC)(editorView.state, editorView.dispatch);
32
- api === null || api === void 0 ? void 0 : api.core.actions.execute(closeActiveTableMenu());
32
+ api === null || api === void 0 ? void 0 : api.core.actions.execute(closeActiveTableMenu(api));
33
33
  api === null || api === void 0 ? void 0 : api.core.actions.focus();
34
34
  };
35
35
  return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
@@ -33,7 +33,7 @@ export const AddRowAboveItem = props => {
33
33
  index,
34
34
  moveCursorToInsertedRow: true
35
35
  })(editorView.state, editorView.dispatch);
36
- api === null || api === void 0 ? void 0 : api.core.actions.execute(closeActiveTableMenu());
36
+ api === null || api === void 0 ? void 0 : api.core.actions.execute(closeActiveTableMenu(api));
37
37
  api === null || api === void 0 ? void 0 : api.core.actions.focus();
38
38
  };
39
39
  return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
@@ -33,7 +33,7 @@ export const AddRowBelowItem = props => {
33
33
  index,
34
34
  moveCursorToInsertedRow: true
35
35
  })(editorView.state, editorView.dispatch);
36
- api === null || api === void 0 ? void 0 : api.core.actions.execute(closeActiveTableMenu());
36
+ api === null || api === void 0 ? void 0 : api.core.actions.execute(closeActiveTableMenu(api));
37
37
  api === null || api === void 0 ? void 0 : api.core.actions.focus();
38
38
  };
39
39
  return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
@@ -57,7 +57,7 @@ export const DeleteRowItem = props => {
57
57
  return;
58
58
  }
59
59
  deleteRowsWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(INPUT_METHOD.TABLE_CONTEXT_MENU, selectionRect, !!isHeaderRowRequired)(editorView.state, editorView.dispatch);
60
- api === null || api === void 0 ? void 0 : api.core.actions.execute(closeActiveTableMenu());
60
+ api === null || api === void 0 ? void 0 : api.core.actions.execute(closeActiveTableMenu(api));
61
61
  api === null || api === void 0 ? void 0 : api.core.actions.focus();
62
62
  };
63
63
  return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
@@ -44,7 +44,7 @@ export const MoveRowDownItem = props => {
44
44
  return;
45
45
  }
46
46
  moveSourceWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, api === null || api === void 0 ? void 0 : (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 ? void 0 : _api$accessibilityUti.actions.ariaNotify, getPluginState(editorView.state).getIntl)(INPUT_METHOD.TABLE_CONTEXT_MENU, TABLE_ROW, getSelectedRowIndexes(selectionRect), selectionRect.bottom)(editorView.state, editorView.dispatch);
47
- api === null || api === void 0 ? void 0 : api.core.actions.execute(closeActiveTableMenu());
47
+ api === null || api === void 0 ? void 0 : api.core.actions.execute(closeActiveTableMenu(api));
48
48
  api === null || api === void 0 ? void 0 : api.core.actions.focus();
49
49
  };
50
50
  if (!tableNode || !shouldShowMoveRowDown(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isLastRow)) {
@@ -44,7 +44,7 @@ export const MoveRowUpItem = props => {
44
44
  return;
45
45
  }
46
46
  moveSourceWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, api === null || api === void 0 ? void 0 : (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 ? void 0 : _api$accessibilityUti.actions.ariaNotify, getPluginState(editorView.state).getIntl)(INPUT_METHOD.TABLE_CONTEXT_MENU, TABLE_ROW, getSelectedRowIndexes(selectionRect), selectionRect.top - 1)(editorView.state, editorView.dispatch);
47
- api === null || api === void 0 ? void 0 : api.core.actions.execute(closeActiveTableMenu());
47
+ api === null || api === void 0 ? void 0 : api.core.actions.execute(closeActiveTableMenu(api));
48
48
  api === null || api === void 0 ? void 0 : api.core.actions.focus();
49
49
  };
50
50
  if (!tableNode || !shouldShowMoveRowUp(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isFirstRow)) {
@@ -27,17 +27,17 @@ export const TableMenu = /*#__PURE__*/memo(({
27
27
  };
28
28
  });
29
29
  const tableMenuContext = useMemo(() => {
30
- if (!selection || !tableNode) {
31
- return {
32
- editorView
33
- };
30
+ // rely on selection plugins state to re-render the row/column menu, but use editorView.selection
31
+ // for cell menu state as the selection plugin won't update when text selection changes within cells
32
+ if (!tableNode || !editorView || !selection) {
33
+ return undefined;
34
34
  }
35
35
  const tableMap = TableMap.get(tableNode);
36
- const selectionRect = getSelectionRect(selection);
36
+ const selectionRect = getSelectionRect(editorView.state.selection);
37
37
  const cellOps = {
38
38
  editorView,
39
- canMergeCells: canMergeCellSelection(selection),
40
- canSplitCell: canSplitCellSelection(selection),
39
+ canMergeCells: canMergeCellSelection(editorView.state.selection),
40
+ canSplitCell: canSplitCellSelection(editorView.state.selection),
41
41
  hasMergedCellsInTable: tableMap.hasMergedCells()
42
42
  };
43
43
  if (!selectionRect) {
@@ -52,7 +52,7 @@ export const TableMenu = /*#__PURE__*/memo(({
52
52
  isLastColumn: selectionRect.right === tableMap.width,
53
53
  selectedColumnCount: selectionRect.right - selectionRect.left
54
54
  };
55
- }, [editorView, selection, tableNode]);
55
+ }, [editorView, tableNode, selection]);
56
56
  if (components.length === 0) {
57
57
  return null;
58
58
  }
@@ -1,4 +1,4 @@
1
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]';
2
+ export const TABLE_MENU_SELECTOR = '[data-testid="column-handle-menu"], [data-testid="row-handle-menu"], [data-toolbar-component="menu"], [data-toolbar-nested-dropdown-menu]';
3
3
  export const TABLE_ROW = 'table-row';
4
4
  export const TABLE_COLUMN = 'table-column';
@@ -46,7 +46,7 @@ export const BackgroundColorItem = ({
46
46
  return;
47
47
  }
48
48
  setColorWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(INPUT_METHOD.TABLE_CONTEXT_MENU, color, editorView)(editorView.state, editorView.dispatch);
49
- api === null || api === void 0 ? void 0 : api.core.actions.execute(closeActiveTableMenu());
49
+ api === null || api === void 0 ? void 0 : api.core.actions.execute(closeActiveTableMenu(api));
50
50
  api === null || api === void 0 ? void 0 : api.core.actions.focus();
51
51
  }, [api, editorView]);
52
52
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
@@ -29,7 +29,7 @@ export const ClearCellsItem = ({
29
29
  targetCellPosition
30
30
  } = getPluginState(editorView.state);
31
31
  emptyMultipleCellsWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(INPUT_METHOD.TABLE_CONTEXT_MENU, targetCellPosition)(editorView.state, editorView.dispatch);
32
- api === null || api === void 0 ? void 0 : api.core.actions.execute(closeActiveTableMenu());
32
+ api === null || api === void 0 ? void 0 : api.core.actions.execute(closeActiveTableMenu(api));
33
33
  api === null || api === void 0 ? void 0 : api.core.actions.focus();
34
34
  };
35
35
  return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
@@ -1,15 +1,24 @@
1
1
  import { pluginKey } from '../plugin-key';
2
- export var closeActiveTableMenu = function closeActiveTableMenu() {
2
+ var applyMenuUserIntent = function applyMenuUserIntent(tr, api, nextActiveTableMenu) {
3
+ var _api$userIntent;
4
+ var isRowOrColumnMenuOpen = nextActiveTableMenu.type === 'row' || nextActiveTableMenu.type === 'column';
5
+ api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || _api$userIntent.commands.setCurrentUserIntent(isRowOrColumnMenuOpen ? 'tableDragMenuPopupOpen' : 'default')({
6
+ tr: tr
7
+ });
8
+ };
9
+ export var closeActiveTableMenu = function closeActiveTableMenu(api) {
3
10
  return function (_ref) {
4
11
  var tr = _ref.tr;
12
+ var nextActiveTableMenu = {
13
+ type: 'none'
14
+ };
5
15
  tr.setMeta(pluginKey, {
6
16
  type: 'SET_ACTIVE_TABLE_MENU',
7
17
  data: {
8
- activeTableMenu: {
9
- type: 'none'
10
- }
18
+ activeTableMenu: nextActiveTableMenu
11
19
  }
12
20
  });
21
+ applyMenuUserIntent(tr, api, nextActiveTableMenu);
13
22
  if (!tr.docChanged) {
14
23
  tr.setMeta('addToHistory', false);
15
24
  }
@@ -25,17 +34,19 @@ var isSameActiveTableMenu = function isSameActiveTableMenu(current, next) {
25
34
  }
26
35
  return true;
27
36
  };
28
- export var toggleActiveTableMenu = function toggleActiveTableMenu(activeTableMenu, currentActiveTableMenu) {
37
+ export var toggleActiveTableMenu = function toggleActiveTableMenu(activeTableMenu, currentActiveTableMenu, api) {
29
38
  return function (_ref2) {
30
39
  var tr = _ref2.tr;
40
+ var nextActiveTableMenu = isSameActiveTableMenu(currentActiveTableMenu, activeTableMenu) ? {
41
+ type: 'none'
42
+ } : activeTableMenu;
31
43
  tr.setMeta(pluginKey, {
32
44
  type: 'SET_ACTIVE_TABLE_MENU',
33
45
  data: {
34
- activeTableMenu: isSameActiveTableMenu(currentActiveTableMenu, activeTableMenu) ? {
35
- type: 'none'
36
- } : activeTableMenu
46
+ activeTableMenu: nextActiveTableMenu
37
47
  }
38
48
  });
49
+ applyMenuUserIntent(tr, api, nextActiveTableMenu);
39
50
  tr.setMeta('addToHistory', false);
40
51
  return tr;
41
52
  };
@@ -13,7 +13,6 @@ import { deleteRows } from '../transforms/delete-rows';
13
13
  import { mergeCells } from '../transforms/merge';
14
14
  import { withEditorAnalyticsAPI, getSelectedCellInfo, getSelectedTableInfo } from '../utils/analytics';
15
15
  import { checkIfNumberColumnEnabled } from '../utils/nodes';
16
- import { toggleActiveTableMenu } from './active-table-menu';
17
16
  import { clearMultipleCells } from './clear';
18
17
  import { wrapTableInExpand } from './collapse';
19
18
  import { changeColumnWidthByStep } from './column-resize';
@@ -24,45 +23,6 @@ import { deleteTable, deleteTableIfSelected, getTableSelectionType, setMultipleC
24
23
  import { sortByColumn } from './sort';
25
24
  import { splitCell } from './split-cell';
26
25
  import { toggleHeaderColumn, toggleHeaderRow, toggleNumberColumn } from './toggle';
27
- export var toggleActiveTableMenuWithAnalytics = function toggleActiveTableMenuWithAnalytics(editorAnalyticsAPI) {
28
- return function (direction, index) {
29
- var trigger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'mouse';
30
- return withEditorAnalyticsAPI(function (state) {
31
- var _getPluginState = getPluginState(state),
32
- previousActiveTableMenu = _getPluginState.activeTableMenu;
33
- var isSameActiveMenu = (previousActiveTableMenu === null || previousActiveTableMenu === void 0 ? void 0 : previousActiveTableMenu.type) === direction && previousActiveTableMenu.index === index;
34
- if (isSameActiveMenu) {
35
- return undefined;
36
- }
37
- return {
38
- action: TABLE_ACTION.DRAG_MENU_OPENED,
39
- actionSubject: ACTION_SUBJECT.TABLE,
40
- actionSubjectId: null,
41
- eventType: EVENT_TYPE.TRACK,
42
- attributes: {
43
- inputMethod: trigger === 'keyboard' ? INPUT_METHOD.KEYBOARD : INPUT_METHOD.MOUSE,
44
- direction: direction
45
- }
46
- };
47
- })(editorAnalyticsAPI)(function (state, dispatch) {
48
- if (dispatch) {
49
- var _getPluginState2 = getPluginState(state),
50
- currentActiveTableMenu = _getPluginState2.activeTableMenu;
51
- var newTr = toggleActiveTableMenu({
52
- type: direction,
53
- index: index,
54
- openedBy: trigger
55
- }, currentActiveTableMenu)({
56
- tr: state.tr
57
- });
58
- if (newTr) {
59
- dispatch(newTr);
60
- }
61
- }
62
- return true;
63
- });
64
- };
65
- };
66
26
  export var emptyMultipleCellsWithAnalytics = function emptyMultipleCellsWithAnalytics(editorAnalyticsAPI) {
67
27
  return function (inputMethod, targetCellPosition) {
68
28
  return withEditorAnalyticsAPI(function (_ref) {
@@ -227,8 +187,8 @@ export var changeColumnWidthByStepWithAnalytics = function changeColumnWidthBySt
227
187
  table = _getSelectedTableInfo2.table,
228
188
  totalRowCount = _getSelectedTableInfo2.totalRowCount,
229
189
  totalColumnCount = _getSelectedTableInfo2.totalColumnCount;
230
- var _getPluginState3 = getPluginState(state),
231
- colIndex = _getPluginState3.hoveredCell.colIndex;
190
+ var _getPluginState = getPluginState(state),
191
+ colIndex = _getPluginState.hoveredCell.colIndex;
232
192
  return {
233
193
  action: TABLE_ACTION.COLUMN_RESIZED,
234
194
  actionSubject: ACTION_SUBJECT.TABLE,
@@ -348,8 +308,8 @@ export var deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut = function delete
348
308
  }
349
309
  var selectionType = getTableSelectionType(selection);
350
310
  if (selectionType === 'row') {
351
- var _getPluginState4 = getPluginState(state),
352
- pluginConfig = _getPluginState4.pluginConfig;
311
+ var _getPluginState2 = getPluginState(state),
312
+ pluginConfig = _getPluginState2.pluginConfig;
353
313
  var isHeaderRowRequired = pluginConfig.isHeaderRowRequired || false;
354
314
  return deleteRowsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT, rect, isHeaderRowRequired)(state, dispatch);
355
315
  } else if (selectionType === 'column') {
@@ -393,8 +353,8 @@ export var toggleHeaderRowWithAnalytics = function toggleHeaderRowWithAnalytics(
393
353
  var _getSelectedTableInfo7 = getSelectedTableInfo(state.selection),
394
354
  totalRowCount = _getSelectedTableInfo7.totalRowCount,
395
355
  totalColumnCount = _getSelectedTableInfo7.totalColumnCount;
396
- var _getPluginState5 = getPluginState(state),
397
- isHeaderRowEnabled = _getPluginState5.isHeaderRowEnabled;
356
+ var _getPluginState3 = getPluginState(state),
357
+ isHeaderRowEnabled = _getPluginState3.isHeaderRowEnabled;
398
358
  return {
399
359
  action: TABLE_ACTION.TOGGLED_HEADER_ROW,
400
360
  actionSubject: ACTION_SUBJECT.TABLE,
@@ -413,8 +373,8 @@ export var toggleHeaderColumnWithAnalytics = function toggleHeaderColumnWithAnal
413
373
  var _getSelectedTableInfo8 = getSelectedTableInfo(state.selection),
414
374
  totalRowCount = _getSelectedTableInfo8.totalRowCount,
415
375
  totalColumnCount = _getSelectedTableInfo8.totalColumnCount;
416
- var _getPluginState6 = getPluginState(state),
417
- isHeaderColumnEnabled = _getPluginState6.isHeaderColumnEnabled;
376
+ var _getPluginState4 = getPluginState(state),
377
+ isHeaderColumnEnabled = _getPluginState4.isHeaderColumnEnabled;
418
378
  return {
419
379
  action: TABLE_ACTION.TOGGLED_HEADER_COLUMN,
420
380
  actionSubject: ACTION_SUBJECT.TABLE,
@@ -90,7 +90,7 @@ var destroyFn = function destroyFn(editorView, editorAnalyticsAPI, isTableScalin
90
90
  api === null || api === void 0 || api.core.actions.execute(function (_ref7) {
91
91
  var _api$userIntent;
92
92
  var tr = _ref7.tr;
93
- closeActiveTableMenu()({
93
+ closeActiveTableMenu(api)({
94
94
  tr: tr
95
95
  });
96
96
  api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || _api$userIntent.commands.setCurrentUserIntent('dragging')({
@@ -49,7 +49,7 @@ var updateTargetCellPosition = function updateTargetCellPosition(_ref2) {
49
49
  }
50
50
  var hasTargetCellChanged = pluginState.targetCellPosition !== _targetCellPosition;
51
51
  var hasActiveTableMenu = pluginState.activeTableMenu != null && pluginState.activeTableMenu.type !== 'none';
52
- var shouldCloseMenu = hasActiveTableMenu && (!tableNode || hasTargetCellChanged || !(tr.selection instanceof CellSelection));
52
+ var shouldCloseMenu = hasActiveTableMenu && tr.selectionSet && (!tableNode || hasTargetCellChanged || !(tr.selection instanceof CellSelection));
53
53
  if (!hasTargetCellChanged && !shouldCloseMenu) {
54
54
  return pluginState;
55
55
  }
@@ -43,7 +43,10 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
43
43
  wasFullWidthModeEnabled: previousFullWidthModeEnabled,
44
44
  isHeaderRowEnabled: !!pluginConfig.allowHeaderRow,
45
45
  isHeaderColumnEnabled: false,
46
- isTableScalingEnabled: isTableScalingEnabled
46
+ isTableScalingEnabled: isTableScalingEnabled,
47
+ activeTableMenu: {
48
+ type: 'none'
49
+ }
47
50
  }, defaultHoveredCell), defaultTableSelection), {}, {
48
51
  getIntl: getIntl
49
52
  }));
@@ -5,6 +5,7 @@ import { getDomRefFromSelection } from '@atlaskit/editor-common/get-dom-ref-from
5
5
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
6
6
  import { ResizerBreakoutModeLabel } from '@atlaskit/editor-common/resizer';
7
7
  import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
8
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
9
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
9
10
  import FloatingContextualButton from './FloatingContextualButton';
10
11
  import FloatingContextualMenu from './FloatingContextualMenu';
@@ -12,6 +13,7 @@ import FloatingDragMenu from './FloatingDragMenu';
12
13
  // Ignored via go/ees005
13
14
  // eslint-disable-next-line import/no-named-as-default
14
15
  import FloatingInsertButton from './FloatingInsertButton';
16
+ import FloatingTableMenu from './FloatingTableMenu';
15
17
  import { FloatingToolbarLabel } from './FloatingToolbarLabel/FloatingToolbarLabel';
16
18
  import { GlobalStylesWrapper } from './global-styles';
17
19
  import { SizeSelector } from './SizeSelector';
@@ -135,7 +137,15 @@ var ContentComponentInternal = function ContentComponentInternal(_ref) {
135
137
  isCommentEditor: options === null || options === void 0 ? void 0 : options.isCommentEditor,
136
138
  api: api,
137
139
  isDragMenuOpen: isDragMenuOpen
138
- }), /*#__PURE__*/React.createElement(FloatingDragMenu, {
140
+ }), expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) ? /*#__PURE__*/React.createElement(FloatingTableMenu, {
141
+ api: api,
142
+ boundariesElement: popupsBoundariesElement,
143
+ editorView: editorView,
144
+ mountPoint: popupsMountPoint,
145
+ stickyHeaders: stickyHeader,
146
+ tableWrapper: tableWrapperTarget,
147
+ targetCellPosition: targetCellPosition
148
+ }) : /*#__PURE__*/React.createElement(FloatingDragMenu, {
139
149
  editorView: editorView,
140
150
  mountPoint: popupsMountPoint,
141
151
  boundariesElement: popupsBoundariesElement,
@@ -67,7 +67,7 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
67
67
  toggleActiveTableMenu({
68
68
  type: 'cell',
69
69
  openedBy: 'mouse'
70
- }, currentActiveTableMenu)({
70
+ }, currentActiveTableMenu, api)({
71
71
  tr: tr
72
72
  });
73
73
  return tr;
@@ -102,7 +102,7 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
102
102
  toggleActiveTableMenu({
103
103
  type: 'cell',
104
104
  openedBy: 'keyboard'
105
- }, currentActiveTableMenu)({
105
+ }, currentActiveTableMenu, api)({
106
106
  tr: tr
107
107
  });
108
108
  return tr;
@@ -34,11 +34,11 @@ export var CellMenuPopup = function CellMenuPopup(_ref) {
34
34
  var closeCellMenu = useCallback(function () {
35
35
  var _getPluginState = getPluginState(editorView.state),
36
36
  isCellMenuOpenByKeyboard = _getPluginState.isCellMenuOpenByKeyboard;
37
- api === null || api === void 0 || api.core.actions.execute(closeActiveTableMenu());
37
+ api === null || api === void 0 || api.core.actions.execute(closeActiveTableMenu(api));
38
38
  if (isCellMenuOpenByKeyboard) {
39
39
  setFocusToCellMenu(false)(editorView.state, editorView.dispatch);
40
40
  }
41
- }, [api === null || api === void 0 ? void 0 : api.core.actions, editorView]);
41
+ }, [api, editorView]);
42
42
  var isEventInsideCellMenu = useCallback(function (event) {
43
43
  var _popupContentRef$curr;
44
44
  var target = event.target;
@@ -14,9 +14,12 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
14
14
  * @jsxRuntime classic
15
15
  * @jsx jsx
16
16
  */
17
+
17
18
  import React, { Component } from 'react';
19
+
18
20
  /* eslint-disable @typescript-eslint/consistent-type-imports, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766; jsx required at runtime for @jsxRuntime classic */
19
21
  import { jsx } from '@emotion/react';
22
+ import memoizeOne from 'memoize-one';
20
23
  import { injectIntl } from 'react-intl';
21
24
  import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
22
25
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
@@ -54,7 +57,6 @@ import { getMergedCellsPositions } from '../../pm-plugins/utils/table';
54
57
  import { TableCssClassName as ClassName } from '../../types';
55
58
  import { colorPalletteColumns, contextualMenuDropdownWidthDnD } from '../consts';
56
59
  import { cellColourPreviewStyles } from './styles';
57
- var arrowsList = new Set(!expValEquals('platform_editor_toolbar_submenu_open_click', 'isEnabled', true) ? ['ArrowRight', 'ArrowLeft'] : ['ArrowRight']);
58
60
  var dropdownMenuSection = {
59
61
  hasSeparator: true
60
62
  };
@@ -62,6 +64,10 @@ var elementBeforeIconStyles = xcss({
62
64
  marginRight: 'space.negative.075',
63
65
  display: 'flex'
64
66
  });
67
+ var getArrowsList = memoizeOne(function () {
68
+ return new Set(!expValEquals('platform_editor_toolbar_submenu_open_click', 'isEnabled', true) ? ['ArrowRight', 'ArrowLeft'] : ['ArrowRight']);
69
+ });
70
+
65
71
  // eslint-disable-next-line @repo/internal/react/no-class-components
66
72
  export var ContextualMenu = /*#__PURE__*/function (_Component) {
67
73
  function ContextualMenu() {
@@ -564,7 +570,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
564
570
  var event = payload.event;
565
571
  if (event && event instanceof KeyboardEvent) {
566
572
  if (!_this.state.isSubmenuOpen) {
567
- if (arrowsList.has(event.key)) {
573
+ if (getArrowsList().has(event.key)) {
568
574
  // preventing default behavior for avoiding cursor jump to next/previous table column
569
575
  // when left/right arrow pressed.
570
576
  event.preventDefault();
@@ -1,19 +1,11 @@
1
1
  import React from 'react';
2
- import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
3
2
  import { Popup } from '@atlaskit/editor-common/ui';
4
- import { UserIntentPopupWrapper } from '@atlaskit/editor-common/user-intent';
5
3
  import { akEditorFloatingDialogZIndex, akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
6
4
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
7
5
  import { fg } from '@atlaskit/platform-feature-flags';
8
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
9
6
  import { TableCssClassName as ClassName } from '../../types';
10
- import { dragMenuDropdownWidth, dragTableInsertColumnButtonSize, tablePopupMenuFitHeight } from '../consts';
11
- import { COLUMN_MENU } from '../TableMenu/column/keys';
12
- import { ROW_MENU } from '../TableMenu/row/keys';
13
- import { TABLE_MENU_WIDTH } from '../TableMenu/shared/consts';
14
- import { TableMenu } from '../TableMenu/shared/TableMenu';
7
+ import { dragMenuDropdownWidth, tablePopupMenuFitHeight } from '../consts';
15
8
  import DragMenu from './DragMenu';
16
- var TABLE_MENU_OFFSET = dragTableInsertColumnButtonSize + 4;
17
9
  var FloatingDragMenu = function FloatingDragMenu(_ref) {
18
10
  var _getEditorFeatureFlag;
19
11
  var mountPoint = _ref.mountPoint,
@@ -35,23 +27,11 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
35
27
  api = _ref.api,
36
28
  isCommentEditor = _ref.isCommentEditor,
37
29
  tableWrapper = _ref.tableWrapper;
38
- var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['table'], function (states) {
39
- var _states$tableState;
40
- return {
41
- activeTableMenu: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : _states$tableState.activeTableMenu
42
- };
43
- }),
44
- activeTableMenu = _useSharedPluginState.activeTableMenu;
45
- var isActiveTableMenuDragMenu = (activeTableMenu === null || activeTableMenu === void 0 ? void 0 : activeTableMenu.type) === 'row' || (activeTableMenu === null || activeTableMenu === void 0 ? void 0 : activeTableMenu.type) === 'column';
46
- var hasActiveTableMenuState = activeTableMenu !== undefined;
47
- var isDragMenuOpen = expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) && hasActiveTableMenuState ? isActiveTableMenuDragMenu : isOpen;
48
- var dragMenuDirection = expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) && hasActiveTableMenuState ? isActiveTableMenuDragMenu ? activeTableMenu.type : undefined : direction;
49
- var dragMenuIndex = expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) && hasActiveTableMenuState ? isActiveTableMenuDragMenu ? activeTableMenu.index : undefined : index;
50
- if (!isDragMenuOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
30
+ if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
51
31
  return null;
52
32
  }
53
33
  var inStickyMode = (stickyHeaders === null || stickyHeaders === void 0 ? void 0 : stickyHeaders.sticky) || (tableWrapper === null || tableWrapper === void 0 ? void 0 : tableWrapper.classList.contains(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW)) && fg('platform_editor_table_sticky_header_patch_7');
54
- var targetHandleRef = dragMenuDirection === 'row' ? document.querySelector('#drag-handle-button-row') : document.querySelector('#drag-handle-button-column');
34
+ var targetHandleRef = direction === 'row' ? document.querySelector('#drag-handle-button-row') : document.querySelector('#drag-handle-button-column');
55
35
  if (!targetHandleRef || !(editorView.state.selection instanceof CellSelection)) {
56
36
  return null;
57
37
  }
@@ -60,8 +40,8 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
60
40
  tableWithFixedColumnWidthsOption = _ref2$tableWithFixedC === void 0 ? false : _ref2$tableWithFixedC;
61
41
  var shouldUseIncreasedScalingPercent = isTableScalingEnabled && (tableWithFixedColumnWidthsOption || isCommentEditor);
62
42
  return /*#__PURE__*/React.createElement(Popup, {
63
- alignX: dragMenuDirection === 'row' ? 'right' : undefined,
64
- alignY: dragMenuDirection === 'row' ? 'start' : undefined
43
+ alignX: direction === 'row' ? 'right' : undefined,
44
+ alignY: direction === 'row' ? 'start' : undefined
65
45
  // Ignored via go/ees005
66
46
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
67
47
  ,
@@ -69,7 +49,7 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
69
49
  mountTo: mountPoint,
70
50
  boundariesElement: boundariesElement,
71
51
  scrollableElement: scrollableElement,
72
- fitWidth: expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) ? TABLE_MENU_WIDTH : dragMenuDropdownWidth,
52
+ fitWidth: dragMenuDropdownWidth,
73
53
  fitHeight: tablePopupMenuFitHeight
74
54
  // z-index value below is to ensure that this menu is above other floating menu
75
55
  // in table, but below floating dialogs like typeaheads, pickers, etc.
@@ -77,22 +57,14 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
77
57
  ,
78
58
  zIndex: inStickyMode ? akEditorFloatingDialogZIndex : akEditorFloatingOverlapPanelZIndex,
79
59
  forcePlacement: true,
80
- preventOverflow: expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) ? dragMenuDirection === 'row' : undefined,
81
- offset: expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) ? [TABLE_MENU_OFFSET, 0] : direction === 'row' ? [-9, 0] : [0, -7],
60
+ offset: direction === 'row' ? [-9, 0] : [0, -7],
82
61
  stick: true
83
- }, expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) ? /*#__PURE__*/React.createElement(UserIntentPopupWrapper, {
84
- api: api,
85
- userIntent: "tableDragMenuPopupOpen"
86
- }, /*#__PURE__*/React.createElement(TableMenu, {
87
- api: api,
88
- editorView: editorView,
89
- surface: dragMenuDirection === 'row' ? ROW_MENU : COLUMN_MENU
90
- })) : /*#__PURE__*/React.createElement(DragMenu, {
62
+ }, /*#__PURE__*/React.createElement(DragMenu, {
91
63
  editorView: editorView,
92
- isOpen: isDragMenuOpen,
64
+ isOpen: isOpen,
93
65
  tableNode: tableNode,
94
- direction: dragMenuDirection,
95
- index: dragMenuIndex,
66
+ direction: direction,
67
+ index: index,
96
68
  target: targetHandleRef || undefined,
97
69
  targetCellPosition: targetCellPosition,
98
70
  getEditorContainerWidth: getEditorContainerWidth,