@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,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,171 @@ 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 var getColumnMenuComponents = function getColumnMenuComponents(_ref) {
16
17
  var api = _ref.api;
17
- return [
18
+ return 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: function component(props) {
38
+ return /*#__PURE__*/React.createElement(ColumnToggleSection, {
39
+ api: api
40
+ }, props.children);
41
+ }
42
+ }, {
43
+ type: HEADER_COLUMN_TOGGLE_ITEM.type,
44
+ key: HEADER_COLUMN_TOGGLE_ITEM.key,
45
+ parents: [{
46
+ type: COLUMN_TOGGLE_SECTION.type,
47
+ key: COLUMN_TOGGLE_SECTION.key,
48
+ rank: COLUMN_TOGGLE_SECTION_RANK[HEADER_COLUMN_TOGGLE_ITEM.key]
49
+ }],
50
+ component: function component() {
51
+ return /*#__PURE__*/React.createElement(HeaderColumnToggleItem, {
52
+ api: api
53
+ });
54
+ }
55
+ },
56
+ // --- Background color section ---
57
+ {
58
+ type: COLUMN_BACKGROUND_SECTION.type,
59
+ key: COLUMN_BACKGROUND_SECTION.key,
60
+ parents: [{
61
+ type: COLUMN_MENU.type,
62
+ key: COLUMN_MENU.key,
63
+ rank: COLUMN_SECTION_RANK[COLUMN_BACKGROUND_SECTION.key]
64
+ }],
65
+ component: function component(props) {
66
+ return /*#__PURE__*/React.createElement(ColumnBackgroundSection, {
67
+ api: api
68
+ }, props.children);
69
+ }
70
+ },
71
+ // --- Sort section ---
72
+ {
73
+ type: COLUMN_SORT_SECTION.type,
74
+ key: COLUMN_SORT_SECTION.key,
75
+ parents: [{
76
+ type: COLUMN_MENU.type,
77
+ key: COLUMN_MENU.key,
78
+ rank: COLUMN_SECTION_RANK[COLUMN_SORT_SECTION.key]
79
+ }],
80
+ component: function component(props) {
81
+ return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
82
+ hasSeparator: true
83
+ }, props.children);
84
+ }
85
+ }, {
86
+ type: SORT_INCREASING_ITEM.type,
87
+ key: SORT_INCREASING_ITEM.key,
88
+ parents: [{
89
+ type: COLUMN_SORT_SECTION.type,
90
+ key: COLUMN_SORT_SECTION.key,
91
+ rank: COLUMN_SORT_SECTION_RANK[SORT_INCREASING_ITEM.key]
92
+ }],
93
+ component: function component() {
94
+ return /*#__PURE__*/React.createElement(SortIncreasingItem, {
95
+ api: api
96
+ });
97
+ }
98
+ }, {
99
+ type: SORT_DECREASING_ITEM.type,
100
+ key: SORT_DECREASING_ITEM.key,
101
+ parents: [{
102
+ type: COLUMN_SORT_SECTION.type,
103
+ key: COLUMN_SORT_SECTION.key,
104
+ rank: COLUMN_SORT_SECTION_RANK[SORT_DECREASING_ITEM.key]
105
+ }],
106
+ component: function component() {
107
+ return /*#__PURE__*/React.createElement(SortDecreasingItem, {
108
+ api: api
109
+ });
110
+ }
111
+ },
112
+ // --- Add / Move section ---
113
+ {
114
+ type: COLUMN_ADD_SECTION.type,
115
+ key: COLUMN_ADD_SECTION.key,
116
+ parents: [{
117
+ type: COLUMN_MENU.type,
118
+ key: COLUMN_MENU.key,
119
+ rank: COLUMN_SECTION_RANK[COLUMN_ADD_SECTION.key]
120
+ }],
121
+ component: function component(props) {
122
+ return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
123
+ hasSeparator: true
124
+ }, props.children);
125
+ }
126
+ }, {
127
+ type: ADD_COLUMN_LEFT_ITEM.type,
128
+ key: ADD_COLUMN_LEFT_ITEM.key,
129
+ parents: [{
130
+ type: COLUMN_ADD_SECTION.type,
131
+ key: COLUMN_ADD_SECTION.key,
132
+ rank: COLUMN_ADD_SECTION_RANK[ADD_COLUMN_LEFT_ITEM.key]
133
+ }],
134
+ component: function component() {
135
+ return /*#__PURE__*/React.createElement(AddColumnLeftItem, {
136
+ api: api
137
+ });
138
+ }
139
+ }, {
140
+ type: MOVE_COLUMN_LEFT_ITEM.type,
141
+ key: MOVE_COLUMN_LEFT_ITEM.key,
142
+ parents: [{
143
+ type: COLUMN_ADD_SECTION.type,
144
+ key: COLUMN_ADD_SECTION.key,
145
+ rank: COLUMN_ADD_SECTION_RANK[MOVE_COLUMN_LEFT_ITEM.key]
146
+ }],
147
+ component: function component() {
148
+ return /*#__PURE__*/React.createElement(MoveColumnLeftItem, {
149
+ api: api
150
+ });
151
+ }
152
+ }, {
153
+ type: MOVE_COLUMN_RIGHT_ITEM.type,
154
+ key: MOVE_COLUMN_RIGHT_ITEM.key,
155
+ parents: [{
156
+ type: COLUMN_ADD_SECTION.type,
157
+ key: COLUMN_ADD_SECTION.key,
158
+ rank: COLUMN_ADD_SECTION_RANK[MOVE_COLUMN_RIGHT_ITEM.key]
159
+ }],
160
+ component: function component() {
161
+ return /*#__PURE__*/React.createElement(MoveColumnRightItem, {
162
+ api: api
163
+ });
164
+ }
165
+ },
166
+ // --- Danger section (Clear cells, Delete column) ---
167
+ {
168
+ type: COLUMN_DANGER_SECTION.type,
169
+ key: COLUMN_DANGER_SECTION.key,
170
+ parents: [{
171
+ type: COLUMN_MENU.type,
172
+ key: COLUMN_MENU.key,
173
+ rank: COLUMN_SECTION_RANK[COLUMN_DANGER_SECTION.key]
174
+ }],
175
+ component: function component(props) {
176
+ return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
177
+ hasSeparator: true
178
+ }, props.children);
179
+ }
180
+ }] : [
181
+ // --- Cell menu update OFF: legacy column menu (registers its own add/delete items) ---
182
+
18
183
  // --- Menu surface ---
19
184
  {
20
185
  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 var AddColumnRightItem = function AddColumnRightItem(_ref) {
13
13
  var _useTableMenuContext, _tooltip;
@@ -32,7 +32,7 @@ export var AddColumnRightItem = function AddColumnRightItem(_ref) {
32
32
  if (!editorView) {
33
33
  return;
34
34
  }
35
- var selectionRect = getSelectionRect(editorView.state.selection);
35
+ var selectionRect = getMenuSelectionRect(editorView.state.selection);
36
36
  var index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.right;
37
37
  if (index === undefined) {
38
38
  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 var DeleteColumnItem = function DeleteColumnItem(_ref) {
14
14
  var _tableMenuContext$sel, _tooltip;
@@ -34,7 +34,7 @@ export var DeleteColumnItem = function DeleteColumnItem(_ref) {
34
34
  if (!editorView) {
35
35
  return;
36
36
  }
37
- var selectionRect = getSelectionRect(editorView.state.selection);
37
+ var selectionRect = getMenuSelectionRect(editorView.state.selection);
38
38
  if (!selectionRect) {
39
39
  return;
40
40
  }
@@ -51,7 +51,7 @@ export var DeleteColumnItem = function DeleteColumnItem(_ref) {
51
51
  if (!editorView) {
52
52
  return;
53
53
  }
54
- var selectionRect = getSelectionRect(editorView.state.selection);
54
+ var selectionRect = getMenuSelectionRect(editorView.state.selection);
55
55
  if (!selectionRect) {
56
56
  return;
57
57
  }
@@ -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
  var shouldShowDistributeColumns = function shouldShowDistributeColumns(selectedColumnCount) {
@@ -36,7 +36,7 @@ export var DistributeColumnsItem = function DistributeColumnsItem(_ref) {
36
36
  if (!editorView) {
37
37
  return;
38
38
  }
39
- var selectionRect = getSelectionRect(editorView.state.selection);
39
+ var selectionRect = getMenuSelectionRect(editorView.state.selection);
40
40
  var editorContainerWidth = api === null || api === void 0 || (_api$width = api.width) === null || _api$width === void 0 ? void 0 : _api$width.sharedState.currentState();
41
41
  if (!selectionRect || !editorContainerWidth) {
42
42
  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,141 @@ 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 var getRowMenuComponents = function getRowMenuComponents(_ref) {
12
13
  var api = _ref.api;
13
- return [
14
+ return 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: function component(props) {
34
+ return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, props.children);
35
+ }
36
+ }, {
37
+ type: HEADER_ROW_TOGGLE_ITEM.type,
38
+ key: HEADER_ROW_TOGGLE_ITEM.key,
39
+ parents: [{
40
+ type: ROW_TOGGLE_SECTION.type,
41
+ key: ROW_TOGGLE_SECTION.key,
42
+ rank: ROW_TOGGLE_SECTION_RANK[HEADER_ROW_TOGGLE_ITEM.key]
43
+ }],
44
+ component: function component() {
45
+ return /*#__PURE__*/React.createElement(HeaderRowToggleItem, {
46
+ api: api
47
+ });
48
+ }
49
+ }, {
50
+ type: NUMBERED_ROWS_TOGGLE_ITEM.type,
51
+ key: NUMBERED_ROWS_TOGGLE_ITEM.key,
52
+ parents: [{
53
+ type: ROW_TOGGLE_SECTION.type,
54
+ key: ROW_TOGGLE_SECTION.key,
55
+ rank: ROW_TOGGLE_SECTION_RANK[NUMBERED_ROWS_TOGGLE_ITEM.key]
56
+ }],
57
+ component: function component() {
58
+ return /*#__PURE__*/React.createElement(NumberedRowsToggleItem, {
59
+ api: api
60
+ });
61
+ }
62
+ },
63
+ // --- Background color section ---
64
+ {
65
+ type: ROW_BACKGROUND_SECTION.type,
66
+ key: ROW_BACKGROUND_SECTION.key,
67
+ parents: [{
68
+ type: ROW_MENU.type,
69
+ key: ROW_MENU.key,
70
+ rank: ROW_MENU_SECTION_RANK[ROW_BACKGROUND_SECTION.key]
71
+ }],
72
+ component: function component(props) {
73
+ return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
74
+ hasSeparator: true
75
+ }, props.children);
76
+ }
77
+ },
78
+ // --- Add / Move section ---
79
+ {
80
+ type: ROW_ADD_SECTION.type,
81
+ key: ROW_ADD_SECTION.key,
82
+ parents: [{
83
+ type: ROW_MENU.type,
84
+ key: ROW_MENU.key,
85
+ rank: ROW_MENU_SECTION_RANK[ROW_ADD_SECTION.key]
86
+ }],
87
+ component: function component(props) {
88
+ return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
89
+ hasSeparator: true
90
+ }, props.children);
91
+ }
92
+ }, {
93
+ type: ADD_ROW_ABOVE_ITEM.type,
94
+ key: ADD_ROW_ABOVE_ITEM.key,
95
+ parents: [{
96
+ type: ROW_ADD_SECTION.type,
97
+ key: ROW_ADD_SECTION.key,
98
+ rank: ROW_ADD_SECTION_RANK[ADD_ROW_ABOVE_ITEM.key]
99
+ }],
100
+ component: function component() {
101
+ return /*#__PURE__*/React.createElement(AddRowAboveItem, {
102
+ api: api
103
+ });
104
+ }
105
+ }, {
106
+ type: MOVE_ROW_UP_ITEM.type,
107
+ key: MOVE_ROW_UP_ITEM.key,
108
+ parents: [{
109
+ type: ROW_ADD_SECTION.type,
110
+ key: ROW_ADD_SECTION.key,
111
+ rank: ROW_ADD_SECTION_RANK[MOVE_ROW_UP_ITEM.key]
112
+ }],
113
+ component: function component() {
114
+ return /*#__PURE__*/React.createElement(MoveRowUpItem, {
115
+ api: api
116
+ });
117
+ }
118
+ }, {
119
+ type: MOVE_ROW_DOWN_ITEM.type,
120
+ key: MOVE_ROW_DOWN_ITEM.key,
121
+ parents: [{
122
+ type: ROW_ADD_SECTION.type,
123
+ key: ROW_ADD_SECTION.key,
124
+ rank: ROW_ADD_SECTION_RANK[MOVE_ROW_DOWN_ITEM.key]
125
+ }],
126
+ component: function component() {
127
+ return /*#__PURE__*/React.createElement(MoveRowDownItem, {
128
+ api: api
129
+ });
130
+ }
131
+ },
132
+ // --- Danger section (Clear cells, Delete row) ---
133
+ {
134
+ type: ROW_DANGER_SECTION.type,
135
+ key: ROW_DANGER_SECTION.key,
136
+ parents: [{
137
+ type: ROW_MENU.type,
138
+ key: ROW_MENU.key,
139
+ rank: ROW_MENU_SECTION_RANK[ROW_DANGER_SECTION.key]
140
+ }],
141
+ component: function component(props) {
142
+ return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
143
+ hasSeparator: true
144
+ }, props.children);
145
+ }
146
+ }] : [
147
+ // --- Cell menu update OFF: legacy row menu (registers its own add/delete items) ---
148
+
14
149
  // --- Menu surface ---
15
150
  {
16
151
  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 var AddRowBelowItem = function AddRowBelowItem(props) {
12
12
  var _useTableMenuContext, _tooltip;
@@ -20,7 +20,7 @@ export var AddRowBelowItem = function AddRowBelowItem(props) {
20
20
  if (!editorView) {
21
21
  return;
22
22
  }
23
- var selectionRect = getSelectionRect(editorView.state.selection);
23
+ var selectionRect = getMenuSelectionRect(editorView.state.selection);
24
24
  var index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.bottom;
25
25
  if (index === undefined) {
26
26
  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 var DeleteRowItem = function DeleteRowItem(props) {
14
14
  var _tableMenuContext$sel, _tooltip;
@@ -30,7 +30,7 @@ export var DeleteRowItem = function DeleteRowItem(props) {
30
30
  if (!editorView) {
31
31
  return;
32
32
  }
33
- var selectionRect = getSelectionRect(editorView.state.selection);
33
+ var selectionRect = getMenuSelectionRect(editorView.state.selection);
34
34
  if (!selectionRect) {
35
35
  return;
36
36
  }
@@ -47,7 +47,7 @@ export var DeleteRowItem = function DeleteRowItem(props) {
47
47
  if (!editorView) {
48
48
  return;
49
49
  }
50
- var selectionRect = getSelectionRect(editorView.state.selection);
50
+ var selectionRect = getMenuSelectionRect(editorView.state.selection);
51
51
  if (!selectionRect) {
52
52
  return;
53
53
  }
@@ -1,13 +1,153 @@
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 var getSharedItems = function getSharedItems(_ref) {
9
15
  var api = _ref.api;
10
- return [{
16
+ return 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: function component() {
37
+ return /*#__PURE__*/React.createElement(BackgroundColorItem, {
38
+ api: api
39
+ });
40
+ }
41
+ }, {
42
+ type: ADD_COLUMN_RIGHT_ITEM.type,
43
+ key: ADD_COLUMN_RIGHT_ITEM.key,
44
+ parents: [{
45
+ type: COLUMN_ADD_SECTION.type,
46
+ key: COLUMN_ADD_SECTION.key,
47
+ rank: COLUMN_ADD_SECTION_RANK[ADD_COLUMN_RIGHT_ITEM.key]
48
+ }, {
49
+ type: CELL_ADD_SECTION.type,
50
+ key: CELL_ADD_SECTION.key,
51
+ rank: CELL_ADD_SECTION_RANK[ADD_COLUMN_RIGHT_ITEM.key]
52
+ }],
53
+ component: function component() {
54
+ return /*#__PURE__*/React.createElement(AddColumnRightItem, {
55
+ api: api
56
+ });
57
+ }
58
+ }, {
59
+ type: ADD_ROW_BELOW_ITEM.type,
60
+ key: ADD_ROW_BELOW_ITEM.key,
61
+ parents: [{
62
+ type: ROW_ADD_SECTION.type,
63
+ key: ROW_ADD_SECTION.key,
64
+ rank: ROW_ADD_SECTION_RANK[ADD_ROW_BELOW_ITEM.key]
65
+ }, {
66
+ type: CELL_ADD_SECTION.type,
67
+ key: CELL_ADD_SECTION.key,
68
+ rank: CELL_ADD_SECTION_RANK[ADD_ROW_BELOW_ITEM.key]
69
+ }],
70
+ component: function component() {
71
+ return /*#__PURE__*/React.createElement(AddRowBelowItem, {
72
+ api: api
73
+ });
74
+ }
75
+ }, {
76
+ type: DISTRIBUTE_COLUMNS_ITEM.type,
77
+ key: DISTRIBUTE_COLUMNS_ITEM.key,
78
+ parents: [{
79
+ type: COLUMN_ADD_SECTION.type,
80
+ key: COLUMN_ADD_SECTION.key,
81
+ rank: COLUMN_ADD_SECTION_RANK[DISTRIBUTE_COLUMNS_ITEM.key]
82
+ }, {
83
+ type: CELL_ADD_SECTION.type,
84
+ key: CELL_ADD_SECTION.key,
85
+ rank: CELL_ADD_SECTION_RANK[DISTRIBUTE_COLUMNS_ITEM.key]
86
+ }],
87
+ component: function component() {
88
+ return /*#__PURE__*/React.createElement(DistributeColumnsItem, {
89
+ api: api
90
+ });
91
+ }
92
+ }, {
93
+ type: CLEAR_CELLS_ITEM.type,
94
+ key: CLEAR_CELLS_ITEM.key,
95
+ parents: [{
96
+ type: ROW_DANGER_SECTION.type,
97
+ key: ROW_DANGER_SECTION.key,
98
+ rank: ROW_DANGER_SECTION_RANK[CLEAR_CELLS_ITEM.key]
99
+ }, {
100
+ type: COLUMN_DANGER_SECTION.type,
101
+ key: COLUMN_DANGER_SECTION.key,
102
+ rank: COLUMN_DANGER_SECTION_RANK[CLEAR_CELLS_ITEM.key]
103
+ }, {
104
+ type: CELL_DANGER_SECTION.type,
105
+ key: CELL_DANGER_SECTION.key,
106
+ rank: CELL_DANGER_SECTION_RANK[CLEAR_CELLS_ITEM.key]
107
+ }],
108
+ component: function component() {
109
+ return /*#__PURE__*/React.createElement(ClearCellsItem, {
110
+ api: api
111
+ });
112
+ }
113
+ }, {
114
+ type: DELETE_COLUMN_ITEM.type,
115
+ key: DELETE_COLUMN_ITEM.key,
116
+ parents: [{
117
+ type: COLUMN_DANGER_SECTION.type,
118
+ key: COLUMN_DANGER_SECTION.key,
119
+ rank: COLUMN_DANGER_SECTION_RANK[DELETE_COLUMN_ITEM.key]
120
+ }, {
121
+ type: CELL_DANGER_SECTION.type,
122
+ key: CELL_DANGER_SECTION.key,
123
+ rank: CELL_DANGER_SECTION_RANK[DELETE_COLUMN_ITEM.key]
124
+ }],
125
+ component: function component() {
126
+ return /*#__PURE__*/React.createElement(DeleteColumnItem, {
127
+ api: api
128
+ });
129
+ }
130
+ }, {
131
+ type: DELETE_ROW_ITEM.type,
132
+ key: DELETE_ROW_ITEM.key,
133
+ parents: [{
134
+ type: ROW_DANGER_SECTION.type,
135
+ key: ROW_DANGER_SECTION.key,
136
+ rank: ROW_DANGER_SECTION_RANK[DELETE_ROW_ITEM.key]
137
+ }, {
138
+ type: CELL_DANGER_SECTION.type,
139
+ key: CELL_DANGER_SECTION.key,
140
+ rank: CELL_DANGER_SECTION_RANK[DELETE_ROW_ITEM.key]
141
+ }],
142
+ component: function component() {
143
+ return /*#__PURE__*/React.createElement(DeleteRowItem, {
144
+ api: api
145
+ });
146
+ }
147
+ }] : [
148
+ // --- Cell menu update OFF: legacy shared items (background color + clear cells only).
149
+ // The add/delete items are registered by the row/column menu files in this mode.
150
+ {
11
151
  type: BACKGROUND_COLOR_ITEM.type,
12
152
  key: BACKGROUND_COLOR_ITEM.key,
13
153
  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 var getMenuSelectionRect = function 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
+ };
@@ -0,0 +1,8 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type IntlShape } from 'react-intl';
3
+ interface Props {
4
+ children: ReactNode;
5
+ intl: IntlShape | undefined;
6
+ }
7
+ export declare function TableSSRReactContextsProvider({ children, intl }: Props): ReactNode;
8
+ export {};
@@ -1,3 +1,4 @@
1
+ import type { IntlShape } from 'react-intl';
1
2
  import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
2
3
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
3
4
  import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
@@ -14,6 +15,7 @@ type TableViewOptions = {
14
15
  eventDispatcher: EventDispatcher;
15
16
  getEditorContainerWidth: GetEditorContainerWidth;
16
17
  getEditorFeatureFlags: GetEditorFeatureFlags;
18
+ intl?: IntlShape;
17
19
  isChromelessEditor?: boolean;
18
20
  isCommentEditor?: boolean;
19
21
  pluginInjectionApi?: PluginInjectionAPI;
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import type { IntlShape } from 'react-intl';
2
3
  import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
3
4
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
4
5
  import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
@@ -14,6 +15,7 @@ export default class TableView extends ReactNodeView<Props> {
14
15
  private renderedDOM?;
15
16
  private resizeObserver?;
16
17
  private roundedTableEdges;
18
+ private intl?;
17
19
  eventDispatcher?: EventDispatcher;
18
20
  getPos: getPosHandlerNode;
19
21
  options: TableOptions | undefined;
@@ -43,5 +45,5 @@ export default class TableView extends ReactNodeView<Props> {
43
45
  }): boolean;
44
46
  destroy(): void;
45
47
  }
46
- export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, dispatchAnalyticsEvent: DispatchAnalyticsEvent, pluginInjectionApi?: PluginInjectionAPI, isCommentEditor?: boolean, isChromelessEditor?: boolean, allowFixedColumnWidthOption?: boolean) => NodeView;
48
+ export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, dispatchAnalyticsEvent: DispatchAnalyticsEvent, pluginInjectionApi?: PluginInjectionAPI, isCommentEditor?: boolean, isChromelessEditor?: boolean, allowFixedColumnWidthOption?: boolean, intl?: IntlShape) => NodeView;
47
49
  export {};