@atlaskit/editor-plugin-table 24.3.14 → 24.4.1

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 (73) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/cjs/nodeviews/TableResizer.js +4 -10
  3. package/dist/cjs/nodeviews/TableSSRReactContextsProvider.js +23 -0
  4. package/dist/cjs/nodeviews/table-node-views.js +1 -1
  5. package/dist/cjs/nodeviews/table.js +14 -21
  6. package/dist/cjs/pm-plugins/commands/insert.js +10 -1
  7. package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +12 -25
  8. package/dist/cjs/pm-plugins/main.js +3 -1
  9. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +10 -22
  10. package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +2 -1
  11. package/dist/cjs/tablePlugin.js +10 -1
  12. package/dist/cjs/ui/TableMenu/cell/getCellMenuComponents.js +153 -1
  13. package/dist/cjs/ui/TableMenu/cell/keys.js +19 -5
  14. package/dist/cjs/ui/TableMenu/column/getColumnMenuComponents.js +166 -1
  15. package/dist/cjs/ui/TableMenu/column/items/AddColumnRightItem.js +2 -2
  16. package/dist/cjs/ui/TableMenu/column/items/DeleteColumnItem.js +3 -3
  17. package/dist/cjs/ui/TableMenu/column/items/DistributeColumnsItem.js +2 -2
  18. package/dist/cjs/ui/TableMenu/row/getRowMenuComponents.js +136 -1
  19. package/dist/cjs/ui/TableMenu/row/items/AddRowBelowItem.js +2 -2
  20. package/dist/cjs/ui/TableMenu/row/items/DeleteRowItem.js +3 -3
  21. package/dist/cjs/ui/TableMenu/shared/getSharedItems.js +141 -1
  22. package/dist/cjs/ui/TableMenu/shared/selection.js +19 -0
  23. package/dist/es2019/nodeviews/TableResizer.js +4 -10
  24. package/dist/es2019/nodeviews/TableSSRReactContextsProvider.js +17 -0
  25. package/dist/es2019/nodeviews/table-node-views.js +1 -1
  26. package/dist/es2019/nodeviews/table.js +15 -22
  27. package/dist/es2019/pm-plugins/commands/insert.js +10 -1
  28. package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +12 -25
  29. package/dist/es2019/pm-plugins/main.js +4 -2
  30. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +10 -22
  31. package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +2 -1
  32. package/dist/es2019/tablePlugin.js +10 -1
  33. package/dist/es2019/ui/TableMenu/cell/getCellMenuComponents.js +134 -2
  34. package/dist/es2019/ui/TableMenu/cell/keys.js +25 -2
  35. package/dist/es2019/ui/TableMenu/column/getColumnMenuComponents.js +144 -1
  36. package/dist/es2019/ui/TableMenu/column/items/AddColumnRightItem.js +2 -2
  37. package/dist/es2019/ui/TableMenu/column/items/DeleteColumnItem.js +3 -3
  38. package/dist/es2019/ui/TableMenu/column/items/DistributeColumnsItem.js +2 -2
  39. package/dist/es2019/ui/TableMenu/row/getRowMenuComponents.js +118 -1
  40. package/dist/es2019/ui/TableMenu/row/items/AddRowBelowItem.js +2 -2
  41. package/dist/es2019/ui/TableMenu/row/items/DeleteRowItem.js +3 -3
  42. package/dist/es2019/ui/TableMenu/shared/getSharedItems.js +130 -4
  43. package/dist/es2019/ui/TableMenu/shared/selection.js +14 -0
  44. package/dist/esm/nodeviews/TableResizer.js +4 -10
  45. package/dist/esm/nodeviews/TableSSRReactContextsProvider.js +16 -0
  46. package/dist/esm/nodeviews/table-node-views.js +1 -1
  47. package/dist/esm/nodeviews/table.js +15 -22
  48. package/dist/esm/pm-plugins/commands/insert.js +10 -1
  49. package/dist/esm/pm-plugins/drag-and-drop/plugin.js +12 -25
  50. package/dist/esm/pm-plugins/main.js +4 -2
  51. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +10 -22
  52. package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +2 -1
  53. package/dist/esm/tablePlugin.js +10 -1
  54. package/dist/esm/ui/TableMenu/cell/getCellMenuComponents.js +154 -2
  55. package/dist/esm/ui/TableMenu/cell/keys.js +16 -2
  56. package/dist/esm/ui/TableMenu/column/getColumnMenuComponents.js +166 -1
  57. package/dist/esm/ui/TableMenu/column/items/AddColumnRightItem.js +2 -2
  58. package/dist/esm/ui/TableMenu/column/items/DeleteColumnItem.js +3 -3
  59. package/dist/esm/ui/TableMenu/column/items/DistributeColumnsItem.js +2 -2
  60. package/dist/esm/ui/TableMenu/row/getRowMenuComponents.js +136 -1
  61. package/dist/esm/ui/TableMenu/row/items/AddRowBelowItem.js +2 -2
  62. package/dist/esm/ui/TableMenu/row/items/DeleteRowItem.js +3 -3
  63. package/dist/esm/ui/TableMenu/shared/getSharedItems.js +144 -4
  64. package/dist/esm/ui/TableMenu/shared/selection.js +14 -0
  65. package/dist/types/nodeviews/TableSSRReactContextsProvider.d.ts +8 -0
  66. package/dist/types/nodeviews/table-node-views.d.ts +2 -0
  67. package/dist/types/nodeviews/table.d.ts +3 -1
  68. package/dist/types/nodeviews/types.d.ts +2 -0
  69. package/dist/types/tablePluginType.d.ts +3 -2
  70. package/dist/types/ui/TableMenu/cell/keys.d.ts +2 -0
  71. package/dist/types/ui/TableMenu/column/getColumnMenuComponents.d.ts +1 -1
  72. package/dist/types/ui/TableMenu/shared/selection.d.ts +8 -0
  73. package/package.json +9 -3
@@ -1,3 +1,5 @@
1
+ import { ADD_COLUMN_RIGHT_ITEM, DELETE_COLUMN_ITEM, DISTRIBUTE_COLUMNS_ITEM } from '../column/keys';
2
+ import { ADD_ROW_BELOW_ITEM, DELETE_ROW_ITEM } from '../row/keys';
1
3
  import { BACKGROUND_COLOR_ITEM, CLEAR_CELLS_ITEM } from '../shared/keys';
2
4
 
3
5
  // --- Menu surface ---
@@ -13,13 +15,18 @@ export const CELL_ACTION_SECTION = {
13
15
  type: 'menu-section',
14
16
  key: 'cell-action-section'
15
17
  };
18
+ export const CELL_ADD_SECTION = {
19
+ type: 'menu-section',
20
+ key: 'cell-add-section'
21
+ };
16
22
  export const CELL_DANGER_SECTION = {
17
23
  type: 'menu-section',
18
24
  key: 'cell-danger-section'
19
25
  };
20
26
  export const CELL_MENU_RANK = {
21
27
  [CELL_ACTION_SECTION.key]: 100,
22
- [CELL_DANGER_SECTION.key]: 200
28
+ [CELL_ADD_SECTION.key]: 200,
29
+ [CELL_DANGER_SECTION.key]: 300
23
30
  };
24
31
  export const MERGE_CELLS_ITEM = {
25
32
  type: 'menu-item',
@@ -51,6 +58,10 @@ export const VERTICAL_ALIGN_BOTTOM_ITEM = {
51
58
  };
52
59
 
53
60
  // --- Item ranks within their sections ---
61
+ //
62
+ // The add/delete items rendered in the cell menu are shared with the row/column
63
+ // menus (registered once in `../shared/getSharedItems` with multiple parents), so
64
+ // we reuse their existing keys here rather than declaring cell-specific ones.
54
65
 
55
66
  export const CELL_ACTION_SECTION_RANK = {
56
67
  [BACKGROUND_COLOR_ITEM.key]: 100,
@@ -66,6 +77,18 @@ export const VERTICAL_ALIGN_MENU_SECTION_RANK = {
66
77
  [VERTICAL_ALIGN_MIDDLE_ITEM.key]: 200,
67
78
  [VERTICAL_ALIGN_BOTTOM_ITEM.key]: 300
68
79
  };
80
+
81
+ // Merge/Split cells are relocated from the action section into the add section when the
82
+ // cell menu update gate is on; they sit at the top of the section.
83
+ export const CELL_ADD_SECTION_RANK = {
84
+ [MERGE_CELLS_ITEM.key]: 100,
85
+ [SPLIT_CELL_ITEM.key]: 200,
86
+ [ADD_COLUMN_RIGHT_ITEM.key]: 300,
87
+ [ADD_ROW_BELOW_ITEM.key]: 400,
88
+ [DISTRIBUTE_COLUMNS_ITEM.key]: 500
89
+ };
69
90
  export const CELL_DANGER_SECTION_RANK = {
70
- [CLEAR_CELLS_ITEM.key]: 100
91
+ [CLEAR_CELLS_ITEM.key]: 100,
92
+ [DELETE_COLUMN_ITEM.key]: 200,
93
+ [DELETE_ROW_ITEM.key]: 300
71
94
  };
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import { AddColumnLeftItem } from './items/AddColumnLeftItem';
4
5
  import { AddColumnRightItem } from './items/AddColumnRightItem';
5
6
  import { ColumnBackgroundSection } from './items/ColumnBackgroundSection';
@@ -14,7 +15,149 @@ import { SortIncreasingItem } from './items/SortIncreasingItem';
14
15
  import { COLUMN_MENU, COLUMN_TOGGLE_SECTION, COLUMN_BACKGROUND_SECTION, COLUMN_SORT_SECTION, COLUMN_ADD_SECTION, COLUMN_DANGER_SECTION, COLUMN_SECTION_RANK, HEADER_COLUMN_TOGGLE_ITEM, SORT_INCREASING_ITEM, SORT_DECREASING_ITEM, ADD_COLUMN_LEFT_ITEM, ADD_COLUMN_RIGHT_ITEM, MOVE_COLUMN_LEFT_ITEM, MOVE_COLUMN_RIGHT_ITEM, DISTRIBUTE_COLUMNS_ITEM, DELETE_COLUMN_ITEM, COLUMN_TOGGLE_SECTION_RANK, COLUMN_SORT_SECTION_RANK, COLUMN_ADD_SECTION_RANK, COLUMN_DANGER_SECTION_RANK } from './keys';
15
16
  export const getColumnMenuComponents = ({
16
17
  api
17
- }) => [
18
+ }) => fg('platform_editor_table_cell_menu_update') ? [
19
+ // --- Cell menu update ON ---
20
+ // AddColumnRightItem/DistributeColumnsItem/DeleteColumnItem are registered in
21
+ // `../shared/getSharedItems` (shared with the cell menu), so they are omitted here.
22
+
23
+ // --- Menu surface ---
24
+ {
25
+ type: COLUMN_MENU.type,
26
+ key: COLUMN_MENU.key
27
+ },
28
+ // --- Toggle section (Header column) ---
29
+ {
30
+ type: COLUMN_TOGGLE_SECTION.type,
31
+ key: COLUMN_TOGGLE_SECTION.key,
32
+ parents: [{
33
+ type: COLUMN_MENU.type,
34
+ key: COLUMN_MENU.key,
35
+ rank: COLUMN_SECTION_RANK[COLUMN_TOGGLE_SECTION.key]
36
+ }],
37
+ component: props => /*#__PURE__*/React.createElement(ColumnToggleSection, {
38
+ api: api
39
+ }, props.children)
40
+ }, {
41
+ type: HEADER_COLUMN_TOGGLE_ITEM.type,
42
+ key: HEADER_COLUMN_TOGGLE_ITEM.key,
43
+ parents: [{
44
+ type: COLUMN_TOGGLE_SECTION.type,
45
+ key: COLUMN_TOGGLE_SECTION.key,
46
+ rank: COLUMN_TOGGLE_SECTION_RANK[HEADER_COLUMN_TOGGLE_ITEM.key]
47
+ }],
48
+ component: () => /*#__PURE__*/React.createElement(HeaderColumnToggleItem, {
49
+ api: api
50
+ })
51
+ },
52
+ // --- Background color section ---
53
+ {
54
+ type: COLUMN_BACKGROUND_SECTION.type,
55
+ key: COLUMN_BACKGROUND_SECTION.key,
56
+ parents: [{
57
+ type: COLUMN_MENU.type,
58
+ key: COLUMN_MENU.key,
59
+ rank: COLUMN_SECTION_RANK[COLUMN_BACKGROUND_SECTION.key]
60
+ }],
61
+ component: props => /*#__PURE__*/React.createElement(ColumnBackgroundSection, {
62
+ api: api
63
+ }, props.children)
64
+ },
65
+ // --- Sort section ---
66
+ {
67
+ type: COLUMN_SORT_SECTION.type,
68
+ key: COLUMN_SORT_SECTION.key,
69
+ parents: [{
70
+ type: COLUMN_MENU.type,
71
+ key: COLUMN_MENU.key,
72
+ rank: COLUMN_SECTION_RANK[COLUMN_SORT_SECTION.key]
73
+ }],
74
+ component: props => /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
75
+ hasSeparator: true
76
+ }, props.children)
77
+ }, {
78
+ type: SORT_INCREASING_ITEM.type,
79
+ key: SORT_INCREASING_ITEM.key,
80
+ parents: [{
81
+ type: COLUMN_SORT_SECTION.type,
82
+ key: COLUMN_SORT_SECTION.key,
83
+ rank: COLUMN_SORT_SECTION_RANK[SORT_INCREASING_ITEM.key]
84
+ }],
85
+ component: () => /*#__PURE__*/React.createElement(SortIncreasingItem, {
86
+ api: api
87
+ })
88
+ }, {
89
+ type: SORT_DECREASING_ITEM.type,
90
+ key: SORT_DECREASING_ITEM.key,
91
+ parents: [{
92
+ type: COLUMN_SORT_SECTION.type,
93
+ key: COLUMN_SORT_SECTION.key,
94
+ rank: COLUMN_SORT_SECTION_RANK[SORT_DECREASING_ITEM.key]
95
+ }],
96
+ component: () => /*#__PURE__*/React.createElement(SortDecreasingItem, {
97
+ api: api
98
+ })
99
+ },
100
+ // --- Add / Move section ---
101
+ {
102
+ type: COLUMN_ADD_SECTION.type,
103
+ key: COLUMN_ADD_SECTION.key,
104
+ parents: [{
105
+ type: COLUMN_MENU.type,
106
+ key: COLUMN_MENU.key,
107
+ rank: COLUMN_SECTION_RANK[COLUMN_ADD_SECTION.key]
108
+ }],
109
+ component: props => /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
110
+ hasSeparator: true
111
+ }, props.children)
112
+ }, {
113
+ type: ADD_COLUMN_LEFT_ITEM.type,
114
+ key: ADD_COLUMN_LEFT_ITEM.key,
115
+ parents: [{
116
+ type: COLUMN_ADD_SECTION.type,
117
+ key: COLUMN_ADD_SECTION.key,
118
+ rank: COLUMN_ADD_SECTION_RANK[ADD_COLUMN_LEFT_ITEM.key]
119
+ }],
120
+ component: () => /*#__PURE__*/React.createElement(AddColumnLeftItem, {
121
+ api: api
122
+ })
123
+ }, {
124
+ type: MOVE_COLUMN_LEFT_ITEM.type,
125
+ key: MOVE_COLUMN_LEFT_ITEM.key,
126
+ parents: [{
127
+ type: COLUMN_ADD_SECTION.type,
128
+ key: COLUMN_ADD_SECTION.key,
129
+ rank: COLUMN_ADD_SECTION_RANK[MOVE_COLUMN_LEFT_ITEM.key]
130
+ }],
131
+ component: () => /*#__PURE__*/React.createElement(MoveColumnLeftItem, {
132
+ api: api
133
+ })
134
+ }, {
135
+ type: MOVE_COLUMN_RIGHT_ITEM.type,
136
+ key: MOVE_COLUMN_RIGHT_ITEM.key,
137
+ parents: [{
138
+ type: COLUMN_ADD_SECTION.type,
139
+ key: COLUMN_ADD_SECTION.key,
140
+ rank: COLUMN_ADD_SECTION_RANK[MOVE_COLUMN_RIGHT_ITEM.key]
141
+ }],
142
+ component: () => /*#__PURE__*/React.createElement(MoveColumnRightItem, {
143
+ api: api
144
+ })
145
+ },
146
+ // --- Danger section (Clear cells, Delete column) ---
147
+ {
148
+ type: COLUMN_DANGER_SECTION.type,
149
+ key: COLUMN_DANGER_SECTION.key,
150
+ parents: [{
151
+ type: COLUMN_MENU.type,
152
+ key: COLUMN_MENU.key,
153
+ rank: COLUMN_SECTION_RANK[COLUMN_DANGER_SECTION.key]
154
+ }],
155
+ component: props => /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
156
+ hasSeparator: true
157
+ }, props.children)
158
+ }] : [
159
+ // --- Cell menu update OFF: legacy column menu (registers its own add/delete items) ---
160
+
18
161
  // --- Menu surface ---
19
162
  {
20
163
  type: COLUMN_MENU.type,
@@ -4,10 +4,10 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
5
5
  import { addColumnAfter, tooltip } from '@atlaskit/editor-common/keymaps';
6
6
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
7
- import { getSelectionRect } from '@atlaskit/editor-tables/utils';
8
7
  import { TableColumnAddRightIcon, ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
9
8
  import { closeActiveTableMenu } from '../../../../pm-plugins/commands';
10
9
  import { insertColumnWithAnalytics } from '../../../../pm-plugins/commands/commands-with-analytics';
10
+ import { getMenuSelectionRect } from '../../shared/selection';
11
11
  import { useTableMenuContext } from '../../shared/TableMenuContext';
12
12
  export const AddColumnRightItem = ({
13
13
  api
@@ -36,7 +36,7 @@ export const AddColumnRightItem = ({
36
36
  if (!editorView) {
37
37
  return;
38
38
  }
39
- const selectionRect = getSelectionRect(editorView.state.selection);
39
+ const selectionRect = getMenuSelectionRect(editorView.state.selection);
40
40
  const index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.right;
41
41
  if (index === undefined) {
42
42
  return;
@@ -4,11 +4,11 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
5
5
  import { deleteColumn, tooltip } from '@atlaskit/editor-common/keymaps';
6
6
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
7
- import { getSelectionRect } from '@atlaskit/editor-tables/utils';
8
7
  import { DeleteIcon, ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
9
8
  import { clearHoverSelection, closeActiveTableMenu, hoverColumns } from '../../../../pm-plugins/commands';
10
9
  import { deleteColumnsWithAnalytics } from '../../../../pm-plugins/commands/commands-with-analytics';
11
10
  import { getSelectedColumnIndexes } from '../../../../pm-plugins/utils/selection';
11
+ import { getMenuSelectionRect } from '../../shared/selection';
12
12
  import { useTableMenuContext } from '../../shared/TableMenuContext';
13
13
  export const DeleteColumnItem = ({
14
14
  api
@@ -38,7 +38,7 @@ export const DeleteColumnItem = ({
38
38
  if (!editorView) {
39
39
  return;
40
40
  }
41
- const selectionRect = getSelectionRect(editorView.state.selection);
41
+ const selectionRect = getMenuSelectionRect(editorView.state.selection);
42
42
  if (!selectionRect) {
43
43
  return;
44
44
  }
@@ -55,7 +55,7 @@ export const DeleteColumnItem = ({
55
55
  if (!editorView) {
56
56
  return;
57
57
  }
58
- const selectionRect = getSelectionRect(editorView.state.selection);
58
+ const selectionRect = getMenuSelectionRect(editorView.state.selection);
59
59
  if (!selectionRect) {
60
60
  return;
61
61
  }
@@ -3,11 +3,11 @@ import { useIntl } from 'react-intl';
3
3
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
5
5
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
6
- import { getSelectionRect } from '@atlaskit/editor-tables/utils';
7
6
  import { TableColumnsDistributeIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
8
7
  import { closeActiveTableMenu } from '../../../../pm-plugins/commands';
9
8
  import { distributeColumnsWidthsWithAnalytics } from '../../../../pm-plugins/commands/commands-with-analytics';
10
9
  import { getNewResizeStateFromSelectedColumns } from '../../../../pm-plugins/table-resizing/utils/resize-state';
10
+ import { getMenuSelectionRect } from '../../shared/selection';
11
11
  import { useTableMenuContext } from '../../shared/TableMenuContext';
12
12
  /** Distribute columns is only visible when more than one column is selected. */
13
13
  const shouldShowDistributeColumns = selectedColumnCount => (selectedColumnCount !== null && selectedColumnCount !== void 0 ? selectedColumnCount : 0) > 1;
@@ -38,7 +38,7 @@ export const DistributeColumnsItem = ({
38
38
  if (!editorView) {
39
39
  return;
40
40
  }
41
- const selectionRect = getSelectionRect(editorView.state.selection);
41
+ const selectionRect = getMenuSelectionRect(editorView.state.selection);
42
42
  const editorContainerWidth = api === null || api === void 0 ? void 0 : (_api$width = api.width) === null || _api$width === void 0 ? void 0 : _api$width.sharedState.currentState();
43
43
  if (!selectionRect || !editorContainerWidth) {
44
44
  return;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import { AddRowAboveItem } from './items/AddRowAboveItem';
4
5
  import { AddRowBelowItem } from './items/AddRowBelowItem';
5
6
  import { DeleteRowItem } from './items/DeleteRowItem';
@@ -10,7 +11,123 @@ import { NumberedRowsToggleItem } from './items/NumberedRowsToggleItem';
10
11
  import { ROW_MENU, ROW_TOGGLE_SECTION, ROW_BACKGROUND_SECTION, ROW_ADD_SECTION, ROW_DANGER_SECTION, ROW_MENU_SECTION_RANK, HEADER_ROW_TOGGLE_ITEM, NUMBERED_ROWS_TOGGLE_ITEM, ADD_ROW_ABOVE_ITEM, ADD_ROW_BELOW_ITEM, MOVE_ROW_UP_ITEM, MOVE_ROW_DOWN_ITEM, DELETE_ROW_ITEM, ROW_TOGGLE_SECTION_RANK, ROW_ADD_SECTION_RANK, ROW_DANGER_SECTION_RANK } from './keys';
11
12
  export const getRowMenuComponents = ({
12
13
  api
13
- }) => [
14
+ }) => fg('platform_editor_table_cell_menu_update') ? [
15
+ // --- Cell menu update ON ---
16
+ // AddRowBelowItem/DeleteRowItem are registered in `../shared/getSharedItems`
17
+ // (shared with the cell menu), so they are omitted here.
18
+
19
+ // --- Menu surface ---
20
+ {
21
+ type: ROW_MENU.type,
22
+ key: ROW_MENU.key
23
+ },
24
+ // --- Toggle section (Header row, Numbered rows) ---
25
+ {
26
+ type: ROW_TOGGLE_SECTION.type,
27
+ key: ROW_TOGGLE_SECTION.key,
28
+ parents: [{
29
+ type: ROW_MENU.type,
30
+ key: ROW_MENU.key,
31
+ rank: ROW_MENU_SECTION_RANK[ROW_TOGGLE_SECTION.key]
32
+ }],
33
+ component: props => /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, props.children)
34
+ }, {
35
+ type: HEADER_ROW_TOGGLE_ITEM.type,
36
+ key: HEADER_ROW_TOGGLE_ITEM.key,
37
+ parents: [{
38
+ type: ROW_TOGGLE_SECTION.type,
39
+ key: ROW_TOGGLE_SECTION.key,
40
+ rank: ROW_TOGGLE_SECTION_RANK[HEADER_ROW_TOGGLE_ITEM.key]
41
+ }],
42
+ component: () => /*#__PURE__*/React.createElement(HeaderRowToggleItem, {
43
+ api: api
44
+ })
45
+ }, {
46
+ type: NUMBERED_ROWS_TOGGLE_ITEM.type,
47
+ key: NUMBERED_ROWS_TOGGLE_ITEM.key,
48
+ parents: [{
49
+ type: ROW_TOGGLE_SECTION.type,
50
+ key: ROW_TOGGLE_SECTION.key,
51
+ rank: ROW_TOGGLE_SECTION_RANK[NUMBERED_ROWS_TOGGLE_ITEM.key]
52
+ }],
53
+ component: () => /*#__PURE__*/React.createElement(NumberedRowsToggleItem, {
54
+ api: api
55
+ })
56
+ },
57
+ // --- Background color section ---
58
+ {
59
+ type: ROW_BACKGROUND_SECTION.type,
60
+ key: ROW_BACKGROUND_SECTION.key,
61
+ parents: [{
62
+ type: ROW_MENU.type,
63
+ key: ROW_MENU.key,
64
+ rank: ROW_MENU_SECTION_RANK[ROW_BACKGROUND_SECTION.key]
65
+ }],
66
+ component: props => /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
67
+ hasSeparator: true
68
+ }, props.children)
69
+ },
70
+ // --- Add / Move section ---
71
+ {
72
+ type: ROW_ADD_SECTION.type,
73
+ key: ROW_ADD_SECTION.key,
74
+ parents: [{
75
+ type: ROW_MENU.type,
76
+ key: ROW_MENU.key,
77
+ rank: ROW_MENU_SECTION_RANK[ROW_ADD_SECTION.key]
78
+ }],
79
+ component: props => /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
80
+ hasSeparator: true
81
+ }, props.children)
82
+ }, {
83
+ type: ADD_ROW_ABOVE_ITEM.type,
84
+ key: ADD_ROW_ABOVE_ITEM.key,
85
+ parents: [{
86
+ type: ROW_ADD_SECTION.type,
87
+ key: ROW_ADD_SECTION.key,
88
+ rank: ROW_ADD_SECTION_RANK[ADD_ROW_ABOVE_ITEM.key]
89
+ }],
90
+ component: () => /*#__PURE__*/React.createElement(AddRowAboveItem, {
91
+ api: api
92
+ })
93
+ }, {
94
+ type: MOVE_ROW_UP_ITEM.type,
95
+ key: MOVE_ROW_UP_ITEM.key,
96
+ parents: [{
97
+ type: ROW_ADD_SECTION.type,
98
+ key: ROW_ADD_SECTION.key,
99
+ rank: ROW_ADD_SECTION_RANK[MOVE_ROW_UP_ITEM.key]
100
+ }],
101
+ component: () => /*#__PURE__*/React.createElement(MoveRowUpItem, {
102
+ api: api
103
+ })
104
+ }, {
105
+ type: MOVE_ROW_DOWN_ITEM.type,
106
+ key: MOVE_ROW_DOWN_ITEM.key,
107
+ parents: [{
108
+ type: ROW_ADD_SECTION.type,
109
+ key: ROW_ADD_SECTION.key,
110
+ rank: ROW_ADD_SECTION_RANK[MOVE_ROW_DOWN_ITEM.key]
111
+ }],
112
+ component: () => /*#__PURE__*/React.createElement(MoveRowDownItem, {
113
+ api: api
114
+ })
115
+ },
116
+ // --- Danger section (Clear cells, Delete row) ---
117
+ {
118
+ type: ROW_DANGER_SECTION.type,
119
+ key: ROW_DANGER_SECTION.key,
120
+ parents: [{
121
+ type: ROW_MENU.type,
122
+ key: ROW_MENU.key,
123
+ rank: ROW_MENU_SECTION_RANK[ROW_DANGER_SECTION.key]
124
+ }],
125
+ component: props => /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
126
+ hasSeparator: true
127
+ }, props.children)
128
+ }] : [
129
+ // --- Cell menu update OFF: legacy row menu (registers its own add/delete items) ---
130
+
14
131
  // --- Menu surface ---
15
132
  {
16
133
  type: ROW_MENU.type,
@@ -3,10 +3,10 @@ import { useIntl } from 'react-intl';
3
3
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { addRowAfter, tooltip } from '@atlaskit/editor-common/keymaps';
5
5
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
6
- import { getSelectionRect } from '@atlaskit/editor-tables/utils';
7
6
  import { TableRowAddBelowIcon, ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
8
7
  import { closeActiveTableMenu } from '../../../../pm-plugins/commands';
9
8
  import { insertRowWithAnalytics } from '../../../../pm-plugins/commands/commands-with-analytics';
9
+ import { getMenuSelectionRect } from '../../shared/selection';
10
10
  import { useTableMenuContext } from '../../shared/TableMenuContext';
11
11
  export const AddRowBelowItem = props => {
12
12
  var _useTableMenuContext, _tooltip;
@@ -24,7 +24,7 @@ export const AddRowBelowItem = props => {
24
24
  if (!editorView) {
25
25
  return;
26
26
  }
27
- const selectionRect = getSelectionRect(editorView.state.selection);
27
+ const selectionRect = getMenuSelectionRect(editorView.state.selection);
28
28
  const index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.bottom;
29
29
  if (index === undefined) {
30
30
  return;
@@ -4,11 +4,11 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
5
5
  import { deleteRow, tooltip } from '@atlaskit/editor-common/keymaps';
6
6
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
7
- import { getSelectionRect } from '@atlaskit/editor-tables/utils';
8
7
  import { DeleteIcon, ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
9
8
  import { clearHoverSelection, closeActiveTableMenu, hoverRows } from '../../../../pm-plugins/commands';
10
9
  import { deleteRowsWithAnalytics } from '../../../../pm-plugins/commands/commands-with-analytics';
11
10
  import { getSelectedRowIndexes } from '../../../../pm-plugins/utils/selection';
11
+ import { getMenuSelectionRect } from '../../shared/selection';
12
12
  import { useTableMenuContext } from '../../shared/TableMenuContext';
13
13
  export const DeleteRowItem = props => {
14
14
  var _tableMenuContext$sel, _tooltip;
@@ -35,7 +35,7 @@ export const DeleteRowItem = props => {
35
35
  if (!editorView) {
36
36
  return;
37
37
  }
38
- const selectionRect = getSelectionRect(editorView.state.selection);
38
+ const selectionRect = getMenuSelectionRect(editorView.state.selection);
39
39
  if (!selectionRect) {
40
40
  return;
41
41
  }
@@ -52,7 +52,7 @@ export const DeleteRowItem = props => {
52
52
  if (!editorView) {
53
53
  return;
54
54
  }
55
- const selectionRect = getSelectionRect(editorView.state.selection);
55
+ const selectionRect = getMenuSelectionRect(editorView.state.selection);
56
56
  if (!selectionRect) {
57
57
  return;
58
58
  }
@@ -1,13 +1,139 @@
1
1
  import React from 'react';
2
- import { CELL_ACTION_SECTION, CELL_DANGER_SECTION, CELL_ACTION_SECTION_RANK, CELL_DANGER_SECTION_RANK } from '../cell/keys';
3
- import { COLUMN_BACKGROUND_SECTION, COLUMN_DANGER_SECTION, COLUMN_BACKGROUND_SECTION_RANK, COLUMN_DANGER_SECTION_RANK } from '../column/keys';
4
- import { ROW_BACKGROUND_SECTION, ROW_DANGER_SECTION, ROW_BACKGROUND_SECTION_RANK, ROW_DANGER_SECTION_RANK } from '../row/keys';
2
+ import { fg } from '@atlaskit/platform-feature-flags';
3
+ import { CELL_ACTION_SECTION, CELL_ADD_SECTION, CELL_DANGER_SECTION, CELL_ACTION_SECTION_RANK, CELL_ADD_SECTION_RANK, CELL_DANGER_SECTION_RANK } from '../cell/keys';
4
+ import { AddColumnRightItem } from '../column/items/AddColumnRightItem';
5
+ import { DeleteColumnItem } from '../column/items/DeleteColumnItem';
6
+ import { DistributeColumnsItem } from '../column/items/DistributeColumnsItem';
7
+ import { ADD_COLUMN_RIGHT_ITEM, COLUMN_ADD_SECTION, COLUMN_BACKGROUND_SECTION, COLUMN_DANGER_SECTION, COLUMN_ADD_SECTION_RANK, COLUMN_BACKGROUND_SECTION_RANK, COLUMN_DANGER_SECTION_RANK, DELETE_COLUMN_ITEM, DISTRIBUTE_COLUMNS_ITEM } from '../column/keys';
8
+ import { AddRowBelowItem } from '../row/items/AddRowBelowItem';
9
+ import { DeleteRowItem } from '../row/items/DeleteRowItem';
10
+ import { ADD_ROW_BELOW_ITEM, DELETE_ROW_ITEM, ROW_ADD_SECTION, ROW_BACKGROUND_SECTION, ROW_DANGER_SECTION, ROW_ADD_SECTION_RANK, ROW_BACKGROUND_SECTION_RANK, ROW_DANGER_SECTION_RANK } from '../row/keys';
5
11
  import { BackgroundColorItem } from './items/BackgroundColorItem';
6
12
  import { ClearCellsItem } from './items/ClearCellsItem';
7
13
  import { BACKGROUND_COLOR_ITEM, CLEAR_CELLS_ITEM } from './keys';
8
14
  export const getSharedItems = ({
9
15
  api
10
- }) => [{
16
+ }) => fg('platform_editor_table_cell_menu_update') ? [
17
+ // --- Cell menu update ON ---
18
+ // The add/delete items move out of the row/column menu files and are registered here
19
+ // once with an additional cell parent, so they render inside the cell menu too.
20
+ {
21
+ type: BACKGROUND_COLOR_ITEM.type,
22
+ key: BACKGROUND_COLOR_ITEM.key,
23
+ parents: [{
24
+ type: ROW_BACKGROUND_SECTION.type,
25
+ key: ROW_BACKGROUND_SECTION.key,
26
+ rank: ROW_BACKGROUND_SECTION_RANK[BACKGROUND_COLOR_ITEM.key]
27
+ }, {
28
+ type: COLUMN_BACKGROUND_SECTION.type,
29
+ key: COLUMN_BACKGROUND_SECTION.key,
30
+ rank: COLUMN_BACKGROUND_SECTION_RANK[BACKGROUND_COLOR_ITEM.key]
31
+ }, {
32
+ type: CELL_ACTION_SECTION.type,
33
+ key: CELL_ACTION_SECTION.key,
34
+ rank: CELL_ACTION_SECTION_RANK[BACKGROUND_COLOR_ITEM.key]
35
+ }],
36
+ component: () => /*#__PURE__*/React.createElement(BackgroundColorItem, {
37
+ api: api
38
+ })
39
+ }, {
40
+ type: ADD_COLUMN_RIGHT_ITEM.type,
41
+ key: ADD_COLUMN_RIGHT_ITEM.key,
42
+ parents: [{
43
+ type: COLUMN_ADD_SECTION.type,
44
+ key: COLUMN_ADD_SECTION.key,
45
+ rank: COLUMN_ADD_SECTION_RANK[ADD_COLUMN_RIGHT_ITEM.key]
46
+ }, {
47
+ type: CELL_ADD_SECTION.type,
48
+ key: CELL_ADD_SECTION.key,
49
+ rank: CELL_ADD_SECTION_RANK[ADD_COLUMN_RIGHT_ITEM.key]
50
+ }],
51
+ component: () => /*#__PURE__*/React.createElement(AddColumnRightItem, {
52
+ api: api
53
+ })
54
+ }, {
55
+ type: ADD_ROW_BELOW_ITEM.type,
56
+ key: ADD_ROW_BELOW_ITEM.key,
57
+ parents: [{
58
+ type: ROW_ADD_SECTION.type,
59
+ key: ROW_ADD_SECTION.key,
60
+ rank: ROW_ADD_SECTION_RANK[ADD_ROW_BELOW_ITEM.key]
61
+ }, {
62
+ type: CELL_ADD_SECTION.type,
63
+ key: CELL_ADD_SECTION.key,
64
+ rank: CELL_ADD_SECTION_RANK[ADD_ROW_BELOW_ITEM.key]
65
+ }],
66
+ component: () => /*#__PURE__*/React.createElement(AddRowBelowItem, {
67
+ api: api
68
+ })
69
+ }, {
70
+ type: DISTRIBUTE_COLUMNS_ITEM.type,
71
+ key: DISTRIBUTE_COLUMNS_ITEM.key,
72
+ parents: [{
73
+ type: COLUMN_ADD_SECTION.type,
74
+ key: COLUMN_ADD_SECTION.key,
75
+ rank: COLUMN_ADD_SECTION_RANK[DISTRIBUTE_COLUMNS_ITEM.key]
76
+ }, {
77
+ type: CELL_ADD_SECTION.type,
78
+ key: CELL_ADD_SECTION.key,
79
+ rank: CELL_ADD_SECTION_RANK[DISTRIBUTE_COLUMNS_ITEM.key]
80
+ }],
81
+ component: () => /*#__PURE__*/React.createElement(DistributeColumnsItem, {
82
+ api: api
83
+ })
84
+ }, {
85
+ type: CLEAR_CELLS_ITEM.type,
86
+ key: CLEAR_CELLS_ITEM.key,
87
+ parents: [{
88
+ type: ROW_DANGER_SECTION.type,
89
+ key: ROW_DANGER_SECTION.key,
90
+ rank: ROW_DANGER_SECTION_RANK[CLEAR_CELLS_ITEM.key]
91
+ }, {
92
+ type: COLUMN_DANGER_SECTION.type,
93
+ key: COLUMN_DANGER_SECTION.key,
94
+ rank: COLUMN_DANGER_SECTION_RANK[CLEAR_CELLS_ITEM.key]
95
+ }, {
96
+ type: CELL_DANGER_SECTION.type,
97
+ key: CELL_DANGER_SECTION.key,
98
+ rank: CELL_DANGER_SECTION_RANK[CLEAR_CELLS_ITEM.key]
99
+ }],
100
+ component: () => /*#__PURE__*/React.createElement(ClearCellsItem, {
101
+ api: api
102
+ })
103
+ }, {
104
+ type: DELETE_COLUMN_ITEM.type,
105
+ key: DELETE_COLUMN_ITEM.key,
106
+ parents: [{
107
+ type: COLUMN_DANGER_SECTION.type,
108
+ key: COLUMN_DANGER_SECTION.key,
109
+ rank: COLUMN_DANGER_SECTION_RANK[DELETE_COLUMN_ITEM.key]
110
+ }, {
111
+ type: CELL_DANGER_SECTION.type,
112
+ key: CELL_DANGER_SECTION.key,
113
+ rank: CELL_DANGER_SECTION_RANK[DELETE_COLUMN_ITEM.key]
114
+ }],
115
+ component: () => /*#__PURE__*/React.createElement(DeleteColumnItem, {
116
+ api: api
117
+ })
118
+ }, {
119
+ type: DELETE_ROW_ITEM.type,
120
+ key: DELETE_ROW_ITEM.key,
121
+ parents: [{
122
+ type: ROW_DANGER_SECTION.type,
123
+ key: ROW_DANGER_SECTION.key,
124
+ rank: ROW_DANGER_SECTION_RANK[DELETE_ROW_ITEM.key]
125
+ }, {
126
+ type: CELL_DANGER_SECTION.type,
127
+ key: CELL_DANGER_SECTION.key,
128
+ rank: CELL_DANGER_SECTION_RANK[DELETE_ROW_ITEM.key]
129
+ }],
130
+ component: () => /*#__PURE__*/React.createElement(DeleteRowItem, {
131
+ api: api
132
+ })
133
+ }] : [
134
+ // --- Cell menu update OFF: legacy shared items (background color + clear cells only).
135
+ // The add/delete items are registered by the row/column menu files in this mode.
136
+ {
11
137
  type: BACKGROUND_COLOR_ITEM.type,
12
138
  key: BACKGROUND_COLOR_ITEM.key,
13
139
  parents: [{
@@ -0,0 +1,14 @@
1
+ import { findCellRectClosestToPos, getSelectionRect, isSelectionType } from '@atlaskit/editor-tables/utils';
2
+ import { fg } from '@atlaskit/platform-feature-flags';
3
+
4
+ /**
5
+ * Resolve the table `Rect` for the current selection. Falls back to the closest cell's rect
6
+ * for a `TextSelection` (cell menu), where `getSelectionRect` returns `undefined`. Gated:
7
+ * with the gate off this behaves exactly like `getSelectionRect`.
8
+ */
9
+ export const getMenuSelectionRect = selection => {
10
+ if (!fg('platform_editor_table_cell_menu_update')) {
11
+ return getSelectionRect(selection);
12
+ }
13
+ return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
14
+ };
@@ -248,11 +248,8 @@ export var TableResizer = function TableResizer(_ref) {
248
248
  };
249
249
  }, [editorView, displayGuideline, displayGapCursor]);
250
250
  var handleResizeStart = useCallback(function () {
251
- var _pluginInjectionApi$u;
252
- if (expValEquals('cc_editor_interactivity_monitoring', 'isEnabled', true)) {
253
- var _insm$session;
254
- (_insm$session = insm.session) === null || _insm$session === void 0 || _insm$session.startFeature('tableResize');
255
- }
251
+ var _insm$session, _pluginInjectionApi$u;
252
+ (_insm$session = insm.session) === null || _insm$session === void 0 || _insm$session.startFeature('tableResize');
256
253
  startMeasure();
257
254
  isResizing.current = true;
258
255
  var dispatch = editorView.dispatch,
@@ -324,7 +321,7 @@ export var TableResizer = function TableResizer(_ref) {
324
321
  return rafSchd(handleResize);
325
322
  }, [handleResize]);
326
323
  var handleResizeStop = useCallback(function (originalState, delta) {
327
- var _node$attrs$localId2, _node$attrs2, _pluginInjectionApi$u3;
324
+ var _node$attrs$localId2, _node$attrs2, _pluginInjectionApi$u3, _insm$session2;
328
325
  isResizing.current = false;
329
326
  var newWidth = originalState.width + delta.width;
330
327
  var originalNewWidth = newWidth;
@@ -405,10 +402,7 @@ export var TableResizer = function TableResizer(_ref) {
405
402
  if (onResizeStop) {
406
403
  onResizeStop();
407
404
  }
408
- if (expValEquals('cc_editor_interactivity_monitoring', 'isEnabled', true)) {
409
- var _insm$session2;
410
- (_insm$session2 = insm.session) === null || _insm$session2 === void 0 || _insm$session2.endFeature('tableResize');
411
- }
405
+ (_insm$session2 = insm.session) === null || _insm$session2 === void 0 || _insm$session2.endFeature('tableResize');
412
406
  return newWidth;
413
407
  }, [editorView, getPos, node, widthToWidest, endMeasure, displayGapCursor, displayGuideline, updateWidth, scheduleResize, onResizeStop, pluginInjectionApi, attachAnalyticsEvent, tableRef, isTableScalingEnabled, shouldUseIncreasedScalingPercent, formatMessage, isFullPageAppearance]);
414
408
  var handleTableSizeChangeOnKeypress = useCallback(function (step) {