@atlaskit/editor-plugin-table 24.3.13 → 24.4.0

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 (64) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/cjs/nodeviews/TableSSRReactContextsProvider.js +23 -0
  3. package/dist/cjs/nodeviews/table-node-views.js +1 -1
  4. package/dist/cjs/nodeviews/table.js +14 -21
  5. package/dist/cjs/pm-plugins/commands/insert.js +10 -1
  6. package/dist/cjs/pm-plugins/main.js +3 -1
  7. package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +2 -1
  8. package/dist/cjs/tablePlugin.js +10 -1
  9. package/dist/cjs/ui/TableMenu/cell/getCellMenuComponents.js +153 -1
  10. package/dist/cjs/ui/TableMenu/cell/keys.js +19 -5
  11. package/dist/cjs/ui/TableMenu/column/getColumnMenuComponents.js +166 -1
  12. package/dist/cjs/ui/TableMenu/column/items/AddColumnRightItem.js +2 -2
  13. package/dist/cjs/ui/TableMenu/column/items/DeleteColumnItem.js +3 -3
  14. package/dist/cjs/ui/TableMenu/column/items/DistributeColumnsItem.js +2 -2
  15. package/dist/cjs/ui/TableMenu/row/getRowMenuComponents.js +136 -1
  16. package/dist/cjs/ui/TableMenu/row/items/AddRowBelowItem.js +2 -2
  17. package/dist/cjs/ui/TableMenu/row/items/DeleteRowItem.js +3 -3
  18. package/dist/cjs/ui/TableMenu/shared/getSharedItems.js +141 -1
  19. package/dist/cjs/ui/TableMenu/shared/selection.js +19 -0
  20. package/dist/es2019/nodeviews/TableSSRReactContextsProvider.js +17 -0
  21. package/dist/es2019/nodeviews/table-node-views.js +1 -1
  22. package/dist/es2019/nodeviews/table.js +15 -22
  23. package/dist/es2019/pm-plugins/commands/insert.js +10 -1
  24. package/dist/es2019/pm-plugins/main.js +4 -2
  25. package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +2 -1
  26. package/dist/es2019/tablePlugin.js +10 -1
  27. package/dist/es2019/ui/TableMenu/cell/getCellMenuComponents.js +134 -2
  28. package/dist/es2019/ui/TableMenu/cell/keys.js +25 -2
  29. package/dist/es2019/ui/TableMenu/column/getColumnMenuComponents.js +144 -1
  30. package/dist/es2019/ui/TableMenu/column/items/AddColumnRightItem.js +2 -2
  31. package/dist/es2019/ui/TableMenu/column/items/DeleteColumnItem.js +3 -3
  32. package/dist/es2019/ui/TableMenu/column/items/DistributeColumnsItem.js +2 -2
  33. package/dist/es2019/ui/TableMenu/row/getRowMenuComponents.js +118 -1
  34. package/dist/es2019/ui/TableMenu/row/items/AddRowBelowItem.js +2 -2
  35. package/dist/es2019/ui/TableMenu/row/items/DeleteRowItem.js +3 -3
  36. package/dist/es2019/ui/TableMenu/shared/getSharedItems.js +130 -4
  37. package/dist/es2019/ui/TableMenu/shared/selection.js +14 -0
  38. package/dist/esm/nodeviews/TableSSRReactContextsProvider.js +16 -0
  39. package/dist/esm/nodeviews/table-node-views.js +1 -1
  40. package/dist/esm/nodeviews/table.js +15 -22
  41. package/dist/esm/pm-plugins/commands/insert.js +10 -1
  42. package/dist/esm/pm-plugins/main.js +4 -2
  43. package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +2 -1
  44. package/dist/esm/tablePlugin.js +10 -1
  45. package/dist/esm/ui/TableMenu/cell/getCellMenuComponents.js +154 -2
  46. package/dist/esm/ui/TableMenu/cell/keys.js +16 -2
  47. package/dist/esm/ui/TableMenu/column/getColumnMenuComponents.js +166 -1
  48. package/dist/esm/ui/TableMenu/column/items/AddColumnRightItem.js +2 -2
  49. package/dist/esm/ui/TableMenu/column/items/DeleteColumnItem.js +3 -3
  50. package/dist/esm/ui/TableMenu/column/items/DistributeColumnsItem.js +2 -2
  51. package/dist/esm/ui/TableMenu/row/getRowMenuComponents.js +136 -1
  52. package/dist/esm/ui/TableMenu/row/items/AddRowBelowItem.js +2 -2
  53. package/dist/esm/ui/TableMenu/row/items/DeleteRowItem.js +3 -3
  54. package/dist/esm/ui/TableMenu/shared/getSharedItems.js +144 -4
  55. package/dist/esm/ui/TableMenu/shared/selection.js +14 -0
  56. package/dist/types/nodeviews/TableSSRReactContextsProvider.d.ts +8 -0
  57. package/dist/types/nodeviews/table-node-views.d.ts +2 -0
  58. package/dist/types/nodeviews/table.d.ts +3 -1
  59. package/dist/types/nodeviews/types.d.ts +2 -0
  60. package/dist/types/tablePluginType.d.ts +3 -2
  61. package/dist/types/ui/TableMenu/cell/keys.d.ts +2 -0
  62. package/dist/types/ui/TableMenu/column/getColumnMenuComponents.d.ts +1 -1
  63. package/dist/types/ui/TableMenu/shared/selection.d.ts +8 -0
  64. package/package.json +14 -8
@@ -11,10 +11,10 @@ var _analytics = require("@atlaskit/editor-common/analytics");
11
11
  var _hooks = require("@atlaskit/editor-common/hooks");
12
12
  var _keymaps = require("@atlaskit/editor-common/keymaps");
13
13
  var _messages = require("@atlaskit/editor-common/messages");
14
- var _utils = require("@atlaskit/editor-tables/utils");
15
14
  var _editorToolbar = require("@atlaskit/editor-toolbar");
16
15
  var _commands = require("../../../../pm-plugins/commands");
17
16
  var _commandsWithAnalytics = require("../../../../pm-plugins/commands/commands-with-analytics");
17
+ var _selection = require("../../shared/selection");
18
18
  var _TableMenuContext = require("../../shared/TableMenuContext");
19
19
  var AddColumnRightItem = exports.AddColumnRightItem = function AddColumnRightItem(_ref) {
20
20
  var _useTableMenuContext, _tooltip;
@@ -39,7 +39,7 @@ var AddColumnRightItem = exports.AddColumnRightItem = function AddColumnRightIte
39
39
  if (!editorView) {
40
40
  return;
41
41
  }
42
- var selectionRect = (0, _utils.getSelectionRect)(editorView.state.selection);
42
+ var selectionRect = (0, _selection.getMenuSelectionRect)(editorView.state.selection);
43
43
  var index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.right;
44
44
  if (index === undefined) {
45
45
  return;
@@ -11,11 +11,11 @@ var _analytics = require("@atlaskit/editor-common/analytics");
11
11
  var _hooks = require("@atlaskit/editor-common/hooks");
12
12
  var _keymaps = require("@atlaskit/editor-common/keymaps");
13
13
  var _messages = require("@atlaskit/editor-common/messages");
14
- var _utils = require("@atlaskit/editor-tables/utils");
15
14
  var _editorToolbar = require("@atlaskit/editor-toolbar");
16
15
  var _commands = require("../../../../pm-plugins/commands");
17
16
  var _commandsWithAnalytics = require("../../../../pm-plugins/commands/commands-with-analytics");
18
17
  var _selection = require("../../../../pm-plugins/utils/selection");
18
+ var _selection2 = require("../../shared/selection");
19
19
  var _TableMenuContext = require("../../shared/TableMenuContext");
20
20
  var DeleteColumnItem = exports.DeleteColumnItem = function DeleteColumnItem(_ref) {
21
21
  var _tableMenuContext$sel, _tooltip;
@@ -41,7 +41,7 @@ var DeleteColumnItem = exports.DeleteColumnItem = function DeleteColumnItem(_ref
41
41
  if (!editorView) {
42
42
  return;
43
43
  }
44
- var selectionRect = (0, _utils.getSelectionRect)(editorView.state.selection);
44
+ var selectionRect = (0, _selection2.getMenuSelectionRect)(editorView.state.selection);
45
45
  if (!selectionRect) {
46
46
  return;
47
47
  }
@@ -58,7 +58,7 @@ var DeleteColumnItem = exports.DeleteColumnItem = function DeleteColumnItem(_ref
58
58
  if (!editorView) {
59
59
  return;
60
60
  }
61
- var selectionRect = (0, _utils.getSelectionRect)(editorView.state.selection);
61
+ var selectionRect = (0, _selection2.getMenuSelectionRect)(editorView.state.selection);
62
62
  if (!selectionRect) {
63
63
  return;
64
64
  }
@@ -10,11 +10,11 @@ var _reactIntl = require("react-intl");
10
10
  var _analytics = require("@atlaskit/editor-common/analytics");
11
11
  var _hooks = require("@atlaskit/editor-common/hooks");
12
12
  var _messages = require("@atlaskit/editor-common/messages");
13
- var _utils = require("@atlaskit/editor-tables/utils");
14
13
  var _editorToolbar = require("@atlaskit/editor-toolbar");
15
14
  var _commands = require("../../../../pm-plugins/commands");
16
15
  var _commandsWithAnalytics = require("../../../../pm-plugins/commands/commands-with-analytics");
17
16
  var _resizeState = require("../../../../pm-plugins/table-resizing/utils/resize-state");
17
+ var _selection = require("../../shared/selection");
18
18
  var _TableMenuContext = require("../../shared/TableMenuContext");
19
19
  /** Distribute columns is only visible when more than one column is selected. */
20
20
  var shouldShowDistributeColumns = function shouldShowDistributeColumns(selectedColumnCount) {
@@ -43,7 +43,7 @@ var DistributeColumnsItem = exports.DistributeColumnsItem = function DistributeC
43
43
  if (!editorView) {
44
44
  return;
45
45
  }
46
- var selectionRect = (0, _utils.getSelectionRect)(editorView.state.selection);
46
+ var selectionRect = (0, _selection.getMenuSelectionRect)(editorView.state.selection);
47
47
  var editorContainerWidth = api === null || api === void 0 || (_api$width = api.width) === null || _api$width === void 0 ? void 0 : _api$width.sharedState.currentState();
48
48
  if (!selectionRect || !editorContainerWidth) {
49
49
  return;
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.getRowMenuComponents = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _editorToolbar = require("@atlaskit/editor-toolbar");
10
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
11
  var _AddRowAboveItem = require("./items/AddRowAboveItem");
11
12
  var _AddRowBelowItem = require("./items/AddRowBelowItem");
12
13
  var _DeleteRowItem = require("./items/DeleteRowItem");
@@ -17,7 +18,141 @@ var _NumberedRowsToggleItem = require("./items/NumberedRowsToggleItem");
17
18
  var _keys = require("./keys");
18
19
  var getRowMenuComponents = exports.getRowMenuComponents = function getRowMenuComponents(_ref) {
19
20
  var api = _ref.api;
20
- return [
21
+ return (0, _platformFeatureFlags.fg)('platform_editor_table_cell_menu_update') ? [
22
+ // --- Cell menu update ON ---
23
+ // AddRowBelowItem/DeleteRowItem are registered in `../shared/getSharedItems`
24
+ // (shared with the cell menu), so they are omitted here.
25
+
26
+ // --- Menu surface ---
27
+ {
28
+ type: _keys.ROW_MENU.type,
29
+ key: _keys.ROW_MENU.key
30
+ },
31
+ // --- Toggle section (Header row, Numbered rows) ---
32
+ {
33
+ type: _keys.ROW_TOGGLE_SECTION.type,
34
+ key: _keys.ROW_TOGGLE_SECTION.key,
35
+ parents: [{
36
+ type: _keys.ROW_MENU.type,
37
+ key: _keys.ROW_MENU.key,
38
+ rank: _keys.ROW_MENU_SECTION_RANK[_keys.ROW_TOGGLE_SECTION.key]
39
+ }],
40
+ component: function component(props) {
41
+ return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, null, props.children);
42
+ }
43
+ }, {
44
+ type: _keys.HEADER_ROW_TOGGLE_ITEM.type,
45
+ key: _keys.HEADER_ROW_TOGGLE_ITEM.key,
46
+ parents: [{
47
+ type: _keys.ROW_TOGGLE_SECTION.type,
48
+ key: _keys.ROW_TOGGLE_SECTION.key,
49
+ rank: _keys.ROW_TOGGLE_SECTION_RANK[_keys.HEADER_ROW_TOGGLE_ITEM.key]
50
+ }],
51
+ component: function component() {
52
+ return /*#__PURE__*/_react.default.createElement(_HeaderRowToggleItem.HeaderRowToggleItem, {
53
+ api: api
54
+ });
55
+ }
56
+ }, {
57
+ type: _keys.NUMBERED_ROWS_TOGGLE_ITEM.type,
58
+ key: _keys.NUMBERED_ROWS_TOGGLE_ITEM.key,
59
+ parents: [{
60
+ type: _keys.ROW_TOGGLE_SECTION.type,
61
+ key: _keys.ROW_TOGGLE_SECTION.key,
62
+ rank: _keys.ROW_TOGGLE_SECTION_RANK[_keys.NUMBERED_ROWS_TOGGLE_ITEM.key]
63
+ }],
64
+ component: function component() {
65
+ return /*#__PURE__*/_react.default.createElement(_NumberedRowsToggleItem.NumberedRowsToggleItem, {
66
+ api: api
67
+ });
68
+ }
69
+ },
70
+ // --- Background color section ---
71
+ {
72
+ type: _keys.ROW_BACKGROUND_SECTION.type,
73
+ key: _keys.ROW_BACKGROUND_SECTION.key,
74
+ parents: [{
75
+ type: _keys.ROW_MENU.type,
76
+ key: _keys.ROW_MENU.key,
77
+ rank: _keys.ROW_MENU_SECTION_RANK[_keys.ROW_BACKGROUND_SECTION.key]
78
+ }],
79
+ component: function component(props) {
80
+ return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
81
+ hasSeparator: true
82
+ }, props.children);
83
+ }
84
+ },
85
+ // --- Add / Move section ---
86
+ {
87
+ type: _keys.ROW_ADD_SECTION.type,
88
+ key: _keys.ROW_ADD_SECTION.key,
89
+ parents: [{
90
+ type: _keys.ROW_MENU.type,
91
+ key: _keys.ROW_MENU.key,
92
+ rank: _keys.ROW_MENU_SECTION_RANK[_keys.ROW_ADD_SECTION.key]
93
+ }],
94
+ component: function component(props) {
95
+ return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
96
+ hasSeparator: true
97
+ }, props.children);
98
+ }
99
+ }, {
100
+ type: _keys.ADD_ROW_ABOVE_ITEM.type,
101
+ key: _keys.ADD_ROW_ABOVE_ITEM.key,
102
+ parents: [{
103
+ type: _keys.ROW_ADD_SECTION.type,
104
+ key: _keys.ROW_ADD_SECTION.key,
105
+ rank: _keys.ROW_ADD_SECTION_RANK[_keys.ADD_ROW_ABOVE_ITEM.key]
106
+ }],
107
+ component: function component() {
108
+ return /*#__PURE__*/_react.default.createElement(_AddRowAboveItem.AddRowAboveItem, {
109
+ api: api
110
+ });
111
+ }
112
+ }, {
113
+ type: _keys.MOVE_ROW_UP_ITEM.type,
114
+ key: _keys.MOVE_ROW_UP_ITEM.key,
115
+ parents: [{
116
+ type: _keys.ROW_ADD_SECTION.type,
117
+ key: _keys.ROW_ADD_SECTION.key,
118
+ rank: _keys.ROW_ADD_SECTION_RANK[_keys.MOVE_ROW_UP_ITEM.key]
119
+ }],
120
+ component: function component() {
121
+ return /*#__PURE__*/_react.default.createElement(_MoveRowUpItem.MoveRowUpItem, {
122
+ api: api
123
+ });
124
+ }
125
+ }, {
126
+ type: _keys.MOVE_ROW_DOWN_ITEM.type,
127
+ key: _keys.MOVE_ROW_DOWN_ITEM.key,
128
+ parents: [{
129
+ type: _keys.ROW_ADD_SECTION.type,
130
+ key: _keys.ROW_ADD_SECTION.key,
131
+ rank: _keys.ROW_ADD_SECTION_RANK[_keys.MOVE_ROW_DOWN_ITEM.key]
132
+ }],
133
+ component: function component() {
134
+ return /*#__PURE__*/_react.default.createElement(_MoveRowDownItem.MoveRowDownItem, {
135
+ api: api
136
+ });
137
+ }
138
+ },
139
+ // --- Danger section (Clear cells, Delete row) ---
140
+ {
141
+ type: _keys.ROW_DANGER_SECTION.type,
142
+ key: _keys.ROW_DANGER_SECTION.key,
143
+ parents: [{
144
+ type: _keys.ROW_MENU.type,
145
+ key: _keys.ROW_MENU.key,
146
+ rank: _keys.ROW_MENU_SECTION_RANK[_keys.ROW_DANGER_SECTION.key]
147
+ }],
148
+ component: function component(props) {
149
+ return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
150
+ hasSeparator: true
151
+ }, props.children);
152
+ }
153
+ }] : [
154
+ // --- Cell menu update OFF: legacy row menu (registers its own add/delete items) ---
155
+
21
156
  // --- Menu surface ---
22
157
  {
23
158
  type: _keys.ROW_MENU.type,
@@ -10,10 +10,10 @@ var _reactIntl = require("react-intl");
10
10
  var _analytics = require("@atlaskit/editor-common/analytics");
11
11
  var _keymaps = require("@atlaskit/editor-common/keymaps");
12
12
  var _messages = require("@atlaskit/editor-common/messages");
13
- var _utils = require("@atlaskit/editor-tables/utils");
14
13
  var _editorToolbar = require("@atlaskit/editor-toolbar");
15
14
  var _commands = require("../../../../pm-plugins/commands");
16
15
  var _commandsWithAnalytics = require("../../../../pm-plugins/commands/commands-with-analytics");
16
+ var _selection = require("../../shared/selection");
17
17
  var _TableMenuContext = require("../../shared/TableMenuContext");
18
18
  var AddRowBelowItem = exports.AddRowBelowItem = function AddRowBelowItem(props) {
19
19
  var _useTableMenuContext, _tooltip;
@@ -27,7 +27,7 @@ var AddRowBelowItem = exports.AddRowBelowItem = function AddRowBelowItem(props)
27
27
  if (!editorView) {
28
28
  return;
29
29
  }
30
- var selectionRect = (0, _utils.getSelectionRect)(editorView.state.selection);
30
+ var selectionRect = (0, _selection.getMenuSelectionRect)(editorView.state.selection);
31
31
  var index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.bottom;
32
32
  if (index === undefined) {
33
33
  return;
@@ -11,11 +11,11 @@ var _analytics = require("@atlaskit/editor-common/analytics");
11
11
  var _hooks = require("@atlaskit/editor-common/hooks");
12
12
  var _keymaps = require("@atlaskit/editor-common/keymaps");
13
13
  var _messages = require("@atlaskit/editor-common/messages");
14
- var _utils = require("@atlaskit/editor-tables/utils");
15
14
  var _editorToolbar = require("@atlaskit/editor-toolbar");
16
15
  var _commands = require("../../../../pm-plugins/commands");
17
16
  var _commandsWithAnalytics = require("../../../../pm-plugins/commands/commands-with-analytics");
18
17
  var _selection = require("../../../../pm-plugins/utils/selection");
18
+ var _selection2 = require("../../shared/selection");
19
19
  var _TableMenuContext = require("../../shared/TableMenuContext");
20
20
  var DeleteRowItem = exports.DeleteRowItem = function DeleteRowItem(props) {
21
21
  var _tableMenuContext$sel, _tooltip;
@@ -37,7 +37,7 @@ var DeleteRowItem = exports.DeleteRowItem = function DeleteRowItem(props) {
37
37
  if (!editorView) {
38
38
  return;
39
39
  }
40
- var selectionRect = (0, _utils.getSelectionRect)(editorView.state.selection);
40
+ var selectionRect = (0, _selection2.getMenuSelectionRect)(editorView.state.selection);
41
41
  if (!selectionRect) {
42
42
  return;
43
43
  }
@@ -54,7 +54,7 @@ var DeleteRowItem = exports.DeleteRowItem = function DeleteRowItem(props) {
54
54
  if (!editorView) {
55
55
  return;
56
56
  }
57
- var selectionRect = (0, _utils.getSelectionRect)(editorView.state.selection);
57
+ var selectionRect = (0, _selection2.getMenuSelectionRect)(editorView.state.selection);
58
58
  if (!selectionRect) {
59
59
  return;
60
60
  }
@@ -6,15 +6,155 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.getSharedItems = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
9
10
  var _keys = require("../cell/keys");
11
+ var _AddColumnRightItem = require("../column/items/AddColumnRightItem");
12
+ var _DeleteColumnItem = require("../column/items/DeleteColumnItem");
13
+ var _DistributeColumnsItem = require("../column/items/DistributeColumnsItem");
10
14
  var _keys2 = require("../column/keys");
15
+ var _AddRowBelowItem = require("../row/items/AddRowBelowItem");
16
+ var _DeleteRowItem = require("../row/items/DeleteRowItem");
11
17
  var _keys3 = require("../row/keys");
12
18
  var _BackgroundColorItem = require("./items/BackgroundColorItem");
13
19
  var _ClearCellsItem = require("./items/ClearCellsItem");
14
20
  var _keys4 = require("./keys");
15
21
  var getSharedItems = exports.getSharedItems = function getSharedItems(_ref) {
16
22
  var api = _ref.api;
17
- return [{
23
+ return (0, _platformFeatureFlags.fg)('platform_editor_table_cell_menu_update') ? [
24
+ // --- Cell menu update ON ---
25
+ // The add/delete items move out of the row/column menu files and are registered here
26
+ // once with an additional cell parent, so they render inside the cell menu too.
27
+ {
28
+ type: _keys4.BACKGROUND_COLOR_ITEM.type,
29
+ key: _keys4.BACKGROUND_COLOR_ITEM.key,
30
+ parents: [{
31
+ type: _keys3.ROW_BACKGROUND_SECTION.type,
32
+ key: _keys3.ROW_BACKGROUND_SECTION.key,
33
+ rank: _keys3.ROW_BACKGROUND_SECTION_RANK[_keys4.BACKGROUND_COLOR_ITEM.key]
34
+ }, {
35
+ type: _keys2.COLUMN_BACKGROUND_SECTION.type,
36
+ key: _keys2.COLUMN_BACKGROUND_SECTION.key,
37
+ rank: _keys2.COLUMN_BACKGROUND_SECTION_RANK[_keys4.BACKGROUND_COLOR_ITEM.key]
38
+ }, {
39
+ type: _keys.CELL_ACTION_SECTION.type,
40
+ key: _keys.CELL_ACTION_SECTION.key,
41
+ rank: _keys.CELL_ACTION_SECTION_RANK[_keys4.BACKGROUND_COLOR_ITEM.key]
42
+ }],
43
+ component: function component() {
44
+ return /*#__PURE__*/_react.default.createElement(_BackgroundColorItem.BackgroundColorItem, {
45
+ api: api
46
+ });
47
+ }
48
+ }, {
49
+ type: _keys2.ADD_COLUMN_RIGHT_ITEM.type,
50
+ key: _keys2.ADD_COLUMN_RIGHT_ITEM.key,
51
+ parents: [{
52
+ type: _keys2.COLUMN_ADD_SECTION.type,
53
+ key: _keys2.COLUMN_ADD_SECTION.key,
54
+ rank: _keys2.COLUMN_ADD_SECTION_RANK[_keys2.ADD_COLUMN_RIGHT_ITEM.key]
55
+ }, {
56
+ type: _keys.CELL_ADD_SECTION.type,
57
+ key: _keys.CELL_ADD_SECTION.key,
58
+ rank: _keys.CELL_ADD_SECTION_RANK[_keys2.ADD_COLUMN_RIGHT_ITEM.key]
59
+ }],
60
+ component: function component() {
61
+ return /*#__PURE__*/_react.default.createElement(_AddColumnRightItem.AddColumnRightItem, {
62
+ api: api
63
+ });
64
+ }
65
+ }, {
66
+ type: _keys3.ADD_ROW_BELOW_ITEM.type,
67
+ key: _keys3.ADD_ROW_BELOW_ITEM.key,
68
+ parents: [{
69
+ type: _keys3.ROW_ADD_SECTION.type,
70
+ key: _keys3.ROW_ADD_SECTION.key,
71
+ rank: _keys3.ROW_ADD_SECTION_RANK[_keys3.ADD_ROW_BELOW_ITEM.key]
72
+ }, {
73
+ type: _keys.CELL_ADD_SECTION.type,
74
+ key: _keys.CELL_ADD_SECTION.key,
75
+ rank: _keys.CELL_ADD_SECTION_RANK[_keys3.ADD_ROW_BELOW_ITEM.key]
76
+ }],
77
+ component: function component() {
78
+ return /*#__PURE__*/_react.default.createElement(_AddRowBelowItem.AddRowBelowItem, {
79
+ api: api
80
+ });
81
+ }
82
+ }, {
83
+ type: _keys2.DISTRIBUTE_COLUMNS_ITEM.type,
84
+ key: _keys2.DISTRIBUTE_COLUMNS_ITEM.key,
85
+ parents: [{
86
+ type: _keys2.COLUMN_ADD_SECTION.type,
87
+ key: _keys2.COLUMN_ADD_SECTION.key,
88
+ rank: _keys2.COLUMN_ADD_SECTION_RANK[_keys2.DISTRIBUTE_COLUMNS_ITEM.key]
89
+ }, {
90
+ type: _keys.CELL_ADD_SECTION.type,
91
+ key: _keys.CELL_ADD_SECTION.key,
92
+ rank: _keys.CELL_ADD_SECTION_RANK[_keys2.DISTRIBUTE_COLUMNS_ITEM.key]
93
+ }],
94
+ component: function component() {
95
+ return /*#__PURE__*/_react.default.createElement(_DistributeColumnsItem.DistributeColumnsItem, {
96
+ api: api
97
+ });
98
+ }
99
+ }, {
100
+ type: _keys4.CLEAR_CELLS_ITEM.type,
101
+ key: _keys4.CLEAR_CELLS_ITEM.key,
102
+ parents: [{
103
+ type: _keys3.ROW_DANGER_SECTION.type,
104
+ key: _keys3.ROW_DANGER_SECTION.key,
105
+ rank: _keys3.ROW_DANGER_SECTION_RANK[_keys4.CLEAR_CELLS_ITEM.key]
106
+ }, {
107
+ type: _keys2.COLUMN_DANGER_SECTION.type,
108
+ key: _keys2.COLUMN_DANGER_SECTION.key,
109
+ rank: _keys2.COLUMN_DANGER_SECTION_RANK[_keys4.CLEAR_CELLS_ITEM.key]
110
+ }, {
111
+ type: _keys.CELL_DANGER_SECTION.type,
112
+ key: _keys.CELL_DANGER_SECTION.key,
113
+ rank: _keys.CELL_DANGER_SECTION_RANK[_keys4.CLEAR_CELLS_ITEM.key]
114
+ }],
115
+ component: function component() {
116
+ return /*#__PURE__*/_react.default.createElement(_ClearCellsItem.ClearCellsItem, {
117
+ api: api
118
+ });
119
+ }
120
+ }, {
121
+ type: _keys2.DELETE_COLUMN_ITEM.type,
122
+ key: _keys2.DELETE_COLUMN_ITEM.key,
123
+ parents: [{
124
+ type: _keys2.COLUMN_DANGER_SECTION.type,
125
+ key: _keys2.COLUMN_DANGER_SECTION.key,
126
+ rank: _keys2.COLUMN_DANGER_SECTION_RANK[_keys2.DELETE_COLUMN_ITEM.key]
127
+ }, {
128
+ type: _keys.CELL_DANGER_SECTION.type,
129
+ key: _keys.CELL_DANGER_SECTION.key,
130
+ rank: _keys.CELL_DANGER_SECTION_RANK[_keys2.DELETE_COLUMN_ITEM.key]
131
+ }],
132
+ component: function component() {
133
+ return /*#__PURE__*/_react.default.createElement(_DeleteColumnItem.DeleteColumnItem, {
134
+ api: api
135
+ });
136
+ }
137
+ }, {
138
+ type: _keys3.DELETE_ROW_ITEM.type,
139
+ key: _keys3.DELETE_ROW_ITEM.key,
140
+ parents: [{
141
+ type: _keys3.ROW_DANGER_SECTION.type,
142
+ key: _keys3.ROW_DANGER_SECTION.key,
143
+ rank: _keys3.ROW_DANGER_SECTION_RANK[_keys3.DELETE_ROW_ITEM.key]
144
+ }, {
145
+ type: _keys.CELL_DANGER_SECTION.type,
146
+ key: _keys.CELL_DANGER_SECTION.key,
147
+ rank: _keys.CELL_DANGER_SECTION_RANK[_keys3.DELETE_ROW_ITEM.key]
148
+ }],
149
+ component: function component() {
150
+ return /*#__PURE__*/_react.default.createElement(_DeleteRowItem.DeleteRowItem, {
151
+ api: api
152
+ });
153
+ }
154
+ }] : [
155
+ // --- Cell menu update OFF: legacy shared items (background color + clear cells only).
156
+ // The add/delete items are registered by the row/column menu files in this mode.
157
+ {
18
158
  type: _keys4.BACKGROUND_COLOR_ITEM.type,
19
159
  key: _keys4.BACKGROUND_COLOR_ITEM.key,
20
160
  parents: [{
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getMenuSelectionRect = void 0;
7
+ var _utils = require("@atlaskit/editor-tables/utils");
8
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
9
+ /**
10
+ * Resolve the table `Rect` for the current selection. Falls back to the closest cell's rect
11
+ * for a `TextSelection` (cell menu), where `getSelectionRect` returns `undefined`. Gated:
12
+ * with the gate off this behaves exactly like `getSelectionRect`.
13
+ */
14
+ var getMenuSelectionRect = exports.getMenuSelectionRect = function getMenuSelectionRect(selection) {
15
+ if (!(0, _platformFeatureFlags.fg)('platform_editor_table_cell_menu_update')) {
16
+ return (0, _utils.getSelectionRect)(selection);
17
+ }
18
+ return (0, _utils.isSelectionType)(selection, 'cell') ? (0, _utils.getSelectionRect)(selection) : (0, _utils.findCellRectClosestToPos)(selection.$from);
19
+ };
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { RawIntlProvider } from 'react-intl';
3
+ import { isSSR, isSSRStreaming } from '@atlaskit/editor-common/core-utils';
4
+ export function TableSSRReactContextsProvider({
5
+ children,
6
+ intl
7
+ }) {
8
+ if (!isSSR() || !isSSRStreaming()) {
9
+ return children;
10
+ }
11
+ if (!intl) {
12
+ return children;
13
+ }
14
+ return /*#__PURE__*/React.createElement(RawIntlProvider, {
15
+ value: intl
16
+ }, children);
17
+ }
@@ -7,7 +7,7 @@ import TableRow from './TableRow';
7
7
  import TableRowNativeStickyWithFallback from './TableRowNativeStickyWithFallback';
8
8
  export const tableView = options => {
9
9
  return (node, view, getPos) => {
10
- return createTableView(node, view, getPos, options.portalProviderAPI, options.eventDispatcher, options.getEditorContainerWidth, options.getEditorFeatureFlags, options.dispatchAnalyticsEvent, options.pluginInjectionApi, options.isCommentEditor, options.isChromelessEditor, options === null || options === void 0 ? void 0 : options.allowFixedColumnWidthOption);
10
+ return createTableView(node, view, getPos, options.portalProviderAPI, options.eventDispatcher, options.getEditorContainerWidth, options.getEditorFeatureFlags, options.dispatchAnalyticsEvent, options.pluginInjectionApi, options.isCommentEditor, options.isChromelessEditor, options === null || options === void 0 ? void 0 : options.allowFixedColumnWidthOption, options.intl);
11
11
  };
12
12
  };
13
13
  export const tableCellView = options => {
@@ -1,6 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React from 'react';
3
- import { isSSR, isSSRStreaming } from '@atlaskit/editor-common/core-utils';
3
+ import { isSSRStreaming } from '@atlaskit/editor-common/core-utils';
4
4
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
5
5
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
6
6
  import { isTableInContentMode } from '@atlaskit/editor-common/table';
@@ -17,6 +17,7 @@ import { isTableNested, tablesHaveDifferentColumnWidths } from '../pm-plugins/ut
17
17
  import { isContentModeSupported } from '../pm-plugins/utils/tableMode/is-content-mode-supported';
18
18
  import { RoundedTableEdges } from './rounded-table-edges';
19
19
  import { TableComponentWithSharedState } from './TableComponentWithSharedState';
20
+ import { TableSSRReactContextsProvider } from './TableSSRReactContextsProvider';
20
21
  import { tableNodeSpecWithFixedToDOM } from './toDOM';
21
22
  const tableAttributes = node => {
22
23
  return {
@@ -62,6 +63,7 @@ export default class TableView extends ReactNodeView {
62
63
  this.eventDispatcher = props.eventDispatcher;
63
64
  this.options = props.options;
64
65
  this.getEditorFeatureFlags = props.getEditorFeatureFlags;
66
+ this.intl = props.intl;
65
67
  if (expValEquals('platform_editor_table_q4_loveability', 'isEnabled', true)) {
66
68
  this.roundedTableEdges = new RoundedTableEdges(() => this.table, props.node);
67
69
  }
@@ -140,7 +142,11 @@ export default class TableView extends ReactNodeView {
140
142
  }
141
143
 
142
144
  // Remove the ProseMirror table DOM structure to avoid duplication, as it's replaced with the React table node.
143
- if (this.dom && this.renderedDOM) {
145
+ // In SSR streaming the portal renders via `container.innerHTML = html` (portal/common.tsx), which detaches
146
+ // `renderedDOM` from `dom` before this runs; require it to still be a child so `removeChild` doesn't throw
147
+ // `NotFoundError` (which would make EditorSSRRenderer fall back to the position-blind schema toDOM and lose
148
+ // nested detection). CSR keeps the original condition unchanged.
149
+ if (this.dom && this.renderedDOM && (!isSSRStreaming() || this.renderedDOM.parentNode === this.dom)) {
144
150
  this.dom.removeChild(this.renderedDOM);
145
151
  }
146
152
  // Move the table from the ProseMirror table structure into the React rendered table node.
@@ -232,7 +238,9 @@ export default class TableView extends ReactNodeView {
232
238
  return didUpdate;
233
239
  }
234
240
  render(props, forwardRef) {
235
- return /*#__PURE__*/React.createElement(TableComponentWithSharedState, {
241
+ return /*#__PURE__*/React.createElement(TableSSRReactContextsProvider, {
242
+ intl: this.intl
243
+ }, /*#__PURE__*/React.createElement(TableComponentWithSharedState, {
236
244
  forwardRef: forwardRef,
237
245
  getNode: this.getNode,
238
246
  view: props.view,
@@ -247,7 +255,7 @@ export default class TableView extends ReactNodeView {
247
255
  getEditorFeatureFlags: props.getEditorFeatureFlags,
248
256
  dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
249
257
  allowFixedColumnWidthOption: props.allowFixedColumnWidthOption
250
- });
258
+ }));
251
259
  }
252
260
  viewShouldUpdate(nextNode) {
253
261
  const {
@@ -315,7 +323,7 @@ export default class TableView extends ReactNodeView {
315
323
  super.destroy();
316
324
  }
317
325
  }
318
- export const createTableView = (node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi, isCommentEditor, isChromelessEditor, allowFixedColumnWidthOption) => {
326
+ export const createTableView = (node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi, isCommentEditor, isChromelessEditor, allowFixedColumnWidthOption, intl) => {
319
327
  var _pluginInjectionApi$t;
320
328
  const {
321
329
  pluginConfig,
@@ -332,22 +340,6 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
332
340
  } = getPluginConfig(pluginConfig);
333
341
  const isTableFixedColumnWidthsOptionEnabled = (fg('platform_editor_table_fixed_column_width_prop') ? allowFixedColumnWidthOption : getEditorFeatureFlags === null || getEditorFeatureFlags === void 0 ? void 0 : getEditorFeatureFlags().tableWithFixedColumnWidthsOption) || false;
334
342
  const shouldUseIncreasedScalingPercent = isTableScalingEnabled && (isTableFixedColumnWidthsOptionEnabled || isCommentEditor);
335
-
336
- // In SSR use native ProseMirror spec-based render for table nodes
337
- if (isSSR() && isSSRStreaming()) {
338
- const isNested = isTableNested(view.state, typeof getPos === 'function' ? getPos() : undefined);
339
- const tableDOMStructure = tableNodeSpecWithFixedToDOM({
340
- allowColumnResizing: allowColumnResizing !== null && allowColumnResizing !== void 0 ? allowColumnResizing : false,
341
- tableResizingEnabled: allowTableResizing !== null && allowTableResizing !== void 0 ? allowTableResizing : false,
342
- getEditorContainerWidth,
343
- isTableScalingEnabled,
344
- shouldUseIncreasedScalingPercent,
345
- isCommentEditor,
346
- isChromelessEditor,
347
- isNested
348
- }).toDOM(node);
349
- return DOMSerializer.renderSpec(document, tableDOMStructure);
350
- }
351
343
  return new TableView({
352
344
  node,
353
345
  view,
@@ -371,6 +363,7 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
371
363
  getEditorFeatureFlags,
372
364
  dispatchAnalyticsEvent,
373
365
  pluginInjectionApi,
374
- allowFixedColumnWidthOption
366
+ allowFixedColumnWidthOption,
367
+ intl
375
368
  }).init();
376
369
  };
@@ -6,7 +6,9 @@ import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
6
6
  import { hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
7
7
  import { TableMap } from '@atlaskit/editor-tables/table-map';
8
8
  import { addColumnAt as addColumnAtPMUtils, addRowAt, findTable, selectedRect } from '@atlaskit/editor-tables/utils';
9
+ import { fg } from '@atlaskit/platform-feature-flags';
9
10
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
11
+ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
10
12
  import { updateRowOrColumnMovedTransform } from '../analytics/commands';
11
13
  import { META_KEYS } from '../table-analytics';
12
14
  import { rescaleColumns } from '../transforms/column-width';
@@ -232,7 +234,14 @@ export const insertTableWithNestingSupport = ({
232
234
  }, api, analyticsPayload) => ({
233
235
  tr
234
236
  }) => {
235
- var _api$contentInsertion, _api$contentInsertion2, _tr$selection$$from$n2;
237
+ var _api$markdownMode, _api$contentInsertion, _api$contentInsertion2, _tr$selection$$from$n2;
238
+ // Delegate to the markdown plugin to insert a markdown table string at the CM cursor position.
239
+ const markdownState = api === null || api === void 0 ? void 0 : (_api$markdownMode = api.markdownMode) === null || _api$markdownMode === void 0 ? void 0 : _api$markdownMode.sharedState.currentState();
240
+ if (markdownState !== null && markdownState !== void 0 && markdownState.isMarkdownMode && (markdownState === null || markdownState === void 0 ? void 0 : markdownState.view) === 'syntax' && expValEqualsNoExposure('cc-markdown-mode', 'isEnabled', true) && fg('platform_editor_markdown_compatible_toolbar')) {
241
+ var _api$markdownMode2;
242
+ api === null || api === void 0 ? void 0 : (_api$markdownMode2 = api.markdownMode) === null || _api$markdownMode2 === void 0 ? void 0 : _api$markdownMode2.actions.insertSourceTable(createTableProps.rowsCount, createTableProps.colsCount);
243
+ return tr;
244
+ }
236
245
  const {
237
246
  schema
238
247
  } = tr.doc.type;
@@ -1,7 +1,7 @@
1
1
  import { bind } from 'bind-event-listener';
2
2
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import { getBrowserInfo } from '@atlaskit/editor-common/browser';
4
- import { insideTable } from '@atlaskit/editor-common/core-utils';
4
+ import { insideTable, isSSRStreaming } from '@atlaskit/editor-common/core-utils';
5
5
  import { isNestedTablesSupported } from '@atlaskit/editor-common/nesting';
6
6
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
7
7
  import { transformSliceToRemoveOpenBodiedExtension, transformSliceToRemoveOpenExpand, transformSliceToRemoveOpenLayoutNodes, transformSliceToRemoveOpenMultiBodiedExtension, transformSliceToRemoveOpenNestedExpand } from '@atlaskit/editor-common/transforms';
@@ -60,6 +60,7 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
60
60
  }
61
61
  return editorView.state;
62
62
  };
63
+ const intl = isSSRStreaming() ? getIntl() : undefined;
63
64
  const getNodeView = () => {
64
65
  return {
65
66
  table: tableView({
@@ -71,7 +72,8 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
71
72
  pluginInjectionApi,
72
73
  isCommentEditor,
73
74
  isChromelessEditor,
74
- allowFixedColumnWidthOption
75
+ allowFixedColumnWidthOption,
76
+ intl
75
77
  }),
76
78
  tableRow: tableRowView({
77
79
  eventDispatcher,
@@ -1,3 +1,4 @@
1
+ import { isSSRStreaming } from '@atlaskit/editor-common/core-utils';
1
2
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
2
3
  import { calcTableColumnWidths, getFragmentBackingArray } from '@atlaskit/editor-common/utils';
3
4
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
@@ -22,7 +23,7 @@ const generateColStyle = (fixedColWidth, tableWidth, isCommentEditor, isChromele
22
23
  if (hasTableBeenResized) {
23
24
  return `width: max(${fixedColWidth}px, ${tableCellMinWidth}px)`;
24
25
  }
25
- return `width: ${tableCellMinWidth}px)`;
26
+ return isSSRStreaming() ? `width: ${tableCellMinWidth}px` : `width: ${tableCellMinWidth}px)`;
26
27
  }
27
28
  if (isFullPageEditor || !isFullPageEditor && isTableHasWidth) {
28
29
  const scaledPercent = isNumberColumnEnabled ? `calc(calc(var(--ak-editor-table-width) - ${akEditorTableNumberColumnWidth}px - 1px)/${tableWidth})` : `calc(calc(var(--ak-editor-table-width) - 1px)/${tableWidth})`;