@atlaskit/editor-plugin-table 22.4.7 → 22.4.8

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 (45) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/ui/FloatingContextualButton/index.js +5 -0
  3. package/dist/cjs/ui/FloatingContextualMenu/CellMenuPopup.js +103 -0
  4. package/dist/cjs/ui/FloatingContextualMenu/index.js +13 -2
  5. package/dist/cjs/ui/TableMenu/cell/getCellMenuComponents.js +77 -0
  6. package/dist/cjs/ui/TableMenu/cell/items/MergeCellsItem.js +21 -0
  7. package/dist/cjs/ui/TableMenu/cell/items/SplitCellItem.js +21 -0
  8. package/dist/cjs/ui/TableMenu/cell/keys.js +40 -0
  9. package/dist/cjs/ui/TableMenu/column/items/MoveColumnRightItem.js +2 -6
  10. package/dist/cjs/ui/TableMenu/shared/TableMenu.js +2 -1
  11. package/dist/cjs/ui/TableMenu/shared/getSharedItems.js +28 -19
  12. package/dist/cjs/ui/TableMenu/shared/getTableMenuComponents.js +2 -1
  13. package/dist/es2019/ui/FloatingContextualButton/index.js +5 -0
  14. package/dist/es2019/ui/FloatingContextualMenu/CellMenuPopup.js +99 -0
  15. package/dist/es2019/ui/FloatingContextualMenu/index.js +13 -3
  16. package/dist/es2019/ui/TableMenu/cell/getCellMenuComponents.js +61 -0
  17. package/dist/es2019/ui/TableMenu/cell/items/MergeCellsItem.js +15 -0
  18. package/dist/es2019/ui/TableMenu/cell/items/SplitCellItem.js +15 -0
  19. package/dist/es2019/ui/TableMenu/cell/keys.js +42 -0
  20. package/dist/es2019/ui/TableMenu/column/items/MoveColumnRightItem.js +3 -5
  21. package/dist/es2019/ui/TableMenu/shared/TableMenu.js +2 -1
  22. package/dist/es2019/ui/TableMenu/shared/getSharedItems.js +9 -0
  23. package/dist/es2019/ui/TableMenu/shared/getTableMenuComponents.js +2 -1
  24. package/dist/esm/ui/FloatingContextualButton/index.js +5 -0
  25. package/dist/esm/ui/FloatingContextualMenu/CellMenuPopup.js +95 -0
  26. package/dist/esm/ui/FloatingContextualMenu/index.js +13 -3
  27. package/dist/esm/ui/TableMenu/cell/getCellMenuComponents.js +71 -0
  28. package/dist/esm/ui/TableMenu/cell/items/MergeCellsItem.js +14 -0
  29. package/dist/esm/ui/TableMenu/cell/items/SplitCellItem.js +14 -0
  30. package/dist/esm/ui/TableMenu/cell/keys.js +34 -0
  31. package/dist/esm/ui/TableMenu/column/items/MoveColumnRightItem.js +3 -7
  32. package/dist/esm/ui/TableMenu/shared/TableMenu.js +2 -1
  33. package/dist/esm/ui/TableMenu/shared/getSharedItems.js +9 -0
  34. package/dist/esm/ui/TableMenu/shared/getTableMenuComponents.js +2 -1
  35. package/dist/types/ui/FloatingContextualMenu/CellMenuPopup.d.ts +12 -0
  36. package/dist/types/ui/TableMenu/cell/getCellMenuComponents.d.ts +9 -0
  37. package/dist/types/ui/TableMenu/cell/items/MergeCellsItem.d.ts +2 -0
  38. package/dist/types/ui/TableMenu/cell/items/SplitCellItem.d.ts +2 -0
  39. package/dist/types/ui/TableMenu/cell/keys.d.ts +9 -0
  40. package/dist/types-ts4.5/ui/FloatingContextualMenu/CellMenuPopup.d.ts +12 -0
  41. package/dist/types-ts4.5/ui/TableMenu/cell/getCellMenuComponents.d.ts +9 -0
  42. package/dist/types-ts4.5/ui/TableMenu/cell/items/MergeCellsItem.d.ts +2 -0
  43. package/dist/types-ts4.5/ui/TableMenu/cell/items/SplitCellItem.d.ts +2 -0
  44. package/dist/types-ts4.5/ui/TableMenu/cell/keys.d.ts +9 -0
  45. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 22.4.8
4
+
5
+ ### Patch Changes
6
+
7
+ - [`98ee7ca379f42`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/98ee7ca379f42) -
8
+ Add experiment-gated table menu updates for cell menu
9
+ - Updated dependencies
10
+
3
11
  ## 22.4.7
4
12
 
5
13
  ### Patch Changes
@@ -57,6 +57,11 @@ var FloatingContextualButtonInner = /*#__PURE__*/_react.default.memo(function (p
57
57
  var handleClick = function handleClick() {
58
58
  var state = editorView.state,
59
59
  dispatch = editorView.dispatch;
60
+ if ((0, _expValEquals.expValEquals)('platform_editor_table_menu_updates', 'isEnabled', true)) {
61
+ (0, _commands.toggleContextualMenu)()(state, dispatch);
62
+ return;
63
+ }
64
+
60
65
  // Clicking outside the dropdown handles toggling the menu closed
61
66
  // (otherwise these two toggles combat each other).
62
67
  // In the event a user clicks the chevron button again
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+
3
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.CellMenuPopup = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _bindEventListener = require("bind-event-listener");
10
+ var _hooks = require("@atlaskit/editor-common/hooks");
11
+ var _userIntent = require("@atlaskit/editor-common/user-intent");
12
+ var _commands = require("../../pm-plugins/commands");
13
+ var _types = require("../../types");
14
+ var _keys = require("../TableMenu/cell/keys");
15
+ var _TableMenu = require("../TableMenu/shared/TableMenu");
16
+ 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); }
17
+ var CellMenuPopup = exports.CellMenuPopup = function CellMenuPopup(_ref) {
18
+ var api = _ref.api,
19
+ editorView = _ref.editorView,
20
+ isCellMenuOpenByKeyboard = _ref.isCellMenuOpenByKeyboard,
21
+ isOpen = _ref.isOpen,
22
+ targetCellRef = _ref.targetCellRef;
23
+ var tableMenuRef = (0, _react.useRef)(null);
24
+ var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['userIntent'], function (states) {
25
+ var _states$userIntentSta;
26
+ return {
27
+ currentUserIntent: (_states$userIntentSta = states.userIntentState) === null || _states$userIntentSta === void 0 ? void 0 : _states$userIntentSta.currentUserIntent
28
+ };
29
+ }),
30
+ currentUserIntent = _useSharedPluginState.currentUserIntent;
31
+ var closeCellMenu = (0, _react.useCallback)(function () {
32
+ var state = editorView.state,
33
+ dispatch = editorView.dispatch,
34
+ dom = editorView.dom;
35
+ (0, _commands.toggleContextualMenu)()(state, dispatch);
36
+ if (isCellMenuOpenByKeyboard) {
37
+ (0, _commands.setFocusToCellMenu)(false)(state, dispatch);
38
+ dom.focus();
39
+ }
40
+ }, [editorView, isCellMenuOpenByKeyboard]);
41
+ (0, _react.useEffect)(function () {
42
+ if (!isOpen || currentUserIntent !== 'tableDragMenuPopupOpen') {
43
+ return;
44
+ }
45
+ closeCellMenu();
46
+ }, [closeCellMenu, currentUserIntent, isOpen]);
47
+ (0, _react.useEffect)(function () {
48
+ if (!isOpen) {
49
+ return;
50
+ }
51
+ if (!(targetCellRef instanceof HTMLElement)) {
52
+ return;
53
+ }
54
+ var ownerDocument = targetCellRef.ownerDocument;
55
+ var handlePointerDown = function handlePointerDown(event) {
56
+ var _tableMenuRef$current;
57
+ var target = event.target;
58
+ if (!(target instanceof Node)) {
59
+ return;
60
+ }
61
+ if ((_tableMenuRef$current = tableMenuRef.current) !== null && _tableMenuRef$current !== void 0 && _tableMenuRef$current.contains(target)) {
62
+ return;
63
+ }
64
+ var cellMenuButton = ownerDocument.querySelector(".".concat(_types.TableCssClassName.CONTEXTUAL_MENU_BUTTON));
65
+ if (cellMenuButton !== null && cellMenuButton !== void 0 && cellMenuButton.contains(target)) {
66
+ return;
67
+ }
68
+ closeCellMenu();
69
+ };
70
+ var handleKeyDown = function handleKeyDown(event) {
71
+ if (event.key === 'Escape') {
72
+ closeCellMenu();
73
+ }
74
+ };
75
+ var unbindPointerDown = (0, _bindEventListener.bind)(ownerDocument, {
76
+ type: 'pointerdown',
77
+ listener: handlePointerDown,
78
+ options: {
79
+ capture: true
80
+ }
81
+ });
82
+ var unbindKeyDown = (0, _bindEventListener.bind)(ownerDocument, {
83
+ type: 'keydown',
84
+ listener: handleKeyDown,
85
+ options: {
86
+ capture: true
87
+ }
88
+ });
89
+ return function () {
90
+ unbindPointerDown();
91
+ unbindKeyDown();
92
+ };
93
+ }, [closeCellMenu, isOpen, targetCellRef]);
94
+ return /*#__PURE__*/_react.default.createElement(_userIntent.UserIntentPopupWrapper, {
95
+ api: api,
96
+ userIntent: "tableContextualMenuPopupOpen"
97
+ }, /*#__PURE__*/_react.default.createElement("div", {
98
+ ref: tableMenuRef
99
+ }, /*#__PURE__*/_react.default.createElement(_TableMenu.TableMenu, {
100
+ api: api,
101
+ surface: _keys.CELL_MENU
102
+ })));
103
+ };
@@ -10,8 +10,11 @@ var _ui = require("@atlaskit/editor-common/ui");
10
10
  var _utils = require("@atlaskit/editor-prosemirror/utils");
11
11
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
12
12
  var _utils2 = require("@atlaskit/editor-tables/utils");
13
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
13
14
  var _pluginFactory = require("../../pm-plugins/plugin-factory");
14
15
  var _consts = require("../consts");
16
+ var _consts2 = require("../TableMenu/shared/consts");
17
+ var _CellMenuPopup = require("./CellMenuPopup");
15
18
  var _ContextualMenu = _interopRequireDefault(require("./ContextualMenu"));
16
19
  var _styles = require("./styles");
17
20
  /**
@@ -72,7 +75,7 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
72
75
  boundariesElement: boundariesElement,
73
76
  scrollableElement: scrollableElement,
74
77
  fitHeight: _consts.tablePopupMenuFitHeight,
75
- fitWidth: _consts.contextualMenuDropdownWidthDnD
78
+ fitWidth: (0, _expValEquals.expValEquals)('platform_editor_table_menu_updates', 'isEnabled', true) ? _consts2.TABLE_MENU_WIDTH : _consts.contextualMenuDropdownWidthDnD
76
79
  // z-index value below is to ensure that this menu is above other floating menu
77
80
  // in table, but below floating dialogs like typeaheads, pickers, etc.
78
81
  ,
@@ -82,7 +85,15 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
82
85
  ,
83
86
  offset: [-7, 0],
84
87
  stick: true
85
- }, (0, _react.jsx)("div", {
88
+ }, (0, _expValEquals.expValEquals)('platform_editor_table_menu_updates', 'isEnabled', true) ? (0, _react.jsx)(_CellMenuPopup.CellMenuPopup, {
89
+ api: api,
90
+ editorView: editorView,
91
+ isCellMenuOpenByKeyboard: isCellMenuOpenByKeyboard,
92
+ isOpen: isOpen,
93
+ targetCellRef: targetCellRef
94
+ }) :
95
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
96
+ (0, _react.jsx)("div", {
86
97
  css: (0, _styles.tablePopupStyles)()
87
98
  }, (0, _react.jsx)(_ContextualMenu.default, {
88
99
  editorView: editorView
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getCellMenuComponents = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _editorToolbar = require("@atlaskit/editor-toolbar");
10
+ var _MergeCellsItem = require("./items/MergeCellsItem");
11
+ var _SplitCellItem = require("./items/SplitCellItem");
12
+ var _keys = require("./keys");
13
+ /**
14
+ * Returns the RegisterComponent[] array defining the cell contextual menu surface.
15
+ *
16
+ * This is a **UI-only stub** — all items are always visible with no conditional
17
+ * logic and no wired actions. Functional behaviour (actions, conditional visibility)
18
+ * will be connected in follow-up tickets.
19
+ */
20
+ var getCellMenuComponents = exports.getCellMenuComponents = function getCellMenuComponents() {
21
+ return [
22
+ // --- Menu surface ---
23
+ {
24
+ type: _keys.CELL_MENU.type,
25
+ key: _keys.CELL_MENU.key
26
+ },
27
+ // --- Main action section (Background color, Merge cells, Split cell) ---
28
+ {
29
+ type: _keys.CELL_ACTION_SECTION.type,
30
+ key: _keys.CELL_ACTION_SECTION.key,
31
+ parents: [{
32
+ type: _keys.CELL_MENU.type,
33
+ key: _keys.CELL_MENU.key,
34
+ rank: _keys.CELL_MENU_SECTION_RANK[_keys.CELL_ACTION_SECTION.key]
35
+ }],
36
+ component: function component(props) {
37
+ return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, null, props.children);
38
+ }
39
+ }, {
40
+ type: _keys.MERGE_CELLS_ITEM.type,
41
+ key: _keys.MERGE_CELLS_ITEM.key,
42
+ parents: [{
43
+ type: _keys.CELL_ACTION_SECTION.type,
44
+ key: _keys.CELL_ACTION_SECTION.key,
45
+ rank: _keys.CELL_ACTION_SECTION_RANK[_keys.MERGE_CELLS_ITEM.key]
46
+ }],
47
+ component: function component() {
48
+ return /*#__PURE__*/_react.default.createElement(_MergeCellsItem.MergeCellsItem, null);
49
+ }
50
+ }, {
51
+ type: _keys.SPLIT_CELL_ITEM.type,
52
+ key: _keys.SPLIT_CELL_ITEM.key,
53
+ parents: [{
54
+ type: _keys.CELL_ACTION_SECTION.type,
55
+ key: _keys.CELL_ACTION_SECTION.key,
56
+ rank: _keys.CELL_ACTION_SECTION_RANK[_keys.SPLIT_CELL_ITEM.key]
57
+ }],
58
+ component: function component() {
59
+ return /*#__PURE__*/_react.default.createElement(_SplitCellItem.SplitCellItem, null);
60
+ }
61
+ },
62
+ // --- Danger section (Clear cell) ---
63
+ {
64
+ type: _keys.CELL_DANGER_SECTION.type,
65
+ key: _keys.CELL_DANGER_SECTION.key,
66
+ parents: [{
67
+ type: _keys.CELL_MENU.type,
68
+ key: _keys.CELL_MENU.key,
69
+ rank: _keys.CELL_MENU_SECTION_RANK[_keys.CELL_DANGER_SECTION.key]
70
+ }],
71
+ component: function component(props) {
72
+ return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
73
+ hasSeparator: true
74
+ }, props.children);
75
+ }
76
+ }];
77
+ };
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.MergeCellsItem = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _reactIntl = require("react-intl");
10
+ var _messages = require("@atlaskit/editor-common/messages");
11
+ var _editorToolbar = require("@atlaskit/editor-toolbar");
12
+ var MergeCellsItem = exports.MergeCellsItem = function MergeCellsItem() {
13
+ var _useIntl = (0, _reactIntl.useIntl)(),
14
+ formatMessage = _useIntl.formatMessage;
15
+ return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
16
+ elemBefore: /*#__PURE__*/_react.default.createElement(_editorToolbar.TableCellMergeIcon, {
17
+ label: "",
18
+ size: "small"
19
+ })
20
+ }, formatMessage(_messages.tableMessages.mergeCells));
21
+ };
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.SplitCellItem = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _reactIntl = require("react-intl");
10
+ var _messages = require("@atlaskit/editor-common/messages");
11
+ var _editorToolbar = require("@atlaskit/editor-toolbar");
12
+ var SplitCellItem = exports.SplitCellItem = function SplitCellItem() {
13
+ var _useIntl = (0, _reactIntl.useIntl)(),
14
+ formatMessage = _useIntl.formatMessage;
15
+ return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
16
+ elemBefore: /*#__PURE__*/_react.default.createElement(_editorToolbar.TableCellSplitIcon, {
17
+ label: "",
18
+ size: "small"
19
+ })
20
+ }, formatMessage(_messages.tableMessages.splitCell));
21
+ };
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.SPLIT_CELL_ITEM = exports.MERGE_CELLS_ITEM = exports.CELL_MENU_SECTION_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
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _keys = require("../shared/keys");
10
+ // --- Menu surface ---
11
+
12
+ var CELL_MENU = exports.CELL_MENU = {
13
+ type: 'menu',
14
+ key: 'cell-contextual-menu'
15
+ };
16
+
17
+ // --- Sections ---
18
+
19
+ var CELL_ACTION_SECTION = exports.CELL_ACTION_SECTION = {
20
+ type: 'menu-section',
21
+ key: 'cell-action-section'
22
+ };
23
+ var CELL_DANGER_SECTION = exports.CELL_DANGER_SECTION = {
24
+ type: 'menu-section',
25
+ key: 'cell-danger-section'
26
+ };
27
+ var CELL_MENU_SECTION_RANK = exports.CELL_MENU_SECTION_RANK = (0, _defineProperty2.default)((0, _defineProperty2.default)({}, CELL_ACTION_SECTION.key, 100), CELL_DANGER_SECTION.key, 200);
28
+ var MERGE_CELLS_ITEM = exports.MERGE_CELLS_ITEM = {
29
+ type: 'menu-item',
30
+ key: 'merge-cells'
31
+ };
32
+ var SPLIT_CELL_ITEM = exports.SPLIT_CELL_ITEM = {
33
+ type: 'menu-item',
34
+ key: 'split-cell'
35
+ };
36
+
37
+ // --- Item ranks within their sections ---
38
+
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);
40
+ var CELL_DANGER_SECTION_RANK = exports.CELL_DANGER_SECTION_RANK = (0, _defineProperty2.default)({}, _keys.CLEAR_CELLS_ITEM.key, 100);
@@ -10,12 +10,8 @@ var _reactIntl = require("react-intl");
10
10
  var _keymaps = require("@atlaskit/editor-common/keymaps");
11
11
  var _messages = require("@atlaskit/editor-common/messages");
12
12
  var _editorToolbar = require("@atlaskit/editor-toolbar");
13
- var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
14
- var getMoveColumnRightShortcut = function getMoveColumnRightShortcut() {
15
- return (0, _keymaps.tooltip)((0, _expValEquals.expValEquals)('editor-a11y-fy26-keyboard-move-row-column', 'isEnabled', true) ? _keymaps.moveColumnRight : _keymaps.moveColumnRightOld);
16
- };
17
13
  var MoveColumnRightItem = exports.MoveColumnRightItem = function MoveColumnRightItem() {
18
- var _getMoveColumnRightSh;
14
+ var _tooltip;
19
15
  var _useIntl = (0, _reactIntl.useIntl)(),
20
16
  formatMessage = _useIntl.formatMessage;
21
17
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
@@ -25,7 +21,7 @@ var MoveColumnRightItem = exports.MoveColumnRightItem = function MoveColumnRight
25
21
  size: "small"
26
22
  }),
27
23
  elemAfter: /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarKeyboardShortcutHint, {
28
- shortcut: (_getMoveColumnRightSh = getMoveColumnRightShortcut()) !== null && _getMoveColumnRightSh !== void 0 ? _getMoveColumnRightSh : ''
24
+ shortcut: (_tooltip = (0, _keymaps.tooltip)(_keymaps.moveColumnRight)) !== null && _tooltip !== void 0 ? _tooltip : ''
29
25
  })
30
26
  }, formatMessage(_messages.tableMessages.moveColumnRight, {
31
27
  0: 1
@@ -32,4 +32,5 @@ var TableMenu = exports.TableMenu = /*#__PURE__*/(0, _react.memo)(function (_ref
32
32
  surface: surface,
33
33
  components: components
34
34
  }));
35
- });
35
+ });
36
+ TableMenu.displayName = 'TableMenu';
@@ -6,38 +6,47 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.getSharedItems = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
- var _keys = require("../column/keys");
10
- var _keys2 = require("../row/keys");
9
+ var _keys = require("../cell/keys");
10
+ var _keys2 = require("../column/keys");
11
+ var _keys3 = require("../row/keys");
11
12
  var _BackgroundColorItem = require("./items/BackgroundColorItem");
12
13
  var _ClearCellsItem = require("./items/ClearCellsItem");
13
- var _keys3 = require("./keys");
14
+ var _keys4 = require("./keys");
14
15
  var getSharedItems = exports.getSharedItems = function getSharedItems() {
15
16
  return [{
16
- type: _keys3.BACKGROUND_COLOR_ITEM.type,
17
- key: _keys3.BACKGROUND_COLOR_ITEM.key,
17
+ type: _keys4.BACKGROUND_COLOR_ITEM.type,
18
+ key: _keys4.BACKGROUND_COLOR_ITEM.key,
18
19
  parents: [{
19
- type: _keys2.ROW_BACKGROUND_SECTION.type,
20
- key: _keys2.ROW_BACKGROUND_SECTION.key,
21
- rank: _keys2.ROW_BACKGROUND_SECTION_RANK[_keys3.BACKGROUND_COLOR_ITEM.key]
20
+ type: _keys3.ROW_BACKGROUND_SECTION.type,
21
+ key: _keys3.ROW_BACKGROUND_SECTION.key,
22
+ rank: _keys3.ROW_BACKGROUND_SECTION_RANK[_keys4.BACKGROUND_COLOR_ITEM.key]
22
23
  }, {
23
- type: _keys.COLUMN_BACKGROUND_SECTION.type,
24
- key: _keys.COLUMN_BACKGROUND_SECTION.key,
25
- rank: _keys.COLUMN_BACKGROUND_SECTION_RANK[_keys3.BACKGROUND_COLOR_ITEM.key]
24
+ type: _keys2.COLUMN_BACKGROUND_SECTION.type,
25
+ key: _keys2.COLUMN_BACKGROUND_SECTION.key,
26
+ rank: _keys2.COLUMN_BACKGROUND_SECTION_RANK[_keys4.BACKGROUND_COLOR_ITEM.key]
27
+ }, {
28
+ type: _keys.CELL_ACTION_SECTION.type,
29
+ key: _keys.CELL_ACTION_SECTION.key,
30
+ rank: _keys.CELL_ACTION_SECTION_RANK[_keys4.BACKGROUND_COLOR_ITEM.key]
26
31
  }],
27
32
  component: function component() {
28
33
  return /*#__PURE__*/_react.default.createElement(_BackgroundColorItem.BackgroundColorItem, null);
29
34
  }
30
35
  }, {
31
- type: _keys3.CLEAR_CELLS_ITEM.type,
32
- key: _keys3.CLEAR_CELLS_ITEM.key,
36
+ type: _keys4.CLEAR_CELLS_ITEM.type,
37
+ key: _keys4.CLEAR_CELLS_ITEM.key,
33
38
  parents: [{
34
- type: _keys2.ROW_DANGER_SECTION.type,
35
- key: _keys2.ROW_DANGER_SECTION.key,
36
- rank: _keys2.ROW_DANGER_SECTION_RANK[_keys3.CLEAR_CELLS_ITEM.key]
39
+ type: _keys3.ROW_DANGER_SECTION.type,
40
+ key: _keys3.ROW_DANGER_SECTION.key,
41
+ rank: _keys3.ROW_DANGER_SECTION_RANK[_keys4.CLEAR_CELLS_ITEM.key]
42
+ }, {
43
+ type: _keys2.COLUMN_DANGER_SECTION.type,
44
+ key: _keys2.COLUMN_DANGER_SECTION.key,
45
+ rank: _keys2.COLUMN_DANGER_SECTION_RANK[_keys4.CLEAR_CELLS_ITEM.key]
37
46
  }, {
38
- type: _keys.COLUMN_DANGER_SECTION.type,
39
- key: _keys.COLUMN_DANGER_SECTION.key,
40
- rank: _keys.COLUMN_DANGER_SECTION_RANK[_keys3.CLEAR_CELLS_ITEM.key]
47
+ type: _keys.CELL_DANGER_SECTION.type,
48
+ key: _keys.CELL_DANGER_SECTION.key,
49
+ rank: _keys.CELL_DANGER_SECTION_RANK[_keys4.CLEAR_CELLS_ITEM.key]
41
50
  }],
42
51
  component: function component() {
43
52
  return /*#__PURE__*/_react.default.createElement(_ClearCellsItem.ClearCellsItem, null);
@@ -6,9 +6,10 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.getTableMenuComponents = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _getCellMenuComponents = require("../cell/getCellMenuComponents");
9
10
  var _getColumnMenuComponents = require("../column/getColumnMenuComponents");
10
11
  var _getRowMenuComponents = require("../row/getRowMenuComponents");
11
12
  var _getSharedItems = require("./getSharedItems");
12
13
  var getTableMenuComponents = exports.getTableMenuComponents = function getTableMenuComponents() {
13
- return [].concat((0, _toConsumableArray2.default)((0, _getRowMenuComponents.getRowMenuComponents)()), (0, _toConsumableArray2.default)((0, _getColumnMenuComponents.getColumnMenuComponents)()), (0, _toConsumableArray2.default)((0, _getSharedItems.getSharedItems)()));
14
+ return [].concat((0, _toConsumableArray2.default)((0, _getRowMenuComponents.getRowMenuComponents)()), (0, _toConsumableArray2.default)((0, _getColumnMenuComponents.getColumnMenuComponents)()), (0, _toConsumableArray2.default)((0, _getCellMenuComponents.getCellMenuComponents)()), (0, _toConsumableArray2.default)((0, _getSharedItems.getSharedItems)()));
14
15
  };
@@ -52,6 +52,11 @@ const FloatingContextualButtonInner = /*#__PURE__*/React.memo(props => {
52
52
  state,
53
53
  dispatch
54
54
  } = editorView;
55
+ if (expValEquals('platform_editor_table_menu_updates', 'isEnabled', true)) {
56
+ toggleContextualMenu()(state, dispatch);
57
+ return;
58
+ }
59
+
55
60
  // Clicking outside the dropdown handles toggling the menu closed
56
61
  // (otherwise these two toggles combat each other).
57
62
  // In the event a user clicks the chevron button again
@@ -0,0 +1,99 @@
1
+ import React, { useCallback, useEffect, useRef } from 'react';
2
+ import { bind } from 'bind-event-listener';
3
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
+ import { UserIntentPopupWrapper } from '@atlaskit/editor-common/user-intent';
5
+ import { setFocusToCellMenu, toggleContextualMenu } from '../../pm-plugins/commands';
6
+ import { TableCssClassName as ClassName } from '../../types';
7
+ import { CELL_MENU } from '../TableMenu/cell/keys';
8
+ import { TableMenu } from '../TableMenu/shared/TableMenu';
9
+ export const CellMenuPopup = ({
10
+ api,
11
+ editorView,
12
+ isCellMenuOpenByKeyboard,
13
+ isOpen,
14
+ targetCellRef
15
+ }) => {
16
+ const tableMenuRef = useRef(null);
17
+ const {
18
+ currentUserIntent
19
+ } = useSharedPluginStateWithSelector(api, ['userIntent'], states => {
20
+ var _states$userIntentSta;
21
+ return {
22
+ currentUserIntent: (_states$userIntentSta = states.userIntentState) === null || _states$userIntentSta === void 0 ? void 0 : _states$userIntentSta.currentUserIntent
23
+ };
24
+ });
25
+ const closeCellMenu = useCallback(() => {
26
+ const {
27
+ state,
28
+ dispatch,
29
+ dom
30
+ } = editorView;
31
+ toggleContextualMenu()(state, dispatch);
32
+ if (isCellMenuOpenByKeyboard) {
33
+ setFocusToCellMenu(false)(state, dispatch);
34
+ dom.focus();
35
+ }
36
+ }, [editorView, isCellMenuOpenByKeyboard]);
37
+ useEffect(() => {
38
+ if (!isOpen || currentUserIntent !== 'tableDragMenuPopupOpen') {
39
+ return;
40
+ }
41
+ closeCellMenu();
42
+ }, [closeCellMenu, currentUserIntent, isOpen]);
43
+ useEffect(() => {
44
+ if (!isOpen) {
45
+ return;
46
+ }
47
+ if (!(targetCellRef instanceof HTMLElement)) {
48
+ return;
49
+ }
50
+ const ownerDocument = targetCellRef.ownerDocument;
51
+ const handlePointerDown = event => {
52
+ var _tableMenuRef$current;
53
+ const target = event.target;
54
+ if (!(target instanceof Node)) {
55
+ return;
56
+ }
57
+ if ((_tableMenuRef$current = tableMenuRef.current) !== null && _tableMenuRef$current !== void 0 && _tableMenuRef$current.contains(target)) {
58
+ return;
59
+ }
60
+ const cellMenuButton = ownerDocument.querySelector(`.${ClassName.CONTEXTUAL_MENU_BUTTON}`);
61
+ if (cellMenuButton !== null && cellMenuButton !== void 0 && cellMenuButton.contains(target)) {
62
+ return;
63
+ }
64
+ closeCellMenu();
65
+ };
66
+ const handleKeyDown = event => {
67
+ if (event.key === 'Escape') {
68
+ closeCellMenu();
69
+ }
70
+ };
71
+ const unbindPointerDown = bind(ownerDocument, {
72
+ type: 'pointerdown',
73
+ listener: handlePointerDown,
74
+ options: {
75
+ capture: true
76
+ }
77
+ });
78
+ const unbindKeyDown = bind(ownerDocument, {
79
+ type: 'keydown',
80
+ listener: handleKeyDown,
81
+ options: {
82
+ capture: true
83
+ }
84
+ });
85
+ return () => {
86
+ unbindPointerDown();
87
+ unbindKeyDown();
88
+ };
89
+ }, [closeCellMenu, isOpen, targetCellRef]);
90
+ return /*#__PURE__*/React.createElement(UserIntentPopupWrapper, {
91
+ api: api,
92
+ userIntent: "tableContextualMenuPopupOpen"
93
+ }, /*#__PURE__*/React.createElement("div", {
94
+ ref: tableMenuRef
95
+ }, /*#__PURE__*/React.createElement(TableMenu, {
96
+ api: api,
97
+ surface: CELL_MENU
98
+ })));
99
+ };
@@ -8,9 +8,11 @@ import { Popup } from '@atlaskit/editor-common/ui';
8
8
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
9
9
  import { akEditorFloatingDialogZIndex, akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
10
10
  import { findCellRectClosestToPos, getSelectionRect, isSelectionType } from '@atlaskit/editor-tables/utils';
11
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
11
12
  import { getPluginState } from '../../pm-plugins/plugin-factory';
12
13
  import { contextualMenuDropdownWidthDnD, contextualMenuTriggerSize, tablePopupMenuFitHeight } from '../consts';
13
-
14
+ import { TABLE_MENU_WIDTH } from '../TableMenu/shared/consts';
15
+ import { CellMenuPopup } from './CellMenuPopup';
14
16
  // Ignored via go/ees005
15
17
  // eslint-disable-next-line import/no-named-as-default
16
18
  import ContextualMenu from './ContextualMenu';
@@ -68,7 +70,7 @@ const FloatingContextualMenu = ({
68
70
  boundariesElement: boundariesElement,
69
71
  scrollableElement: scrollableElement,
70
72
  fitHeight: tablePopupMenuFitHeight,
71
- fitWidth: contextualMenuDropdownWidthDnD
73
+ fitWidth: expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) ? TABLE_MENU_WIDTH : contextualMenuDropdownWidthDnD
72
74
  // z-index value below is to ensure that this menu is above other floating menu
73
75
  // in table, but below floating dialogs like typeaheads, pickers, etc.
74
76
  ,
@@ -78,7 +80,15 @@ const FloatingContextualMenu = ({
78
80
  ,
79
81
  offset: [-7, 0],
80
82
  stick: true
81
- }, jsx("div", {
83
+ }, expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) ? jsx(CellMenuPopup, {
84
+ api: api,
85
+ editorView: editorView,
86
+ isCellMenuOpenByKeyboard: isCellMenuOpenByKeyboard,
87
+ isOpen: isOpen,
88
+ targetCellRef: targetCellRef
89
+ }) :
90
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
91
+ jsx("div", {
82
92
  css: tablePopupStyles()
83
93
  }, jsx(ContextualMenu, {
84
94
  editorView: editorView
@@ -0,0 +1,61 @@
1
+ import React from 'react';
2
+ import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
3
+ import { MergeCellsItem } from './items/MergeCellsItem';
4
+ import { SplitCellItem } from './items/SplitCellItem';
5
+ import { CELL_MENU, CELL_ACTION_SECTION, CELL_DANGER_SECTION, CELL_MENU_SECTION_RANK, MERGE_CELLS_ITEM, SPLIT_CELL_ITEM, CELL_ACTION_SECTION_RANK } from './keys';
6
+
7
+ /**
8
+ * Returns the RegisterComponent[] array defining the cell contextual menu surface.
9
+ *
10
+ * This is a **UI-only stub** — all items are always visible with no conditional
11
+ * logic and no wired actions. Functional behaviour (actions, conditional visibility)
12
+ * will be connected in follow-up tickets.
13
+ */
14
+ export const getCellMenuComponents = () => [
15
+ // --- Menu surface ---
16
+ {
17
+ type: CELL_MENU.type,
18
+ key: CELL_MENU.key
19
+ },
20
+ // --- Main action section (Background color, Merge cells, Split cell) ---
21
+ {
22
+ type: CELL_ACTION_SECTION.type,
23
+ key: CELL_ACTION_SECTION.key,
24
+ parents: [{
25
+ type: CELL_MENU.type,
26
+ key: CELL_MENU.key,
27
+ rank: CELL_MENU_SECTION_RANK[CELL_ACTION_SECTION.key]
28
+ }],
29
+ component: props => /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, props.children)
30
+ }, {
31
+ type: MERGE_CELLS_ITEM.type,
32
+ key: MERGE_CELLS_ITEM.key,
33
+ parents: [{
34
+ type: CELL_ACTION_SECTION.type,
35
+ key: CELL_ACTION_SECTION.key,
36
+ rank: CELL_ACTION_SECTION_RANK[MERGE_CELLS_ITEM.key]
37
+ }],
38
+ component: () => /*#__PURE__*/React.createElement(MergeCellsItem, null)
39
+ }, {
40
+ type: SPLIT_CELL_ITEM.type,
41
+ key: SPLIT_CELL_ITEM.key,
42
+ parents: [{
43
+ type: CELL_ACTION_SECTION.type,
44
+ key: CELL_ACTION_SECTION.key,
45
+ rank: CELL_ACTION_SECTION_RANK[SPLIT_CELL_ITEM.key]
46
+ }],
47
+ component: () => /*#__PURE__*/React.createElement(SplitCellItem, null)
48
+ },
49
+ // --- Danger section (Clear cell) ---
50
+ {
51
+ type: CELL_DANGER_SECTION.type,
52
+ key: CELL_DANGER_SECTION.key,
53
+ parents: [{
54
+ type: CELL_MENU.type,
55
+ key: CELL_MENU.key,
56
+ rank: CELL_MENU_SECTION_RANK[CELL_DANGER_SECTION.key]
57
+ }],
58
+ component: props => /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
59
+ hasSeparator: true
60
+ }, props.children)
61
+ }];