@atlaskit/editor-plugin-table 10.9.20 → 10.9.21

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 (50) hide show
  1. package/CHANGELOG.md +9 -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/tablePlugin.js +14 -10
  6. package/dist/cjs/ui/ContentComponent.js +21 -64
  7. package/dist/cjs/ui/DragHandle/index.js +19 -17
  8. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +14 -11
  9. package/dist/cjs/ui/TableFloatingControls/CornerControls/DragCornerControls.js +14 -10
  10. package/dist/cjs/ui/TableFloatingControls/FloatingControlsWithSelection.js +14 -10
  11. package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +14 -10
  12. package/dist/cjs/ui/global-styles.js +14 -10
  13. package/dist/cjs/ui/icons/SortingIconWrapper.js +14 -11
  14. package/dist/es2019/nodeviews/TableComponentWithSharedState.js +92 -78
  15. package/dist/es2019/nodeviews/TableContainer.js +44 -39
  16. package/dist/es2019/nodeviews/TableResizer.js +17 -12
  17. package/dist/es2019/tablePlugin.js +16 -11
  18. package/dist/es2019/ui/ContentComponent.js +21 -64
  19. package/dist/es2019/ui/DragHandle/index.js +21 -18
  20. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +16 -12
  21. package/dist/es2019/ui/TableFloatingControls/CornerControls/DragCornerControls.js +16 -11
  22. package/dist/es2019/ui/TableFloatingControls/FloatingControlsWithSelection.js +16 -11
  23. package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +16 -11
  24. package/dist/es2019/ui/global-styles.js +16 -11
  25. package/dist/es2019/ui/icons/SortingIconWrapper.js +16 -12
  26. package/dist/esm/nodeviews/TableComponentWithSharedState.js +92 -79
  27. package/dist/esm/nodeviews/TableContainer.js +42 -38
  28. package/dist/esm/nodeviews/TableResizer.js +16 -12
  29. package/dist/esm/tablePlugin.js +15 -11
  30. package/dist/esm/ui/ContentComponent.js +21 -64
  31. package/dist/esm/ui/DragHandle/index.js +20 -18
  32. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +15 -12
  33. package/dist/esm/ui/TableFloatingControls/CornerControls/DragCornerControls.js +15 -11
  34. package/dist/esm/ui/TableFloatingControls/FloatingControlsWithSelection.js +15 -11
  35. package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +15 -11
  36. package/dist/esm/ui/global-styles.js +15 -11
  37. package/dist/esm/ui/icons/SortingIconWrapper.js +15 -12
  38. package/package.json +4 -4
  39. package/src/nodeviews/TableComponentWithSharedState.tsx +97 -125
  40. package/src/nodeviews/TableContainer.tsx +59 -67
  41. package/src/nodeviews/TableResizer.tsx +21 -17
  42. package/src/tablePlugin.tsx +24 -13
  43. package/src/ui/ContentComponent.tsx +19 -64
  44. package/src/ui/DragHandle/index.tsx +24 -24
  45. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +21 -14
  46. package/src/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +20 -12
  47. package/src/ui/TableFloatingControls/FloatingControlsWithSelection.tsx +20 -13
  48. package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +20 -13
  49. package/src/ui/global-styles.tsx +20 -13
  50. package/src/ui/icons/SortingIconWrapper.tsx +20 -14
@@ -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>();
@@ -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`.
@@ -874,17 +895,7 @@ const tablePlugin: TablePlugin = ({ config: options, api }) => {
874
895
  )(pluginConfig(options?.tableOptions)),
875
896
  },
876
897
  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;
898
+ const { mode } = useTableSharedState(api);
888
899
 
889
900
  useEffect(() => {
890
901
  const { state, dispatch } = editorView;
@@ -9,7 +9,6 @@ import {
9
9
  } from '@atlaskit/editor-common/types';
10
10
  import { EditorView } from '@atlaskit/editor-prosemirror/view';
11
11
  import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
12
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
13
12
 
14
13
  import { TablePlugin, TablePluginOptions } from '../tablePluginType';
15
14
 
@@ -51,82 +50,38 @@ const ContentComponentInternal = ({
51
50
  const editorAnalyticsAPI = api?.analytics?.actions;
52
51
  const ariaNotifyPlugin = api?.accessibilityUtils?.actions.ariaNotify;
53
52
 
54
- const resizingTableLocalId = useInternalTablePluginStateSelector(api, 'resizingTableLocalId', {
55
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
56
- });
57
- const resizingTableRef = useInternalTablePluginStateSelector(api, 'resizingTableRef', {
58
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
59
- });
60
- const isTableResizing = useInternalTablePluginStateSelector(api, 'isTableResizing', {
61
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
62
- });
63
- const isResizing = useInternalTablePluginStateSelector(api, 'isResizing', {
64
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
65
- });
66
- const widthToWidest = useInternalTablePluginStateSelector(api, 'widthToWidest', {
67
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
68
- });
53
+ const resizingTableLocalId = useInternalTablePluginStateSelector(api, 'resizingTableLocalId');
54
+ const resizingTableRef = useInternalTablePluginStateSelector(api, 'resizingTableRef');
55
+ const isTableResizing = useInternalTablePluginStateSelector(api, 'isTableResizing');
56
+ const isResizing = useInternalTablePluginStateSelector(api, 'isResizing');
57
+ const widthToWidest = useInternalTablePluginStateSelector(api, 'widthToWidest');
69
58
 
70
- const tableNode = useInternalTablePluginStateSelector(api, 'tableNode', {
71
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
72
- });
73
- const targetCellPosition = useInternalTablePluginStateSelector(api, 'targetCellPosition', {
74
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
75
- });
76
- const isContextualMenuOpen = useInternalTablePluginStateSelector(api, 'isContextualMenuOpen', {
77
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
78
- });
79
- const tableRef = useInternalTablePluginStateSelector(api, 'tableRef', {
80
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
81
- });
82
- const pluginConfig = useInternalTablePluginStateSelector(api, 'pluginConfig', {
83
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
84
- });
59
+ const tableNode = useInternalTablePluginStateSelector(api, 'tableNode');
60
+ const targetCellPosition = useInternalTablePluginStateSelector(api, 'targetCellPosition');
61
+ const isContextualMenuOpen = useInternalTablePluginStateSelector(api, 'isContextualMenuOpen');
62
+ const tableRef = useInternalTablePluginStateSelector(api, 'tableRef');
63
+ const pluginConfig = useInternalTablePluginStateSelector(api, 'pluginConfig');
85
64
  const insertColumnButtonIndex = useInternalTablePluginStateSelector(
86
65
  api,
87
66
  'insertColumnButtonIndex',
88
- {
89
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
90
- },
91
67
  );
92
- const insertRowButtonIndex = useInternalTablePluginStateSelector(api, 'insertRowButtonIndex', {
93
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
94
- });
95
- const isHeaderColumnEnabled = useInternalTablePluginStateSelector(api, 'isHeaderColumnEnabled', {
96
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
97
- });
98
- const isHeaderRowEnabled = useInternalTablePluginStateSelector(api, 'isHeaderRowEnabled', {
99
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
100
- });
101
- const isDragAndDropEnabled = useInternalTablePluginStateSelector(api, 'isDragAndDropEnabled', {
102
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
103
- });
104
- const tableWrapperTarget = useInternalTablePluginStateSelector(api, 'tableWrapperTarget', {
105
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
106
- });
68
+ const insertRowButtonIndex = useInternalTablePluginStateSelector(api, 'insertRowButtonIndex');
69
+ const isHeaderColumnEnabled = useInternalTablePluginStateSelector(api, 'isHeaderColumnEnabled');
70
+ const isHeaderRowEnabled = useInternalTablePluginStateSelector(api, 'isHeaderRowEnabled');
71
+ const isDragAndDropEnabled = useInternalTablePluginStateSelector(api, 'isDragAndDropEnabled');
72
+ const tableWrapperTarget = useInternalTablePluginStateSelector(api, 'tableWrapperTarget');
107
73
  const isCellMenuOpenByKeyboard = useInternalTablePluginStateSelector(
108
74
  api,
109
75
  'isCellMenuOpenByKeyboard',
110
- {
111
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
112
- },
113
76
  );
114
77
 
115
78
  const { allowControls } = pluginConfig ?? {};
116
79
 
117
- const stickyHeader = useInternalTablePluginStateSelector(api, 'stickyHeader', {
118
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
119
- });
80
+ const stickyHeader = useInternalTablePluginStateSelector(api, 'stickyHeader');
120
81
 
121
- const dragMenuDirection = useInternalTablePluginStateSelector(api, 'dragMenuDirection', {
122
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
123
- });
124
- const dragMenuIndex = useInternalTablePluginStateSelector(api, 'dragMenuIndex', {
125
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
126
- });
127
- const isDragMenuOpen = useInternalTablePluginStateSelector(api, 'isDragMenuOpen', {
128
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
129
- });
82
+ const dragMenuDirection = useInternalTablePluginStateSelector(api, 'dragMenuDirection');
83
+ const dragMenuIndex = useInternalTablePluginStateSelector(api, 'dragMenuIndex');
84
+ const isDragMenuOpen = useInternalTablePluginStateSelector(api, 'isDragMenuOpen');
130
85
 
131
86
  return (
132
87
  <>
@@ -8,7 +8,10 @@ import type { WrappedComponentProps } from 'react-intl-next';
8
8
  import { injectIntl } from 'react-intl-next';
9
9
 
10
10
  import { browser } from '@atlaskit/editor-common/browser';
11
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
11
+ import {
12
+ sharedPluginStateHookMigratorFactory,
13
+ useSharedPluginState,
14
+ } from '@atlaskit/editor-common/hooks';
12
15
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
13
16
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
14
17
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
@@ -16,7 +19,6 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
16
19
  import { findTable, TableMap } from '@atlaskit/editor-tables';
17
20
  import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
18
21
  import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';
19
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
20
22
  import { token } from '@atlaskit/tokens';
21
23
 
22
24
  import { getPluginState as getDnDPluginState } from '../../pm-plugins/drag-and-drop/plugin-factory';
@@ -311,6 +313,25 @@ const DragHandleComponent = ({
311
313
  );
312
314
  };
313
315
 
316
+ const useSharedState = sharedPluginStateHookMigratorFactory(
317
+ (api: ExtractInjectionAPI<TablePlugin> | undefined) => {
318
+ const hoveredColumns = useInternalTablePluginStateSelector(api, 'hoveredColumns');
319
+ const hoveredRows = useInternalTablePluginStateSelector(api, 'hoveredRows');
320
+ return {
321
+ hoveredColumns,
322
+ hoveredRows,
323
+ };
324
+ },
325
+ (api: ExtractInjectionAPI<TablePlugin> | undefined) => {
326
+ const { tableState } = useSharedPluginState(api, ['table']);
327
+ const tableStateInternal = tableState as TableSharedStateInternal;
328
+ return {
329
+ hoveredColumns: tableStateInternal?.hoveredColumns,
330
+ hoveredRows: tableStateInternal?.hoveredRows,
331
+ };
332
+ },
333
+ );
334
+
314
335
  const DragHandleComponentWithSharedState = ({
315
336
  isDragMenuTarget,
316
337
  tableLocalId,
@@ -329,28 +350,7 @@ const DragHandleComponentWithSharedState = ({
329
350
  intl,
330
351
  api,
331
352
  }: DragHandleWithSharedStateProps & WrappedComponentProps) => {
332
- const { tableState } = useSharedPluginState(api, ['table'], {
333
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
334
- }) as {
335
- tableState?: TableSharedStateInternal;
336
- };
337
-
338
- // hoveredColumns
339
- const hoveredColumnsSelector = useInternalTablePluginStateSelector(api, 'hoveredColumns', {
340
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
341
- });
342
- const hoveredColumns = editorExperiment('platform_editor_usesharedpluginstateselector', true)
343
- ? hoveredColumnsSelector
344
- : tableState?.hoveredColumns;
345
-
346
- // hoveredRows
347
- const hoveredRowsSelector = useInternalTablePluginStateSelector(api, 'hoveredRows', {
348
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
349
- });
350
- const hoveredRows = editorExperiment('platform_editor_usesharedpluginstateselector', true)
351
- ? hoveredRowsSelector
352
- : tableState?.hoveredRows;
353
-
353
+ const { hoveredColumns, hoveredRows } = useSharedState(api);
354
354
  return (
355
355
  <DragHandleComponent
356
356
  isDragMenuTarget={isDragMenuTarget}
@@ -2,7 +2,10 @@
2
2
  import type { MouseEvent } from 'react';
3
3
  import React, { useCallback, useMemo, useRef } from 'react';
4
4
 
5
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
5
+ import {
6
+ sharedPluginStateHookMigratorFactory,
7
+ useSharedPluginState,
8
+ } from '@atlaskit/editor-common/hooks';
6
9
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
7
10
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
8
11
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
@@ -12,7 +15,6 @@ import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
12
15
  import { CellSelection } from '@atlaskit/editor-tables';
13
16
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
14
17
  import { fg } from '@atlaskit/platform-feature-flags';
15
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
16
18
 
17
19
  import {
18
20
  clearHoverSelection,
@@ -60,6 +62,21 @@ const getSelectedColumns = (selection: Selection) => {
60
62
  return [];
61
63
  };
62
64
 
65
+ const useSharedState = sharedPluginStateHookMigratorFactory(
66
+ (api: ExtractInjectionAPI<TablePlugin> | undefined) => {
67
+ const selection = useSharedPluginStateSelector(api, 'selection.selection');
68
+ return {
69
+ selection,
70
+ };
71
+ },
72
+ (api: ExtractInjectionAPI<TablePlugin> | undefined) => {
73
+ const { selectionState } = useSharedPluginState(api, ['selection']);
74
+ return {
75
+ selection: selectionState?.selection,
76
+ };
77
+ },
78
+ );
79
+
63
80
  export const ColumnControls = ({
64
81
  editorView,
65
82
  tableActive,
@@ -78,17 +95,7 @@ export const ColumnControls = ({
78
95
  api,
79
96
  }: ColumnControlsProps & { api?: ExtractInjectionAPI<TablePlugin> }) => {
80
97
  const columnControlsRef = useRef<HTMLDivElement>(null);
81
-
82
- // selection
83
- const { selectionState } = useSharedPluginState(api, ['selection'], {
84
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
85
- });
86
- const selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection', {
87
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
88
- });
89
- const selection = editorExperiment('platform_editor_usesharedpluginstateselector', true)
90
- ? selectionsSelector
91
- : selectionState?.selection;
98
+ const { selection } = useSharedState(api);
92
99
 
93
100
  const widths =
94
101
  colWidths
@@ -107,7 +114,7 @@ export const ColumnControls = ({
107
114
  const hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
108
115
 
109
116
  const rowControlStickyTop = 45;
110
- const marginTop = hasHeaderRow && stickyTop !== undefined ? rowControlStickyTop ?? 0 : 0;
117
+ const marginTop = hasHeaderRow && stickyTop !== undefined ? (rowControlStickyTop ?? 0) : 0;
111
118
 
112
119
  const handleClick = useCallback(
113
120
  (event: MouseEvent) => {
@@ -4,12 +4,14 @@ import classnames from 'classnames';
4
4
  import type { WrappedComponentProps } from 'react-intl-next';
5
5
  import { injectIntl } from 'react-intl-next';
6
6
 
7
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
7
+ import {
8
+ sharedPluginStateHookMigratorFactory,
9
+ useSharedPluginState,
10
+ } from '@atlaskit/editor-common/hooks';
8
11
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
9
12
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
10
13
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
11
14
  import { findTable, isTableSelected, selectTable } from '@atlaskit/editor-tables/utils';
12
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
13
15
 
14
16
  import { clearHoverSelection } from '../../../pm-plugins/commands';
15
17
  import type { TablePlugin } from '../../../tablePluginType';
@@ -66,6 +68,21 @@ const DragCornerControlsComponent = ({
66
68
  );
67
69
  };
68
70
 
71
+ const useSharedState = sharedPluginStateHookMigratorFactory(
72
+ (api: ExtractInjectionAPI<TablePlugin> | undefined) => {
73
+ const selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection');
74
+ return {
75
+ selection: selectionsSelector,
76
+ };
77
+ },
78
+ (api: ExtractInjectionAPI<TablePlugin> | undefined) => {
79
+ const { selectionState } = useSharedPluginState(api, ['selection']);
80
+ return {
81
+ selection: selectionState?.selection,
82
+ };
83
+ },
84
+ );
85
+
69
86
  const DragCornerControlsComponentWithSelection = ({
70
87
  editorView,
71
88
  isInDanger,
@@ -73,16 +90,7 @@ const DragCornerControlsComponentWithSelection = ({
73
90
  intl: { formatMessage },
74
91
  api,
75
92
  }: CornerControlProps & WrappedComponentProps & { api?: ExtractInjectionAPI<TablePlugin> }) => {
76
- // selection
77
- const { selectionState } = useSharedPluginState(api, ['selection'], {
78
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
79
- });
80
- const selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection', {
81
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
82
- });
83
- const selection = editorExperiment('platform_editor_usesharedpluginstateselector', true)
84
- ? selectionsSelector
85
- : selectionState?.selection;
93
+ const { selection } = useSharedState(api);
86
94
 
87
95
  const handleOnClick = () => {
88
96
  const { state, dispatch } = editorView;
@@ -1,10 +1,12 @@
1
1
  import React from 'react';
2
2
 
3
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
+ import {
4
+ sharedPluginStateHookMigratorFactory,
5
+ useSharedPluginState,
6
+ } from '@atlaskit/editor-common/hooks';
4
7
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
5
8
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
6
9
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
7
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
10
 
9
11
  import type { TablePlugin } from '../../tablePluginType';
10
12
 
@@ -26,6 +28,21 @@ type FloatingControlsWithSelectionProps = {
26
28
  api?: ExtractInjectionAPI<TablePlugin>;
27
29
  };
28
30
 
31
+ const useSharedState = sharedPluginStateHookMigratorFactory(
32
+ (api: ExtractInjectionAPI<TablePlugin> | undefined) => {
33
+ const selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection');
34
+ return {
35
+ selection: selectionsSelector,
36
+ };
37
+ },
38
+ (api: ExtractInjectionAPI<TablePlugin> | undefined) => {
39
+ const { selectionState } = useSharedPluginState(api, ['selection']);
40
+ return {
41
+ selection: selectionState?.selection,
42
+ };
43
+ },
44
+ );
45
+
29
46
  export const FloatingControlsWithSelection = ({
30
47
  editorView,
31
48
  tableRef,
@@ -40,17 +57,7 @@ export const FloatingControlsWithSelection = ({
40
57
  tableActive,
41
58
  api,
42
59
  }: FloatingControlsWithSelectionProps) => {
43
- // selection
44
- const { selectionState } = useSharedPluginState(api, ['selection'], {
45
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
46
- });
47
- const selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection', {
48
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
49
- });
50
- const selection = editorExperiment('platform_editor_usesharedpluginstateselector', true)
51
- ? selectionsSelector
52
- : selectionState?.selection;
53
-
60
+ const { selection } = useSharedState(api);
54
61
  return (
55
62
  <>
56
63
  <CornerControls