@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
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.ColumnControls = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
+ var _analytics = require("@atlaskit/editor-common/analytics");
9
10
  var _hooks = require("@atlaskit/editor-common/hooks");
10
11
  var _styles = require("@atlaskit/editor-common/styles");
11
12
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
@@ -13,8 +14,8 @@ var _editorTables = require("@atlaskit/editor-tables");
13
14
  var _utils = require("@atlaskit/editor-tables/utils");
14
15
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
15
16
  var _commands = require("../../../pm-plugins/commands");
16
- var _commandsWithAnalytics = require("../../../pm-plugins/commands/commands-with-analytics");
17
- var _commandsWithAnalytics2 = require("../../../pm-plugins/drag-and-drop/commands-with-analytics");
17
+ var _commandsWithAnalytics = require("../../../pm-plugins/drag-and-drop/commands-with-analytics");
18
+ var _pluginFactory = require("../../../pm-plugins/plugin-factory");
18
19
  var _rowControls = require("../../../pm-plugins/utils/row-controls");
19
20
  var _selection = require("../../../pm-plugins/utils/selection");
20
21
  var _types = require("../../../types");
@@ -33,7 +34,7 @@ var getSelectedColumns = function getSelectedColumns(selection) {
33
34
  return [];
34
35
  };
35
36
  var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
36
- var _colWidths$map$join, _api$analytics3;
37
+ var _colWidths$map$join;
37
38
  var editorView = _ref.editorView,
38
39
  tableActive = _ref.tableActive,
39
40
  tableRef = _ref.tableRef,
@@ -130,17 +131,48 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
130
131
  var state = editorView.state,
131
132
  dispatch = editorView.dispatch;
132
133
  if (event !== null && event !== void 0 && event.shiftKey) {
134
+ // Shift-click extends the selection rather than toggling the menu, but the
135
+ // open drag menu would otherwise stay anchored to a stale column. Close it here
136
+ // for the updated menu (legacy menu closes via outside-click on its dropdown).
137
+ if ((0, _expValEquals.expValEquals)('platform_editor_table_menu_updates', 'isEnabled', true)) {
138
+ api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)(api));
139
+ }
133
140
  return;
134
141
  }
135
142
  if ((0, _expValEquals.expValEquals)('platform_editor_table_menu_updates', 'isEnabled', true)) {
136
- if (colIndex !== undefined) {
137
- var _api$analytics;
138
- (0, _commandsWithAnalytics.toggleActiveTableMenuWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)('column', colIndex, trigger)(state, dispatch);
143
+ if (colIndex !== undefined && api) {
144
+ var _getTablePluginState = (0, _pluginFactory.getPluginState)(state),
145
+ currentActiveTableMenu = _getTablePluginState.activeTableMenu;
146
+ var isSameActiveMenu = (currentActiveTableMenu === null || currentActiveTableMenu === void 0 ? void 0 : currentActiveTableMenu.type) === 'column' && currentActiveTableMenu.index === colIndex;
147
+ api.core.actions.execute(function (_ref2) {
148
+ var tr = _ref2.tr;
149
+ if (!isSameActiveMenu) {
150
+ var _api$analytics;
151
+ (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || _api$analytics.attachAnalyticsEvent({
152
+ action: _analytics.TABLE_ACTION.DRAG_MENU_OPENED,
153
+ actionSubject: _analytics.ACTION_SUBJECT.TABLE,
154
+ actionSubjectId: null,
155
+ eventType: _analytics.EVENT_TYPE.TRACK,
156
+ attributes: {
157
+ inputMethod: trigger === 'keyboard' ? _analytics.INPUT_METHOD.KEYBOARD : _analytics.INPUT_METHOD.MOUSE,
158
+ direction: 'column'
159
+ }
160
+ })(tr);
161
+ }
162
+ (0, _commands.toggleActiveTableMenu)({
163
+ type: 'column',
164
+ index: colIndex,
165
+ openedBy: trigger
166
+ }, currentActiveTableMenu, api)({
167
+ tr: tr
168
+ });
169
+ return tr;
170
+ });
139
171
  }
140
172
  return;
141
173
  }
142
- (0, _commandsWithAnalytics2.toggleDragMenuWithAnalytics)(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)(undefined, 'column', colIndex, trigger)(state, dispatch);
143
- }, [editorView, colIndex, api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions]);
174
+ (0, _commandsWithAnalytics.toggleDragMenuWithAnalytics)(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)(undefined, 'column', colIndex, trigger)(state, dispatch);
175
+ }, [editorView, colIndex, api]);
144
176
  var colIndexes = (0, _react.useMemo)(function () {
145
177
  // Ignored via go/ees005
146
178
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -247,9 +279,9 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
247
279
  overflowX: stickyTop ? 'hidden' : 'visible',
248
280
  pointerEvents: isDragging ? 'none' : undefined
249
281
  }
250
- }, columnParams.map(function (_ref2, index) {
251
- var startIndex = _ref2.startIndex,
252
- endIndex = _ref2.endIndex;
282
+ }, columnParams.map(function (_ref3, index) {
283
+ var startIndex = _ref3.startIndex,
284
+ endIndex = _ref3.endIndex;
253
285
  return /*#__PURE__*/_react.default.createElement("div", {
254
286
  style: {
255
287
  gridColumn: "".concat(startIndex + 1, " / span 1")
@@ -8,14 +8,14 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.DragControlsWithSelection = exports.DragControls = void 0;
9
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
10
  var _react = _interopRequireWildcard(require("react"));
11
+ var _analytics = require("@atlaskit/editor-common/analytics");
11
12
  var _hooks = require("@atlaskit/editor-common/hooks");
12
13
  var _editorTables = require("@atlaskit/editor-tables");
13
14
  var _utils = require("@atlaskit/editor-tables/utils");
14
15
  var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
15
16
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
16
17
  var _commands = require("../../../pm-plugins/commands");
17
- var _commandsWithAnalytics = require("../../../pm-plugins/commands/commands-with-analytics");
18
- var _commandsWithAnalytics2 = require("../../../pm-plugins/drag-and-drop/commands-with-analytics");
18
+ var _commandsWithAnalytics = require("../../../pm-plugins/drag-and-drop/commands-with-analytics");
19
19
  var _pluginFactory = require("../../../pm-plugins/plugin-factory");
20
20
  var _rowControls = require("../../../pm-plugins/utils/row-controls");
21
21
  var _selection = require("../../../pm-plugins/utils/selection");
@@ -37,7 +37,7 @@ var getSelectedRows = function getSelectedRows(selection) {
37
37
  return [];
38
38
  };
39
39
  var DragControls = exports.DragControls = function DragControls(_ref) {
40
- var _tableNode$attrs$loca, _tableNode$attrs, _api$analytics3;
40
+ var _tableNode$attrs$loca, _tableNode$attrs;
41
41
  var tableRef = _ref.tableRef,
42
42
  tableNode = _ref.tableNode,
43
43
  tableWidth = _ref.tableWidth,
@@ -92,18 +92,49 @@ var DragControls = exports.DragControls = function DragControls(_ref) {
92
92
  var toggleDragMenuHandler = (0, _react.useCallback)(function (trigger, event) {
93
93
  var _api$analytics2;
94
94
  if (event !== null && event !== void 0 && event.shiftKey) {
95
+ // Shift-click extends the selection rather than toggling the menu, but the
96
+ // open drag menu would otherwise stay anchored to a stale row. Close it here
97
+ // for the updated menu (legacy menu closes via outside-click on its dropdown).
98
+ if ((0, _expValEquals.expValEquals)('platform_editor_table_menu_updates', 'isEnabled', true)) {
99
+ api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)(api));
100
+ }
95
101
  return;
96
102
  }
97
103
  var rowIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex;
98
104
  if ((0, _expValEquals.expValEquals)('platform_editor_table_menu_updates', 'isEnabled', true)) {
99
- if (rowIndex !== undefined) {
100
- var _api$analytics;
101
- (0, _commandsWithAnalytics.toggleActiveTableMenuWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)('row', rowIndex, trigger)(editorView.state, editorView.dispatch);
105
+ if (rowIndex !== undefined && api) {
106
+ var _getTablePluginState2 = (0, _pluginFactory.getPluginState)(editorView.state),
107
+ currentActiveTableMenu = _getTablePluginState2.activeTableMenu;
108
+ var isSameActiveMenu = (currentActiveTableMenu === null || currentActiveTableMenu === void 0 ? void 0 : currentActiveTableMenu.type) === 'row' && currentActiveTableMenu.index === rowIndex;
109
+ api.core.actions.execute(function (_ref4) {
110
+ var tr = _ref4.tr;
111
+ if (!isSameActiveMenu) {
112
+ var _api$analytics;
113
+ (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || _api$analytics.attachAnalyticsEvent({
114
+ action: _analytics.TABLE_ACTION.DRAG_MENU_OPENED,
115
+ actionSubject: _analytics.ACTION_SUBJECT.TABLE,
116
+ actionSubjectId: null,
117
+ eventType: _analytics.EVENT_TYPE.TRACK,
118
+ attributes: {
119
+ inputMethod: trigger === 'keyboard' ? _analytics.INPUT_METHOD.KEYBOARD : _analytics.INPUT_METHOD.MOUSE,
120
+ direction: 'row'
121
+ }
122
+ })(tr);
123
+ }
124
+ (0, _commands.toggleActiveTableMenu)({
125
+ type: 'row',
126
+ index: rowIndex,
127
+ openedBy: trigger
128
+ }, currentActiveTableMenu, api)({
129
+ tr: tr
130
+ });
131
+ return tr;
132
+ });
102
133
  }
103
134
  return;
104
135
  }
105
- (0, _commandsWithAnalytics2.toggleDragMenuWithAnalytics)(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)(undefined, 'row', rowIndex, trigger)(editorView.state, editorView.dispatch);
106
- }, [editorView, hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex, api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions]);
136
+ (0, _commandsWithAnalytics.toggleDragMenuWithAnalytics)(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)(undefined, 'row', rowIndex, trigger)(editorView.state, editorView.dispatch);
137
+ }, [editorView, hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex, api]);
107
138
  var rowIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex;
108
139
  var handleMouseOut = (0, _react.useCallback)(function () {
109
140
  if (tableActive) {
@@ -234,9 +265,9 @@ var DragControls = exports.DragControls = function DragControls(_ref) {
234
265
  },
235
266
  onMouseMove: handleMouseMove,
236
267
  contentEditable: false
237
- }, rowsParams.map(function (_ref4, index) {
238
- var startIndex = _ref4.startIndex,
239
- endIndex = _ref4.endIndex;
268
+ }, rowsParams.map(function (_ref5, index) {
269
+ var startIndex = _ref5.startIndex,
270
+ endIndex = _ref5.endIndex;
240
271
  return (
241
272
  /*#__PURE__*/
242
273
  // Ignored via go/ees005
@@ -287,21 +318,21 @@ var DragControls = exports.DragControls = function DragControls(_ref) {
287
318
  );
288
319
  }), rowHandles());
289
320
  };
290
- var DragControlsWithSelection = exports.DragControlsWithSelection = function DragControlsWithSelection(_ref5) {
291
- var editorView = _ref5.editorView,
292
- tableRef = _ref5.tableRef,
293
- tableNode = _ref5.tableNode,
294
- tableWidth = _ref5.tableWidth,
295
- tableActive = _ref5.tableActive,
296
- hoveredCell = _ref5.hoveredCell,
297
- isInDanger = _ref5.isInDanger,
298
- isTableHovered = _ref5.isTableHovered,
299
- isResizing = _ref5.isResizing,
300
- hoverRows = _ref5.hoverRows,
301
- selectRow = _ref5.selectRow,
302
- selectRows = _ref5.selectRows,
303
- updateCellHoverLocation = _ref5.updateCellHoverLocation,
304
- api = _ref5.api;
321
+ var DragControlsWithSelection = exports.DragControlsWithSelection = function DragControlsWithSelection(_ref6) {
322
+ var editorView = _ref6.editorView,
323
+ tableRef = _ref6.tableRef,
324
+ tableNode = _ref6.tableNode,
325
+ tableWidth = _ref6.tableWidth,
326
+ tableActive = _ref6.tableActive,
327
+ hoveredCell = _ref6.hoveredCell,
328
+ isInDanger = _ref6.isInDanger,
329
+ isTableHovered = _ref6.isTableHovered,
330
+ isResizing = _ref6.isResizing,
331
+ hoverRows = _ref6.hoverRows,
332
+ selectRow = _ref6.selectRow,
333
+ selectRows = _ref6.selectRows,
334
+ updateCellHoverLocation = _ref6.updateCellHoverLocation,
335
+ api = _ref6.api;
305
336
  var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['selection'], function (states) {
306
337
  var _states$selectionStat;
307
338
  return {
@@ -33,7 +33,7 @@ var MergeCellsItem = exports.MergeCellsItem = function MergeCellsItem(_ref) {
33
33
  return;
34
34
  }
35
35
  (0, _commandsWithAnalytics.mergeCellsWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(_analytics.INPUT_METHOD.CONTEXT_MENU)(editorView.state, editorView.dispatch);
36
- api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)());
36
+ api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)(api));
37
37
  api === null || api === void 0 || api.core.actions.focus();
38
38
  };
39
39
  if (!shouldShowMergeCells(tableMenuContext)) {
@@ -33,7 +33,7 @@ var SplitCellItem = exports.SplitCellItem = function SplitCellItem(_ref) {
33
33
  return;
34
34
  }
35
35
  (0, _commandsWithAnalytics.splitCellWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(_analytics.INPUT_METHOD.CONTEXT_MENU)(editorView.state, editorView.dispatch);
36
- api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)());
36
+ api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)(api));
37
37
  api === null || api === void 0 || api.core.actions.focus();
38
38
  };
39
39
  if (!shouldShowSplitCell(tableMenuContext)) {
@@ -39,7 +39,7 @@ var VerticalAlignDropdownItem = exports.VerticalAlignDropdownItem = function Ver
39
39
  }, targetCellPosition)({
40
40
  tr: tr
41
41
  });
42
- (0, _commands.closeActiveTableMenu)()({
42
+ (0, _commands.closeActiveTableMenu)(api)({
43
43
  tr: tr
44
44
  });
45
45
  return tr;
@@ -46,7 +46,7 @@ var AddColumnLeftItem = exports.AddColumnLeftItem = function AddColumnLeftItem(_
46
46
  }
47
47
  var shouldUseIncreasedScalingPercent = isTableScalingEnabled && (isTableFixedColumnWidthsOptionEnabled || isCommentEditor);
48
48
  (0, _commandsWithAnalytics.insertColumnWithAnalytics)(api, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, index)(editorView.state, editorView.dispatch, editorView);
49
- api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)());
49
+ api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)(api));
50
50
  api === null || api === void 0 || api.core.actions.focus();
51
51
  };
52
52
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
@@ -46,7 +46,7 @@ var AddColumnRightItem = exports.AddColumnRightItem = function AddColumnRightIte
46
46
  }
47
47
  var shouldUseIncreasedScalingPercent = isTableScalingEnabled && (isTableFixedColumnWidthsOptionEnabled || isCommentEditor);
48
48
  (0, _commandsWithAnalytics.insertColumnWithAnalytics)(api, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, index)(editorView.state, editorView.dispatch, editorView);
49
- api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)());
49
+ api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)(api));
50
50
  api === null || api === void 0 || api.core.actions.focus();
51
51
  };
52
52
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
@@ -64,7 +64,7 @@ var DeleteColumnItem = exports.DeleteColumnItem = function DeleteColumnItem(_ref
64
64
  }
65
65
  var shouldUseIncreasedScalingPercent = isTableScalingEnabled && (isTableFixedColumnWidthsOptionEnabled || isCommentEditor);
66
66
  (0, _commandsWithAnalytics.deleteColumnsWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, api, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, selectionRect)(editorView.state, editorView.dispatch, editorView);
67
- api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)());
67
+ api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)(api));
68
68
  api === null || api === void 0 || api.core.actions.focus();
69
69
  };
70
70
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
@@ -55,7 +55,7 @@ var DistributeColumnsItem = exports.DistributeColumnsItem = function DistributeC
55
55
  return;
56
56
  }
57
57
  (0, _commandsWithAnalytics.distributeColumnsWidthsWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, api)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, newResizeState)(editorView.state, editorView.dispatch);
58
- api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)());
58
+ api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)(api));
59
59
  api === null || api === void 0 || api.core.actions.focus();
60
60
  };
61
61
  if (!shouldShowDistributeColumns(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedColumnCount)) {
@@ -49,7 +49,7 @@ var MoveColumnLeftItem = exports.MoveColumnLeftItem = function MoveColumnLeftIte
49
49
  return;
50
50
  }
51
51
  (0, _commandsWithAnalytics.moveSourceWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, api === null || api === void 0 || (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 ? void 0 : _api$accessibilityUti.actions.ariaNotify, (0, _pluginFactory.getPluginState)(editorView.state).getIntl)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, _consts.TABLE_COLUMN, (0, _selection.getSelectedColumnIndexes)(selectionRect), selectionRect.left - 1)(editorView.state, editorView.dispatch);
52
- api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)());
52
+ api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)(api));
53
53
  api === null || api === void 0 || api.core.actions.focus();
54
54
  };
55
55
  if (!tableNode || !shouldShowMoveColumnLeft(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isFirstColumn)) {
@@ -48,7 +48,7 @@ var MoveColumnRightItem = exports.MoveColumnRightItem = function MoveColumnRight
48
48
  return;
49
49
  }
50
50
  (0, _commandsWithAnalytics.moveSourceWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, api === null || api === void 0 || (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 ? void 0 : _api$accessibilityUti.actions.ariaNotify, (0, _pluginFactory.getPluginState)(editorView.state).getIntl)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, _consts.TABLE_COLUMN, (0, _selection.getSelectedColumnIndexes)(selectionRect), selectionRect.right)(editorView.state, editorView.dispatch);
51
- api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)());
51
+ api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)(api));
52
52
  api === null || api === void 0 || api.core.actions.focus();
53
53
  };
54
54
  if (!tableNode || !shouldShowMoveColumnRight(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isLastColumn)) {
@@ -33,7 +33,7 @@ var SortDecreasingItem = exports.SortDecreasingItem = function SortDecreasingIte
33
33
  return;
34
34
  }
35
35
  (0, _commandsWithAnalytics.sortColumnWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, columnIndex, _customSteps.TableSortOrder.DESC)(editorView.state, editorView.dispatch);
36
- api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)());
36
+ api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)(api));
37
37
  api === null || api === void 0 || api.core.actions.focus();
38
38
  };
39
39
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
@@ -33,7 +33,7 @@ var SortIncreasingItem = exports.SortIncreasingItem = function SortIncreasingIte
33
33
  return;
34
34
  }
35
35
  (0, _commandsWithAnalytics.sortColumnWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, columnIndex, _customSteps.TableSortOrder.ASC)(editorView.state, editorView.dispatch);
36
- api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)());
36
+ api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)(api));
37
37
  api === null || api === void 0 || api.core.actions.focus();
38
38
  };
39
39
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
@@ -36,7 +36,7 @@ var AddRowAboveItem = exports.AddRowAboveItem = function AddRowAboveItem(props)
36
36
  index: index,
37
37
  moveCursorToInsertedRow: true
38
38
  })(editorView.state, editorView.dispatch);
39
- api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)());
39
+ api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)(api));
40
40
  api === null || api === void 0 || api.core.actions.focus();
41
41
  };
42
42
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
@@ -36,7 +36,7 @@ var AddRowBelowItem = exports.AddRowBelowItem = function AddRowBelowItem(props)
36
36
  index: index,
37
37
  moveCursorToInsertedRow: true
38
38
  })(editorView.state, editorView.dispatch);
39
- api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)());
39
+ api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)(api));
40
40
  api === null || api === void 0 || api.core.actions.focus();
41
41
  };
42
42
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
@@ -59,7 +59,7 @@ var DeleteRowItem = exports.DeleteRowItem = function DeleteRowItem(props) {
59
59
  return;
60
60
  }
61
61
  (0, _commandsWithAnalytics.deleteRowsWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, selectionRect, !!isHeaderRowRequired)(editorView.state, editorView.dispatch);
62
- api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)());
62
+ api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)(api));
63
63
  api === null || api === void 0 || api.core.actions.focus();
64
64
  };
65
65
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
@@ -48,7 +48,7 @@ var MoveRowDownItem = exports.MoveRowDownItem = function MoveRowDownItem(props)
48
48
  return;
49
49
  }
50
50
  (0, _commandsWithAnalytics.moveSourceWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, api === null || api === void 0 || (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 ? void 0 : _api$accessibilityUti.actions.ariaNotify, (0, _pluginFactory.getPluginState)(editorView.state).getIntl)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, _consts.TABLE_ROW, (0, _selection.getSelectedRowIndexes)(selectionRect), selectionRect.bottom)(editorView.state, editorView.dispatch);
51
- api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)());
51
+ api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)(api));
52
52
  api === null || api === void 0 || api.core.actions.focus();
53
53
  };
54
54
  if (!tableNode || !shouldShowMoveRowDown(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isLastRow)) {
@@ -48,7 +48,7 @@ var MoveRowUpItem = exports.MoveRowUpItem = function MoveRowUpItem(props) {
48
48
  return;
49
49
  }
50
50
  (0, _commandsWithAnalytics.moveSourceWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, api === null || api === void 0 || (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 ? void 0 : _api$accessibilityUti.actions.ariaNotify, (0, _pluginFactory.getPluginState)(editorView.state).getIntl)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, _consts.TABLE_ROW, (0, _selection.getSelectedRowIndexes)(selectionRect), selectionRect.top - 1)(editorView.state, editorView.dispatch);
51
- api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)());
51
+ api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)(api));
52
52
  api === null || api === void 0 || api.core.actions.focus();
53
53
  };
54
54
  if (!tableNode || !shouldShowMoveRowUp(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isFirstRow)) {
@@ -37,17 +37,17 @@ var TableMenu = exports.TableMenu = /*#__PURE__*/(0, _react.memo)(function (_ref
37
37
  tableNode = _useSharedPluginState.tableNode,
38
38
  selection = _useSharedPluginState.selection;
39
39
  var tableMenuContext = (0, _react.useMemo)(function () {
40
- if (!selection || !tableNode) {
41
- return {
42
- editorView: editorView
43
- };
40
+ // rely on selection plugins state to re-render the row/column menu, but use editorView.selection
41
+ // for cell menu state as the selection plugin won't update when text selection changes within cells
42
+ if (!tableNode || !editorView || !selection) {
43
+ return undefined;
44
44
  }
45
45
  var tableMap = _tableMap.TableMap.get(tableNode);
46
- var selectionRect = (0, _utils.getSelectionRect)(selection);
46
+ var selectionRect = (0, _utils.getSelectionRect)(editorView.state.selection);
47
47
  var cellOps = {
48
48
  editorView: editorView,
49
- canMergeCells: (0, _merge.canMergeCellSelection)(selection),
50
- canSplitCell: (0, _splitCell.canSplitCellSelection)(selection),
49
+ canMergeCells: (0, _merge.canMergeCellSelection)(editorView.state.selection),
50
+ canSplitCell: (0, _splitCell.canSplitCellSelection)(editorView.state.selection),
51
51
  hasMergedCellsInTable: tableMap.hasMergedCells()
52
52
  };
53
53
  if (!selectionRect) {
@@ -61,7 +61,7 @@ var TableMenu = exports.TableMenu = /*#__PURE__*/(0, _react.memo)(function (_ref
61
61
  isLastColumn: selectionRect.right === tableMap.width,
62
62
  selectedColumnCount: selectionRect.right - selectionRect.left
63
63
  });
64
- }, [editorView, selection, tableNode]);
64
+ }, [editorView, tableNode, selection]);
65
65
  if (components.length === 0) {
66
66
  return null;
67
67
  }
@@ -5,6 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.TABLE_ROW = exports.TABLE_MENU_WIDTH = exports.TABLE_MENU_SELECTOR = exports.TABLE_COLUMN = void 0;
7
7
  var TABLE_MENU_WIDTH = exports.TABLE_MENU_WIDTH = 280;
8
- var TABLE_MENU_SELECTOR = exports.TABLE_MENU_SELECTOR = '[data-testid="column-handle-menu"], [data-testid="row-handle-menu"], [data-toolbar-nested-dropdown-menu]';
8
+ var TABLE_MENU_SELECTOR = exports.TABLE_MENU_SELECTOR = '[data-testid="column-handle-menu"], [data-testid="row-handle-menu"], [data-toolbar-component="menu"], [data-toolbar-nested-dropdown-menu]';
9
9
  var TABLE_ROW = exports.TABLE_ROW = 'table-row';
10
10
  var TABLE_COLUMN = exports.TABLE_COLUMN = 'table-column';
@@ -50,7 +50,7 @@ var BackgroundColorItem = exports.BackgroundColorItem = function BackgroundColor
50
50
  return;
51
51
  }
52
52
  (0, _commandsWithAnalytics.setColorWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, color, editorView)(editorView.state, editorView.dispatch);
53
- api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)());
53
+ api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)(api));
54
54
  api === null || api === void 0 || api.core.actions.focus();
55
55
  }, [api, editorView]);
56
56
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
@@ -32,7 +32,7 @@ var ClearCellsItem = exports.ClearCellsItem = function ClearCellsItem(_ref) {
32
32
  var _getPluginState = (0, _pluginFactory.getPluginState)(editorView.state),
33
33
  targetCellPosition = _getPluginState.targetCellPosition;
34
34
  (0, _commandsWithAnalytics.emptyMultipleCellsWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, targetCellPosition)(editorView.state, editorView.dispatch);
35
- api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)());
35
+ api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)(api));
36
36
  api === null || api === void 0 || api.core.actions.focus();
37
37
  };
38
38
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
@@ -1,15 +1,24 @@
1
1
  import { pluginKey } from '../plugin-key';
2
- export const closeActiveTableMenu = () => ({
2
+ const applyMenuUserIntent = (tr, api, nextActiveTableMenu) => {
3
+ var _api$userIntent;
4
+ const isRowOrColumnMenuOpen = nextActiveTableMenu.type === 'row' || nextActiveTableMenu.type === 'column';
5
+ api === null || api === void 0 ? void 0 : (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.commands.setCurrentUserIntent(isRowOrColumnMenuOpen ? 'tableDragMenuPopupOpen' : 'default')({
6
+ tr
7
+ });
8
+ };
9
+ export const closeActiveTableMenu = api => ({
3
10
  tr
4
11
  }) => {
12
+ const 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
  }
@@ -24,17 +33,19 @@ const isSameActiveTableMenu = (current, next) => {
24
33
  }
25
34
  return true;
26
35
  };
27
- export const toggleActiveTableMenu = (activeTableMenu, currentActiveTableMenu) => ({
36
+ export const toggleActiveTableMenu = (activeTableMenu, currentActiveTableMenu, api) => ({
28
37
  tr
29
38
  }) => {
39
+ const nextActiveTableMenu = isSameActiveTableMenu(currentActiveTableMenu, activeTableMenu) ? {
40
+ type: 'none'
41
+ } : activeTableMenu;
30
42
  tr.setMeta(pluginKey, {
31
43
  type: 'SET_ACTIVE_TABLE_MENU',
32
44
  data: {
33
- activeTableMenu: isSameActiveTableMenu(currentActiveTableMenu, activeTableMenu) ? {
34
- type: 'none'
35
- } : activeTableMenu
45
+ activeTableMenu: nextActiveTableMenu
36
46
  }
37
47
  });
48
+ applyMenuUserIntent(tr, api, nextActiveTableMenu);
38
49
  tr.setMeta('addToHistory', false);
39
50
  return tr;
40
51
  };
@@ -10,7 +10,6 @@ import { deleteRows } from '../transforms/delete-rows';
10
10
  import { mergeCells } from '../transforms/merge';
11
11
  import { withEditorAnalyticsAPI, getSelectedCellInfo, getSelectedTableInfo } from '../utils/analytics';
12
12
  import { checkIfNumberColumnEnabled } from '../utils/nodes';
13
- import { toggleActiveTableMenu } from './active-table-menu';
14
13
  import { clearMultipleCells } from './clear';
15
14
  import { wrapTableInExpand } from './collapse';
16
15
  import { changeColumnWidthByStep } from './column-resize';
@@ -21,44 +20,6 @@ import { deleteTable, deleteTableIfSelected, getTableSelectionType, setMultipleC
21
20
  import { sortByColumn } from './sort';
22
21
  import { splitCell } from './split-cell';
23
22
  import { toggleHeaderColumn, toggleHeaderRow, toggleNumberColumn } from './toggle';
24
- export const toggleActiveTableMenuWithAnalytics = editorAnalyticsAPI => (direction, index, trigger = 'mouse') => {
25
- return withEditorAnalyticsAPI(state => {
26
- const {
27
- activeTableMenu: previousActiveTableMenu
28
- } = getPluginState(state);
29
- const isSameActiveMenu = (previousActiveTableMenu === null || previousActiveTableMenu === void 0 ? void 0 : previousActiveTableMenu.type) === direction && previousActiveTableMenu.index === index;
30
- if (isSameActiveMenu) {
31
- return undefined;
32
- }
33
- return {
34
- action: TABLE_ACTION.DRAG_MENU_OPENED,
35
- actionSubject: ACTION_SUBJECT.TABLE,
36
- actionSubjectId: null,
37
- eventType: EVENT_TYPE.TRACK,
38
- attributes: {
39
- inputMethod: trigger === 'keyboard' ? INPUT_METHOD.KEYBOARD : INPUT_METHOD.MOUSE,
40
- direction
41
- }
42
- };
43
- })(editorAnalyticsAPI)((state, dispatch) => {
44
- if (dispatch) {
45
- const {
46
- activeTableMenu: currentActiveTableMenu
47
- } = getPluginState(state);
48
- const newTr = toggleActiveTableMenu({
49
- type: direction,
50
- index,
51
- openedBy: trigger
52
- }, currentActiveTableMenu)({
53
- tr: state.tr
54
- });
55
- if (newTr) {
56
- dispatch(newTr);
57
- }
58
- }
59
- return true;
60
- });
61
- };
62
23
  export const emptyMultipleCellsWithAnalytics = editorAnalyticsAPI => (inputMethod, targetCellPosition) => withEditorAnalyticsAPI(({
63
24
  selection
64
25
  }) => {
@@ -98,7 +98,7 @@ const destroyFn = (editorView, editorAnalyticsAPI, isTableScalingEnabled, isTabl
98
98
  tr
99
99
  }) => {
100
100
  var _api$userIntent;
101
- closeActiveTableMenu()({
101
+ closeActiveTableMenu(api)({
102
102
  tr
103
103
  });
104
104
  api === null || api === void 0 ? void 0 : (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.commands.setCurrentUserIntent('dragging')({
@@ -44,7 +44,7 @@ const updateTargetCellPosition = ({
44
44
  }
45
45
  const hasTargetCellChanged = pluginState.targetCellPosition !== targetCellPosition;
46
46
  const hasActiveTableMenu = pluginState.activeTableMenu != null && pluginState.activeTableMenu.type !== 'none';
47
- const shouldCloseMenu = hasActiveTableMenu && (!tableNode || hasTargetCellChanged || !(tr.selection instanceof CellSelection));
47
+ const shouldCloseMenu = hasActiveTableMenu && tr.selectionSet && (!tableNode || hasTargetCellChanged || !(tr.selection instanceof CellSelection));
48
48
  if (!hasTargetCellChanged && !shouldCloseMenu) {
49
49
  return pluginState;
50
50
  }
@@ -41,6 +41,9 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
41
41
  isHeaderRowEnabled: !!pluginConfig.allowHeaderRow,
42
42
  isHeaderColumnEnabled: false,
43
43
  isTableScalingEnabled: isTableScalingEnabled,
44
+ activeTableMenu: {
45
+ type: 'none'
46
+ },
44
47
  ...defaultHoveredCell,
45
48
  ...defaultTableSelection,
46
49
  getIntl