@atlaskit/editor-plugin-table 22.4.17 → 22.4.19

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 (115) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/nodeviews/TableCell.js +9 -2
  3. package/dist/cjs/pm-plugins/commands/active-table-menu.js +18 -21
  4. package/dist/cjs/pm-plugins/commands/commands-with-analytics.js +17 -10
  5. package/dist/cjs/pm-plugins/commands/index.js +6 -0
  6. package/dist/cjs/pm-plugins/commands/misc.js +37 -5
  7. package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +23 -12
  8. package/dist/cjs/tablePlugin.js +5 -4
  9. package/dist/cjs/ui/FloatingContextualButton/index.js +32 -9
  10. package/dist/cjs/ui/FloatingContextualMenu/CellMenuPopup.js +2 -2
  11. package/dist/cjs/ui/TableMenu/cell/getCellMenuComponents.js +76 -0
  12. package/dist/cjs/ui/TableMenu/cell/items/MergeCellsItem.js +2 -1
  13. package/dist/cjs/ui/TableMenu/cell/items/SplitCellItem.js +2 -1
  14. package/dist/cjs/ui/TableMenu/cell/items/VerticalAlignDropdownItem.js +61 -0
  15. package/dist/cjs/ui/TableMenu/cell/items/VerticalAlignNestedMenu.js +56 -0
  16. package/dist/cjs/ui/TableMenu/cell/items/verticalAlignUtils.js +20 -0
  17. package/dist/cjs/ui/TableMenu/cell/keys.js +24 -2
  18. package/dist/cjs/ui/TableMenu/column/items/AddColumnLeftItem.js +3 -0
  19. package/dist/cjs/ui/TableMenu/column/items/AddColumnRightItem.js +3 -0
  20. package/dist/cjs/ui/TableMenu/column/items/DeleteColumnItem.js +2 -0
  21. package/dist/cjs/ui/TableMenu/column/items/DistributeColumnsItem.js +3 -0
  22. package/dist/cjs/ui/TableMenu/column/items/MoveColumnLeftItem.js +3 -0
  23. package/dist/cjs/ui/TableMenu/column/items/MoveColumnRightItem.js +3 -0
  24. package/dist/cjs/ui/TableMenu/column/items/SortDecreasingItem.js +3 -0
  25. package/dist/cjs/ui/TableMenu/column/items/SortIncreasingItem.js +3 -0
  26. package/dist/cjs/ui/TableMenu/row/items/AddRowAboveItem.js +3 -0
  27. package/dist/cjs/ui/TableMenu/row/items/AddRowBelowItem.js +3 -0
  28. package/dist/cjs/ui/TableMenu/row/items/DeleteRowItem.js +2 -0
  29. package/dist/cjs/ui/TableMenu/row/items/MoveRowDownItem.js +3 -0
  30. package/dist/cjs/ui/TableMenu/row/items/MoveRowUpItem.js +3 -0
  31. package/dist/cjs/ui/TableMenu/shared/TableMenu.js +2 -11
  32. package/dist/cjs/ui/TableMenu/shared/items/BackgroundColorItem.js +4 -3
  33. package/dist/cjs/ui/TableMenu/shared/items/ClearCellsItem.js +2 -1
  34. package/dist/es2019/nodeviews/TableCell.js +9 -2
  35. package/dist/es2019/pm-plugins/commands/active-table-menu.js +19 -18
  36. package/dist/es2019/pm-plugins/commands/commands-with-analytics.js +10 -2
  37. package/dist/es2019/pm-plugins/commands/index.js +1 -1
  38. package/dist/es2019/pm-plugins/commands/misc.js +31 -0
  39. package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +22 -10
  40. package/dist/es2019/tablePlugin.js +6 -5
  41. package/dist/es2019/ui/FloatingContextualButton/index.js +36 -9
  42. package/dist/es2019/ui/FloatingContextualMenu/CellMenuPopup.js +2 -2
  43. package/dist/es2019/ui/TableMenu/cell/getCellMenuComponents.js +67 -1
  44. package/dist/es2019/ui/TableMenu/cell/items/MergeCellsItem.js +2 -1
  45. package/dist/es2019/ui/TableMenu/cell/items/SplitCellItem.js +2 -1
  46. package/dist/es2019/ui/TableMenu/cell/items/VerticalAlignDropdownItem.js +56 -0
  47. package/dist/es2019/ui/TableMenu/cell/items/VerticalAlignNestedMenu.js +48 -0
  48. package/dist/es2019/ui/TableMenu/cell/items/verticalAlignUtils.js +15 -0
  49. package/dist/es2019/ui/TableMenu/cell/keys.js +31 -2
  50. package/dist/es2019/ui/TableMenu/column/items/AddColumnLeftItem.js +3 -0
  51. package/dist/es2019/ui/TableMenu/column/items/AddColumnRightItem.js +3 -0
  52. package/dist/es2019/ui/TableMenu/column/items/DeleteColumnItem.js +3 -1
  53. package/dist/es2019/ui/TableMenu/column/items/DistributeColumnsItem.js +3 -0
  54. package/dist/es2019/ui/TableMenu/column/items/MoveColumnLeftItem.js +3 -0
  55. package/dist/es2019/ui/TableMenu/column/items/MoveColumnRightItem.js +3 -0
  56. package/dist/es2019/ui/TableMenu/column/items/SortDecreasingItem.js +3 -0
  57. package/dist/es2019/ui/TableMenu/column/items/SortIncreasingItem.js +3 -0
  58. package/dist/es2019/ui/TableMenu/row/items/AddRowAboveItem.js +3 -0
  59. package/dist/es2019/ui/TableMenu/row/items/AddRowBelowItem.js +3 -0
  60. package/dist/es2019/ui/TableMenu/row/items/DeleteRowItem.js +3 -1
  61. package/dist/es2019/ui/TableMenu/row/items/MoveRowDownItem.js +3 -0
  62. package/dist/es2019/ui/TableMenu/row/items/MoveRowUpItem.js +3 -0
  63. package/dist/es2019/ui/TableMenu/shared/TableMenu.js +2 -11
  64. package/dist/es2019/ui/TableMenu/shared/items/BackgroundColorItem.js +4 -3
  65. package/dist/es2019/ui/TableMenu/shared/items/ClearCellsItem.js +2 -1
  66. package/dist/esm/nodeviews/TableCell.js +9 -2
  67. package/dist/esm/pm-plugins/commands/active-table-menu.js +18 -21
  68. package/dist/esm/pm-plugins/commands/commands-with-analytics.js +17 -10
  69. package/dist/esm/pm-plugins/commands/index.js +1 -1
  70. package/dist/esm/pm-plugins/commands/misc.js +36 -4
  71. package/dist/esm/pm-plugins/drag-and-drop/plugin.js +23 -12
  72. package/dist/esm/tablePlugin.js +6 -5
  73. package/dist/esm/ui/FloatingContextualButton/index.js +32 -9
  74. package/dist/esm/ui/FloatingContextualMenu/CellMenuPopup.js +2 -2
  75. package/dist/esm/ui/TableMenu/cell/getCellMenuComponents.js +77 -1
  76. package/dist/esm/ui/TableMenu/cell/items/MergeCellsItem.js +2 -1
  77. package/dist/esm/ui/TableMenu/cell/items/SplitCellItem.js +2 -1
  78. package/dist/esm/ui/TableMenu/cell/items/VerticalAlignDropdownItem.js +53 -0
  79. package/dist/esm/ui/TableMenu/cell/items/VerticalAlignNestedMenu.js +47 -0
  80. package/dist/esm/ui/TableMenu/cell/items/verticalAlignUtils.js +14 -0
  81. package/dist/esm/ui/TableMenu/cell/keys.js +23 -1
  82. package/dist/esm/ui/TableMenu/column/items/AddColumnLeftItem.js +3 -0
  83. package/dist/esm/ui/TableMenu/column/items/AddColumnRightItem.js +3 -0
  84. package/dist/esm/ui/TableMenu/column/items/DeleteColumnItem.js +3 -1
  85. package/dist/esm/ui/TableMenu/column/items/DistributeColumnsItem.js +3 -0
  86. package/dist/esm/ui/TableMenu/column/items/MoveColumnLeftItem.js +3 -0
  87. package/dist/esm/ui/TableMenu/column/items/MoveColumnRightItem.js +3 -0
  88. package/dist/esm/ui/TableMenu/column/items/SortDecreasingItem.js +3 -0
  89. package/dist/esm/ui/TableMenu/column/items/SortIncreasingItem.js +3 -0
  90. package/dist/esm/ui/TableMenu/row/items/AddRowAboveItem.js +3 -0
  91. package/dist/esm/ui/TableMenu/row/items/AddRowBelowItem.js +3 -0
  92. package/dist/esm/ui/TableMenu/row/items/DeleteRowItem.js +3 -1
  93. package/dist/esm/ui/TableMenu/row/items/MoveRowDownItem.js +3 -0
  94. package/dist/esm/ui/TableMenu/row/items/MoveRowUpItem.js +3 -0
  95. package/dist/esm/ui/TableMenu/shared/TableMenu.js +2 -11
  96. package/dist/esm/ui/TableMenu/shared/items/BackgroundColorItem.js +4 -3
  97. package/dist/esm/ui/TableMenu/shared/items/ClearCellsItem.js +2 -1
  98. package/dist/types/pm-plugins/commands/active-table-menu.d.ts +3 -3
  99. package/dist/types/pm-plugins/commands/index.d.ts +1 -1
  100. package/dist/types/pm-plugins/commands/misc.d.ts +4 -0
  101. package/dist/types/ui/TableMenu/cell/items/VerticalAlignDropdownItem.d.ts +12 -0
  102. package/dist/types/ui/TableMenu/cell/items/VerticalAlignNestedMenu.d.ts +4 -0
  103. package/dist/types/ui/TableMenu/cell/items/verticalAlignUtils.d.ts +3 -0
  104. package/dist/types/ui/TableMenu/cell/keys.d.ts +8 -1
  105. package/dist/types-ts4.5/pm-plugins/commands/active-table-menu.d.ts +3 -3
  106. package/dist/types-ts4.5/pm-plugins/commands/index.d.ts +1 -1
  107. package/dist/types-ts4.5/pm-plugins/commands/misc.d.ts +4 -0
  108. package/dist/types-ts4.5/ui/TableMenu/cell/items/VerticalAlignDropdownItem.d.ts +12 -0
  109. package/dist/types-ts4.5/ui/TableMenu/cell/items/VerticalAlignNestedMenu.d.ts +4 -0
  110. package/dist/types-ts4.5/ui/TableMenu/cell/items/verticalAlignUtils.d.ts +3 -0
  111. package/dist/types-ts4.5/ui/TableMenu/cell/keys.d.ts +8 -1
  112. package/package.json +5 -4
  113. package/dist/cjs/ui/TableMenu/shared/TableMenu.compiled.css +0 -4
  114. package/dist/es2019/ui/TableMenu/shared/TableMenu.compiled.css +0 -4
  115. package/dist/esm/ui/TableMenu/shared/TableMenu.compiled.css +0 -4
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.VerticalAlignNestedMenu = void 0;
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _reactIntl = require("react-intl");
11
+ var _messages = require("@atlaskit/editor-common/messages");
12
+ var _editorToolbar = require("@atlaskit/editor-toolbar");
13
+ var _alignPositionBottom = _interopRequireDefault(require("@atlaskit/icon-lab/core/align-position-bottom"));
14
+ var _alignPositionCenterVertical = _interopRequireDefault(require("@atlaskit/icon-lab/core/align-position-center-vertical"));
15
+ var _alignPositionTop = _interopRequireDefault(require("@atlaskit/icon-lab/core/align-position-top"));
16
+ var _TableMenuContext = require("../../shared/TableMenuContext");
17
+ var _verticalAlignUtils = require("./verticalAlignUtils");
18
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
19
+ var getTriggerIcon = function getTriggerIcon(valign) {
20
+ switch (valign) {
21
+ case 'middle':
22
+ return _alignPositionCenterVertical.default;
23
+ case 'bottom':
24
+ return _alignPositionBottom.default;
25
+ case 'top':
26
+ default:
27
+ return _alignPositionTop.default;
28
+ }
29
+ };
30
+ var VerticalAlignNestedMenu = exports.VerticalAlignNestedMenu = function VerticalAlignNestedMenu(_ref) {
31
+ var _useTableMenuContext;
32
+ var children = _ref.children;
33
+ var _ref2 = (_useTableMenuContext = (0, _TableMenuContext.useTableMenuContext)()) !== null && _useTableMenuContext !== void 0 ? _useTableMenuContext : {},
34
+ editorView = _ref2.editorView;
35
+ var _useIntl = (0, _reactIntl.useIntl)(),
36
+ formatMessage = _useIntl.formatMessage;
37
+ var selectedValign = (0, _react.useMemo)(function () {
38
+ return (0, _verticalAlignUtils.getSelectedCellValign)(editorView);
39
+ }, [editorView]);
40
+ var TriggerIcon = getTriggerIcon(selectedValign);
41
+ if (!editorView) {
42
+ return null;
43
+ }
44
+ return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarNestedDropdownMenu, {
45
+ elemBefore: /*#__PURE__*/_react.default.createElement(TriggerIcon, {
46
+ color: "currentColor",
47
+ label: "",
48
+ size: "small"
49
+ }),
50
+ elemAfter: /*#__PURE__*/_react.default.createElement(_editorToolbar.NestedDropdownRightIcon, {
51
+ label: "",
52
+ size: "small"
53
+ }),
54
+ text: formatMessage(_messages.tableMessages.cellAlignment)
55
+ }, children);
56
+ };
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getSelectedCellValign = void 0;
7
+ var _pluginFactory = require("../../../../pm-plugins/plugin-factory");
8
+ var getNormalizedValign = function getNormalizedValign(valign) {
9
+ return valign !== null && valign !== void 0 ? valign : 'top';
10
+ };
11
+ var getSelectedCellValign = exports.getSelectedCellValign = function getSelectedCellValign(editorView) {
12
+ if (!editorView) {
13
+ return 'top';
14
+ }
15
+ var state = editorView.state;
16
+ var _getPluginState = (0, _pluginFactory.getPluginState)(state),
17
+ targetCellPosition = _getPluginState.targetCellPosition;
18
+ var cell = typeof targetCellPosition === 'number' ? state.doc.nodeAt(targetCellPosition) : undefined;
19
+ return getNormalizedValign(cell === null || cell === void 0 ? void 0 : cell.attrs.valign);
20
+ };
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.SPLIT_CELL_ITEM = exports.MERGE_CELLS_ITEM = exports.CELL_MENU_RANK = exports.CELL_MENU = exports.CELL_DANGER_SECTION_RANK = exports.CELL_DANGER_SECTION = exports.CELL_ACTION_SECTION_RANK = exports.CELL_ACTION_SECTION = void 0;
7
+ exports.VERTICAL_ALIGN_TOP_ITEM = exports.VERTICAL_ALIGN_MIDDLE_ITEM = exports.VERTICAL_ALIGN_MENU_SECTION_RANK = exports.VERTICAL_ALIGN_MENU_SECTION = exports.VERTICAL_ALIGN_MENU_RANK = exports.VERTICAL_ALIGN_MENU = exports.VERTICAL_ALIGN_BOTTOM_ITEM = exports.SPLIT_CELL_ITEM = exports.MERGE_CELLS_ITEM = exports.CELL_MENU_RANK = exports.CELL_MENU = exports.CELL_DANGER_SECTION_RANK = exports.CELL_DANGER_SECTION = exports.CELL_ACTION_SECTION_RANK = exports.CELL_ACTION_SECTION = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _keys = require("../shared/keys");
10
10
  // --- Menu surface ---
@@ -33,8 +33,30 @@ var SPLIT_CELL_ITEM = exports.SPLIT_CELL_ITEM = {
33
33
  type: 'menu-item',
34
34
  key: 'split-cell'
35
35
  };
36
+ var VERTICAL_ALIGN_MENU = exports.VERTICAL_ALIGN_MENU = {
37
+ type: 'nested-menu',
38
+ key: 'vertical-align'
39
+ };
40
+ var VERTICAL_ALIGN_MENU_SECTION = exports.VERTICAL_ALIGN_MENU_SECTION = {
41
+ type: 'menu-section',
42
+ key: 'vertical-align-section'
43
+ };
44
+ var VERTICAL_ALIGN_TOP_ITEM = exports.VERTICAL_ALIGN_TOP_ITEM = {
45
+ type: 'menu-item',
46
+ key: 'vertical-align-top'
47
+ };
48
+ var VERTICAL_ALIGN_MIDDLE_ITEM = exports.VERTICAL_ALIGN_MIDDLE_ITEM = {
49
+ type: 'menu-item',
50
+ key: 'vertical-align-middle'
51
+ };
52
+ var VERTICAL_ALIGN_BOTTOM_ITEM = exports.VERTICAL_ALIGN_BOTTOM_ITEM = {
53
+ type: 'menu-item',
54
+ key: 'vertical-align-bottom'
55
+ };
36
56
 
37
57
  // --- Item ranks within their sections ---
38
58
 
39
- var CELL_ACTION_SECTION_RANK = exports.CELL_ACTION_SECTION_RANK = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _keys.BACKGROUND_COLOR_ITEM.key, 100), MERGE_CELLS_ITEM.key, 200), SPLIT_CELL_ITEM.key, 300);
59
+ var CELL_ACTION_SECTION_RANK = exports.CELL_ACTION_SECTION_RANK = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _keys.BACKGROUND_COLOR_ITEM.key, 100), VERTICAL_ALIGN_MENU.key, 200), MERGE_CELLS_ITEM.key, 300), SPLIT_CELL_ITEM.key, 400);
60
+ var VERTICAL_ALIGN_MENU_RANK = exports.VERTICAL_ALIGN_MENU_RANK = (0, _defineProperty2.default)({}, VERTICAL_ALIGN_MENU_SECTION.key, 100);
61
+ var VERTICAL_ALIGN_MENU_SECTION_RANK = exports.VERTICAL_ALIGN_MENU_SECTION_RANK = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, VERTICAL_ALIGN_TOP_ITEM.key, 100), VERTICAL_ALIGN_MIDDLE_ITEM.key, 200), VERTICAL_ALIGN_BOTTOM_ITEM.key, 300);
40
62
  var CELL_DANGER_SECTION_RANK = exports.CELL_DANGER_SECTION_RANK = (0, _defineProperty2.default)({}, _keys.CLEAR_CELLS_ITEM.key, 100);
@@ -13,6 +13,7 @@ var _keymaps = require("@atlaskit/editor-common/keymaps");
13
13
  var _messages = require("@atlaskit/editor-common/messages");
14
14
  var _utils = require("@atlaskit/editor-tables/utils");
15
15
  var _editorToolbar = require("@atlaskit/editor-toolbar");
16
+ var _commands = require("../../../../pm-plugins/commands");
16
17
  var _commandsWithAnalytics = require("../../../../pm-plugins/commands/commands-with-analytics");
17
18
  var _TableMenuContext = require("../../shared/TableMenuContext");
18
19
  var AddColumnLeftItem = exports.AddColumnLeftItem = function AddColumnLeftItem(_ref) {
@@ -45,6 +46,8 @@ var AddColumnLeftItem = exports.AddColumnLeftItem = function AddColumnLeftItem(_
45
46
  }
46
47
  var shouldUseIncreasedScalingPercent = isTableScalingEnabled && (isTableFixedColumnWidthsOptionEnabled || isCommentEditor);
47
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)());
50
+ api === null || api === void 0 || api.core.actions.focus();
48
51
  };
49
52
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
50
53
  onClick: handleClick,
@@ -13,6 +13,7 @@ var _keymaps = require("@atlaskit/editor-common/keymaps");
13
13
  var _messages = require("@atlaskit/editor-common/messages");
14
14
  var _utils = require("@atlaskit/editor-tables/utils");
15
15
  var _editorToolbar = require("@atlaskit/editor-toolbar");
16
+ var _commands = require("../../../../pm-plugins/commands");
16
17
  var _commandsWithAnalytics = require("../../../../pm-plugins/commands/commands-with-analytics");
17
18
  var _TableMenuContext = require("../../shared/TableMenuContext");
18
19
  var AddColumnRightItem = exports.AddColumnRightItem = function AddColumnRightItem(_ref) {
@@ -45,6 +46,8 @@ var AddColumnRightItem = exports.AddColumnRightItem = function AddColumnRightIte
45
46
  }
46
47
  var shouldUseIncreasedScalingPercent = isTableScalingEnabled && (isTableFixedColumnWidthsOptionEnabled || isCommentEditor);
47
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)());
50
+ api === null || api === void 0 || api.core.actions.focus();
48
51
  };
49
52
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
50
53
  onClick: handleClick,
@@ -64,6 +64,8 @@ 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)());
68
+ api === null || api === void 0 || api.core.actions.focus();
67
69
  };
68
70
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
69
71
  onClick: handleClick,
@@ -12,6 +12,7 @@ var _hooks = require("@atlaskit/editor-common/hooks");
12
12
  var _messages = require("@atlaskit/editor-common/messages");
13
13
  var _utils = require("@atlaskit/editor-tables/utils");
14
14
  var _editorToolbar = require("@atlaskit/editor-toolbar");
15
+ var _commands = require("../../../../pm-plugins/commands");
15
16
  var _commandsWithAnalytics = require("../../../../pm-plugins/commands/commands-with-analytics");
16
17
  var _resizeState = require("../../../../pm-plugins/table-resizing/utils/resize-state");
17
18
  var _TableMenuContext = require("../../shared/TableMenuContext");
@@ -54,6 +55,8 @@ var DistributeColumnsItem = exports.DistributeColumnsItem = function DistributeC
54
55
  return;
55
56
  }
56
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)());
59
+ api === null || api === void 0 || api.core.actions.focus();
57
60
  };
58
61
  if (!shouldShowDistributeColumns(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedColumnCount)) {
59
62
  return null;
@@ -14,6 +14,7 @@ var _messages = require("@atlaskit/editor-common/messages");
14
14
  var _utils = require("@atlaskit/editor-tables/utils");
15
15
  var _editorToolbar = require("@atlaskit/editor-toolbar");
16
16
  var _tableColumnMoveLeft = _interopRequireDefault(require("@atlaskit/icon/core/table-column-move-left"));
17
+ var _commands = require("../../../../pm-plugins/commands");
17
18
  var _commandsWithAnalytics = require("../../../../pm-plugins/drag-and-drop/commands-with-analytics");
18
19
  var _pluginFactory = require("../../../../pm-plugins/plugin-factory");
19
20
  var _selection = require("../../../../pm-plugins/utils/selection");
@@ -48,6 +49,8 @@ var MoveColumnLeftItem = exports.MoveColumnLeftItem = function MoveColumnLeftIte
48
49
  return;
49
50
  }
50
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)());
53
+ api === null || api === void 0 || api.core.actions.focus();
51
54
  };
52
55
  if (!tableNode || !shouldShowMoveColumnLeft(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isFirstColumn)) {
53
56
  return null;
@@ -13,6 +13,7 @@ var _keymaps = require("@atlaskit/editor-common/keymaps");
13
13
  var _messages = require("@atlaskit/editor-common/messages");
14
14
  var _utils = require("@atlaskit/editor-tables/utils");
15
15
  var _editorToolbar = require("@atlaskit/editor-toolbar");
16
+ var _commands = require("../../../../pm-plugins/commands");
16
17
  var _commandsWithAnalytics = require("../../../../pm-plugins/drag-and-drop/commands-with-analytics");
17
18
  var _pluginFactory = require("../../../../pm-plugins/plugin-factory");
18
19
  var _selection = require("../../../../pm-plugins/utils/selection");
@@ -47,6 +48,8 @@ var MoveColumnRightItem = exports.MoveColumnRightItem = function MoveColumnRight
47
48
  return;
48
49
  }
49
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)());
52
+ api === null || api === void 0 || api.core.actions.focus();
50
53
  };
51
54
  if (!tableNode || !shouldShowMoveColumnRight(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isLastColumn)) {
52
55
  return null;
@@ -12,6 +12,7 @@ var _analytics = require("@atlaskit/editor-common/analytics");
12
12
  var _messages = require("@atlaskit/editor-common/messages");
13
13
  var _utils = require("@atlaskit/editor-tables/utils");
14
14
  var _editorToolbar = require("@atlaskit/editor-toolbar");
15
+ var _commands = require("../../../../pm-plugins/commands");
15
16
  var _commandsWithAnalytics = require("../../../../pm-plugins/commands/commands-with-analytics");
16
17
  var _TableMenuContext = require("../../shared/TableMenuContext");
17
18
  var SortDecreasingItem = exports.SortDecreasingItem = function SortDecreasingItem(_ref) {
@@ -32,6 +33,8 @@ var SortDecreasingItem = exports.SortDecreasingItem = function SortDecreasingIte
32
33
  return;
33
34
  }
34
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)());
37
+ api === null || api === void 0 || api.core.actions.focus();
35
38
  };
36
39
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
37
40
  onClick: handleClick,
@@ -12,6 +12,7 @@ var _analytics = require("@atlaskit/editor-common/analytics");
12
12
  var _messages = require("@atlaskit/editor-common/messages");
13
13
  var _utils = require("@atlaskit/editor-tables/utils");
14
14
  var _editorToolbar = require("@atlaskit/editor-toolbar");
15
+ var _commands = require("../../../../pm-plugins/commands");
15
16
  var _commandsWithAnalytics = require("../../../../pm-plugins/commands/commands-with-analytics");
16
17
  var _TableMenuContext = require("../../shared/TableMenuContext");
17
18
  var SortIncreasingItem = exports.SortIncreasingItem = function SortIncreasingItem(_ref) {
@@ -32,6 +33,8 @@ var SortIncreasingItem = exports.SortIncreasingItem = function SortIncreasingIte
32
33
  return;
33
34
  }
34
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)());
37
+ api === null || api === void 0 || api.core.actions.focus();
35
38
  };
36
39
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
37
40
  onClick: handleClick,
@@ -12,6 +12,7 @@ var _keymaps = require("@atlaskit/editor-common/keymaps");
12
12
  var _messages = require("@atlaskit/editor-common/messages");
13
13
  var _utils = require("@atlaskit/editor-tables/utils");
14
14
  var _editorToolbar = require("@atlaskit/editor-toolbar");
15
+ var _commands = require("../../../../pm-plugins/commands");
15
16
  var _commandsWithAnalytics = require("../../../../pm-plugins/commands/commands-with-analytics");
16
17
  var _TableMenuContext = require("../../shared/TableMenuContext");
17
18
  var AddRowAboveItem = exports.AddRowAboveItem = function AddRowAboveItem(props) {
@@ -35,6 +36,8 @@ var AddRowAboveItem = exports.AddRowAboveItem = function AddRowAboveItem(props)
35
36
  index: index,
36
37
  moveCursorToInsertedRow: true
37
38
  })(editorView.state, editorView.dispatch);
39
+ api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)());
40
+ api === null || api === void 0 || api.core.actions.focus();
38
41
  };
39
42
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
40
43
  onClick: handleClick,
@@ -12,6 +12,7 @@ var _keymaps = require("@atlaskit/editor-common/keymaps");
12
12
  var _messages = require("@atlaskit/editor-common/messages");
13
13
  var _utils = require("@atlaskit/editor-tables/utils");
14
14
  var _editorToolbar = require("@atlaskit/editor-toolbar");
15
+ var _commands = require("../../../../pm-plugins/commands");
15
16
  var _commandsWithAnalytics = require("../../../../pm-plugins/commands/commands-with-analytics");
16
17
  var _TableMenuContext = require("../../shared/TableMenuContext");
17
18
  var AddRowBelowItem = exports.AddRowBelowItem = function AddRowBelowItem(props) {
@@ -35,6 +36,8 @@ var AddRowBelowItem = exports.AddRowBelowItem = function AddRowBelowItem(props)
35
36
  index: index,
36
37
  moveCursorToInsertedRow: true
37
38
  })(editorView.state, editorView.dispatch);
39
+ api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)());
40
+ api === null || api === void 0 || api.core.actions.focus();
38
41
  };
39
42
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
40
43
  onClick: handleClick,
@@ -59,6 +59,8 @@ 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)());
63
+ api === null || api === void 0 || api.core.actions.focus();
62
64
  };
63
65
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
64
66
  onClick: handleClick,
@@ -13,6 +13,7 @@ var _keymaps = require("@atlaskit/editor-common/keymaps");
13
13
  var _messages = require("@atlaskit/editor-common/messages");
14
14
  var _utils = require("@atlaskit/editor-tables/utils");
15
15
  var _editorToolbar = require("@atlaskit/editor-toolbar");
16
+ var _commands = require("../../../../pm-plugins/commands");
16
17
  var _commandsWithAnalytics = require("../../../../pm-plugins/drag-and-drop/commands-with-analytics");
17
18
  var _pluginFactory = require("../../../../pm-plugins/plugin-factory");
18
19
  var _selection = require("../../../../pm-plugins/utils/selection");
@@ -47,6 +48,8 @@ var MoveRowDownItem = exports.MoveRowDownItem = function MoveRowDownItem(props)
47
48
  return;
48
49
  }
49
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)());
52
+ api === null || api === void 0 || api.core.actions.focus();
50
53
  };
51
54
  if (!tableNode || !shouldShowMoveRowDown(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isLastRow)) {
52
55
  return null;
@@ -13,6 +13,7 @@ var _keymaps = require("@atlaskit/editor-common/keymaps");
13
13
  var _messages = require("@atlaskit/editor-common/messages");
14
14
  var _utils = require("@atlaskit/editor-tables/utils");
15
15
  var _editorToolbar = require("@atlaskit/editor-toolbar");
16
+ var _commands = require("../../../../pm-plugins/commands");
16
17
  var _commandsWithAnalytics = require("../../../../pm-plugins/drag-and-drop/commands-with-analytics");
17
18
  var _pluginFactory = require("../../../../pm-plugins/plugin-factory");
18
19
  var _selection = require("../../../../pm-plugins/utils/selection");
@@ -47,6 +48,8 @@ var MoveRowUpItem = exports.MoveRowUpItem = function MoveRowUpItem(props) {
47
48
  return;
48
49
  }
49
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)());
52
+ api === null || api === void 0 || api.core.actions.focus();
50
53
  };
51
54
  if (!tableNode || !shouldShowMoveRowUp(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isFirstRow)) {
52
55
  return null;
@@ -1,4 +1,3 @@
1
- /* TableMenu.tsx generated by @compiled/babel-plugin v0.39.1 */
2
1
  "use strict";
3
2
 
4
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -7,24 +6,19 @@ Object.defineProperty(exports, "__esModule", {
7
6
  value: true
8
7
  });
9
8
  exports.TableMenu = void 0;
10
- require("./TableMenu.compiled.css");
11
- var _runtime = require("@compiled/react/runtime");
12
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
10
  var _react = _interopRequireWildcard(require("react"));
14
11
  var _hooks = require("@atlaskit/editor-common/hooks");
15
12
  var _tableMap = require("@atlaskit/editor-tables/table-map");
16
13
  var _utils = require("@atlaskit/editor-tables/utils");
14
+ var _toolbarMenuContainer = require("@atlaskit/editor-toolbar/toolbar-menu-container");
17
15
  var _editorUiControlModel = require("@atlaskit/editor-ui-control-model");
18
- var _compiled = require("@atlaskit/primitives/compiled");
19
16
  var _splitCell = require("../../../pm-plugins/commands/split-cell");
20
17
  var _merge = require("../../../pm-plugins/transforms/merge");
21
18
  var _TableMenuContext = require("./TableMenuContext");
22
19
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
23
20
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
24
21
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
25
- var tableMenuContainerStyles = {
26
- container: "_2rko1qi0 _1bsb1178 _16qs130s _bfhk1bhr"
27
- };
28
22
  var TableMenu = exports.TableMenu = /*#__PURE__*/(0, _react.memo)(function (_ref) {
29
23
  var api = _ref.api,
30
24
  editorView = _ref.editorView,
@@ -73,10 +67,7 @@ var TableMenu = exports.TableMenu = /*#__PURE__*/(0, _react.memo)(function (_ref
73
67
  }
74
68
  return /*#__PURE__*/_react.default.createElement(_TableMenuContext.TableMenuProvider, {
75
69
  value: tableMenuContext
76
- }, /*#__PURE__*/_react.default.createElement(_compiled.Box, {
77
- xcss: tableMenuContainerStyles.container,
78
- testId: surface.key
79
- }, /*#__PURE__*/_react.default.createElement(_editorUiControlModel.SurfaceRenderer, {
70
+ }, /*#__PURE__*/_react.default.createElement(_toolbarMenuContainer.ToolbarMenuContainer, null, /*#__PURE__*/_react.default.createElement(_editorUiControlModel.SurfaceRenderer, {
80
71
  surface: surface,
81
72
  components: components
82
73
  })));
@@ -28,7 +28,7 @@ var colorPaletteStyles = {
28
28
  colorPreview: "_2rko12b0 _1h6d1l7x _1dqonqa1 _189ee4h9 _1bsbdlk8 _4t3idlk8 _1o9zidpf"
29
29
  };
30
30
  var BackgroundColorItem = exports.BackgroundColorItem = function BackgroundColorItem(_ref) {
31
- var _useTableMenuContext, _api$analytics2;
31
+ var _useTableMenuContext;
32
32
  var api = _ref.api;
33
33
  var _ref2 = (_useTableMenuContext = (0, _TableMenuContext.useTableMenuContext)()) !== null && _useTableMenuContext !== void 0 ? _useTableMenuContext : {},
34
34
  editorView = _ref2.editorView;
@@ -50,8 +50,9 @@ 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
- (0, _commands.closeActiveTableMenu)()(editorView.state, editorView.dispatch);
54
- }, [api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, editorView]);
53
+ api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)());
54
+ api === null || api === void 0 || api.core.actions.focus();
55
+ }, [api, editorView]);
55
56
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
56
57
  var colorPreviewStyle = (0, _react.useMemo)(function () {
57
58
  return {
@@ -32,7 +32,8 @@ 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
- (0, _commands.closeActiveTableMenu)()(editorView.state, editorView.dispatch);
35
+ api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)());
36
+ api === null || api === void 0 || api.core.actions.focus();
36
37
  };
37
38
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
38
39
  onClick: handleClick,
@@ -27,6 +27,13 @@ function delayUntilIdle(cb) {
27
27
  // Ignored via go/ees005
28
28
  // eslint-disable-next-line require-unicode-regexp
29
29
  const cssVariablePattern = /^VAR\(--.*\)$/;
30
+ const getCellDomAttrsForTableMenuUpdates = node => {
31
+ const attrs = getCellDomAttrs(node);
32
+ if (expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) && node.attrs.valign) {
33
+ attrs['data-valign'] = node.attrs.valign;
34
+ }
35
+ return attrs;
36
+ };
30
37
  export default class TableCell extends TableNodeView {
31
38
  constructor(node, view, getPos, eventDispatcher, editorAnalyticsAPI) {
32
39
  super(node, view, getPos, eventDispatcher);
@@ -147,8 +154,8 @@ export default class TableCell extends TableNodeView {
147
154
  if (this.node.type !== node.type) {
148
155
  return false;
149
156
  }
150
- const attrs = getCellDomAttrs(this.node);
151
- const nextAttrs = getCellDomAttrs(node);
157
+ const attrs = getCellDomAttrsForTableMenuUpdates(this.node);
158
+ const nextAttrs = getCellDomAttrsForTableMenuUpdates(node);
152
159
  const {
153
160
  colspan,
154
161
  rowspan
@@ -1,20 +1,20 @@
1
- import { createCommand, getPluginState } from '../plugin-factory';
2
- export const closeActiveTableMenu = () => createCommand(state => {
3
- const {
4
- activeTableMenu
5
- } = getPluginState(state);
6
- if (!activeTableMenu || activeTableMenu.type === 'none') {
7
- return false;
8
- }
9
- return {
1
+ import { pluginKey } from '../plugin-key';
2
+ export const closeActiveTableMenu = () => ({
3
+ tr
4
+ }) => {
5
+ tr.setMeta(pluginKey, {
10
6
  type: 'SET_ACTIVE_TABLE_MENU',
11
7
  data: {
12
8
  activeTableMenu: {
13
9
  type: 'none'
14
10
  }
15
11
  }
16
- };
17
- }, tr => tr.setMeta('addToHistory', false));
12
+ });
13
+ if (!tr.docChanged) {
14
+ tr.setMeta('addToHistory', false);
15
+ }
16
+ return tr;
17
+ };
18
18
  const isSameActiveTableMenu = (current, next) => {
19
19
  if (!current || current.type !== next.type) {
20
20
  return false;
@@ -24,16 +24,17 @@ const isSameActiveTableMenu = (current, next) => {
24
24
  }
25
25
  return true;
26
26
  };
27
- export const toggleActiveTableMenu = activeTableMenu => createCommand(state => {
28
- const {
29
- activeTableMenu: currentActiveTableMenu
30
- } = getPluginState(state);
31
- return {
27
+ export const toggleActiveTableMenu = (activeTableMenu, currentActiveTableMenu) => ({
28
+ tr
29
+ }) => {
30
+ tr.setMeta(pluginKey, {
32
31
  type: 'SET_ACTIVE_TABLE_MENU',
33
32
  data: {
34
33
  activeTableMenu: isSameActiveTableMenu(currentActiveTableMenu, activeTableMenu) ? {
35
34
  type: 'none'
36
35
  } : activeTableMenu
37
36
  }
38
- };
39
- }, tr => tr.setMeta('addToHistory', false));
37
+ });
38
+ tr.setMeta('addToHistory', false);
39
+ return tr;
40
+ };
@@ -42,11 +42,19 @@ export const toggleActiveTableMenuWithAnalytics = editorAnalyticsAPI => (directi
42
42
  };
43
43
  })(editorAnalyticsAPI)((state, dispatch) => {
44
44
  if (dispatch) {
45
- toggleActiveTableMenu({
45
+ const {
46
+ activeTableMenu: currentActiveTableMenu
47
+ } = getPluginState(state);
48
+ const newTr = toggleActiveTableMenu({
46
49
  type: direction,
47
50
  index,
48
51
  openedBy: trigger
49
- })(state, dispatch);
52
+ }, currentActiveTableMenu)({
53
+ tr: state.tr
54
+ });
55
+ if (newTr) {
56
+ dispatch(newTr);
57
+ }
50
58
  }
51
59
  return true;
52
60
  });
@@ -6,7 +6,7 @@ export { insertColumn, insertRow, createTable } from './insert';
6
6
  export { getNextLayout, toggleContextualMenu, toggleHeaderColumn, toggleHeaderRow, toggleNumberColumn, toggleTableLayout } from './toggle';
7
7
  export { closeActiveTableMenu, toggleActiveTableMenu } from './active-table-menu';
8
8
  export { clearMultipleCells } from './clear';
9
- export { autoSizeTable, convertFirstRowToHeader, deleteTable, hideInsertColumnOrRowButton, moveCursorBackward, selectColumn, selectColumns, selectRow, selectRows, setCellAttr, setEditorFocus, setMultipleCellAttrs, setTableRef, showInsertColumnButton, showInsertRowButton, transformSliceToAddTableHeaders, triggerUnlessTableHeader, addBoldInEmptyHeaderCells, addResizeHandleDecorations, updateWidthToWidest, setFocusToCellMenu } from './misc';
9
+ export { autoSizeTable, convertFirstRowToHeader, deleteTable, hideInsertColumnOrRowButton, moveCursorBackward, selectColumn, selectColumns, selectRow, selectRows, setCellAttr, setEditorFocus, setMultipleCellAttrs, setMultipleCellAttrsEditorCommand, setTableRef, showInsertColumnButton, showInsertRowButton, transformSliceToAddTableHeaders, triggerUnlessTableHeader, addBoldInEmptyHeaderCells, addResizeHandleDecorations, updateWidthToWidest, setFocusToCellMenu } from './misc';
10
10
  export { sortByColumn } from './sort';
11
11
  export { goToNextCell } from './go-to-next-cell';
12
12
  export { removeDescendantNodes } from './referentiality';
@@ -375,6 +375,37 @@ export const setMultipleCellAttrs = (attrs, editorView) => (state, dispatch) =>
375
375
  }
376
376
  return false;
377
377
  };
378
+
379
+ /**
380
+ * EditorCommand variant of `setMultipleCellAttrs`.
381
+ */
382
+ export const setMultipleCellAttrsEditorCommand = (attrs, targetCellPosition) => ({
383
+ tr
384
+ }) => {
385
+ let cursorPos;
386
+ if (isSelectionType(tr.selection, 'cell')) {
387
+ // Ignored via go/ees005
388
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
389
+ const selection = tr.selection;
390
+ selection.forEachCell((_cell, pos) => {
391
+ const $pos = tr.doc.resolve(tr.mapping.map(pos + 1));
392
+ // Ignored via go/ees005
393
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
394
+ setCellAttrs(findCellClosestToPos($pos), attrs)(tr);
395
+ });
396
+ cursorPos = selection.$headCell.pos;
397
+ } else if (typeof targetCellPosition === 'number') {
398
+ // Ignored via go/ees005
399
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
400
+ const cell = findCellClosestToPos(tr.doc.resolve(targetCellPosition + 1));
401
+ setCellAttrs(cell, attrs)(tr);
402
+ cursorPos = cell.pos;
403
+ }
404
+ if (tr.docChanged && cursorPos !== undefined) {
405
+ return tr;
406
+ }
407
+ return null;
408
+ };
378
409
  export const selectColumn = (column, expand, triggeredByKeyboard = false) => createCommand(state => {
379
410
  const cells = getCellsInColumn(column)(state.tr.selection);
380
411
  if (!cells || !cells.length || typeof cells[0].pos !== 'number') {