@atlaskit/editor-plugin-table 10.9.6 → 10.9.8

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 (38) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/nodeviews/TableComponent.js +5 -0
  3. package/dist/cjs/nodeviews/TableComponentWithSharedState.js +33 -19
  4. package/dist/cjs/nodeviews/TableContainer.js +1 -1
  5. package/dist/cjs/nodeviews/TableResizer.js +2 -2
  6. package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +4 -3
  7. package/dist/cjs/ui/ContentComponent.js +77 -37
  8. package/dist/cjs/ui/DragHandle/index.js +3 -3
  9. package/dist/cjs/ui/hooks/useInternalTablePluginStateSelector.js +27 -0
  10. package/dist/es2019/nodeviews/TableComponent.js +5 -0
  11. package/dist/es2019/nodeviews/TableComponentWithSharedState.js +33 -19
  12. package/dist/es2019/nodeviews/TableContainer.js +1 -1
  13. package/dist/es2019/nodeviews/TableResizer.js +2 -2
  14. package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +4 -3
  15. package/dist/es2019/ui/ContentComponent.js +66 -27
  16. package/dist/es2019/ui/DragHandle/index.js +3 -3
  17. package/dist/es2019/ui/hooks/useInternalTablePluginStateSelector.js +21 -0
  18. package/dist/esm/nodeviews/TableComponent.js +5 -0
  19. package/dist/esm/nodeviews/TableComponentWithSharedState.js +33 -19
  20. package/dist/esm/nodeviews/TableContainer.js +1 -1
  21. package/dist/esm/nodeviews/TableResizer.js +2 -2
  22. package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +4 -3
  23. package/dist/esm/ui/ContentComponent.js +77 -37
  24. package/dist/esm/ui/DragHandle/index.js +3 -3
  25. package/dist/esm/ui/hooks/useInternalTablePluginStateSelector.js +21 -0
  26. package/dist/types/ui/hooks/useInternalTablePluginStateSelector.d.ts +20 -0
  27. package/dist/types-ts4.5/ui/hooks/useInternalTablePluginStateSelector.d.ts +20 -0
  28. package/package.json +6 -3
  29. package/src/nodeviews/TableComponent.tsx +5 -0
  30. package/src/nodeviews/TableComponentWithSharedState.tsx +40 -28
  31. package/src/nodeviews/TableContainer.tsx +1 -1
  32. package/src/nodeviews/TableResizer.tsx +4 -4
  33. package/src/pm-plugins/table-resizing/utils/scale-table.ts +5 -3
  34. package/src/ui/ContentComponent.tsx +71 -35
  35. package/src/ui/DragHandle/index.tsx +6 -10
  36. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +1 -1
  37. package/src/ui/TableFloatingControls/NumberColumn/index.tsx +3 -3
  38. package/src/ui/hooks/useInternalTablePluginStateSelector.ts +36 -0
@@ -3,19 +3,15 @@ import React from 'react';
3
3
  import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
4
4
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
5
5
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
6
- import type {
7
- ExtractInjectionAPI,
8
- GetEditorFeatureFlags,
9
- getPosHandlerNode,
10
- } from '@atlaskit/editor-common/types';
6
+ import type { GetEditorFeatureFlags, getPosHandlerNode } from '@atlaskit/editor-common/types';
11
7
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
12
8
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
13
9
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
14
10
  import { findTable } from '@atlaskit/editor-tables';
15
11
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
16
12
 
17
- import { TablePlugin } from '../tablePluginType';
18
13
  import type { PluginInjectionAPI, TableSharedStateInternal } from '../types';
14
+ import { useInternalTablePluginStateSelector } from '../ui/hooks/useInternalTablePluginStateSelector';
19
15
 
20
16
  import TableComponent from './TableComponent';
21
17
  import type { TableOptions } from './types';
@@ -40,16 +36,6 @@ type TableComponentWithSharedStateProps = {
40
36
  allowTableResizing?: boolean;
41
37
  };
42
38
 
43
- const useSharedTablePluginStateSelector = <K extends keyof TableSharedStateInternal>(
44
- api: ExtractInjectionAPI<TablePlugin> | undefined,
45
- key: K,
46
- ) => {
47
- const value = useSharedPluginStateSelector(api, `table.${key}` as never, {
48
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
49
- }) as TableSharedStateInternal[K];
50
- return value;
51
- };
52
-
53
39
  /**
54
40
  * Use useSharedPluginState to control re-renders from plugin dependencies
55
41
  */
@@ -73,21 +59,47 @@ export const TableComponentWithSharedState = ({
73
59
  disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
74
60
  });
75
61
 
76
- const isTableResizingSelector = useSharedTablePluginStateSelector(api, 'isTableResizing');
77
- const isHeaderColumnEnabledSelector = useSharedTablePluginStateSelector(
62
+ const isTableResizingSelector = useInternalTablePluginStateSelector(api, 'isTableResizing', {
63
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
64
+ });
65
+ const isHeaderColumnEnabledSelector = useInternalTablePluginStateSelector(
78
66
  api,
79
67
  'isHeaderColumnEnabled',
68
+ {
69
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
70
+ },
80
71
  );
81
- const isHeaderRowEnabledSelector = useSharedTablePluginStateSelector(api, 'isHeaderRowEnabled');
82
- const orderingSelector = useSharedTablePluginStateSelector(api, 'ordering');
83
- const isResizingSelector = useSharedTablePluginStateSelector(api, 'isResizing');
84
- const isInDangerSelector = useSharedTablePluginStateSelector(api, 'isInDanger');
85
- const hoveredCellSelector = useSharedTablePluginStateSelector(api, 'hoveredCell');
86
- const hoveredRowsSelector = useSharedTablePluginStateSelector(api, 'hoveredRows');
87
- const isTableHoveredSelector = useSharedTablePluginStateSelector(api, 'isTableHovered');
88
- const isWholeTableInDangerSelector = useSharedTablePluginStateSelector(
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(
89
98
  api,
90
99
  'isWholeTableInDanger',
100
+ {
101
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
102
+ },
91
103
  );
92
104
 
93
105
  // mediaState
@@ -203,8 +215,8 @@ export const TableComponentWithSharedState = ({
203
215
  isMediaFullscreen={isFullscreen}
204
216
  options={options}
205
217
  allowControls={allowControls}
206
- isHeaderRowEnabled={isHeaderRowEnabled}
207
- isHeaderColumnEnabled={isHeaderColumnEnabled}
218
+ isHeaderRowEnabled={isHeaderRowEnabled ?? false}
219
+ isHeaderColumnEnabled={isHeaderColumnEnabled ?? false}
208
220
  isDragAndDropEnabled={options?.isDragAndDropEnabled && !isLivePageViewMode}
209
221
  isTableScalingEnabled={options?.isTableScalingEnabled}
210
222
  allowTableAlignment={allowTableAlignment}
@@ -114,7 +114,7 @@ const AlignmentTableContainer = ({
114
114
  : tableState?.wasFullWidthModeEnabled;
115
115
 
116
116
  useEffect(() => {
117
- if (editorExperiment('platform_editor_usesharedpluginstateselector', false) && !tableState) {
117
+ if (!tableState && editorExperiment('platform_editor_usesharedpluginstateselector', false)) {
118
118
  return;
119
119
  }
120
120
 
@@ -19,7 +19,6 @@ import { tableMessages as messages } from '@atlaskit/editor-common/messages';
19
19
  import { logException } from '@atlaskit/editor-common/monitoring';
20
20
  import type { HandleResize, HandleSize } from '@atlaskit/editor-common/resizer';
21
21
  import { ResizerNext } from '@atlaskit/editor-common/resizer';
22
- import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
23
22
  import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
24
23
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
25
24
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
@@ -70,6 +69,7 @@ import {
70
69
  TABLE_HIGHLIGHT_TOLERANCE,
71
70
  TABLE_SNAP_GAP,
72
71
  } from '../ui/consts';
72
+ import { useInternalTablePluginStateSelector } from '../ui/hooks/useInternalTablePluginStateSelector';
73
73
 
74
74
  interface TableResizerProps {
75
75
  width: number;
@@ -218,13 +218,13 @@ export const TableResizer = ({
218
218
  });
219
219
 
220
220
  // widthToWidest
221
- const widthToWidestSelector = useSharedPluginStateSelector(
221
+ const widthToWidestSelector = useInternalTablePluginStateSelector(
222
222
  pluginInjectionApi,
223
- 'table.widthToWidest' as never,
223
+ 'widthToWidest',
224
224
  {
225
225
  disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
226
226
  },
227
- ) as TableSharedStateInternal['widthToWidest'];
227
+ );
228
228
  const widthToWidest = editorExperiment('platform_editor_usesharedpluginstateselector', true)
229
229
  ? widthToWidestSelector
230
230
  : (tableState as TableSharedStateInternal).widthToWidest;
@@ -4,6 +4,7 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
4
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
5
5
  import type { DomAtPos } from '@atlaskit/editor-prosemirror/utils';
6
6
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
7
8
 
8
9
  import type { PluginInjectionAPI } from '../../../types';
9
10
  import { updateColumnWidths } from '../../transforms/column-width';
@@ -267,9 +268,10 @@ export const scaleTable =
267
268
 
268
269
  if (resizeState) {
269
270
  tr = updateColumnWidths(resizeState, node, start, api)(tr);
270
- // Avoid adding this transaction separately to the history as these are automatic updates
271
- // as a consequence of another action
272
- tr.setMeta('addToHistory', false);
271
+
272
+ if (!fg('platform_editor_fix_table_resizing_undo')) {
273
+ tr.setMeta('addToHistory', false);
274
+ }
273
275
 
274
276
  if (tr.docChanged) {
275
277
  tr.setMeta('scrollIntoView', false);
@@ -7,12 +7,11 @@ import {
7
7
  GetEditorContainerWidth,
8
8
  GetEditorFeatureFlags,
9
9
  } from '@atlaskit/editor-common/types';
10
- import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
11
10
  import { EditorView } from '@atlaskit/editor-prosemirror/view';
12
11
  import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
12
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
13
13
 
14
14
  import { TablePlugin, TablePluginOptions } from '../tablePluginType';
15
- import { TableSharedStateInternal } from '../types';
16
15
 
17
16
  import FloatingContextualButton from './FloatingContextualButton';
18
17
  import FloatingContextualMenu from './FloatingContextualMenu';
@@ -23,19 +22,9 @@ import FloatingDragMenu from './FloatingDragMenu';
23
22
  import FloatingInsertButton from './FloatingInsertButton';
24
23
  import { FloatingToolbarLabel } from './FloatingToolbarLabel/FloatingToolbarLabel';
25
24
  import { GlobalStylesWrapper } from './global-styles';
25
+ import { useInternalTablePluginStateSelector } from './hooks/useInternalTablePluginStateSelector';
26
26
  import { FullWidthDisplay } from './TableFullWidthLabel';
27
27
 
28
- const useSharedTablePluginStateSelector = <K extends keyof TableSharedStateInternal>(
29
- api: ExtractInjectionAPI<TablePlugin> | undefined,
30
- key: K,
31
- ) => {
32
- const value = useSharedPluginStateSelector(
33
- api,
34
- `table.${key}` as never,
35
- ) as TableSharedStateInternal[K];
36
- return value;
37
- };
38
-
39
28
  export type ContentComponentProps = {
40
29
  api: ExtractInjectionAPI<TablePlugin> | undefined;
41
30
  editorView: EditorView;
@@ -62,35 +51,82 @@ const ContentComponentInternal = ({
62
51
  const editorAnalyticsAPI = api?.analytics?.actions;
63
52
  const ariaNotifyPlugin = api?.accessibilityUtils?.actions.ariaNotify;
64
53
 
65
- const resizingTableLocalId = useSharedTablePluginStateSelector(api, 'resizingTableLocalId');
66
- const resizingTableRef = useSharedTablePluginStateSelector(api, 'resizingTableRef');
67
- const isTableResizing = useSharedTablePluginStateSelector(api, 'isTableResizing');
68
- const isResizing = useSharedTablePluginStateSelector(api, 'isResizing');
69
- const widthToWidest = useSharedTablePluginStateSelector(api, 'widthToWidest');
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
+ });
70
69
 
71
- const tableNode = useSharedTablePluginStateSelector(api, 'tableNode');
72
- const targetCellPosition = useSharedTablePluginStateSelector(api, 'targetCellPosition');
73
- const isContextualMenuOpen = useSharedTablePluginStateSelector(api, 'isContextualMenuOpen');
74
- const tableRef = useSharedTablePluginStateSelector(api, 'tableRef');
75
- const pluginConfig = useSharedTablePluginStateSelector(api, 'pluginConfig');
76
- const insertColumnButtonIndex = useSharedTablePluginStateSelector(api, 'insertColumnButtonIndex');
77
- const insertRowButtonIndex = useSharedTablePluginStateSelector(api, 'insertRowButtonIndex');
78
- const isHeaderColumnEnabled = useSharedTablePluginStateSelector(api, 'isHeaderColumnEnabled');
79
- const isHeaderRowEnabled = useSharedTablePluginStateSelector(api, 'isHeaderRowEnabled');
80
- const isDragAndDropEnabled = useSharedTablePluginStateSelector(api, 'isDragAndDropEnabled');
81
- const tableWrapperTarget = useSharedTablePluginStateSelector(api, 'tableWrapperTarget');
82
- const isCellMenuOpenByKeyboard = useSharedTablePluginStateSelector(
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
+ });
85
+ const insertColumnButtonIndex = useInternalTablePluginStateSelector(
86
+ api,
87
+ 'insertColumnButtonIndex',
88
+ {
89
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
90
+ },
91
+ );
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
+ });
107
+ const isCellMenuOpenByKeyboard = useInternalTablePluginStateSelector(
83
108
  api,
84
109
  'isCellMenuOpenByKeyboard',
110
+ {
111
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
112
+ },
85
113
  );
86
114
 
87
- const { allowControls } = pluginConfig;
115
+ const { allowControls } = pluginConfig ?? {};
88
116
 
89
- const stickyHeader = useSharedTablePluginStateSelector(api, 'stickyHeader');
117
+ const stickyHeader = useInternalTablePluginStateSelector(api, 'stickyHeader', {
118
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
119
+ });
90
120
 
91
- const dragMenuDirection = useSharedTablePluginStateSelector(api, 'dragMenuDirection');
92
- const dragMenuIndex = useSharedTablePluginStateSelector(api, 'dragMenuIndex');
93
- const isDragMenuOpen = useSharedTablePluginStateSelector(api, 'isDragMenuOpen');
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
+ });
94
130
 
95
131
  return (
96
132
  <>
@@ -11,7 +11,6 @@ import { browser } from '@atlaskit/editor-common/browser';
11
11
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
12
12
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
13
13
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
14
- import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
15
14
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
16
15
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
17
16
  import { findTable, TableMap } from '@atlaskit/editor-tables';
@@ -32,6 +31,7 @@ import { TableCssClassName as ClassName } from '../../types';
32
31
  import type { CellHoverMeta, TableDirection, TableSharedStateInternal } from '../../types';
33
32
  import { dragTableInsertColumnButtonSize } from '../consts';
34
33
  import { DragPreview } from '../DragPreview';
34
+ import { useInternalTablePluginStateSelector } from '../hooks/useInternalTablePluginStateSelector';
35
35
 
36
36
  import { HandleIconComponent } from './HandleIconComponent';
37
37
 
@@ -336,21 +336,17 @@ const DragHandleComponentWithSharedState = ({
336
336
  };
337
337
 
338
338
  // hoveredColumns
339
- const hoveredColumnsSelector = useSharedPluginStateSelector(
340
- api,
341
- 'table.hoveredColumns' as never,
342
- {
343
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
344
- },
345
- ) as TableSharedStateInternal['hoveredColumns'];
339
+ const hoveredColumnsSelector = useInternalTablePluginStateSelector(api, 'hoveredColumns', {
340
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
341
+ });
346
342
  const hoveredColumns = editorExperiment('platform_editor_usesharedpluginstateselector', true)
347
343
  ? hoveredColumnsSelector
348
344
  : tableState?.hoveredColumns;
349
345
 
350
346
  // hoveredRows
351
- const hoveredRowsSelector = useSharedPluginStateSelector(api, 'table.hoveredRows' as never, {
347
+ const hoveredRowsSelector = useInternalTablePluginStateSelector(api, 'hoveredRows', {
352
348
  disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
353
- }) as TableSharedStateInternal['hoveredRows'];
349
+ });
354
350
  const hoveredRows = editorExperiment('platform_editor_usesharedpluginstateselector', true)
355
351
  ? hoveredRowsSelector
356
352
  : tableState?.hoveredRows;
@@ -107,7 +107,7 @@ export const ColumnControls = ({
107
107
  const hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
108
108
 
109
109
  const rowControlStickyTop = 45;
110
- const marginTop = hasHeaderRow && stickyTop !== undefined ? (rowControlStickyTop ?? 0) : 0;
110
+ const marginTop = hasHeaderRow && stickyTop !== undefined ? rowControlStickyTop ?? 0 : 0;
111
111
 
112
112
  const handleClick = useCallback(
113
113
  (event: MouseEvent) => {
@@ -103,10 +103,10 @@ export default class NumberColumn extends Component<Props, any> {
103
103
  const newPos =
104
104
  selection.head > pos
105
105
  ? // Selection is after table
106
- // nodeSize - 3 will move the position inside last table cell
107
- Selection.near(doc.resolve(pos + ($pos.parent.nodeSize - 3)), -1)
106
+ // nodeSize - 3 will move the position inside last table cell
107
+ Selection.near(doc.resolve(pos + ($pos.parent.nodeSize - 3)), -1)
108
108
  : // Selection is before table
109
- Selection.near($pos);
109
+ Selection.near($pos);
110
110
  editorView.dispatch(tr.setSelection(newPos));
111
111
  }
112
112
  selectRow(index, event.shiftKey);
@@ -0,0 +1,36 @@
1
+ import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
3
+
4
+ import { TablePlugin } from '../../tablePluginType';
5
+ import { TableSharedStateInternal } from '../../types';
6
+
7
+ type Options = {
8
+ disabled?: boolean;
9
+ };
10
+
11
+ /**
12
+ * **This hook is only for internal use and should not be used outside of the table plugin.**
13
+ *
14
+ * Hook to select a value from the internal table plugin state.
15
+ * This is a wrapper around `useSharedPluginStateSelector` to provide access to the entire
16
+ * `TableSharedStateInternal` type. Since tables plugin has a lot of internal state that is not
17
+ * exposed via the `TableSharedState` type, we need to use this hook to access it in a type safe way.
18
+ *
19
+ * @param api The editor API
20
+ * @param key Key of TableSharedStateInternal to select
21
+ * @returns
22
+ */
23
+ export const useInternalTablePluginStateSelector = <K extends keyof TableSharedStateInternal>(
24
+ api: ExtractInjectionAPI<TablePlugin> | undefined,
25
+ key: K,
26
+ options?: Options,
27
+ ): TableSharedStateInternal[K] | undefined => {
28
+ // Need to disable the eslint rule here because the key is for the TableSharedStateInternal type
29
+ // and we are using it as a string to access the value in the useSharedPluginStateSelector
30
+ // which is typed only for the public TableSharedState type.
31
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
+ const value = useSharedPluginStateSelector(api, `table.${key}` as any, options) as
33
+ | TableSharedStateInternal[K]
34
+ | undefined;
35
+ return value;
36
+ };