@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
@@ -1,7 +1,13 @@
1
1
  import React from 'react';
2
2
 
3
- import { ACTION_SUBJECT, DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
3
+ import {
4
+ ACTION_SUBJECT,
5
+ ACTION_SUBJECT_ID,
6
+ DispatchAnalyticsEvent,
7
+ } from '@atlaskit/editor-common/analytics';
4
8
  import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
9
+ import { getDomRefFromSelection } from '@atlaskit/editor-common/get-dom-ref-from-selection';
10
+ import { ResizerBreakoutModeLabel } from '@atlaskit/editor-common/resizer';
5
11
  import {
6
12
  ExtractInjectionAPI,
7
13
  GetEditorContainerWidth,
@@ -23,6 +29,7 @@ import FloatingInsertButton from './FloatingInsertButton';
23
29
  import { FloatingToolbarLabel } from './FloatingToolbarLabel/FloatingToolbarLabel';
24
30
  import { GlobalStylesWrapper } from './global-styles';
25
31
  import { useInternalTablePluginStateSelector } from './hooks/useInternalTablePluginStateSelector';
32
+ import { SizeSelector } from './SizeSelector';
26
33
  import { FullWidthDisplay } from './TableFullWidthLabel';
27
34
 
28
35
  export type ContentComponentProps = {
@@ -33,6 +40,7 @@ export type ContentComponentProps = {
33
40
  popupsMountPoint?: HTMLElement;
34
41
  popupsBoundariesElement?: HTMLElement;
35
42
  popupsScrollableElement?: HTMLElement;
43
+ isTableSelectorEnabled: boolean | undefined;
36
44
  defaultGetEditorContainerWidth: GetEditorContainerWidth;
37
45
  defaultGetEditorFeatureFlags: GetEditorFeatureFlags;
38
46
  };
@@ -45,88 +53,48 @@ const ContentComponentInternal = ({
45
53
  popupsMountPoint,
46
54
  popupsBoundariesElement,
47
55
  popupsScrollableElement,
56
+ isTableSelectorEnabled,
48
57
  defaultGetEditorContainerWidth,
49
58
  defaultGetEditorFeatureFlags,
50
59
  }: ContentComponentProps) => {
51
60
  const editorAnalyticsAPI = api?.analytics?.actions;
52
61
  const ariaNotifyPlugin = api?.accessibilityUtils?.actions.ariaNotify;
53
62
 
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
- });
63
+ const resizingTableLocalId = useInternalTablePluginStateSelector(api, 'resizingTableLocalId');
64
+ const resizingTableRef = useInternalTablePluginStateSelector(api, 'resizingTableRef');
65
+ const isTableResizing = useInternalTablePluginStateSelector(api, 'isTableResizing');
66
+ const isResizing = useInternalTablePluginStateSelector(api, 'isResizing');
67
+ const widthToWidest = useInternalTablePluginStateSelector(api, 'widthToWidest');
69
68
 
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
- });
69
+ const tableNode = useInternalTablePluginStateSelector(api, 'tableNode');
70
+ const targetCellPosition = useInternalTablePluginStateSelector(api, 'targetCellPosition');
71
+ const isContextualMenuOpen = useInternalTablePluginStateSelector(api, 'isContextualMenuOpen');
72
+ const tableRef = useInternalTablePluginStateSelector(api, 'tableRef');
73
+ const pluginConfig = useInternalTablePluginStateSelector(api, 'pluginConfig');
85
74
  const insertColumnButtonIndex = useInternalTablePluginStateSelector(
86
75
  api,
87
76
  'insertColumnButtonIndex',
88
- {
89
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
90
- },
91
77
  );
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
- });
78
+ const insertRowButtonIndex = useInternalTablePluginStateSelector(api, 'insertRowButtonIndex');
79
+ const isHeaderColumnEnabled = useInternalTablePluginStateSelector(api, 'isHeaderColumnEnabled');
80
+ const isHeaderRowEnabled = useInternalTablePluginStateSelector(api, 'isHeaderRowEnabled');
81
+ const isDragAndDropEnabled = useInternalTablePluginStateSelector(api, 'isDragAndDropEnabled');
82
+ const tableWrapperTarget = useInternalTablePluginStateSelector(api, 'tableWrapperTarget');
107
83
  const isCellMenuOpenByKeyboard = useInternalTablePluginStateSelector(
108
84
  api,
109
85
  'isCellMenuOpenByKeyboard',
110
- {
111
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
112
- },
113
86
  );
114
87
 
115
88
  const { allowControls } = pluginConfig ?? {};
116
89
 
117
- const stickyHeader = useInternalTablePluginStateSelector(api, 'stickyHeader', {
118
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
119
- });
90
+ const stickyHeader = useInternalTablePluginStateSelector(api, 'stickyHeader');
91
+
92
+ const dragMenuDirection = useInternalTablePluginStateSelector(api, 'dragMenuDirection');
93
+ const dragMenuIndex = useInternalTablePluginStateSelector(api, 'dragMenuIndex');
94
+ const isDragMenuOpen = useInternalTablePluginStateSelector(api, 'isDragMenuOpen');
120
95
 
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
- });
96
+ const isSizeSelectorOpen = useInternalTablePluginStateSelector(api, 'isSizeSelectorOpen');
97
+ const sizeSelectorTargetRef = useInternalTablePluginStateSelector(api, 'sizeSelectorTargetRef');
130
98
 
131
99
  return (
132
100
  <>
@@ -234,7 +202,13 @@ const ContentComponentInternal = ({
234
202
  widthToWidest[resizingTableLocalId] && (
235
203
  <FloatingToolbarLabel
236
204
  target={resizingTableRef}
237
- content={<FullWidthDisplay />}
205
+ content={
206
+ editorExperiment('single_column_layouts', true) ? (
207
+ <ResizerBreakoutModeLabel layout="full-width" />
208
+ ) : (
209
+ <FullWidthDisplay />
210
+ )
211
+ }
238
212
  alignX={'center'}
239
213
  alignY={'bottom'}
240
214
  stick={true}
@@ -243,6 +217,24 @@ const ContentComponentInternal = ({
243
217
  offset={[0, 10]}
244
218
  />
245
219
  )}
220
+
221
+ {isTableSelectorEnabled && isSizeSelectorOpen && (
222
+ <SizeSelector
223
+ api={api}
224
+ isOpenedByKeyboard={false}
225
+ popupsMountPoint={popupsMountPoint}
226
+ target={
227
+ sizeSelectorTargetRef ??
228
+ getDomRefFromSelection(
229
+ editorView,
230
+ ACTION_SUBJECT_ID.PICKER_TABLE_SIZE,
231
+ api?.analytics?.actions,
232
+ )
233
+ }
234
+ popupsBoundariesElement={popupsBoundariesElement}
235
+ popupsScrollableElement={popupsScrollableElement}
236
+ />
237
+ )}
246
238
  </>
247
239
  );
248
240
  };
@@ -255,6 +247,7 @@ export const ContentComponent = ({
255
247
  popupsMountPoint,
256
248
  popupsBoundariesElement,
257
249
  popupsScrollableElement,
250
+ isTableSelectorEnabled,
258
251
  defaultGetEditorContainerWidth,
259
252
  defaultGetEditorFeatureFlags,
260
253
  }: ContentComponentProps) => {
@@ -277,6 +270,7 @@ export const ContentComponent = ({
277
270
  popupsMountPoint={popupsMountPoint}
278
271
  popupsBoundariesElement={popupsBoundariesElement}
279
272
  popupsScrollableElement={popupsScrollableElement}
273
+ isTableSelectorEnabled={isTableSelectorEnabled}
280
274
  defaultGetEditorContainerWidth={defaultGetEditorContainerWidth}
281
275
  defaultGetEditorFeatureFlags={defaultGetEditorFeatureFlags}
282
276
  />
@@ -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
@@ -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
@@ -2,7 +2,10 @@
2
2
  import type { MouseEvent } from 'react';
3
3
  import React, { Fragment, useCallback, useEffect, useMemo, useState } 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 type { ExtractInjectionAPI } 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';
@@ -12,7 +15,6 @@ import { CellSelection } from '@atlaskit/editor-tables';
12
15
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
13
16
  import { fg } from '@atlaskit/platform-feature-flags';
14
17
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
15
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
16
18
  import { token } from '@atlaskit/tokens';
17
19
 
18
20
  import { clearHoverSelection } from '../../../pm-plugins/commands';
@@ -371,6 +373,21 @@ export const DragControls = ({
371
373
  );
372
374
  };
373
375
 
376
+ const useSharedState = sharedPluginStateHookMigratorFactory(
377
+ (api: ExtractInjectionAPI<TablePlugin> | undefined) => {
378
+ const selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection');
379
+ return {
380
+ selection: selectionsSelector,
381
+ };
382
+ },
383
+ (api: ExtractInjectionAPI<TablePlugin> | undefined) => {
384
+ const { selectionState } = useSharedPluginState(api, ['selection']);
385
+ return {
386
+ selection: selectionState?.selection,
387
+ };
388
+ },
389
+ );
390
+
374
391
  export const DragControlsWithSelection = ({
375
392
  editorView,
376
393
  tableRef,
@@ -387,17 +404,7 @@ export const DragControlsWithSelection = ({
387
404
  updateCellHoverLocation,
388
405
  api,
389
406
  }: Exclude<DragControlsProps, 'selection'>) => {
390
- // selection
391
- const { selectionState } = useSharedPluginState(api, ['selection'], {
392
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
393
- });
394
- const selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection', {
395
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
396
- });
397
- const selection = editorExperiment('platform_editor_usesharedpluginstateselector', true)
398
- ? selectionsSelector
399
- : selectionState?.selection;
400
-
407
+ const { selection } = useSharedState(api);
401
408
  return (
402
409
  <DragControls
403
410
  editorView={editorView}
@@ -5,15 +5,32 @@
5
5
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
6
6
  import { Global, jsx } from '@emotion/react';
7
7
 
8
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
8
+ import {
9
+ sharedPluginStateHookMigratorFactory,
10
+ useSharedPluginState,
11
+ } from '@atlaskit/editor-common/hooks';
9
12
  import type { FeatureFlags } from '@atlaskit/editor-common/types';
10
13
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
11
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
12
14
 
13
15
  import type { PluginInjectionAPI } from '../types';
14
16
 
15
17
  import { tableStyles } from './common-styles';
16
18
 
19
+ const useSharedState = sharedPluginStateHookMigratorFactory(
20
+ (api: PluginInjectionAPI | undefined) => {
21
+ const mode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
22
+ return {
23
+ mode,
24
+ };
25
+ },
26
+ (api: PluginInjectionAPI | undefined) => {
27
+ const { editorViewModeState } = useSharedPluginState(api, ['editorViewMode']);
28
+ return {
29
+ mode: editorViewModeState?.mode,
30
+ };
31
+ },
32
+ );
33
+
17
34
  export const GlobalStylesWrapper = ({
18
35
  featureFlags,
19
36
  isDragAndDropEnabledOption,
@@ -23,17 +40,7 @@ export const GlobalStylesWrapper = ({
23
40
  isDragAndDropEnabledOption?: boolean;
24
41
  api?: PluginInjectionAPI;
25
42
  }) => {
26
- // mode
27
- const { editorViewModeState } = useSharedPluginState(api, ['editorViewMode'], {
28
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
29
- });
30
- const modeSelector = useSharedPluginStateSelector(api, 'editorViewMode.mode', {
31
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
32
- });
33
- const mode = editorExperiment('platform_editor_usesharedpluginstateselector', true)
34
- ? modeSelector
35
- : editorViewModeState?.mode;
36
-
43
+ const { mode } = useSharedState(api);
37
44
  const isLivePageViewMode = mode === 'view';
38
45
  return (
39
46
  <Global
@@ -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 { SortingIcon } from '@atlaskit/editor-common/table';
5
8
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
6
9
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
7
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
10
 
9
11
  import type { TablePlugin } from '../../tablePluginType';
10
12
 
@@ -13,19 +15,23 @@ type SortingIconWrapperProps = SortingIconProps & {
13
15
  api: ExtractInjectionAPI<TablePlugin>;
14
16
  };
15
17
 
16
- export const SortingIconWrapper = (props: SortingIconWrapperProps) => {
17
- const { editorViewModeState } = useSharedPluginState(props.api, ['editorViewMode'], {
18
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
19
- });
20
-
21
- // mode
22
- const modeSelector = useSharedPluginStateSelector(props.api, 'editorViewMode.mode', {
23
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
24
- });
25
- const mode = editorExperiment('platform_editor_usesharedpluginstateselector', true)
26
- ? modeSelector
27
- : editorViewModeState?.mode;
18
+ const useSharedState = sharedPluginStateHookMigratorFactory(
19
+ (api: ExtractInjectionAPI<TablePlugin> | undefined) => {
20
+ const mode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
21
+ return {
22
+ mode,
23
+ };
24
+ },
25
+ (api: ExtractInjectionAPI<TablePlugin> | undefined) => {
26
+ const { editorViewModeState } = useSharedPluginState(api, ['editorViewMode']);
27
+ return {
28
+ mode: editorViewModeState?.mode,
29
+ };
30
+ },
31
+ );
28
32
 
33
+ export const SortingIconWrapper = (props: SortingIconWrapperProps) => {
34
+ const { mode } = useSharedState(props.api);
29
35
  if (mode === 'edit') {
30
36
  return null;
31
37
  }