@atlaskit/editor-plugin-table 10.9.20 → 10.9.22

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 (61) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/nodeviews/TableComponentWithSharedState.js +91 -78
  3. package/dist/cjs/nodeviews/TableContainer.js +41 -37
  4. package/dist/cjs/nodeviews/TableResizer.js +15 -11
  5. package/dist/cjs/pm-plugins/main.js +4 -12
  6. package/dist/cjs/tablePlugin.js +22 -12
  7. package/dist/cjs/ui/ContentComponent.js +40 -65
  8. package/dist/cjs/ui/DragHandle/index.js +19 -17
  9. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +14 -11
  10. package/dist/cjs/ui/TableFloatingControls/CornerControls/DragCornerControls.js +14 -10
  11. package/dist/cjs/ui/TableFloatingControls/FloatingControlsWithSelection.js +14 -10
  12. package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +14 -10
  13. package/dist/cjs/ui/global-styles.js +14 -10
  14. package/dist/cjs/ui/icons/SortingIconWrapper.js +14 -11
  15. package/dist/es2019/nodeviews/TableComponentWithSharedState.js +92 -78
  16. package/dist/es2019/nodeviews/TableContainer.js +44 -39
  17. package/dist/es2019/nodeviews/TableResizer.js +17 -12
  18. package/dist/es2019/pm-plugins/main.js +4 -12
  19. package/dist/es2019/tablePlugin.js +24 -13
  20. package/dist/es2019/ui/ContentComponent.js +41 -66
  21. package/dist/es2019/ui/DragHandle/index.js +21 -18
  22. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +16 -12
  23. package/dist/es2019/ui/TableFloatingControls/CornerControls/DragCornerControls.js +16 -11
  24. package/dist/es2019/ui/TableFloatingControls/FloatingControlsWithSelection.js +16 -11
  25. package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +16 -11
  26. package/dist/es2019/ui/global-styles.js +16 -11
  27. package/dist/es2019/ui/icons/SortingIconWrapper.js +16 -12
  28. package/dist/esm/nodeviews/TableComponentWithSharedState.js +92 -79
  29. package/dist/esm/nodeviews/TableContainer.js +42 -38
  30. package/dist/esm/nodeviews/TableResizer.js +16 -12
  31. package/dist/esm/pm-plugins/main.js +4 -12
  32. package/dist/esm/tablePlugin.js +23 -13
  33. package/dist/esm/ui/ContentComponent.js +41 -66
  34. package/dist/esm/ui/DragHandle/index.js +20 -18
  35. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +15 -12
  36. package/dist/esm/ui/TableFloatingControls/CornerControls/DragCornerControls.js +15 -11
  37. package/dist/esm/ui/TableFloatingControls/FloatingControlsWithSelection.js +15 -11
  38. package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +15 -11
  39. package/dist/esm/ui/global-styles.js +15 -11
  40. package/dist/esm/ui/icons/SortingIconWrapper.js +15 -12
  41. package/dist/types/types/index.d.ts +2 -0
  42. package/dist/types/ui/ContentComponent.d.ts +2 -1
  43. package/dist/types/ui/hooks/useInternalTablePluginStateSelector.d.ts +1 -1
  44. package/dist/types-ts4.5/types/index.d.ts +2 -0
  45. package/dist/types-ts4.5/ui/ContentComponent.d.ts +2 -1
  46. package/dist/types-ts4.5/ui/hooks/useInternalTablePluginStateSelector.d.ts +1 -1
  47. package/package.json +4 -7
  48. package/src/nodeviews/TableComponentWithSharedState.tsx +97 -125
  49. package/src/nodeviews/TableContainer.tsx +59 -67
  50. package/src/nodeviews/TableResizer.tsx +21 -17
  51. package/src/pm-plugins/main.ts +5 -13
  52. package/src/tablePlugin.tsx +30 -13
  53. package/src/types/index.ts +2 -0
  54. package/src/ui/ContentComponent.tsx +59 -65
  55. package/src/ui/DragHandle/index.tsx +24 -24
  56. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +20 -13
  57. package/src/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +20 -12
  58. package/src/ui/TableFloatingControls/FloatingControlsWithSelection.tsx +20 -13
  59. package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +20 -13
  60. package/src/ui/global-styles.tsx +20 -13
  61. package/src/ui/icons/SortingIconWrapper.tsx +20 -14
@@ -2,7 +2,10 @@ import React from 'react';
2
2
 
3
3
  import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
4
4
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
5
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
5
+ import {
6
+ sharedPluginStateHookMigratorFactory,
7
+ useSharedPluginState,
8
+ } from '@atlaskit/editor-common/hooks';
6
9
  import type { GetEditorFeatureFlags, getPosHandlerNode } from '@atlaskit/editor-common/types';
7
10
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
8
11
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
@@ -36,6 +39,80 @@ type TableComponentWithSharedStateProps = {
36
39
  allowTableResizing?: boolean;
37
40
  };
38
41
 
42
+ const useSharedState = sharedPluginStateHookMigratorFactory(
43
+ (api: PluginInjectionAPI | undefined) => {
44
+ // tableState
45
+ const isTableResizing = useInternalTablePluginStateSelector(api, 'isTableResizing');
46
+ const isHeaderColumnEnabled = useInternalTablePluginStateSelector(api, 'isHeaderColumnEnabled');
47
+ const isHeaderRowEnabled = useInternalTablePluginStateSelector(api, 'isHeaderRowEnabled');
48
+ const ordering = useInternalTablePluginStateSelector(api, 'ordering');
49
+ const isResizing = useInternalTablePluginStateSelector(api, 'isResizing');
50
+ const isInDanger = useInternalTablePluginStateSelector(api, 'isInDanger');
51
+ const hoveredCell = useInternalTablePluginStateSelector(api, 'hoveredCell');
52
+ const hoveredRows = useInternalTablePluginStateSelector(api, 'hoveredRows');
53
+ const isTableHovered = useInternalTablePluginStateSelector(api, 'isTableHovered');
54
+ const isWholeTableInDanger = useInternalTablePluginStateSelector(api, 'isWholeTableInDanger');
55
+
56
+ // mediaState
57
+ const isFullscreen = useSharedPluginStateSelector(api, 'media.isFullscreen');
58
+
59
+ // selectionState
60
+ const selection = useSharedPluginStateSelector(api, 'selection.selection');
61
+
62
+ // editorViewModeState
63
+ const mode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
64
+
65
+ // widthState
66
+ const width = useSharedPluginStateSelector(api, 'width.width');
67
+ const lineLength = useSharedPluginStateSelector(api, 'width.lineLength');
68
+
69
+ return {
70
+ tableState: undefined,
71
+ widthState: undefined,
72
+ isTableResizing,
73
+ isHeaderColumnEnabled,
74
+ isHeaderRowEnabled,
75
+ ordering,
76
+ isResizing,
77
+ isInDanger,
78
+ hoveredCell,
79
+ hoveredRows,
80
+ isTableHovered,
81
+ isWholeTableInDanger,
82
+ isFullscreen,
83
+ selection,
84
+ mode,
85
+ width,
86
+ lineLength,
87
+ };
88
+ },
89
+ (api: PluginInjectionAPI | undefined) => {
90
+ const { widthState, tableState, mediaState, selectionState, editorViewModeState } =
91
+ useSharedPluginState(api, ['width', 'table', 'media', 'selection', 'editorViewMode']);
92
+ const tableStateInternal = tableState as TableSharedStateInternal | undefined;
93
+
94
+ return {
95
+ tableState,
96
+ widthState,
97
+ isTableResizing: tableStateInternal?.isTableResizing,
98
+ isHeaderColumnEnabled: tableStateInternal?.isHeaderColumnEnabled,
99
+ isHeaderRowEnabled: tableStateInternal?.isHeaderRowEnabled,
100
+ ordering: tableStateInternal?.ordering,
101
+ isResizing: tableStateInternal?.isResizing,
102
+ isInDanger: tableStateInternal?.isInDanger,
103
+ hoveredCell: tableStateInternal?.hoveredCell,
104
+ hoveredRows: tableStateInternal?.hoveredRows,
105
+ isTableHovered: tableStateInternal?.isTableHovered,
106
+ isWholeTableInDanger: tableStateInternal?.isWholeTableInDanger,
107
+ isFullscreen: mediaState?.isFullscreen,
108
+ selection: selectionState?.selection,
109
+ mode: editorViewModeState?.mode,
110
+ width: widthState?.width,
111
+ lineLength: widthState?.lineLength,
112
+ };
113
+ },
114
+ );
115
+
39
116
  /**
40
117
  * Use useSharedPluginState to control re-renders from plugin dependencies
41
118
  */
@@ -54,136 +131,31 @@ export const TableComponentWithSharedState = ({
54
131
  allowTableAlignment,
55
132
  allowTableResizing,
56
133
  }: TableComponentWithSharedStateProps) => {
57
- const { widthState, tableState, mediaState, selectionState, editorViewModeState } =
58
- useSharedPluginState(api, ['width', 'table', 'media', 'selection', 'editorViewMode'], {
59
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
60
- });
61
-
62
- const isTableResizingSelector = useInternalTablePluginStateSelector(api, 'isTableResizing', {
63
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
64
- });
65
- const isHeaderColumnEnabledSelector = useInternalTablePluginStateSelector(
66
- api,
67
- 'isHeaderColumnEnabled',
68
- {
69
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
70
- },
71
- );
72
- const isHeaderRowEnabledSelector = useInternalTablePluginStateSelector(
73
- api,
74
- 'isHeaderRowEnabled',
75
- {
76
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
77
- },
78
- );
79
- const orderingSelector = useInternalTablePluginStateSelector(api, 'ordering', {
80
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
81
- });
82
- const isResizingSelector = useInternalTablePluginStateSelector(api, 'isResizing', {
83
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
84
- });
85
- const isInDangerSelector = useInternalTablePluginStateSelector(api, 'isInDanger', {
86
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
87
- });
88
- const hoveredCellSelector = useInternalTablePluginStateSelector(api, 'hoveredCell', {
89
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
90
- });
91
- const hoveredRowsSelector = useInternalTablePluginStateSelector(api, 'hoveredRows', {
92
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
93
- });
94
- const isTableHoveredSelector = useInternalTablePluginStateSelector(api, 'isTableHovered', {
95
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
96
- });
97
- const isWholeTableInDangerSelector = useInternalTablePluginStateSelector(
98
- api,
99
- 'isWholeTableInDanger',
100
- {
101
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
102
- },
103
- );
104
-
105
- // mediaState
106
- const isFullscreenSelector = useSharedPluginStateSelector(api, 'media.isFullscreen', {
107
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
108
- });
109
- const isFullscreen = editorExperiment('platform_editor_usesharedpluginstateselector', true)
110
- ? isFullscreenSelector
111
- : mediaState?.isFullscreen;
112
-
113
- // selectionState
114
- const selectionSelector = useSharedPluginStateSelector(api, 'selection.selection', {
115
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
116
- });
117
- const selection = editorExperiment('platform_editor_usesharedpluginstateselector', true)
118
- ? selectionSelector
119
- : selectionState?.selection;
120
-
121
- // editorViewModeState
122
- const editorViewModeSelector = useSharedPluginStateSelector(api, 'editorViewMode.mode', {
123
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
124
- });
125
- const mode = editorExperiment('platform_editor_usesharedpluginstateselector', true)
126
- ? editorViewModeSelector
127
- : editorViewModeState?.mode;
134
+ const {
135
+ tableState,
136
+ widthState,
137
+ mode,
138
+ hoveredCell,
139
+ hoveredRows,
140
+ isFullscreen,
141
+ isHeaderColumnEnabled,
142
+ isHeaderRowEnabled,
143
+ isInDanger,
144
+ isResizing,
145
+ isTableHovered,
146
+ isTableResizing,
147
+ isWholeTableInDanger,
148
+ lineLength,
149
+ ordering,
150
+ selection,
151
+ width,
152
+ } = useSharedState(api);
128
153
  const isLivePageViewMode = mode === 'view';
129
154
 
130
- // widthState
131
- const widthSelector = useSharedPluginStateSelector(api, 'width.width', {
132
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
133
- });
134
- const width = editorExperiment('platform_editor_usesharedpluginstateselector', true)
135
- ? widthSelector
136
- : widthState?.width;
137
-
138
- const lineLengthSelector = useSharedPluginStateSelector(api, 'width.lineLength', {
139
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
140
- });
141
- const lineLength = editorExperiment('platform_editor_usesharedpluginstateselector', true)
142
- ? lineLengthSelector
143
- : widthState?.lineLength;
144
-
145
155
  if (editorExperiment('platform_editor_usesharedpluginstateselector', false) && !tableState) {
146
156
  return null;
147
157
  }
148
158
 
149
- // tableState
150
- const isTableResizing = editorExperiment('platform_editor_usesharedpluginstateselector', true)
151
- ? isTableResizingSelector
152
- : (tableState as TableSharedStateInternal).isTableResizing;
153
- const isHeaderColumnEnabled = editorExperiment(
154
- 'platform_editor_usesharedpluginstateselector',
155
- true,
156
- )
157
- ? isHeaderColumnEnabledSelector
158
- : (tableState as TableSharedStateInternal).isHeaderColumnEnabled;
159
- const isHeaderRowEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true)
160
- ? isHeaderRowEnabledSelector
161
- : (tableState as TableSharedStateInternal).isHeaderRowEnabled;
162
- const ordering = editorExperiment('platform_editor_usesharedpluginstateselector', true)
163
- ? orderingSelector
164
- : (tableState as TableSharedStateInternal).ordering;
165
- const isResizing = editorExperiment('platform_editor_usesharedpluginstateselector', true)
166
- ? isResizingSelector
167
- : (tableState as TableSharedStateInternal).isResizing;
168
- const isInDanger = editorExperiment('platform_editor_usesharedpluginstateselector', true)
169
- ? isInDangerSelector
170
- : (tableState as TableSharedStateInternal).isInDanger;
171
- const hoveredCell = editorExperiment('platform_editor_usesharedpluginstateselector', true)
172
- ? hoveredCellSelector
173
- : (tableState as TableSharedStateInternal).hoveredCell;
174
- const hoveredRows = editorExperiment('platform_editor_usesharedpluginstateselector', true)
175
- ? hoveredRowsSelector
176
- : (tableState as TableSharedStateInternal).hoveredRows;
177
- const isTableHovered = editorExperiment('platform_editor_usesharedpluginstateselector', true)
178
- ? isTableHoveredSelector
179
- : (tableState as TableSharedStateInternal).isTableHovered;
180
- const isWholeTableInDanger = editorExperiment(
181
- 'platform_editor_usesharedpluginstateselector',
182
- true,
183
- )
184
- ? isWholeTableInDangerSelector
185
- : (tableState as TableSharedStateInternal).isWholeTableInDanger;
186
-
187
159
  /**
188
160
  * ED-19810
189
161
  * There is a getPos issue coming from this code. We need to apply this workaround for now and apply a patch
@@ -9,7 +9,10 @@ import {
9
9
  type TableEventPayload,
10
10
  } from '@atlaskit/editor-common/analytics';
11
11
  import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
12
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
12
+ import {
13
+ sharedPluginStateHookMigratorFactory,
14
+ useSharedPluginState,
15
+ } from '@atlaskit/editor-common/hooks';
13
16
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
14
17
  import type { EditorContainerWidth } from '@atlaskit/editor-common/types';
15
18
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
@@ -71,6 +74,32 @@ type AlignmentTableContainerProps = {
71
74
  editorView?: EditorView;
72
75
  };
73
76
 
77
+ const useAlignmentStableContainerSharedState = sharedPluginStateHookMigratorFactory(
78
+ (pluginInjectionApi: PluginInjectionAPI | undefined) => {
79
+ const isFullWidthModeEnabled = useSharedPluginStateSelector(
80
+ pluginInjectionApi,
81
+ 'table.isFullWidthModeEnabled',
82
+ );
83
+ const wasFullWidthModeEnabled = useSharedPluginStateSelector(
84
+ pluginInjectionApi,
85
+ 'table.wasFullWidthModeEnabled',
86
+ );
87
+ return {
88
+ tableState: undefined,
89
+ isFullWidthModeEnabled,
90
+ wasFullWidthModeEnabled,
91
+ };
92
+ },
93
+ (pluginInjectionApi: PluginInjectionAPI | undefined) => {
94
+ const { tableState } = useSharedPluginState(pluginInjectionApi, ['table']);
95
+ return {
96
+ tableState,
97
+ isFullWidthModeEnabled: tableState?.isFullWidthModeEnabled,
98
+ wasFullWidthModeEnabled: tableState?.wasFullWidthModeEnabled,
99
+ };
100
+ },
101
+ );
102
+
74
103
  const AlignmentTableContainer = ({
75
104
  node,
76
105
  children,
@@ -79,39 +108,8 @@ const AlignmentTableContainer = ({
79
108
  editorView,
80
109
  }: PropsWithChildren<AlignmentTableContainerProps>) => {
81
110
  const alignment = node.attrs.layout !== ALIGN_START ? ALIGN_CENTER : ALIGN_START;
82
- const { tableState } = useSharedPluginState(pluginInjectionApi, ['table'], {
83
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
84
- });
85
-
86
- // isFullWidthModeEnabled
87
- const isTableFullWidthModeEnabledSelector = useSharedPluginStateSelector(
88
- pluginInjectionApi,
89
- 'table.isFullWidthModeEnabled',
90
- {
91
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
92
- },
93
- );
94
- const isFullWidthModeEnabled = editorExperiment(
95
- 'platform_editor_usesharedpluginstateselector',
96
- true,
97
- )
98
- ? isTableFullWidthModeEnabledSelector
99
- : tableState?.isFullWidthModeEnabled;
100
-
101
- // wasFullWidthModeEnabled
102
- const wasFullWidthModeEnabledSelector = useSharedPluginStateSelector(
103
- pluginInjectionApi,
104
- 'table.wasFullWidthModeEnabled',
105
- {
106
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
107
- },
108
- );
109
- const wasFullWidthModeEnabled = editorExperiment(
110
- 'platform_editor_usesharedpluginstateselector',
111
- true,
112
- )
113
- ? wasFullWidthModeEnabledSelector
114
- : tableState?.wasFullWidthModeEnabled;
111
+ const { tableState, isFullWidthModeEnabled, wasFullWidthModeEnabled } =
112
+ useAlignmentStableContainerSharedState(pluginInjectionApi);
115
113
 
116
114
  useEffect(() => {
117
115
  if (!tableState && editorExperiment('platform_editor_usesharedpluginstateselector', false)) {
@@ -216,6 +214,30 @@ type ResizableTableContainerProps = {
216
214
  isCommentEditor?: boolean;
217
215
  };
218
216
 
217
+ const useResizeableTableContainerSharedState = sharedPluginStateHookMigratorFactory(
218
+ (pluginInjectionApi: PluginInjectionAPI | undefined) => {
219
+ const isFullWidthModeEnabled = useSharedPluginStateSelector(
220
+ pluginInjectionApi,
221
+ 'table.isFullWidthModeEnabled',
222
+ );
223
+ const mode = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.mode');
224
+ return {
225
+ isFullWidthModeEnabled,
226
+ mode,
227
+ };
228
+ },
229
+ (pluginInjectionApi: PluginInjectionAPI | undefined) => {
230
+ const { tableState, editorViewModeState } = useSharedPluginState(pluginInjectionApi, [
231
+ 'table',
232
+ 'editorViewMode',
233
+ ]);
234
+ return {
235
+ isFullWidthModeEnabled: tableState?.isFullWidthModeEnabled,
236
+ mode: editorViewModeState?.mode,
237
+ };
238
+ },
239
+ );
240
+
219
241
  export const ResizableTableContainer = React.memo(
220
242
  ({
221
243
  children,
@@ -240,24 +262,8 @@ export const ResizableTableContainer = React.memo(
240
262
  const tableWidthRef = useRef<number>(akEditorDefaultLayoutWidth);
241
263
  const [resizing, setIsResizing] = useState(false);
242
264
 
243
- const { tableState } = useSharedPluginState(pluginInjectionApi, ['table'], {
244
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
245
- });
246
-
247
- // isFullWidthModeEnabled
248
- const isFullWidthModeEnabledSelector = useSharedPluginStateSelector(
249
- pluginInjectionApi,
250
- 'table.isFullWidthModeEnabled',
251
- {
252
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
253
- },
254
- );
255
- const isFullWidthModeEnabled = editorExperiment(
256
- 'platform_editor_usesharedpluginstateselector',
257
- true,
258
- )
259
- ? isFullWidthModeEnabledSelector
260
- : tableState?.isFullWidthModeEnabled;
265
+ const { isFullWidthModeEnabled, mode } =
266
+ useResizeableTableContainerSharedState(pluginInjectionApi);
261
267
 
262
268
  const updateContainerHeight = useCallback((height: number | 'auto') => {
263
269
  // current StickyHeader State is not stable to be fetch.
@@ -331,17 +337,6 @@ export const ResizableTableContainer = React.memo(
331
337
  );
332
338
 
333
339
  const tableWidth = getTableContainerWidth(node);
334
- const { editorViewModeState } = useSharedPluginState(pluginInjectionApi, ['editorViewMode'], {
335
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
336
- });
337
-
338
- // mode
339
- const modeSelector = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.mode', {
340
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
341
- });
342
- const mode = editorExperiment('platform_editor_usesharedpluginstateselector', true)
343
- ? modeSelector
344
- : editorViewModeState?.mode;
345
340
 
346
341
  let responsiveContainerWidth = 0;
347
342
  const resizeHandleSpacing = 12;
@@ -405,10 +400,7 @@ export const ResizableTableContainer = React.memo(
405
400
  isCommentEditor,
406
401
  };
407
402
 
408
- const isLivePageViewMode =
409
- (editorExperiment('platform_editor_usesharedpluginstateselector', true)
410
- ? mode
411
- : editorViewModeState?.mode) === 'view';
403
+ const isLivePageViewMode = mode === 'view';
412
404
 
413
405
  return (
414
406
  <AlignmentTableContainerWrapper
@@ -13,7 +13,10 @@ import {
13
13
  import { browser } from '@atlaskit/editor-common/browser';
14
14
  import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
15
15
  import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
16
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
16
+ import {
17
+ sharedPluginStateHookMigratorFactory,
18
+ useSharedPluginState,
19
+ } from '@atlaskit/editor-common/hooks';
17
20
  import { focusTableResizer, ToolTipContent } from '@atlaskit/editor-common/keymaps';
18
21
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
19
22
  import { logException } from '@atlaskit/editor-common/monitoring';
@@ -26,7 +29,6 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
26
29
  import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
27
30
  import { findTable } from '@atlaskit/editor-tables/utils';
28
31
  import { fg } from '@atlaskit/platform-feature-flags';
29
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
30
32
  import { token } from '@atlaskit/tokens';
31
33
 
32
34
  import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../pm-plugins/commands/commands-with-analytics';
@@ -182,6 +184,22 @@ const getVisibleGuidelines = (
182
184
  });
183
185
  };
184
186
 
187
+ const useSharedState = sharedPluginStateHookMigratorFactory(
188
+ (pluginInjectionApi: PluginInjectionAPI | undefined) => {
189
+ const widthToWidest = useInternalTablePluginStateSelector(pluginInjectionApi, 'widthToWidest');
190
+ return {
191
+ widthToWidest,
192
+ };
193
+ },
194
+ (pluginInjectionApi: PluginInjectionAPI | undefined) => {
195
+ const { tableState } = useSharedPluginState(pluginInjectionApi, ['table']);
196
+ const tableStateInternal = tableState as TableSharedStateInternal;
197
+ return {
198
+ widthToWidest: tableStateInternal.widthToWidest,
199
+ };
200
+ },
201
+ );
202
+
185
203
  export const TableResizer = ({
186
204
  children,
187
205
  width,
@@ -213,21 +231,7 @@ export const TableResizer = ({
213
231
  const isResizing = useRef(false);
214
232
  const areResizeMetaKeysPressed = useRef(false);
215
233
  const resizerRef = useRef<ResizerNextHandler>(null);
216
- const { tableState } = useSharedPluginState(pluginInjectionApi, ['table'], {
217
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
218
- });
219
-
220
- // widthToWidest
221
- const widthToWidestSelector = useInternalTablePluginStateSelector(
222
- pluginInjectionApi,
223
- 'widthToWidest',
224
- {
225
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
226
- },
227
- );
228
- const widthToWidest = editorExperiment('platform_editor_usesharedpluginstateselector', true)
229
- ? widthToWidestSelector
230
- : (tableState as TableSharedStateInternal).widthToWidest;
234
+ const { widthToWidest } = useSharedState(pluginInjectionApi);
231
235
 
232
236
  // used to reposition tooltip when table is resizing via keyboard
233
237
  const updateTooltip = React.useRef<() => void>();
@@ -308,19 +308,11 @@ export const createPlugin = (
308
308
 
309
309
  // transformSliceToRemoveOpenTable() transforms based on the depth of the root node, assuming that the tables will be at the root
310
310
  // Bodied extensions will contribute to the depth of the table selection so we need to remove them first
311
- if (fg('platform_editor_nested_tables_bodied_extension_fix')) {
312
- /** If a partial paste of bodied extension, paste only text */
313
- slice = transformSliceToRemoveOpenBodiedExtension(slice, schema);
314
-
315
- /** If a partial paste of table, paste only table's content */
316
- slice = transformSliceToRemoveOpenTable(slice, schema);
317
- } else {
318
- /** If a partial paste of table, paste only table's content */
319
- slice = transformSliceToRemoveOpenTable(slice, schema);
320
-
321
- /** If a partial paste of bodied extension, paste only text */
322
- slice = transformSliceToRemoveOpenBodiedExtension(slice, schema);
323
- }
311
+ /** If a partial paste of bodied extension, paste only text */
312
+ slice = transformSliceToRemoveOpenBodiedExtension(slice, schema);
313
+
314
+ /** If a partial paste of table, paste only table's content */
315
+ slice = transformSliceToRemoveOpenTable(slice, schema);
324
316
 
325
317
  /** If a partial paste of multi bodied extension, paste only children */
326
318
  slice = transformSliceToRemoveOpenMultiBodiedExtension(slice, schema);
@@ -19,7 +19,10 @@ import {
19
19
  import { browser } from '@atlaskit/editor-common/browser';
20
20
  import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
21
21
  import { getDomRefFromSelection } from '@atlaskit/editor-common/get-dom-ref-from-selection';
22
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
22
+ import {
23
+ sharedPluginStateHookMigratorFactory,
24
+ useSharedPluginState,
25
+ } from '@atlaskit/editor-common/hooks';
23
26
  import { IconTable } from '@atlaskit/editor-common/icons';
24
27
  import { toggleTable, tooltip } from '@atlaskit/editor-common/keymaps';
25
28
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
@@ -30,7 +33,12 @@ import {
30
33
  import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
31
34
  import { ResizerBreakoutModeLabel } from '@atlaskit/editor-common/resizer';
32
35
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
33
- import type { Command, EditorPlugin, GetEditorContainerWidth } from '@atlaskit/editor-common/types';
36
+ import type {
37
+ Command,
38
+ EditorPlugin,
39
+ ExtractInjectionAPI,
40
+ GetEditorContainerWidth,
41
+ } from '@atlaskit/editor-common/types';
34
42
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
35
43
  import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
36
44
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
@@ -91,6 +99,19 @@ import { getToolbarConfig } from './ui/toolbar';
91
99
 
92
100
  const defaultGetEditorFeatureFlags = () => ({});
93
101
 
102
+ const useTableSharedState = sharedPluginStateHookMigratorFactory(
103
+ (api: ExtractInjectionAPI<TablePlugin> | undefined) => {
104
+ const mode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
105
+ return { mode };
106
+ },
107
+ (api: ExtractInjectionAPI<TablePlugin> | undefined) => {
108
+ const { editorViewModeState } = useSharedPluginState(api, ['editorViewMode']);
109
+ return {
110
+ mode: editorViewModeState?.mode,
111
+ };
112
+ },
113
+ );
114
+
94
115
  /**
95
116
  * Table plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
96
117
  * from `@atlaskit/editor-core`.
@@ -145,6 +166,7 @@ const tablePlugin: TablePlugin = ({ config: options, api }) => {
145
166
  : undefined;
146
167
 
147
168
  const dragAndDropState = dragAndDropPluginKey.getState(editorState);
169
+ const sizeSelectorPluginState = sizeSelectorPluginKey.getState(editorState);
148
170
 
149
171
  const sharedStateInternal: TableSharedStateInternal = {
150
172
  isFullWidthModeEnabled: !!options?.fullWidthEnabled,
@@ -182,6 +204,8 @@ const tablePlugin: TablePlugin = ({ config: options, api }) => {
182
204
  dragMenuDirection: dragAndDropState?.dragMenuDirection,
183
205
  dragMenuIndex: dragAndDropState?.dragMenuIndex,
184
206
  isDragMenuOpen: dragAndDropState?.isDragMenuOpen,
207
+ isSizeSelectorOpen: sizeSelectorPluginState?.isSelectorOpen,
208
+ sizeSelectorTargetRef: sizeSelectorPluginState?.targetRef,
185
209
  };
186
210
 
187
211
  return sharedStateInternal;
@@ -568,6 +592,7 @@ const tablePlugin: TablePlugin = ({ config: options, api }) => {
568
592
  popupsScrollableElement={popupsScrollableElement}
569
593
  defaultGetEditorContainerWidth={defaultGetEditorContainerWidth}
570
594
  defaultGetEditorFeatureFlags={defaultGetEditorFeatureFlags}
595
+ isTableSelectorEnabled={isTableSelectorEnabled}
571
596
  />
572
597
  );
573
598
  }
@@ -601,6 +626,8 @@ const tablePlugin: TablePlugin = ({ config: options, api }) => {
601
626
  dragAndDropState,
602
627
  sizeSelectorPluginState,
603
628
  }) => {
629
+ // Any changes made inside `<WithPluginState>` need to be reflected in the
630
+ // `<ContentComponent>` as well.
604
631
  const isColumnResizing = resizingPluginState?.dragging;
605
632
  const isTableResizing = tableWidthPluginState?.resizing;
606
633
  const resizingTableLocalId = tableWidthPluginState?.tableLocalId;
@@ -874,17 +901,7 @@ const tablePlugin: TablePlugin = ({ config: options, api }) => {
874
901
  )(pluginConfig(options?.tableOptions)),
875
902
  },
876
903
  usePluginHook({ editorView }) {
877
- const { editorViewModeState } = useSharedPluginState(api, ['editorViewMode'], {
878
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
879
- });
880
-
881
- // mode
882
- const modeSelector = useSharedPluginStateSelector(api, 'editorViewMode.mode', {
883
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
884
- });
885
- const mode = editorExperiment('platform_editor_usesharedpluginstateselector', true)
886
- ? modeSelector
887
- : editorViewModeState?.mode;
904
+ const { mode } = useTableSharedState(api);
888
905
 
889
906
  useEffect(() => {
890
907
  const { state, dispatch } = editorView;
@@ -79,6 +79,8 @@ export type TableSharedStateInternal = Pick<
79
79
  dragMenuDirection?: TableDirection;
80
80
  dragMenuIndex?: number;
81
81
  isDragMenuOpen?: boolean;
82
+ isSizeSelectorOpen?: boolean;
83
+ sizeSelectorTargetRef?: HTMLElement;
82
84
  };
83
85
 
84
86
  export type TableSharedState = Pick<