@atlaskit/editor-plugin-table 11.0.2 → 11.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/afm-cc/tsconfig.json +3 -0
  3. package/afm-jira/tsconfig.json +3 -0
  4. package/afm-post-office/tsconfig.json +3 -0
  5. package/dist/cjs/nodeviews/TableComponent.js +57 -3
  6. package/dist/cjs/nodeviews/TableComponentWithSharedState.js +52 -38
  7. package/dist/cjs/nodeviews/TableContainer.js +39 -24
  8. package/dist/cjs/nodeviews/TableResizer.js +13 -8
  9. package/dist/cjs/tablePlugin.js +9 -4
  10. package/dist/cjs/ui/DragHandle/index.js +11 -5
  11. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +9 -4
  12. package/dist/cjs/ui/TableFloatingControls/CornerControls/DragCornerControls.js +10 -5
  13. package/dist/cjs/ui/TableFloatingControls/FloatingControlsWithSelection.js +10 -5
  14. package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +10 -5
  15. package/dist/cjs/ui/global-styles.js +9 -4
  16. package/dist/cjs/ui/icons/SortingIconWrapper.js +9 -4
  17. package/dist/es2019/nodeviews/TableComponent.js +52 -2
  18. package/dist/es2019/nodeviews/TableComponentWithSharedState.js +47 -32
  19. package/dist/es2019/nodeviews/TableContainer.js +33 -18
  20. package/dist/es2019/nodeviews/TableResizer.js +14 -8
  21. package/dist/es2019/tablePlugin.js +9 -3
  22. package/dist/es2019/ui/DragHandle/index.js +11 -4
  23. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +9 -3
  24. package/dist/es2019/ui/TableFloatingControls/CornerControls/DragCornerControls.js +10 -4
  25. package/dist/es2019/ui/TableFloatingControls/FloatingControlsWithSelection.js +10 -4
  26. package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +10 -4
  27. package/dist/es2019/ui/global-styles.js +9 -3
  28. package/dist/es2019/ui/icons/SortingIconWrapper.js +9 -3
  29. package/dist/esm/nodeviews/TableComponent.js +57 -2
  30. package/dist/esm/nodeviews/TableComponentWithSharedState.js +53 -39
  31. package/dist/esm/nodeviews/TableContainer.js +40 -25
  32. package/dist/esm/nodeviews/TableResizer.js +14 -9
  33. package/dist/esm/tablePlugin.js +10 -5
  34. package/dist/esm/ui/DragHandle/index.js +12 -6
  35. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +10 -5
  36. package/dist/esm/ui/TableFloatingControls/CornerControls/DragCornerControls.js +11 -6
  37. package/dist/esm/ui/TableFloatingControls/FloatingControlsWithSelection.js +11 -6
  38. package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +11 -6
  39. package/dist/esm/ui/global-styles.js +10 -5
  40. package/dist/esm/ui/icons/SortingIconWrapper.js +10 -5
  41. package/dist/types/nodeviews/TableComponent.d.ts +4 -0
  42. package/dist/types/ui/hooks/useInternalTablePluginStateSelector.d.ts +1 -1
  43. package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +4 -0
  44. package/dist/types-ts4.5/ui/hooks/useInternalTablePluginStateSelector.d.ts +1 -1
  45. package/package.json +6 -5
  46. package/src/nodeviews/TableComponent.tsx +57 -0
  47. package/src/nodeviews/TableComponentWithSharedState.tsx +62 -32
  48. package/src/nodeviews/TableContainer.tsx +40 -25
  49. package/src/nodeviews/TableResizer.tsx +10 -7
  50. package/src/tablePlugin.tsx +4 -2
  51. package/src/ui/DragHandle/index.tsx +9 -3
  52. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +5 -3
  53. package/src/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +5 -3
  54. package/src/ui/TableFloatingControls/FloatingControlsWithSelection.tsx +5 -3
  55. package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +5 -3
  56. package/src/ui/global-styles.tsx +4 -2
  57. package/src/ui/icons/SortingIconWrapper.tsx +4 -2
  58. package/tsconfig.app.json +3 -0
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.GlobalStylesWrapper = void 0;
7
7
  var _react = require("@emotion/react");
8
8
  var _hooks = require("@atlaskit/editor-common/hooks");
9
- var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
10
9
  var _commonStyles = require("./common-styles");
11
10
  /**
12
11
  * @jsxRuntime classic
@@ -15,13 +14,19 @@ var _commonStyles = require("./common-styles");
15
14
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
16
15
 
17
16
  var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (api) {
18
- var mode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'editorViewMode.mode');
17
+ var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['editorViewMode'], function (states) {
18
+ var _states$editorViewMod;
19
+ return {
20
+ mode: (_states$editorViewMod = states.editorViewModeState) === null || _states$editorViewMod === void 0 ? void 0 : _states$editorViewMod.mode
21
+ };
22
+ }),
23
+ mode = _useSharedPluginState.mode;
19
24
  return {
20
25
  mode: mode
21
26
  };
22
27
  }, function (api) {
23
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['editorViewMode']),
24
- editorViewModeState = _useSharedPluginState.editorViewModeState;
28
+ var _useSharedPluginState2 = (0, _hooks.useSharedPluginState)(api, ['editorViewMode']),
29
+ editorViewModeState = _useSharedPluginState2.editorViewModeState;
25
30
  return {
26
31
  mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode
27
32
  };
@@ -8,15 +8,20 @@ exports.SortingIconWrapper = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _hooks = require("@atlaskit/editor-common/hooks");
10
10
  var _table = require("@atlaskit/editor-common/table");
11
- var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
12
11
  var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (api) {
13
- var mode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'editorViewMode.mode');
12
+ var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['editorViewMode'], function (states) {
13
+ var _states$editorViewMod;
14
+ return {
15
+ mode: (_states$editorViewMod = states.editorViewModeState) === null || _states$editorViewMod === void 0 ? void 0 : _states$editorViewMod.mode
16
+ };
17
+ }),
18
+ mode = _useSharedPluginState.mode;
14
19
  return {
15
20
  mode: mode
16
21
  };
17
22
  }, function (api) {
18
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['editorViewMode']),
19
- editorViewModeState = _useSharedPluginState.editorViewModeState;
23
+ var _useSharedPluginState2 = (0, _hooks.useSharedPluginState)(api, ['editorViewMode']),
24
+ editorViewModeState = _useSharedPluginState2.editorViewModeState;
20
25
  return {
21
26
  mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode
22
27
  };
@@ -15,6 +15,8 @@ import { akEditorTableNumberColumnWidth, akEditorTableToolbarSize as tableToolba
15
15
  import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
16
16
  import { fg } from '@atlaskit/platform-feature-flags';
17
17
  import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
18
+ import UFOLoadHold from '@atlaskit/react-ufo/load-hold';
19
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
18
20
  import { autoSizeTable, clearHoverSelection } from '../pm-plugins/commands';
19
21
  import { autoScrollerFactory } from '../pm-plugins/drag-and-drop/utils/autoscrollers';
20
22
  import { getPluginState } from '../pm-plugins/plugin-factory';
@@ -54,6 +56,12 @@ const isOverflowAnalyticsEnabled = false;
54
56
  // Prevent unnecessary parentWidth updates when table is nested inside of a node that is nested itself.
55
57
  const NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MIN_THRESHOLD = 2;
56
58
  const NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MAX_THRESHOLD = 20;
59
+ let _tableComponentCount = 1;
60
+ /**
61
+ * Exported for test purposes only
62
+ */
63
+ export const _reset_tableComponentCount = () => _tableComponentCount = 0;
64
+
57
65
  // Ignored via go/ees005
58
66
  // eslint-disable-next-line @repo/internal/react/no-class-components
59
67
  class TableComponent extends React.Component {
@@ -67,6 +75,8 @@ class TableComponent extends React.Component {
67
75
  tableWrapperWidth: undefined,
68
76
  tableWrapperHeight: undefined
69
77
  });
78
+ _defineProperty(this, "holdCompleted", false);
79
+ _defineProperty(this, "dispatchEventName", `tableResized-${_tableComponentCount++}`);
70
80
  _defineProperty(this, "handleMouseOut", event => {
71
81
  if (!isTableInFocus(this.props.view)) {
72
82
  return false;
@@ -674,6 +684,14 @@ class TableComponent extends React.Component {
674
684
  // Ignored via go/ees005
675
685
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
676
686
  this.table, tableNode, shouldScaleOnColgroupUpdate, scalePercent);
687
+ if (expValEquals('cc_editor_ufo_hold_table_till_resize_complete', 'isEnabled', true)) {
688
+ // Mark table as updated for TableHold component (if no table exists yet, the colgroup update will not have done anything)
689
+ if (this.table && !this.holdCompleted) {
690
+ const customTableResizedEvent = new CustomEvent(this.dispatchEventName);
691
+ document.dispatchEvent(customTableResizedEvent);
692
+ this.holdCompleted = true;
693
+ }
694
+ }
677
695
  });
678
696
  }
679
697
  }
@@ -974,7 +992,9 @@ class TableComponent extends React.Component {
974
992
  shouldUseIncreasedScalingPercent: shouldUseIncreasedScalingPercent,
975
993
  isCommentEditor: options === null || options === void 0 ? void 0 : options.isCommentEditor,
976
994
  isChromelessEditor: options === null || options === void 0 ? void 0 : options.isChromelessEditor
977
- }, /*#__PURE__*/React.createElement("div", {
995
+ }, expValEquals('cc_editor_ufo_hold_table_till_resize_complete', 'isEnabled', true) ? /*#__PURE__*/React.createElement(TableHold, {
996
+ dispatchEventName: this.dispatchEventName
997
+ }) : null, /*#__PURE__*/React.createElement("div", {
978
998
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
979
999
  className: ClassName.TABLE_STICKY_SENTINEL_TOP,
980
1000
  "data-testid": "sticky-sentinel-top"
@@ -1109,4 +1129,34 @@ class TableComponent extends React.Component {
1109
1129
  }
1110
1130
  }
1111
1131
  _defineProperty(TableComponent, "displayName", 'TableComponent');
1112
- export default injectIntl(TableComponent);
1132
+ export default injectIntl(TableComponent);
1133
+
1134
+ /**
1135
+ * This is needed because of how currently the table is resized post client boot up with code that exists outside react
1136
+ *
1137
+ * This can be deleted once https://home.atlassian.com/o/2346a038-3c8c-498b-a79b-e7847859868d/s/a436116f-02ce-4520-8fbb-7301462a1674/project/ATLAS-97756/updates
1138
+ * is rolled out (and doesn't need to be used in the test arm of that change).
1139
+ */
1140
+ const TableHold = /*#__PURE__*/React.memo(function TableHold({
1141
+ dispatchEventName
1142
+ }) {
1143
+ const [tableUpdateConfirmed, setTableUpdateConfirmed] = React.useState(false);
1144
+ React.useEffect(() => {
1145
+ const customEventListener = () => {
1146
+ setTableUpdateConfirmed(true);
1147
+ };
1148
+
1149
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
1150
+ document.addEventListener(dispatchEventName, customEventListener);
1151
+ return () => {
1152
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
1153
+ document.removeEventListener(dispatchEventName, customEventListener);
1154
+ };
1155
+ }, [dispatchEventName]);
1156
+ if (tableUpdateConfirmed === false) {
1157
+ return /*#__PURE__*/React.createElement(UFOLoadHold, {
1158
+ name: "editor_table_resize"
1159
+ });
1160
+ }
1161
+ return null;
1162
+ });
@@ -1,44 +1,59 @@
1
1
  import React from 'react';
2
- import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
- import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
2
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
3
  import { findTable } from '@atlaskit/editor-tables';
5
4
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
6
- import { useInternalTablePluginStateSelector } from '../ui/hooks/useInternalTablePluginStateSelector';
7
5
  import TableComponent from './TableComponent';
8
6
 
9
7
  // Ignored via go/ees005
10
8
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
9
 
12
10
  const useSharedState = sharedPluginStateHookMigratorFactory(api => {
13
- // tableState
14
- const isTableResizing = useInternalTablePluginStateSelector(api, 'isTableResizing');
15
- const isHeaderColumnEnabled = useInternalTablePluginStateSelector(api, 'isHeaderColumnEnabled');
16
- const isHeaderRowEnabled = useInternalTablePluginStateSelector(api, 'isHeaderRowEnabled');
17
- const ordering = useInternalTablePluginStateSelector(api, 'ordering');
18
- const isResizing = useInternalTablePluginStateSelector(api, 'isResizing');
19
- const isInDanger = useInternalTablePluginStateSelector(api, 'isInDanger');
20
- const hoveredCell = useInternalTablePluginStateSelector(api, 'hoveredCell');
21
- const hoveredRows = useInternalTablePluginStateSelector(api, 'hoveredRows');
22
- const isTableHovered = useInternalTablePluginStateSelector(api, 'isTableHovered');
23
- const isWholeTableInDanger = useInternalTablePluginStateSelector(api, 'isWholeTableInDanger');
24
- // Required so that table controls re-renders
25
- useInternalTablePluginStateSelector(api, 'targetCellPosition');
26
-
27
- // mediaState
28
- const isFullscreen = useSharedPluginStateSelector(api, 'media.isFullscreen');
29
-
30
- // selectionState
31
- const selection = useSharedPluginStateSelector(api, 'selection.selection');
32
-
33
- // editorViewModeState
34
- const mode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
35
-
36
- // widthState
37
- const width = useSharedPluginStateSelector(api, 'width.width');
38
- const lineLength = useSharedPluginStateSelector(api, 'width.lineLength');
39
-
40
- // interactionState
41
- const interaction = useSharedPluginStateSelector(api, 'interaction.interactionState');
11
+ const {
12
+ isTableResizing,
13
+ isHeaderColumnEnabled,
14
+ isHeaderRowEnabled,
15
+ ordering,
16
+ isResizing,
17
+ isInDanger,
18
+ hoveredCell,
19
+ hoveredRows,
20
+ isTableHovered,
21
+ isWholeTableInDanger,
22
+ interaction,
23
+ isFullscreen,
24
+ lineLength,
25
+ mode,
26
+ selection,
27
+ width
28
+ } = useSharedPluginStateWithSelector(api, ['table', 'width', 'media', 'selection', 'editorViewMode', 'interaction'], states => {
29
+ var _states$tableState, _states$tableState2, _states$tableState3, _states$tableState4, _states$tableState5, _states$tableState6, _states$tableState7, _states$tableState8, _states$tableState9, _states$tableState0, _states$tableState1, _states$mediaState, _states$selectionStat, _states$editorViewMod, _states$widthState, _states$widthState2, _states$interactionSt;
30
+ return {
31
+ // tableState
32
+ isTableResizing: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : _states$tableState.isTableResizing,
33
+ isHeaderColumnEnabled: (_states$tableState2 = states.tableState) === null || _states$tableState2 === void 0 ? void 0 : _states$tableState2.isHeaderColumnEnabled,
34
+ isHeaderRowEnabled: (_states$tableState3 = states.tableState) === null || _states$tableState3 === void 0 ? void 0 : _states$tableState3.isHeaderRowEnabled,
35
+ ordering: (_states$tableState4 = states.tableState) === null || _states$tableState4 === void 0 ? void 0 : _states$tableState4.ordering,
36
+ isResizing: (_states$tableState5 = states.tableState) === null || _states$tableState5 === void 0 ? void 0 : _states$tableState5.isResizing,
37
+ isInDanger: (_states$tableState6 = states.tableState) === null || _states$tableState6 === void 0 ? void 0 : _states$tableState6.isInDanger,
38
+ hoveredCell: (_states$tableState7 = states.tableState) === null || _states$tableState7 === void 0 ? void 0 : _states$tableState7.hoveredCell,
39
+ hoveredRows: (_states$tableState8 = states.tableState) === null || _states$tableState8 === void 0 ? void 0 : _states$tableState8.hoveredRows,
40
+ isTableHovered: (_states$tableState9 = states.tableState) === null || _states$tableState9 === void 0 ? void 0 : _states$tableState9.isTableHovered,
41
+ isWholeTableInDanger: (_states$tableState0 = states.tableState) === null || _states$tableState0 === void 0 ? void 0 : _states$tableState0.isWholeTableInDanger,
42
+ // Required so that table control re-renders
43
+ targetCellPosition: (_states$tableState1 = states.tableState) === null || _states$tableState1 === void 0 ? void 0 : _states$tableState1.targetCellPosition,
44
+ // mediaState
45
+ isFullscreen: (_states$mediaState = states.mediaState) === null || _states$mediaState === void 0 ? void 0 : _states$mediaState.isFullscreen,
46
+ // selectionState
47
+ selection: (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection,
48
+ // editorViewModeState
49
+ mode: (_states$editorViewMod = states.editorViewModeState) === null || _states$editorViewMod === void 0 ? void 0 : _states$editorViewMod.mode,
50
+ // widthState
51
+ width: (_states$widthState = states.widthState) === null || _states$widthState === void 0 ? void 0 : _states$widthState.width,
52
+ lineLength: (_states$widthState2 = states.widthState) === null || _states$widthState2 === void 0 ? void 0 : _states$widthState2.lineLength,
53
+ // interactionState
54
+ interaction: (_states$interactionSt = states.interactionState) === null || _states$interactionSt === void 0 ? void 0 : _states$interactionSt.interactionState
55
+ };
56
+ });
42
57
  return {
43
58
  tableState: undefined,
44
59
  widthState: undefined,
@@ -2,9 +2,8 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
3
  import classNames from 'classnames';
4
4
  import { CHANGE_ALIGNMENT_REASON, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
- import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
5
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
6
6
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
7
- import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
8
7
  import { akEditorDefaultLayoutWidth, akEditorGutterPaddingDynamic, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
9
8
  import { fg } from '@atlaskit/platform-feature-flags';
10
9
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
@@ -34,9 +33,17 @@ const InnerContainer = /*#__PURE__*/forwardRef(({
34
33
  "data-testid": "table-container"
35
34
  }, children);
36
35
  });
37
- const useAlignmentStableContainerSharedState = sharedPluginStateHookMigratorFactory(pluginInjectionApi => {
38
- const isFullWidthModeEnabled = useSharedPluginStateSelector(pluginInjectionApi, 'table.isFullWidthModeEnabled');
39
- const wasFullWidthModeEnabled = useSharedPluginStateSelector(pluginInjectionApi, 'table.wasFullWidthModeEnabled');
36
+ const useAlignmentTableContainerSharedState = sharedPluginStateHookMigratorFactory(pluginInjectionApi => {
37
+ const {
38
+ isFullWidthModeEnabled,
39
+ wasFullWidthModeEnabled
40
+ } = useSharedPluginStateWithSelector(pluginInjectionApi, ['table'], states => {
41
+ var _states$tableState, _states$tableState2;
42
+ return {
43
+ isFullWidthModeEnabled: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : _states$tableState.isFullWidthModeEnabled,
44
+ wasFullWidthModeEnabled: (_states$tableState2 = states.tableState) === null || _states$tableState2 === void 0 ? void 0 : _states$tableState2.wasFullWidthModeEnabled
45
+ };
46
+ });
40
47
  return {
41
48
  tableState: undefined,
42
49
  isFullWidthModeEnabled,
@@ -64,7 +71,7 @@ const AlignmentTableContainer = ({
64
71
  tableState,
65
72
  isFullWidthModeEnabled,
66
73
  wasFullWidthModeEnabled
67
- } = useAlignmentStableContainerSharedState(pluginInjectionApi);
74
+ } = useAlignmentTableContainerSharedState(pluginInjectionApi);
68
75
  useEffect(() => {
69
76
  if (!tableState && editorExperiment('platform_editor_usesharedpluginstateselector', false)) {
70
77
  return;
@@ -126,21 +133,27 @@ const AlignmentTableContainerWrapper = ({
126
133
  editorView: editorView
127
134
  }, children);
128
135
  };
129
- const useResizeableTableContainerSharedState = sharedPluginStateHookMigratorFactory(pluginInjectionApi => {
130
- const isFullWidthModeEnabled = useSharedPluginStateSelector(pluginInjectionApi, 'table.isFullWidthModeEnabled');
131
- const mode = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.mode');
136
+ const selector = states => ({
137
+ tableState: states.tableState,
138
+ editorViewModeState: states.editorViewModeState
139
+ });
140
+ const useSharedState = sharedPluginStateHookMigratorFactory(api => {
141
+ const {
142
+ tableState,
143
+ editorViewModeState
144
+ } = useSharedPluginStateWithSelector(api, ['table', 'editorViewMode'], selector);
132
145
  return {
133
- isFullWidthModeEnabled,
134
- mode
146
+ tableState,
147
+ editorViewModeState
135
148
  };
136
- }, pluginInjectionApi => {
149
+ }, api => {
137
150
  const {
138
151
  tableState,
139
152
  editorViewModeState
140
- } = useSharedPluginState(pluginInjectionApi, ['table', 'editorViewMode']);
153
+ } = useSharedPluginState(api, ['table', 'editorViewMode']);
141
154
  return {
142
- isFullWidthModeEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled,
143
- mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode
155
+ tableState,
156
+ editorViewModeState
144
157
  };
145
158
  });
146
159
  export const ResizableTableContainer = /*#__PURE__*/React.memo(({
@@ -166,9 +179,11 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
166
179
  const tableWidthRef = useRef(akEditorDefaultLayoutWidth);
167
180
  const [resizing, setIsResizing] = useState(false);
168
181
  const {
169
- isFullWidthModeEnabled,
170
- mode
171
- } = useResizeableTableContainerSharedState(pluginInjectionApi);
182
+ tableState,
183
+ editorViewModeState
184
+ } = useSharedState(pluginInjectionApi);
185
+ const isFullWidthModeEnabled = tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled;
186
+ const mode = editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
172
187
  const updateContainerHeight = useCallback(height => {
173
188
  var _containerRef$current;
174
189
  // current StickyHeader State is not stable to be fetch.
@@ -4,7 +4,7 @@ import { useIntl } from 'react-intl-next';
4
4
  import { CHANGE_ALIGNMENT_REASON, INPUT_METHOD, TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
5
5
  import { browser } from '@atlaskit/editor-common/browser';
6
6
  import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
7
- import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
7
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
8
8
  import { focusTableResizer, ToolTipContent } from '@atlaskit/editor-common/keymaps';
9
9
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
10
10
  import { logException } from '@atlaskit/editor-common/monitoring';
@@ -26,7 +26,6 @@ import { generateResizedPayload, generateResizeFrameRatePayloads, useMeasureFram
26
26
  import { defaultGuidelines, defaultGuidelinesForPreserveTable, PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET } from '../pm-plugins/utils/guidelines';
27
27
  import { defaultSnappingWidths, defaultTablePreserveSnappingWidths, findClosestSnap, PRESERVE_TABLE_SNAPPING_LENGTH_OFFSET } from '../pm-plugins/utils/snapping';
28
28
  import { TABLE_GUIDELINE_VISIBLE_ADJUSTMENT, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE, TABLE_SNAP_GAP } from '../ui/consts';
29
- import { useInternalTablePluginStateSelector } from '../ui/hooks/useInternalTablePluginStateSelector';
30
29
  const RESIZE_STEP_VALUE = 10;
31
30
  const handles = {
32
31
  right: true
@@ -92,18 +91,25 @@ const getVisibleGuidelines = (guidelines, containerWidth, lineLength, isTableSca
92
91
  return guideline.position && guideline.position.x !== undefined && typeof guideline.position.x === 'number' && Math.abs(guideline.position.x * 2) < width + guidelineVisibleAdjustment;
93
92
  });
94
93
  };
95
- const useSharedState = sharedPluginStateHookMigratorFactory(pluginInjectionApi => {
96
- const widthToWidest = useInternalTablePluginStateSelector(pluginInjectionApi, 'widthToWidest');
94
+ const selector = states => {
95
+ var _states$tableState;
96
+ return {
97
+ widthToWidest: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : _states$tableState.widthToWidest
98
+ };
99
+ };
100
+ const useSharedState = sharedPluginStateHookMigratorFactory(api => {
101
+ const {
102
+ widthToWidest
103
+ } = useSharedPluginStateWithSelector(api, ['table'], selector);
97
104
  return {
98
105
  widthToWidest
99
106
  };
100
- }, pluginInjectionApi => {
107
+ }, api => {
101
108
  const {
102
109
  tableState
103
- } = useSharedPluginState(pluginInjectionApi, ['table']);
104
- const tableStateInternal = tableState;
110
+ } = useSharedPluginState(api, ['table']);
105
111
  return {
106
- widthToWidest: tableStateInternal.widthToWidest
112
+ widthToWidest: tableState === null || tableState === void 0 ? void 0 : tableState.widthToWidest
107
113
  };
108
114
  });
109
115
  export const TableResizer = ({
@@ -4,7 +4,7 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, TA
4
4
  import { browser } from '@atlaskit/editor-common/browser';
5
5
  import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
6
6
  import { getDomRefFromSelection } from '@atlaskit/editor-common/get-dom-ref-from-selection';
7
- import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
7
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
8
8
  import { IconTable } from '@atlaskit/editor-common/icons';
9
9
  import { toggleTable, tooltip } from '@atlaskit/editor-common/keymaps';
10
10
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
@@ -12,7 +12,6 @@ import { getParentOfTypeCount, getPositionAfterTopParentNodeOfType } from '@atla
12
12
  import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
13
13
  import { ResizerBreakoutModeLabel } from '@atlaskit/editor-common/resizer';
14
14
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
15
- import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
16
15
  import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
17
16
  import { hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
18
17
  import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
@@ -61,7 +60,14 @@ import { FullWidthDisplay } from './ui/TableFullWidthLabel';
61
60
  import { getToolbarConfig } from './ui/toolbar';
62
61
  const defaultGetEditorFeatureFlags = () => ({});
63
62
  const useTableSharedState = sharedPluginStateHookMigratorFactory(api => {
64
- const mode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
63
+ const {
64
+ mode
65
+ } = useSharedPluginStateWithSelector(api, ['editorViewMode'], states => {
66
+ var _states$editorViewMod;
67
+ return {
68
+ mode: (_states$editorViewMod = states.editorViewModeState) === null || _states$editorViewMod === void 0 ? void 0 : _states$editorViewMod.mode
69
+ };
70
+ });
65
71
  return {
66
72
  mode
67
73
  };
@@ -5,7 +5,7 @@ import classnames from 'classnames';
5
5
  import ReactDOM from 'react-dom';
6
6
  import { injectIntl } from 'react-intl-next';
7
7
  import { browser } from '@atlaskit/editor-common/browser';
8
- import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
8
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
9
9
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
10
10
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
11
11
  import { findTable, TableMap } from '@atlaskit/editor-tables';
@@ -17,7 +17,6 @@ import { findDuplicatePosition, hasMergedCellsInSelection } from '../../pm-plugi
17
17
  import { TableCssClassName as ClassName } from '../../types';
18
18
  import { dragTableInsertColumnButtonSize } from '../consts';
19
19
  import { DragPreview } from '../DragPreview';
20
- import { useInternalTablePluginStateSelector } from '../hooks/useInternalTablePluginStateSelector';
21
20
  import { HandleIconComponent } from './HandleIconComponent';
22
21
  const DragHandleComponent = ({
23
22
  isDragMenuTarget,
@@ -250,8 +249,16 @@ const DragHandleComponent = ({
250
249
  }), previewContainer));
251
250
  };
252
251
  const useSharedState = sharedPluginStateHookMigratorFactory(api => {
253
- const hoveredColumns = useInternalTablePluginStateSelector(api, 'hoveredColumns');
254
- const hoveredRows = useInternalTablePluginStateSelector(api, 'hoveredRows');
252
+ const {
253
+ hoveredColumns,
254
+ hoveredRows
255
+ } = useSharedPluginStateWithSelector(api, ['table'], states => {
256
+ var _states$tableState, _states$tableState2;
257
+ return {
258
+ hoveredColumns: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : _states$tableState.hoveredColumns,
259
+ hoveredRows: (_states$tableState2 = states.tableState) === null || _states$tableState2 === void 0 ? void 0 : _states$tableState2.hoveredRows
260
+ };
261
+ });
255
262
  return {
256
263
  hoveredColumns,
257
264
  hoveredRows
@@ -1,9 +1,8 @@
1
1
  /* eslint-disable @atlaskit/design-system/prefer-primitives */
2
2
 
3
3
  import React, { useCallback, useMemo, useRef } from 'react';
4
- import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
5
5
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
6
- import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
7
6
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
8
7
  import { CellSelection } from '@atlaskit/editor-tables';
9
8
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
@@ -25,7 +24,14 @@ const getSelectedColumns = selection => {
25
24
  return [];
26
25
  };
27
26
  const useSharedState = sharedPluginStateHookMigratorFactory(api => {
28
- const selection = useSharedPluginStateSelector(api, 'selection.selection');
27
+ const {
28
+ selection
29
+ } = useSharedPluginStateWithSelector(api, ['selection'], states => {
30
+ var _states$selectionStat;
31
+ return {
32
+ selection: (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection
33
+ };
34
+ });
29
35
  return {
30
36
  selection
31
37
  };
@@ -1,9 +1,8 @@
1
1
  import React, { useMemo } from 'react';
2
2
  import classnames from 'classnames';
3
3
  import { injectIntl } from 'react-intl-next';
4
- import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
5
5
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
6
- import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
7
6
  import { findTable, isTableSelected, selectTable } from '@atlaskit/editor-tables/utils';
8
7
  import { clearHoverSelection } from '../../../pm-plugins/commands';
9
8
  import { TableCssClassName as ClassName } from '../../../types';
@@ -60,9 +59,16 @@ const DragCornerControlsComponent = ({
60
59
  }));
61
60
  };
62
61
  const useSharedState = sharedPluginStateHookMigratorFactory(api => {
63
- const selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection');
62
+ const {
63
+ selection
64
+ } = useSharedPluginStateWithSelector(api, ['selection'], states => {
65
+ var _states$selectionStat;
66
+ return {
67
+ selection: (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection
68
+ };
69
+ });
64
70
  return {
65
- selection: selectionsSelector
71
+ selection
66
72
  };
67
73
  }, api => {
68
74
  const {
@@ -1,12 +1,18 @@
1
1
  import React from 'react';
2
- import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
- import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
2
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
3
  import { CornerControls } from './CornerControls/ClassicCornerControls';
5
4
  import { RowControls } from './RowControls/ClassicControls';
6
5
  const useSharedState = sharedPluginStateHookMigratorFactory(api => {
7
- const selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection');
6
+ const {
7
+ selection
8
+ } = useSharedPluginStateWithSelector(api, ['selection'], states => {
9
+ var _states$selectionStat;
10
+ return {
11
+ selection: (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection
12
+ };
13
+ });
8
14
  return {
9
- selection: selectionsSelector
15
+ selection
10
16
  };
11
17
  }, api => {
12
18
  const {
@@ -1,8 +1,7 @@
1
1
  /* eslint-disable @atlaskit/design-system/prefer-primitives */
2
2
 
3
3
  import React, { Fragment, useCallback, useEffect, useMemo, useState } from 'react';
4
- import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
5
- import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
4
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
6
5
  import { CellSelection } from '@atlaskit/editor-tables';
7
6
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
8
7
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -277,9 +276,16 @@ export const DragControls = ({
277
276
  );
278
277
  };
279
278
  const useSharedState = sharedPluginStateHookMigratorFactory(api => {
280
- const selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection');
279
+ const {
280
+ selection
281
+ } = useSharedPluginStateWithSelector(api, ['selection'], states => {
282
+ var _states$selectionStat;
283
+ return {
284
+ selection: (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection
285
+ };
286
+ });
281
287
  return {
282
- selection: selectionsSelector
288
+ selection
283
289
  };
284
290
  }, api => {
285
291
  const {
@@ -4,11 +4,17 @@
4
4
  */
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
- import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
8
- import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
7
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
9
8
  import { tableStyles } from './common-styles';
10
9
  const useSharedState = sharedPluginStateHookMigratorFactory(api => {
11
- const mode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
10
+ const {
11
+ mode
12
+ } = useSharedPluginStateWithSelector(api, ['editorViewMode'], states => {
13
+ var _states$editorViewMod;
14
+ return {
15
+ mode: (_states$editorViewMod = states.editorViewModeState) === null || _states$editorViewMod === void 0 ? void 0 : _states$editorViewMod.mode
16
+ };
17
+ });
12
18
  return {
13
19
  mode
14
20
  };
@@ -1,9 +1,15 @@
1
1
  import React from 'react';
2
- import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
2
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
3
3
  import { SortingIcon } from '@atlaskit/editor-common/table';
4
- import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
5
4
  const useSharedState = sharedPluginStateHookMigratorFactory(api => {
6
- const mode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
5
+ const {
6
+ mode
7
+ } = useSharedPluginStateWithSelector(api, ['editorViewMode'], states => {
8
+ var _states$editorViewMod;
9
+ return {
10
+ mode: (_states$editorViewMod = states.editorViewModeState) === null || _states$editorViewMod === void 0 ? void 0 : _states$editorViewMod.mode
11
+ };
12
+ });
7
13
  return {
8
14
  mode
9
15
  };