@atlaskit/editor-plugin-table 10.9.20 → 10.9.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cjs/nodeviews/TableComponentWithSharedState.js +91 -78
  3. package/dist/cjs/nodeviews/TableContainer.js +41 -37
  4. package/dist/cjs/nodeviews/TableResizer.js +15 -11
  5. package/dist/cjs/tablePlugin.js +14 -10
  6. package/dist/cjs/ui/ContentComponent.js +21 -64
  7. package/dist/cjs/ui/DragHandle/index.js +19 -17
  8. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +14 -11
  9. package/dist/cjs/ui/TableFloatingControls/CornerControls/DragCornerControls.js +14 -10
  10. package/dist/cjs/ui/TableFloatingControls/FloatingControlsWithSelection.js +14 -10
  11. package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +14 -10
  12. package/dist/cjs/ui/global-styles.js +14 -10
  13. package/dist/cjs/ui/icons/SortingIconWrapper.js +14 -11
  14. package/dist/es2019/nodeviews/TableComponentWithSharedState.js +92 -78
  15. package/dist/es2019/nodeviews/TableContainer.js +44 -39
  16. package/dist/es2019/nodeviews/TableResizer.js +17 -12
  17. package/dist/es2019/tablePlugin.js +16 -11
  18. package/dist/es2019/ui/ContentComponent.js +21 -64
  19. package/dist/es2019/ui/DragHandle/index.js +21 -18
  20. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +16 -12
  21. package/dist/es2019/ui/TableFloatingControls/CornerControls/DragCornerControls.js +16 -11
  22. package/dist/es2019/ui/TableFloatingControls/FloatingControlsWithSelection.js +16 -11
  23. package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +16 -11
  24. package/dist/es2019/ui/global-styles.js +16 -11
  25. package/dist/es2019/ui/icons/SortingIconWrapper.js +16 -12
  26. package/dist/esm/nodeviews/TableComponentWithSharedState.js +92 -79
  27. package/dist/esm/nodeviews/TableContainer.js +42 -38
  28. package/dist/esm/nodeviews/TableResizer.js +16 -12
  29. package/dist/esm/tablePlugin.js +15 -11
  30. package/dist/esm/ui/ContentComponent.js +21 -64
  31. package/dist/esm/ui/DragHandle/index.js +20 -18
  32. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +15 -12
  33. package/dist/esm/ui/TableFloatingControls/CornerControls/DragCornerControls.js +15 -11
  34. package/dist/esm/ui/TableFloatingControls/FloatingControlsWithSelection.js +15 -11
  35. package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +15 -11
  36. package/dist/esm/ui/global-styles.js +15 -11
  37. package/dist/esm/ui/icons/SortingIconWrapper.js +15 -12
  38. package/package.json +4 -4
  39. package/src/nodeviews/TableComponentWithSharedState.tsx +97 -125
  40. package/src/nodeviews/TableContainer.tsx +59 -67
  41. package/src/nodeviews/TableResizer.tsx +21 -17
  42. package/src/tablePlugin.tsx +24 -13
  43. package/src/ui/ContentComponent.tsx +19 -64
  44. package/src/ui/DragHandle/index.tsx +24 -24
  45. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +21 -14
  46. package/src/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +20 -12
  47. package/src/ui/TableFloatingControls/FloatingControlsWithSelection.tsx +20 -13
  48. package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +20 -13
  49. package/src/ui/global-styles.tsx +20 -13
  50. package/src/ui/icons/SortingIconWrapper.tsx +20 -14
@@ -13,7 +13,6 @@ var _hooks = require("@atlaskit/editor-common/hooks");
13
13
  var _messages = require("@atlaskit/editor-common/messages");
14
14
  var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
15
15
  var _utils = require("@atlaskit/editor-tables/utils");
16
- var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
17
16
  var _commands = require("../../../pm-plugins/commands");
18
17
  var _types = require("../../../types");
19
18
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
@@ -61,21 +60,26 @@ var DragCornerControlsComponent = function DragCornerControlsComponent(_ref) {
61
60
  className: _types.TableCssClassName.DRAG_CORNER_BUTTON_INNER
62
61
  }));
63
62
  };
63
+ var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (api) {
64
+ var selectionsSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selection.selection');
65
+ return {
66
+ selection: selectionsSelector
67
+ };
68
+ }, function (api) {
69
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['selection']),
70
+ selectionState = _useSharedPluginState.selectionState;
71
+ return {
72
+ selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
73
+ };
74
+ });
64
75
  var DragCornerControlsComponentWithSelection = function DragCornerControlsComponentWithSelection(_ref2) {
65
76
  var editorView = _ref2.editorView,
66
77
  isInDanger = _ref2.isInDanger,
67
78
  isResizing = _ref2.isResizing,
68
79
  formatMessage = _ref2.intl.formatMessage,
69
80
  api = _ref2.api;
70
- // selection
71
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['selection'], {
72
- disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
73
- }),
74
- selectionState = _useSharedPluginState.selectionState;
75
- var selectionsSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selection.selection', {
76
- disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
77
- });
78
- var selection = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? selectionsSelector : selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection;
81
+ var _useSharedState = useSharedState(api),
82
+ selection = _useSharedState.selection;
79
83
  var handleOnClick = function handleOnClick() {
80
84
  var state = editorView.state,
81
85
  dispatch = editorView.dispatch;
@@ -8,9 +8,20 @@ exports.FloatingControlsWithSelection = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _hooks = require("@atlaskit/editor-common/hooks");
10
10
  var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
11
- var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
12
11
  var _ClassicCornerControls = require("./CornerControls/ClassicCornerControls");
13
12
  var _ClassicControls = require("./RowControls/ClassicControls");
13
+ var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (api) {
14
+ var selectionsSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selection.selection');
15
+ return {
16
+ selection: selectionsSelector
17
+ };
18
+ }, function (api) {
19
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['selection']),
20
+ selectionState = _useSharedPluginState.selectionState;
21
+ return {
22
+ selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
23
+ };
24
+ });
14
25
  var FloatingControlsWithSelection = exports.FloatingControlsWithSelection = function FloatingControlsWithSelection(_ref) {
15
26
  var editorView = _ref.editorView,
16
27
  tableRef = _ref.tableRef,
@@ -24,15 +35,8 @@ var FloatingControlsWithSelection = exports.FloatingControlsWithSelection = func
24
35
  selectRow = _ref.selectRow,
25
36
  tableActive = _ref.tableActive,
26
37
  api = _ref.api;
27
- // selection
28
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['selection'], {
29
- disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
30
- }),
31
- selectionState = _useSharedPluginState.selectionState;
32
- var selectionsSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selection.selection', {
33
- disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
34
- });
35
- var selection = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? selectionsSelector : selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection;
38
+ var _useSharedState = useSharedState(api),
39
+ selection = _useSharedState.selection;
36
40
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ClassicCornerControls.CornerControls, {
37
41
  editorView: editorView,
38
42
  tableRef: tableRef,
@@ -14,7 +14,6 @@ var _editorTables = require("@atlaskit/editor-tables");
14
14
  var _utils = require("@atlaskit/editor-tables/utils");
15
15
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
16
  var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
17
- var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
18
17
  var _commands = require("../../../pm-plugins/commands");
19
18
  var _commands2 = require("../../../pm-plugins/drag-and-drop/commands");
20
19
  var _pluginFactory = require("../../../pm-plugins/plugin-factory");
@@ -289,6 +288,18 @@ var DragControls = exports.DragControls = function DragControls(_ref) {
289
288
  }), rowHandles())
290
289
  );
291
290
  };
291
+ var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (api) {
292
+ var selectionsSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selection.selection');
293
+ return {
294
+ selection: selectionsSelector
295
+ };
296
+ }, function (api) {
297
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['selection']),
298
+ selectionState = _useSharedPluginState.selectionState;
299
+ return {
300
+ selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
301
+ };
302
+ });
292
303
  var DragControlsWithSelection = exports.DragControlsWithSelection = function DragControlsWithSelection(_ref5) {
293
304
  var editorView = _ref5.editorView,
294
305
  tableRef = _ref5.tableRef,
@@ -304,15 +315,8 @@ var DragControlsWithSelection = exports.DragControlsWithSelection = function Dra
304
315
  selectRows = _ref5.selectRows,
305
316
  updateCellHoverLocation = _ref5.updateCellHoverLocation,
306
317
  api = _ref5.api;
307
- // selection
308
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['selection'], {
309
- disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
310
- }),
311
- selectionState = _useSharedPluginState.selectionState;
312
- var selectionsSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selection.selection', {
313
- disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
314
- });
315
- var selection = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? selectionsSelector : selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection;
318
+ var _useSharedState = useSharedState(api),
319
+ selection = _useSharedState.selection;
316
320
  return /*#__PURE__*/_react.default.createElement(DragControls, {
317
321
  editorView: editorView,
318
322
  tableRef: tableRef,
@@ -7,7 +7,6 @@ exports.GlobalStylesWrapper = void 0;
7
7
  var _react = require("@emotion/react");
8
8
  var _hooks = require("@atlaskit/editor-common/hooks");
9
9
  var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
10
- var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
11
10
  var _commonStyles = require("./common-styles");
12
11
  /**
13
12
  * @jsxRuntime classic
@@ -15,19 +14,24 @@ var _commonStyles = require("./common-styles");
15
14
  */
16
15
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
17
16
 
17
+ var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (api) {
18
+ var mode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'editorViewMode.mode');
19
+ return {
20
+ mode: mode
21
+ };
22
+ }, function (api) {
23
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['editorViewMode']),
24
+ editorViewModeState = _useSharedPluginState.editorViewModeState;
25
+ return {
26
+ mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode
27
+ };
28
+ });
18
29
  var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWrapper(_ref) {
19
30
  var featureFlags = _ref.featureFlags,
20
31
  isDragAndDropEnabledOption = _ref.isDragAndDropEnabledOption,
21
32
  api = _ref.api;
22
- // mode
23
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['editorViewMode'], {
24
- disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
25
- }),
26
- editorViewModeState = _useSharedPluginState.editorViewModeState;
27
- var modeSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'editorViewMode.mode', {
28
- disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
29
- });
30
- var mode = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? modeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
33
+ var _useSharedState = useSharedState(api),
34
+ mode = _useSharedState.mode;
31
35
  var isLivePageViewMode = mode === 'view';
32
36
  return (0, _react.jsx)(_react.Global, {
33
37
  styles: (0, _commonStyles.tableStyles)({
@@ -9,18 +9,21 @@ var _react = _interopRequireDefault(require("react"));
9
9
  var _hooks = require("@atlaskit/editor-common/hooks");
10
10
  var _table = require("@atlaskit/editor-common/table");
11
11
  var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
12
- var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
13
- var SortingIconWrapper = exports.SortingIconWrapper = function SortingIconWrapper(props) {
14
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(props.api, ['editorViewMode'], {
15
- disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
16
- }),
12
+ var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (api) {
13
+ var mode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'editorViewMode.mode');
14
+ return {
15
+ mode: mode
16
+ };
17
+ }, function (api) {
18
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['editorViewMode']),
17
19
  editorViewModeState = _useSharedPluginState.editorViewModeState;
18
-
19
- // mode
20
- var modeSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(props.api, 'editorViewMode.mode', {
21
- disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
22
- });
23
- var mode = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? modeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
20
+ return {
21
+ mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode
22
+ };
23
+ });
24
+ var SortingIconWrapper = exports.SortingIconWrapper = function SortingIconWrapper(props) {
25
+ var _useSharedState = useSharedState(props.api),
26
+ mode = _useSharedState.mode;
24
27
  if (mode === 'edit') {
25
28
  return null;
26
29
  }
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
2
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
3
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
4
4
  import { findTable } from '@atlaskit/editor-tables';
5
5
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
@@ -9,6 +9,80 @@ import TableComponent from './TableComponent';
9
9
  // Ignored via go/ees005
10
10
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
11
 
12
+ 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
+
25
+ // mediaState
26
+ const isFullscreen = useSharedPluginStateSelector(api, 'media.isFullscreen');
27
+
28
+ // selectionState
29
+ const selection = useSharedPluginStateSelector(api, 'selection.selection');
30
+
31
+ // editorViewModeState
32
+ const mode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
33
+
34
+ // widthState
35
+ const width = useSharedPluginStateSelector(api, 'width.width');
36
+ const lineLength = useSharedPluginStateSelector(api, 'width.lineLength');
37
+ return {
38
+ tableState: undefined,
39
+ widthState: undefined,
40
+ isTableResizing,
41
+ isHeaderColumnEnabled,
42
+ isHeaderRowEnabled,
43
+ ordering,
44
+ isResizing,
45
+ isInDanger,
46
+ hoveredCell,
47
+ hoveredRows,
48
+ isTableHovered,
49
+ isWholeTableInDanger,
50
+ isFullscreen,
51
+ selection,
52
+ mode,
53
+ width,
54
+ lineLength
55
+ };
56
+ }, api => {
57
+ const {
58
+ widthState,
59
+ tableState,
60
+ mediaState,
61
+ selectionState,
62
+ editorViewModeState
63
+ } = useSharedPluginState(api, ['width', 'table', 'media', 'selection', 'editorViewMode']);
64
+ const tableStateInternal = tableState;
65
+ return {
66
+ tableState,
67
+ widthState,
68
+ isTableResizing: tableStateInternal === null || tableStateInternal === void 0 ? void 0 : tableStateInternal.isTableResizing,
69
+ isHeaderColumnEnabled: tableStateInternal === null || tableStateInternal === void 0 ? void 0 : tableStateInternal.isHeaderColumnEnabled,
70
+ isHeaderRowEnabled: tableStateInternal === null || tableStateInternal === void 0 ? void 0 : tableStateInternal.isHeaderRowEnabled,
71
+ ordering: tableStateInternal === null || tableStateInternal === void 0 ? void 0 : tableStateInternal.ordering,
72
+ isResizing: tableStateInternal === null || tableStateInternal === void 0 ? void 0 : tableStateInternal.isResizing,
73
+ isInDanger: tableStateInternal === null || tableStateInternal === void 0 ? void 0 : tableStateInternal.isInDanger,
74
+ hoveredCell: tableStateInternal === null || tableStateInternal === void 0 ? void 0 : tableStateInternal.hoveredCell,
75
+ hoveredRows: tableStateInternal === null || tableStateInternal === void 0 ? void 0 : tableStateInternal.hoveredRows,
76
+ isTableHovered: tableStateInternal === null || tableStateInternal === void 0 ? void 0 : tableStateInternal.isTableHovered,
77
+ isWholeTableInDanger: tableStateInternal === null || tableStateInternal === void 0 ? void 0 : tableStateInternal.isWholeTableInDanger,
78
+ isFullscreen: mediaState === null || mediaState === void 0 ? void 0 : mediaState.isFullscreen,
79
+ selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection,
80
+ mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode,
81
+ width: widthState === null || widthState === void 0 ? void 0 : widthState.width,
82
+ lineLength: widthState === null || widthState === void 0 ? void 0 : widthState.lineLength
83
+ };
84
+ });
85
+
12
86
  /**
13
87
  * Use useSharedPluginState to control re-renders from plugin dependencies
14
88
  */
@@ -28,89 +102,29 @@ export const TableComponentWithSharedState = ({
28
102
  allowTableResizing
29
103
  }) => {
30
104
  const {
31
- widthState,
32
105
  tableState,
33
- mediaState,
34
- selectionState,
35
- editorViewModeState
36
- } = useSharedPluginState(api, ['width', 'table', 'media', 'selection', 'editorViewMode'], {
37
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
38
- });
39
- const isTableResizingSelector = useInternalTablePluginStateSelector(api, 'isTableResizing', {
40
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
41
- });
42
- const isHeaderColumnEnabledSelector = useInternalTablePluginStateSelector(api, 'isHeaderColumnEnabled', {
43
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
44
- });
45
- const isHeaderRowEnabledSelector = useInternalTablePluginStateSelector(api, 'isHeaderRowEnabled', {
46
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
47
- });
48
- const orderingSelector = useInternalTablePluginStateSelector(api, 'ordering', {
49
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
50
- });
51
- const isResizingSelector = useInternalTablePluginStateSelector(api, 'isResizing', {
52
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
53
- });
54
- const isInDangerSelector = useInternalTablePluginStateSelector(api, 'isInDanger', {
55
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
56
- });
57
- const hoveredCellSelector = useInternalTablePluginStateSelector(api, 'hoveredCell', {
58
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
59
- });
60
- const hoveredRowsSelector = useInternalTablePluginStateSelector(api, 'hoveredRows', {
61
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
62
- });
63
- const isTableHoveredSelector = useInternalTablePluginStateSelector(api, 'isTableHovered', {
64
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
65
- });
66
- const isWholeTableInDangerSelector = useInternalTablePluginStateSelector(api, 'isWholeTableInDanger', {
67
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
68
- });
69
-
70
- // mediaState
71
- const isFullscreenSelector = useSharedPluginStateSelector(api, 'media.isFullscreen', {
72
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
73
- });
74
- const isFullscreen = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isFullscreenSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.isFullscreen;
75
-
76
- // selectionState
77
- const selectionSelector = useSharedPluginStateSelector(api, 'selection.selection', {
78
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
79
- });
80
- const selection = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectionSelector : selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection;
81
-
82
- // editorViewModeState
83
- const editorViewModeSelector = useSharedPluginStateSelector(api, 'editorViewMode.mode', {
84
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
85
- });
86
- const mode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? editorViewModeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
106
+ widthState,
107
+ mode,
108
+ hoveredCell,
109
+ hoveredRows,
110
+ isFullscreen,
111
+ isHeaderColumnEnabled,
112
+ isHeaderRowEnabled,
113
+ isInDanger,
114
+ isResizing,
115
+ isTableHovered,
116
+ isTableResizing,
117
+ isWholeTableInDanger,
118
+ lineLength,
119
+ ordering,
120
+ selection,
121
+ width
122
+ } = useSharedState(api);
87
123
  const isLivePageViewMode = mode === 'view';
88
-
89
- // widthState
90
- const widthSelector = useSharedPluginStateSelector(api, 'width.width', {
91
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
92
- });
93
- const width = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? widthSelector : widthState === null || widthState === void 0 ? void 0 : widthState.width;
94
- const lineLengthSelector = useSharedPluginStateSelector(api, 'width.lineLength', {
95
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
96
- });
97
- const lineLength = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? lineLengthSelector : widthState === null || widthState === void 0 ? void 0 : widthState.lineLength;
98
124
  if (editorExperiment('platform_editor_usesharedpluginstateselector', false) && !tableState) {
99
125
  return null;
100
126
  }
101
127
 
102
- // tableState
103
- const isTableResizing = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isTableResizingSelector : tableState.isTableResizing;
104
- const isHeaderColumnEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isHeaderColumnEnabledSelector : tableState.isHeaderColumnEnabled;
105
- const isHeaderRowEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isHeaderRowEnabledSelector : tableState.isHeaderRowEnabled;
106
- const ordering = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? orderingSelector : tableState.ordering;
107
- const isResizing = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isResizingSelector : tableState.isResizing;
108
- const isInDanger = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isInDangerSelector : tableState.isInDanger;
109
- const hoveredCell = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? hoveredCellSelector : tableState.hoveredCell;
110
- const hoveredRows = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? hoveredRowsSelector : tableState.hoveredRows;
111
- const isTableHovered = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isTableHoveredSelector : tableState.isTableHovered;
112
- const isWholeTableInDanger = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isWholeTableInDangerSelector : tableState.isWholeTableInDanger;
113
-
114
128
  /**
115
129
  * ED-19810
116
130
  * There is a getPos issue coming from this code. We need to apply this workaround for now and apply a patch
@@ -2,7 +2,7 @@ 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 { useSharedPluginState } from '@atlaskit/editor-common/hooks';
5
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
6
6
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
7
7
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
8
8
  import { akEditorDefaultLayoutWidth, akEditorGutterPaddingDynamic, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
@@ -34,6 +34,24 @@ const InnerContainer = /*#__PURE__*/forwardRef(({
34
34
  "data-testid": "table-container"
35
35
  }, children);
36
36
  });
37
+ const useAlignmentStableContainerSharedState = sharedPluginStateHookMigratorFactory(pluginInjectionApi => {
38
+ const isFullWidthModeEnabled = useSharedPluginStateSelector(pluginInjectionApi, 'table.isFullWidthModeEnabled');
39
+ const wasFullWidthModeEnabled = useSharedPluginStateSelector(pluginInjectionApi, 'table.wasFullWidthModeEnabled');
40
+ return {
41
+ tableState: undefined,
42
+ isFullWidthModeEnabled,
43
+ wasFullWidthModeEnabled
44
+ };
45
+ }, pluginInjectionApi => {
46
+ const {
47
+ tableState
48
+ } = useSharedPluginState(pluginInjectionApi, ['table']);
49
+ return {
50
+ tableState,
51
+ isFullWidthModeEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled,
52
+ wasFullWidthModeEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.wasFullWidthModeEnabled
53
+ };
54
+ });
37
55
  const AlignmentTableContainer = ({
38
56
  node,
39
57
  children,
@@ -43,22 +61,10 @@ const AlignmentTableContainer = ({
43
61
  }) => {
44
62
  const alignment = node.attrs.layout !== ALIGN_START ? ALIGN_CENTER : ALIGN_START;
45
63
  const {
46
- tableState
47
- } = useSharedPluginState(pluginInjectionApi, ['table'], {
48
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
49
- });
50
-
51
- // isFullWidthModeEnabled
52
- const isTableFullWidthModeEnabledSelector = useSharedPluginStateSelector(pluginInjectionApi, 'table.isFullWidthModeEnabled', {
53
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
54
- });
55
- const isFullWidthModeEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isTableFullWidthModeEnabledSelector : tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled;
56
-
57
- // wasFullWidthModeEnabled
58
- const wasFullWidthModeEnabledSelector = useSharedPluginStateSelector(pluginInjectionApi, 'table.wasFullWidthModeEnabled', {
59
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
60
- });
61
- const wasFullWidthModeEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? wasFullWidthModeEnabledSelector : tableState === null || tableState === void 0 ? void 0 : tableState.wasFullWidthModeEnabled;
64
+ tableState,
65
+ isFullWidthModeEnabled,
66
+ wasFullWidthModeEnabled
67
+ } = useAlignmentStableContainerSharedState(pluginInjectionApi);
62
68
  useEffect(() => {
63
69
  if (!tableState && editorExperiment('platform_editor_usesharedpluginstateselector', false)) {
64
70
  return;
@@ -120,6 +126,23 @@ const AlignmentTableContainerWrapper = ({
120
126
  editorView: editorView
121
127
  }, children);
122
128
  };
129
+ const useResizeableTableContainerSharedState = sharedPluginStateHookMigratorFactory(pluginInjectionApi => {
130
+ const isFullWidthModeEnabled = useSharedPluginStateSelector(pluginInjectionApi, 'table.isFullWidthModeEnabled');
131
+ const mode = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.mode');
132
+ return {
133
+ isFullWidthModeEnabled,
134
+ mode
135
+ };
136
+ }, pluginInjectionApi => {
137
+ const {
138
+ tableState,
139
+ editorViewModeState
140
+ } = useSharedPluginState(pluginInjectionApi, ['table', 'editorViewMode']);
141
+ return {
142
+ isFullWidthModeEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled,
143
+ mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode
144
+ };
145
+ });
123
146
  export const ResizableTableContainer = /*#__PURE__*/React.memo(({
124
147
  children,
125
148
  className,
@@ -143,16 +166,9 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
143
166
  const tableWidthRef = useRef(akEditorDefaultLayoutWidth);
144
167
  const [resizing, setIsResizing] = useState(false);
145
168
  const {
146
- tableState
147
- } = useSharedPluginState(pluginInjectionApi, ['table'], {
148
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
149
- });
150
-
151
- // isFullWidthModeEnabled
152
- const isFullWidthModeEnabledSelector = useSharedPluginStateSelector(pluginInjectionApi, 'table.isFullWidthModeEnabled', {
153
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
154
- });
155
- const isFullWidthModeEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isFullWidthModeEnabledSelector : tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled;
169
+ isFullWidthModeEnabled,
170
+ mode
171
+ } = useResizeableTableContainerSharedState(pluginInjectionApi);
156
172
  const updateContainerHeight = useCallback(height => {
157
173
  var _containerRef$current;
158
174
  // current StickyHeader State is not stable to be fetch.
@@ -206,17 +222,6 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
206
222
  return (_pluginInjectionApi$c = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c2 = pluginInjectionApi.core) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$s = pluginInjectionApi.selection) === null || _pluginInjectionApi$s === void 0 ? void 0 : _pluginInjectionApi$s.commands.displayGapCursor(toggle))) !== null && _pluginInjectionApi$c !== void 0 ? _pluginInjectionApi$c : false;
207
223
  }, [pluginInjectionApi]);
208
224
  const tableWidth = getTableContainerWidth(node);
209
- const {
210
- editorViewModeState
211
- } = useSharedPluginState(pluginInjectionApi, ['editorViewMode'], {
212
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
213
- });
214
-
215
- // mode
216
- const modeSelector = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.mode', {
217
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
218
- });
219
- const mode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? modeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
220
225
  let responsiveContainerWidth = 0;
221
226
  const resizeHandleSpacing = 12;
222
227
  // When Full width editor enabled, a Mac OS user can change "ak-editor-content-area" width by
@@ -267,7 +272,7 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
267
272
  onResizeStop,
268
273
  isCommentEditor
269
274
  };
270
- const isLivePageViewMode = (editorExperiment('platform_editor_usesharedpluginstateselector', true) ? mode : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
275
+ const isLivePageViewMode = mode === 'view';
271
276
  return /*#__PURE__*/React.createElement(AlignmentTableContainerWrapper, {
272
277
  isTableAlignmentEnabled: isTableAlignmentEnabled,
273
278
  node: node,
@@ -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 { useSharedPluginState } from '@atlaskit/editor-common/hooks';
7
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState } 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';
@@ -13,7 +13,6 @@ import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
13
13
  import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
14
14
  import { findTable } from '@atlaskit/editor-tables/utils';
15
15
  import { fg } from '@atlaskit/platform-feature-flags';
16
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
17
16
  import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../pm-plugins/commands/commands-with-analytics';
18
17
  import { updateWidthToWidest } from '../pm-plugins/commands/misc';
19
18
  import { META_KEYS } from '../pm-plugins/table-analytics';
@@ -92,6 +91,20 @@ 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
  };
94
+ const useSharedState = sharedPluginStateHookMigratorFactory(pluginInjectionApi => {
95
+ const widthToWidest = useInternalTablePluginStateSelector(pluginInjectionApi, 'widthToWidest');
96
+ return {
97
+ widthToWidest
98
+ };
99
+ }, pluginInjectionApi => {
100
+ const {
101
+ tableState
102
+ } = useSharedPluginState(pluginInjectionApi, ['table']);
103
+ const tableStateInternal = tableState;
104
+ return {
105
+ widthToWidest: tableStateInternal.widthToWidest
106
+ };
107
+ });
95
108
  export const TableResizer = ({
96
109
  children,
97
110
  width,
@@ -125,16 +138,8 @@ export const TableResizer = ({
125
138
  const areResizeMetaKeysPressed = useRef(false);
126
139
  const resizerRef = useRef(null);
127
140
  const {
128
- tableState
129
- } = useSharedPluginState(pluginInjectionApi, ['table'], {
130
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
131
- });
132
-
133
- // widthToWidest
134
- const widthToWidestSelector = useInternalTablePluginStateSelector(pluginInjectionApi, 'widthToWidest', {
135
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
136
- });
137
- const widthToWidest = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? widthToWidestSelector : tableState.widthToWidest;
141
+ widthToWidest
142
+ } = useSharedState(pluginInjectionApi);
138
143
 
139
144
  // used to reposition tooltip when table is resizing via keyboard
140
145
  const updateTooltip = React.useRef();
@@ -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 { useSharedPluginState } from '@atlaskit/editor-common/hooks';
7
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState } 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';
@@ -59,6 +59,19 @@ import { SizeSelector } from './ui/SizeSelector';
59
59
  import { FullWidthDisplay } from './ui/TableFullWidthLabel';
60
60
  import { getToolbarConfig } from './ui/toolbar';
61
61
  const defaultGetEditorFeatureFlags = () => ({});
62
+ const useTableSharedState = sharedPluginStateHookMigratorFactory(api => {
63
+ const mode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
64
+ return {
65
+ mode
66
+ };
67
+ }, api => {
68
+ const {
69
+ editorViewModeState
70
+ } = useSharedPluginState(api, ['editorViewMode']);
71
+ return {
72
+ mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode
73
+ };
74
+ });
62
75
 
63
76
  /**
64
77
  * Table plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
@@ -681,16 +694,8 @@ const tablePlugin = ({
681
694
  editorView
682
695
  }) {
683
696
  const {
684
- editorViewModeState
685
- } = useSharedPluginState(api, ['editorViewMode'], {
686
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
687
- });
688
-
689
- // mode
690
- const modeSelector = useSharedPluginStateSelector(api, 'editorViewMode.mode', {
691
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
692
- });
693
- const mode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? modeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
697
+ mode
698
+ } = useTableSharedState(api);
694
699
  useEffect(() => {
695
700
  const {
696
701
  state,