@atlaskit/editor-plugin-table 10.9.5 → 10.9.6

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 10.9.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#145707](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/145707)
8
+ [`efae19bca16cb`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/efae19bca16cb) -
9
+ Enable useSharedPluginStateSelector in Table
10
+
3
11
  ## 10.9.5
4
12
 
5
13
  ### Patch Changes
@@ -13,8 +13,10 @@ var _classnames = _interopRequireDefault(require("classnames"));
13
13
  var _analytics = require("@atlaskit/editor-common/analytics");
14
14
  var _hooks = require("@atlaskit/editor-common/hooks");
15
15
  var _nodeWidth = require("@atlaskit/editor-common/node-width");
16
+ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
16
17
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
17
18
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
19
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
18
20
  var _commandsWithAnalytics = require("../pm-plugins/commands/commands-with-analytics");
19
21
  var _pluginFactory = require("../pm-plugins/plugin-factory");
20
22
  var _consts = require("../pm-plugins/table-resizing/utils/consts");
@@ -49,12 +51,27 @@ var AlignmentTableContainer = function AlignmentTableContainer(_ref2) {
49
51
  getPos = _ref2.getPos,
50
52
  editorView = _ref2.editorView;
51
53
  var alignment = node.attrs.layout !== _alignment.ALIGN_START ? _alignment.ALIGN_CENTER : _alignment.ALIGN_START;
52
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['table']),
54
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['table'], {
55
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
56
+ }),
53
57
  tableState = _useSharedPluginState.tableState;
58
+
59
+ // isFullWidthModeEnabled
60
+ var isTableFullWidthModeEnabledSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'table.isFullWidthModeEnabled', {
61
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
62
+ });
63
+ var isFullWidthModeEnabled = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? isTableFullWidthModeEnabledSelector : tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled;
64
+
65
+ // wasFullWidthModeEnabled
66
+ var wasFullWidthModeEnabledSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'table.wasFullWidthModeEnabled', {
67
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
68
+ });
69
+ var wasFullWidthModeEnabled = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? wasFullWidthModeEnabledSelector : tableState === null || tableState === void 0 ? void 0 : tableState.wasFullWidthModeEnabled;
54
70
  (0, _react.useEffect)(function () {
55
- if (tableState && editorView && getPos) {
56
- var wasFullWidthModeEnabled = tableState.wasFullWidthModeEnabled,
57
- isFullWidthModeEnabled = tableState.isFullWidthModeEnabled;
71
+ if ((0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false) && !tableState) {
72
+ return;
73
+ }
74
+ if (editorView && getPos) {
58
75
  var state = editorView.state,
59
76
  dispatch = editorView.dispatch;
60
77
  if (wasFullWidthModeEnabled && isFullWidthModeEnabled !== undefined && !isFullWidthModeEnabled && alignment !== _alignment.ALIGN_CENTER && node.attrs.width > _editorSharedStyles.akEditorDefaultLayoutWidth) {
@@ -70,7 +87,7 @@ var AlignmentTableContainer = function AlignmentTableContainer(_ref2) {
70
87
  }
71
88
  }
72
89
  // eslint-disable-next-line react-hooks/exhaustive-deps
73
- }, [editorView, tableState, node]);
90
+ }, [editorView, tableState, isFullWidthModeEnabled, wasFullWidthModeEnabled, node]);
74
91
  var style = (0, _react.useMemo)(function () {
75
92
  return (0, _tableContainerStyles.getAlignmentStyle)(alignment);
76
93
  }, [alignment]);
@@ -132,10 +149,16 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
132
149
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
133
150
  resizing = _useState2[0],
134
151
  setIsResizing = _useState2[1];
135
- var _useSharedPluginState2 = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['table']),
152
+ var _useSharedPluginState2 = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['table'], {
153
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
154
+ }),
136
155
  tableState = _useSharedPluginState2.tableState;
137
- var _ref5 = tableState,
138
- isFullWidthModeEnabled = _ref5.isFullWidthModeEnabled;
156
+
157
+ // isFullWidthModeEnabled
158
+ var isFullWidthModeEnabledSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'table.isFullWidthModeEnabled', {
159
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
160
+ });
161
+ var isFullWidthModeEnabled = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? isFullWidthModeEnabledSelector : tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled;
139
162
  var updateContainerHeight = (0, _react.useCallback)(function (height) {
140
163
  var _containerRef$current;
141
164
  // current StickyHeader State is not stable to be fetch.
@@ -189,8 +212,16 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
189
212
  return (_pluginInjectionApi$c = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.core) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.actions.execute(pluginInjectionApi === null || pluginInjectionApi === 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;
190
213
  }, [pluginInjectionApi]);
191
214
  var tableWidth = (0, _nodeWidth.getTableContainerWidth)(node);
192
- var _useSharedPluginState3 = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['editorViewMode']),
215
+ var _useSharedPluginState3 = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['editorViewMode'], {
216
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
217
+ }),
193
218
  editorViewModeState = _useSharedPluginState3.editorViewModeState;
219
+
220
+ // mode
221
+ var modeSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'editorViewMode.mode', {
222
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
223
+ });
224
+ var mode = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? modeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
194
225
  var responsiveContainerWidth = 0;
195
226
  var resizeHandleSpacing = 12;
196
227
  // When Full width editor enabled, a Mac OS user can change "ak-editor-content-area" width by
@@ -241,7 +272,7 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
241
272
  onResizeStop: onResizeStop,
242
273
  isCommentEditor: isCommentEditor
243
274
  };
244
- var isLivePageViewMode = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
275
+ var isLivePageViewMode = ((0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? mode : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
245
276
  return /*#__PURE__*/_react.default.createElement(AlignmentTableContainerWrapper, {
246
277
  isTableAlignmentEnabled: isTableAlignmentEnabled,
247
278
  node: node,
@@ -286,28 +317,28 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
286
317
  node: node
287
318
  }, children)) : null));
288
319
  });
289
- var TableContainer = exports.TableContainer = function TableContainer(_ref6) {
290
- var children = _ref6.children,
291
- node = _ref6.node,
292
- className = _ref6.className,
293
- _ref6$containerWidth = _ref6.containerWidth,
294
- editorWidth = _ref6$containerWidth.width,
295
- lineLength = _ref6$containerWidth.lineLength,
296
- editorView = _ref6.editorView,
297
- getPos = _ref6.getPos,
298
- tableRef = _ref6.tableRef,
299
- isNested = _ref6.isNested,
300
- tableWrapperHeight = _ref6.tableWrapperHeight,
301
- isResizing = _ref6.isResizing,
302
- pluginInjectionApi = _ref6.pluginInjectionApi,
303
- isWholeTableInDanger = _ref6.isWholeTableInDanger,
304
- isTableResizingEnabled = _ref6.isTableResizingEnabled,
305
- isTableScalingEnabled = _ref6.isTableScalingEnabled,
306
- isTableWithFixedColumnWidthsOptionEnabled = _ref6.isTableWithFixedColumnWidthsOptionEnabled,
307
- isTableAlignmentEnabled = _ref6.isTableAlignmentEnabled,
308
- shouldUseIncreasedScalingPercent = _ref6.shouldUseIncreasedScalingPercent,
309
- isCommentEditor = _ref6.isCommentEditor,
310
- isChromelessEditor = _ref6.isChromelessEditor;
320
+ var TableContainer = exports.TableContainer = function TableContainer(_ref5) {
321
+ var children = _ref5.children,
322
+ node = _ref5.node,
323
+ className = _ref5.className,
324
+ _ref5$containerWidth = _ref5.containerWidth,
325
+ editorWidth = _ref5$containerWidth.width,
326
+ lineLength = _ref5$containerWidth.lineLength,
327
+ editorView = _ref5.editorView,
328
+ getPos = _ref5.getPos,
329
+ tableRef = _ref5.tableRef,
330
+ isNested = _ref5.isNested,
331
+ tableWrapperHeight = _ref5.tableWrapperHeight,
332
+ isResizing = _ref5.isResizing,
333
+ pluginInjectionApi = _ref5.pluginInjectionApi,
334
+ isWholeTableInDanger = _ref5.isWholeTableInDanger,
335
+ isTableResizingEnabled = _ref5.isTableResizingEnabled,
336
+ isTableScalingEnabled = _ref5.isTableScalingEnabled,
337
+ isTableWithFixedColumnWidthsOptionEnabled = _ref5.isTableWithFixedColumnWidthsOptionEnabled,
338
+ isTableAlignmentEnabled = _ref5.isTableAlignmentEnabled,
339
+ shouldUseIncreasedScalingPercent = _ref5.shouldUseIncreasedScalingPercent,
340
+ isCommentEditor = _ref5.isCommentEditor,
341
+ isChromelessEditor = _ref5.isChromelessEditor;
311
342
  if (isTableResizingEnabled && !isNested) {
312
343
  return /*#__PURE__*/_react.default.createElement(ResizableTableContainer
313
344
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
@@ -19,10 +19,12 @@ var _keymaps = require("@atlaskit/editor-common/keymaps");
19
19
  var _messages = require("@atlaskit/editor-common/messages");
20
20
  var _monitoring = require("@atlaskit/editor-common/monitoring");
21
21
  var _resizer = require("@atlaskit/editor-common/resizer");
22
+ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
22
23
  var _commands = require("@atlaskit/editor-prosemirror/commands");
23
24
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
24
25
  var _utils = require("@atlaskit/editor-tables/utils");
25
26
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
27
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
26
28
  var _commandsWithAnalytics = require("../pm-plugins/commands/commands-with-analytics");
27
29
  var _misc = require("../pm-plugins/commands/misc");
28
30
  var _tableAnalytics = require("../pm-plugins/table-analytics");
@@ -135,10 +137,16 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
135
137
  var isResizing = (0, _react.useRef)(false);
136
138
  var areResizeMetaKeysPressed = (0, _react.useRef)(false);
137
139
  var resizerRef = (0, _react.useRef)(null);
138
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['table']),
140
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['table'], {
141
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
142
+ }),
139
143
  tableState = _useSharedPluginState.tableState;
140
- var _ref2 = tableState,
141
- widthToWidest = _ref2.widthToWidest;
144
+
145
+ // widthToWidest
146
+ var widthToWidestSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'table.widthToWidest', {
147
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
148
+ });
149
+ var widthToWidest = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? widthToWidestSelector : tableState.widthToWidest;
142
150
 
143
151
  // used to reposition tooltip when table is resizing via keyboard
144
152
  var updateTooltip = _react.default.useRef();
@@ -180,12 +188,12 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
180
188
  var excludeGuidelineConfig = (0, _react.useMemo)(function () {
181
189
  return {
182
190
  innerGuidelines: !!isTableAlignmentEnabled,
183
- breakoutPoints: !!(isTableAlignmentEnabled && tableState !== null && tableState !== void 0 && tableState.isFullWidthModeEnabled)
191
+ breakoutPoints: !!(isTableAlignmentEnabled && isFullWidthModeEnabled)
184
192
  };
185
- }, [tableState, isTableAlignmentEnabled]);
186
- var updateActiveGuidelines = (0, _react.useCallback)(function (_ref3) {
187
- var gap = _ref3.gap,
188
- keys = _ref3.keys;
193
+ }, [isFullWidthModeEnabled, isTableAlignmentEnabled]);
194
+ var updateActiveGuidelines = (0, _react.useCallback)(function (_ref2) {
195
+ var gap = _ref2.gap,
196
+ keys = _ref2.keys;
189
197
  if (gap !== currentGap.current) {
190
198
  currentGap.current = gap;
191
199
  var visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? (0, _guidelines.defaultGuidelinesForPreserveTable)(_guidelines.PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET, isFullWidthModeEnabled ? lineLength + 2 * (0, _editorSharedStyles.akEditorGutterPaddingDynamic)() : containerWidth, excludeGuidelineConfig) : _guidelines.defaultGuidelines, containerWidth, lineLength, Boolean(isTableScalingEnabled), Boolean(isFullWidthModeEnabled));
@@ -487,8 +495,8 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
487
495
  needExtendedResizeZone: !isTableSelected,
488
496
  appearance: isTableSelected && isWholeTableInDanger ? 'danger' : undefined,
489
497
  handleHighlight: "shadow",
490
- handleTooltipContent: function handleTooltipContent(_ref4) {
491
- var update = _ref4.update;
498
+ handleTooltipContent: function handleTooltipContent(_ref3) {
499
+ var update = _ref3.update;
492
500
  updateTooltip.current = update;
493
501
  return /*#__PURE__*/_react.default.createElement(_keymaps.ToolTipContent, {
494
502
  description: formatMessage(_messages.tableMessages.resizeTable),
@@ -21,6 +21,7 @@ var _nesting = require("@atlaskit/editor-common/nesting");
21
21
  var _preset = require("@atlaskit/editor-common/preset");
22
22
  var _resizer = require("@atlaskit/editor-common/resizer");
23
23
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
24
+ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
24
25
  var _withPluginState = require("@atlaskit/editor-common/with-plugin-state");
25
26
  var _utils = require("@atlaskit/editor-prosemirror/utils");
26
27
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
@@ -686,9 +687,16 @@ var tablePlugin = function tablePlugin(_ref) {
686
687
  },
687
688
  usePluginHook: function usePluginHook(_ref24) {
688
689
  var editorView = _ref24.editorView;
689
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['editorViewMode']),
690
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['editorViewMode'], {
691
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
692
+ }),
690
693
  editorViewModeState = _useSharedPluginState.editorViewModeState;
691
- var mode = editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
694
+
695
+ // mode
696
+ var modeSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'editorViewMode.mode', {
697
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
698
+ });
699
+ var mode = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? modeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
692
700
  (0, _react.useEffect)(function () {
693
701
  var state = editorView.state,
694
702
  dispatch = editorView.dispatch;
@@ -15,10 +15,12 @@ var _reactIntlNext = require("react-intl-next");
15
15
  var _browser = require("@atlaskit/editor-common/browser");
16
16
  var _hooks = require("@atlaskit/editor-common/hooks");
17
17
  var _messages = require("@atlaskit/editor-common/messages");
18
+ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
18
19
  var _state = require("@atlaskit/editor-prosemirror/state");
19
20
  var _editorTables = require("@atlaskit/editor-tables");
20
21
  var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
21
22
  var _setCustomNativeDragPreview = require("@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview");
23
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
22
24
  var _pluginFactory = require("../../pm-plugins/drag-and-drop/plugin-factory");
23
25
  var _pluginFactory2 = require("../../pm-plugins/plugin-factory");
24
26
  var _mergedCells = require("../../pm-plugins/utils/merged-cells");
@@ -270,8 +272,22 @@ var DragHandleComponentWithSharedState = function DragHandleComponentWithSharedS
270
272
  editorView = _ref5.editorView,
271
273
  intl = _ref5.intl,
272
274
  api = _ref5.api;
273
- var _ref6 = (0, _hooks.useSharedPluginState)(api, ['table']),
275
+ var _ref6 = (0, _hooks.useSharedPluginState)(api, ['table'], {
276
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
277
+ }),
274
278
  tableState = _ref6.tableState;
279
+
280
+ // hoveredColumns
281
+ var hoveredColumnsSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'table.hoveredColumns', {
282
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
283
+ });
284
+ var hoveredColumns = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? hoveredColumnsSelector : tableState === null || tableState === void 0 ? void 0 : tableState.hoveredColumns;
285
+
286
+ // hoveredRows
287
+ var hoveredRowsSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'table.hoveredRows', {
288
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
289
+ });
290
+ var hoveredRows = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? hoveredRowsSelector : tableState === null || tableState === void 0 ? void 0 : tableState.hoveredRows;
275
291
  return /*#__PURE__*/_react.default.createElement(DragHandleComponent, {
276
292
  isDragMenuTarget: isDragMenuTarget,
277
293
  tableLocalId: tableLocalId,
@@ -288,8 +304,8 @@ var DragHandleComponentWithSharedState = function DragHandleComponentWithSharedS
288
304
  onClick: onClick,
289
305
  editorView: editorView,
290
306
  intl: intl,
291
- hoveredColumns: tableState === null || tableState === void 0 ? void 0 : tableState.hoveredColumns,
292
- hoveredRows: tableState === null || tableState === void 0 ? void 0 : tableState.hoveredRows
307
+ hoveredColumns: hoveredColumns,
308
+ hoveredRows: hoveredRows
293
309
  });
294
310
  };
295
311
  var DragHandle = exports.DragHandle = (0, _reactIntlNext.injectIntl)(DragHandleComponent);
@@ -6,6 +6,8 @@ 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
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
9
11
  var _commonStyles = require("./common-styles");
10
12
  /**
11
13
  * @jsxRuntime classic
@@ -17,9 +19,16 @@ var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWra
17
19
  var featureFlags = _ref.featureFlags,
18
20
  isDragAndDropEnabledOption = _ref.isDragAndDropEnabledOption,
19
21
  api = _ref.api;
20
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['editorViewMode']),
22
+ // mode
23
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['editorViewMode'], {
24
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
25
+ }),
21
26
  editorViewModeState = _useSharedPluginState.editorViewModeState;
22
- var isLivePageViewMode = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
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;
31
+ var isLivePageViewMode = mode === 'view';
23
32
  return (0, _react.jsx)(_react.Global, {
24
33
  styles: (0, _commonStyles.tableStyles)({
25
34
  featureFlags: featureFlags,
@@ -4,8 +4,10 @@ import classNames from 'classnames';
4
4
  import { CHANGE_ALIGNMENT_REASON, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
5
  import { useSharedPluginState } 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';
7
8
  import { akEditorDefaultLayoutWidth, akEditorGutterPaddingDynamic, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
8
9
  import { fg } from '@atlaskit/platform-feature-flags';
10
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
9
11
  import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../pm-plugins/commands/commands-with-analytics';
10
12
  import { getPluginState } from '../pm-plugins/plugin-factory';
11
13
  import { TABLE_MAX_WIDTH, TABLE_OFFSET_IN_COMMENT_EDITOR } from '../pm-plugins/table-resizing/utils/consts';
@@ -42,13 +44,26 @@ const AlignmentTableContainer = ({
42
44
  const alignment = node.attrs.layout !== ALIGN_START ? ALIGN_CENTER : ALIGN_START;
43
45
  const {
44
46
  tableState
45
- } = useSharedPluginState(pluginInjectionApi, ['table']);
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;
46
62
  useEffect(() => {
47
- if (tableState && editorView && getPos) {
48
- const {
49
- wasFullWidthModeEnabled,
50
- isFullWidthModeEnabled
51
- } = tableState;
63
+ if (editorExperiment('platform_editor_usesharedpluginstateselector', false) && !tableState) {
64
+ return;
65
+ }
66
+ if (editorView && getPos) {
52
67
  const {
53
68
  state,
54
69
  dispatch
@@ -66,7 +81,7 @@ const AlignmentTableContainer = ({
66
81
  }
67
82
  }
68
83
  // eslint-disable-next-line react-hooks/exhaustive-deps
69
- }, [editorView, tableState, node]);
84
+ }, [editorView, tableState, isFullWidthModeEnabled, wasFullWidthModeEnabled, node]);
70
85
  const style = useMemo(() => {
71
86
  return getAlignmentStyle(alignment);
72
87
  }, [alignment]);
@@ -129,10 +144,15 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
129
144
  const [resizing, setIsResizing] = useState(false);
130
145
  const {
131
146
  tableState
132
- } = useSharedPluginState(pluginInjectionApi, ['table']);
133
- const {
134
- isFullWidthModeEnabled
135
- } = 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;
136
156
  const updateContainerHeight = useCallback(height => {
137
157
  var _containerRef$current;
138
158
  // current StickyHeader State is not stable to be fetch.
@@ -188,7 +208,15 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
188
208
  const tableWidth = getTableContainerWidth(node);
189
209
  const {
190
210
  editorViewModeState
191
- } = useSharedPluginState(pluginInjectionApi, ['editorViewMode']);
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;
192
220
  let responsiveContainerWidth = 0;
193
221
  const resizeHandleSpacing = 12;
194
222
  // When Full width editor enabled, a Mac OS user can change "ak-editor-content-area" width by
@@ -239,7 +267,7 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
239
267
  onResizeStop,
240
268
  isCommentEditor
241
269
  };
242
- const isLivePageViewMode = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
270
+ const isLivePageViewMode = (editorExperiment('platform_editor_usesharedpluginstateselector', true) ? mode : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
243
271
  return /*#__PURE__*/React.createElement(AlignmentTableContainerWrapper, {
244
272
  isTableAlignmentEnabled: isTableAlignmentEnabled,
245
273
  node: node,
@@ -9,10 +9,12 @@ import { focusTableResizer, ToolTipContent } from '@atlaskit/editor-common/keyma
9
9
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
10
10
  import { logException } from '@atlaskit/editor-common/monitoring';
11
11
  import { ResizerNext } from '@atlaskit/editor-common/resizer';
12
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
12
13
  import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
13
14
  import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
14
15
  import { findTable } from '@atlaskit/editor-tables/utils';
15
16
  import { fg } from '@atlaskit/platform-feature-flags';
17
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
16
18
  import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../pm-plugins/commands/commands-with-analytics';
17
19
  import { updateWidthToWidest } from '../pm-plugins/commands/misc';
18
20
  import { META_KEYS } from '../pm-plugins/table-analytics';
@@ -124,10 +126,15 @@ export const TableResizer = ({
124
126
  const resizerRef = useRef(null);
125
127
  const {
126
128
  tableState
127
- } = useSharedPluginState(pluginInjectionApi, ['table']);
128
- const {
129
- widthToWidest
130
- } = tableState;
129
+ } = useSharedPluginState(pluginInjectionApi, ['table'], {
130
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
131
+ });
132
+
133
+ // widthToWidest
134
+ const widthToWidestSelector = useSharedPluginStateSelector(pluginInjectionApi, 'table.widthToWidest', {
135
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
136
+ });
137
+ const widthToWidest = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? widthToWidestSelector : tableState.widthToWidest;
131
138
 
132
139
  // used to reposition tooltip when table is resizing via keyboard
133
140
  const updateTooltip = React.useRef();
@@ -167,8 +174,8 @@ export const TableResizer = ({
167
174
  } = useMeasureFramerate();
168
175
  const excludeGuidelineConfig = useMemo(() => ({
169
176
  innerGuidelines: !!isTableAlignmentEnabled,
170
- breakoutPoints: !!(isTableAlignmentEnabled && tableState !== null && tableState !== void 0 && tableState.isFullWidthModeEnabled)
171
- }), [tableState, isTableAlignmentEnabled]);
177
+ breakoutPoints: !!(isTableAlignmentEnabled && isFullWidthModeEnabled)
178
+ }), [isFullWidthModeEnabled, isTableAlignmentEnabled]);
172
179
  const updateActiveGuidelines = useCallback(({
173
180
  gap,
174
181
  keys
@@ -12,6 +12,7 @@ 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';
15
16
  import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
16
17
  import { hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
17
18
  import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
@@ -681,8 +682,15 @@ const tablePlugin = ({
681
682
  }) {
682
683
  const {
683
684
  editorViewModeState
684
- } = useSharedPluginState(api, ['editorViewMode']);
685
- const mode = editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
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;
686
694
  useEffect(() => {
687
695
  const {
688
696
  state,
@@ -7,10 +7,12 @@ import { injectIntl } from 'react-intl-next';
7
7
  import { browser } from '@atlaskit/editor-common/browser';
8
8
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
9
9
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
10
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
10
11
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
11
12
  import { findTable, TableMap } from '@atlaskit/editor-tables';
12
13
  import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
13
14
  import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';
15
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
14
16
  import { getPluginState as getDnDPluginState } from '../../pm-plugins/drag-and-drop/plugin-factory';
15
17
  import { getPluginState } from '../../pm-plugins/plugin-factory';
16
18
  import { findDuplicatePosition, hasMergedCellsInSelection } from '../../pm-plugins/utils/merged-cells';
@@ -268,7 +270,21 @@ const DragHandleComponentWithSharedState = ({
268
270
  }) => {
269
271
  const {
270
272
  tableState
271
- } = useSharedPluginState(api, ['table']);
273
+ } = useSharedPluginState(api, ['table'], {
274
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
275
+ });
276
+
277
+ // hoveredColumns
278
+ const hoveredColumnsSelector = useSharedPluginStateSelector(api, 'table.hoveredColumns', {
279
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
280
+ });
281
+ const hoveredColumns = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? hoveredColumnsSelector : tableState === null || tableState === void 0 ? void 0 : tableState.hoveredColumns;
282
+
283
+ // hoveredRows
284
+ const hoveredRowsSelector = useSharedPluginStateSelector(api, 'table.hoveredRows', {
285
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
286
+ });
287
+ const hoveredRows = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? hoveredRowsSelector : tableState === null || tableState === void 0 ? void 0 : tableState.hoveredRows;
272
288
  return /*#__PURE__*/React.createElement(DragHandleComponent, {
273
289
  isDragMenuTarget: isDragMenuTarget,
274
290
  tableLocalId: tableLocalId,
@@ -285,8 +301,8 @@ const DragHandleComponentWithSharedState = ({
285
301
  onClick: onClick,
286
302
  editorView: editorView,
287
303
  intl: intl,
288
- hoveredColumns: tableState === null || tableState === void 0 ? void 0 : tableState.hoveredColumns,
289
- hoveredRows: tableState === null || tableState === void 0 ? void 0 : tableState.hoveredRows
304
+ hoveredColumns: hoveredColumns,
305
+ hoveredRows: hoveredRows
290
306
  });
291
307
  };
292
308
  export const DragHandle = injectIntl(DragHandleComponent);
@@ -5,16 +5,25 @@
5
5
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
6
6
  import { Global, jsx } from '@emotion/react';
7
7
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
8
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
9
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
10
  import { tableStyles } from './common-styles';
9
11
  export const GlobalStylesWrapper = ({
10
12
  featureFlags,
11
13
  isDragAndDropEnabledOption,
12
14
  api
13
15
  }) => {
16
+ // mode
14
17
  const {
15
18
  editorViewModeState
16
- } = useSharedPluginState(api, ['editorViewMode']);
17
- const isLivePageViewMode = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
19
+ } = useSharedPluginState(api, ['editorViewMode'], {
20
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
21
+ });
22
+ const modeSelector = useSharedPluginStateSelector(api, 'editorViewMode.mode', {
23
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
24
+ });
25
+ const mode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? modeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
26
+ const isLivePageViewMode = mode === 'view';
18
27
  return jsx(Global, {
19
28
  styles: tableStyles({
20
29
  featureFlags,
@@ -5,8 +5,10 @@ import classNames from 'classnames';
5
5
  import { CHANGE_ALIGNMENT_REASON, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
6
6
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
7
7
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
8
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
8
9
  import { akEditorDefaultLayoutWidth, akEditorGutterPaddingDynamic, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
9
10
  import { fg } from '@atlaskit/platform-feature-flags';
11
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
10
12
  import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../pm-plugins/commands/commands-with-analytics';
11
13
  import { getPluginState } from '../pm-plugins/plugin-factory';
12
14
  import { TABLE_MAX_WIDTH, TABLE_OFFSET_IN_COMMENT_EDITOR } from '../pm-plugins/table-resizing/utils/consts';
@@ -39,12 +41,27 @@ var AlignmentTableContainer = function AlignmentTableContainer(_ref2) {
39
41
  getPos = _ref2.getPos,
40
42
  editorView = _ref2.editorView;
41
43
  var alignment = node.attrs.layout !== ALIGN_START ? ALIGN_CENTER : ALIGN_START;
42
- var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['table']),
44
+ var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['table'], {
45
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
46
+ }),
43
47
  tableState = _useSharedPluginState.tableState;
48
+
49
+ // isFullWidthModeEnabled
50
+ var isTableFullWidthModeEnabledSelector = useSharedPluginStateSelector(pluginInjectionApi, 'table.isFullWidthModeEnabled', {
51
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
52
+ });
53
+ var isFullWidthModeEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isTableFullWidthModeEnabledSelector : tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled;
54
+
55
+ // wasFullWidthModeEnabled
56
+ var wasFullWidthModeEnabledSelector = useSharedPluginStateSelector(pluginInjectionApi, 'table.wasFullWidthModeEnabled', {
57
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
58
+ });
59
+ var wasFullWidthModeEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? wasFullWidthModeEnabledSelector : tableState === null || tableState === void 0 ? void 0 : tableState.wasFullWidthModeEnabled;
44
60
  useEffect(function () {
45
- if (tableState && editorView && getPos) {
46
- var wasFullWidthModeEnabled = tableState.wasFullWidthModeEnabled,
47
- isFullWidthModeEnabled = tableState.isFullWidthModeEnabled;
61
+ if (editorExperiment('platform_editor_usesharedpluginstateselector', false) && !tableState) {
62
+ return;
63
+ }
64
+ if (editorView && getPos) {
48
65
  var state = editorView.state,
49
66
  dispatch = editorView.dispatch;
50
67
  if (wasFullWidthModeEnabled && isFullWidthModeEnabled !== undefined && !isFullWidthModeEnabled && alignment !== ALIGN_CENTER && node.attrs.width > akEditorDefaultLayoutWidth) {
@@ -60,7 +77,7 @@ var AlignmentTableContainer = function AlignmentTableContainer(_ref2) {
60
77
  }
61
78
  }
62
79
  // eslint-disable-next-line react-hooks/exhaustive-deps
63
- }, [editorView, tableState, node]);
80
+ }, [editorView, tableState, isFullWidthModeEnabled, wasFullWidthModeEnabled, node]);
64
81
  var style = useMemo(function () {
65
82
  return getAlignmentStyle(alignment);
66
83
  }, [alignment]);
@@ -122,10 +139,16 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref4) {
122
139
  _useState2 = _slicedToArray(_useState, 2),
123
140
  resizing = _useState2[0],
124
141
  setIsResizing = _useState2[1];
125
- var _useSharedPluginState2 = useSharedPluginState(pluginInjectionApi, ['table']),
142
+ var _useSharedPluginState2 = useSharedPluginState(pluginInjectionApi, ['table'], {
143
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
144
+ }),
126
145
  tableState = _useSharedPluginState2.tableState;
127
- var _ref5 = tableState,
128
- isFullWidthModeEnabled = _ref5.isFullWidthModeEnabled;
146
+
147
+ // isFullWidthModeEnabled
148
+ var isFullWidthModeEnabledSelector = useSharedPluginStateSelector(pluginInjectionApi, 'table.isFullWidthModeEnabled', {
149
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
150
+ });
151
+ var isFullWidthModeEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isFullWidthModeEnabledSelector : tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled;
129
152
  var updateContainerHeight = useCallback(function (height) {
130
153
  var _containerRef$current;
131
154
  // current StickyHeader State is not stable to be fetch.
@@ -179,8 +202,16 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref4) {
179
202
  return (_pluginInjectionApi$c = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.core) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.actions.execute(pluginInjectionApi === null || pluginInjectionApi === 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;
180
203
  }, [pluginInjectionApi]);
181
204
  var tableWidth = getTableContainerWidth(node);
182
- var _useSharedPluginState3 = useSharedPluginState(pluginInjectionApi, ['editorViewMode']),
205
+ var _useSharedPluginState3 = useSharedPluginState(pluginInjectionApi, ['editorViewMode'], {
206
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
207
+ }),
183
208
  editorViewModeState = _useSharedPluginState3.editorViewModeState;
209
+
210
+ // mode
211
+ var modeSelector = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.mode', {
212
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
213
+ });
214
+ var mode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? modeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
184
215
  var responsiveContainerWidth = 0;
185
216
  var resizeHandleSpacing = 12;
186
217
  // When Full width editor enabled, a Mac OS user can change "ak-editor-content-area" width by
@@ -231,7 +262,7 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref4) {
231
262
  onResizeStop: onResizeStop,
232
263
  isCommentEditor: isCommentEditor
233
264
  };
234
- var isLivePageViewMode = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
265
+ var isLivePageViewMode = (editorExperiment('platform_editor_usesharedpluginstateselector', true) ? mode : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
235
266
  return /*#__PURE__*/React.createElement(AlignmentTableContainerWrapper, {
236
267
  isTableAlignmentEnabled: isTableAlignmentEnabled,
237
268
  node: node,
@@ -276,28 +307,28 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref4) {
276
307
  node: node
277
308
  }, children)) : null));
278
309
  });
279
- export var TableContainer = function TableContainer(_ref6) {
280
- var children = _ref6.children,
281
- node = _ref6.node,
282
- className = _ref6.className,
283
- _ref6$containerWidth = _ref6.containerWidth,
284
- editorWidth = _ref6$containerWidth.width,
285
- lineLength = _ref6$containerWidth.lineLength,
286
- editorView = _ref6.editorView,
287
- getPos = _ref6.getPos,
288
- tableRef = _ref6.tableRef,
289
- isNested = _ref6.isNested,
290
- tableWrapperHeight = _ref6.tableWrapperHeight,
291
- isResizing = _ref6.isResizing,
292
- pluginInjectionApi = _ref6.pluginInjectionApi,
293
- isWholeTableInDanger = _ref6.isWholeTableInDanger,
294
- isTableResizingEnabled = _ref6.isTableResizingEnabled,
295
- isTableScalingEnabled = _ref6.isTableScalingEnabled,
296
- isTableWithFixedColumnWidthsOptionEnabled = _ref6.isTableWithFixedColumnWidthsOptionEnabled,
297
- isTableAlignmentEnabled = _ref6.isTableAlignmentEnabled,
298
- shouldUseIncreasedScalingPercent = _ref6.shouldUseIncreasedScalingPercent,
299
- isCommentEditor = _ref6.isCommentEditor,
300
- isChromelessEditor = _ref6.isChromelessEditor;
310
+ export var TableContainer = function TableContainer(_ref5) {
311
+ var children = _ref5.children,
312
+ node = _ref5.node,
313
+ className = _ref5.className,
314
+ _ref5$containerWidth = _ref5.containerWidth,
315
+ editorWidth = _ref5$containerWidth.width,
316
+ lineLength = _ref5$containerWidth.lineLength,
317
+ editorView = _ref5.editorView,
318
+ getPos = _ref5.getPos,
319
+ tableRef = _ref5.tableRef,
320
+ isNested = _ref5.isNested,
321
+ tableWrapperHeight = _ref5.tableWrapperHeight,
322
+ isResizing = _ref5.isResizing,
323
+ pluginInjectionApi = _ref5.pluginInjectionApi,
324
+ isWholeTableInDanger = _ref5.isWholeTableInDanger,
325
+ isTableResizingEnabled = _ref5.isTableResizingEnabled,
326
+ isTableScalingEnabled = _ref5.isTableScalingEnabled,
327
+ isTableWithFixedColumnWidthsOptionEnabled = _ref5.isTableWithFixedColumnWidthsOptionEnabled,
328
+ isTableAlignmentEnabled = _ref5.isTableAlignmentEnabled,
329
+ shouldUseIncreasedScalingPercent = _ref5.shouldUseIncreasedScalingPercent,
330
+ isCommentEditor = _ref5.isCommentEditor,
331
+ isChromelessEditor = _ref5.isChromelessEditor;
301
332
  if (isTableResizingEnabled && !isNested) {
302
333
  return /*#__PURE__*/React.createElement(ResizableTableContainer
303
334
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
@@ -13,10 +13,12 @@ import { focusTableResizer, ToolTipContent } from '@atlaskit/editor-common/keyma
13
13
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
14
14
  import { logException } from '@atlaskit/editor-common/monitoring';
15
15
  import { ResizerNext } from '@atlaskit/editor-common/resizer';
16
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
16
17
  import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
17
18
  import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
18
19
  import { findTable } from '@atlaskit/editor-tables/utils';
19
20
  import { fg } from '@atlaskit/platform-feature-flags';
21
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
20
22
  import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../pm-plugins/commands/commands-with-analytics';
21
23
  import { updateWidthToWidest } from '../pm-plugins/commands/misc';
22
24
  import { META_KEYS } from '../pm-plugins/table-analytics';
@@ -125,10 +127,16 @@ export var TableResizer = function TableResizer(_ref) {
125
127
  var isResizing = useRef(false);
126
128
  var areResizeMetaKeysPressed = useRef(false);
127
129
  var resizerRef = useRef(null);
128
- var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['table']),
130
+ var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['table'], {
131
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
132
+ }),
129
133
  tableState = _useSharedPluginState.tableState;
130
- var _ref2 = tableState,
131
- widthToWidest = _ref2.widthToWidest;
134
+
135
+ // widthToWidest
136
+ var widthToWidestSelector = useSharedPluginStateSelector(pluginInjectionApi, 'table.widthToWidest', {
137
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
138
+ });
139
+ var widthToWidest = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? widthToWidestSelector : tableState.widthToWidest;
132
140
 
133
141
  // used to reposition tooltip when table is resizing via keyboard
134
142
  var updateTooltip = React.useRef();
@@ -170,12 +178,12 @@ export var TableResizer = function TableResizer(_ref) {
170
178
  var excludeGuidelineConfig = useMemo(function () {
171
179
  return {
172
180
  innerGuidelines: !!isTableAlignmentEnabled,
173
- breakoutPoints: !!(isTableAlignmentEnabled && tableState !== null && tableState !== void 0 && tableState.isFullWidthModeEnabled)
181
+ breakoutPoints: !!(isTableAlignmentEnabled && isFullWidthModeEnabled)
174
182
  };
175
- }, [tableState, isTableAlignmentEnabled]);
176
- var updateActiveGuidelines = useCallback(function (_ref3) {
177
- var gap = _ref3.gap,
178
- keys = _ref3.keys;
183
+ }, [isFullWidthModeEnabled, isTableAlignmentEnabled]);
184
+ var updateActiveGuidelines = useCallback(function (_ref2) {
185
+ var gap = _ref2.gap,
186
+ keys = _ref2.keys;
179
187
  if (gap !== currentGap.current) {
180
188
  currentGap.current = gap;
181
189
  var visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? defaultGuidelinesForPreserveTable(PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET, isFullWidthModeEnabled ? lineLength + 2 * akEditorGutterPaddingDynamic() : containerWidth, excludeGuidelineConfig) : defaultGuidelines, containerWidth, lineLength, Boolean(isTableScalingEnabled), Boolean(isFullWidthModeEnabled));
@@ -477,8 +485,8 @@ export var TableResizer = function TableResizer(_ref) {
477
485
  needExtendedResizeZone: !isTableSelected,
478
486
  appearance: isTableSelected && isWholeTableInDanger ? 'danger' : undefined,
479
487
  handleHighlight: "shadow",
480
- handleTooltipContent: function handleTooltipContent(_ref4) {
481
- var update = _ref4.update;
488
+ handleTooltipContent: function handleTooltipContent(_ref3) {
489
+ var update = _ref3.update;
482
490
  updateTooltip.current = update;
483
491
  return /*#__PURE__*/React.createElement(ToolTipContent, {
484
492
  description: formatMessage(messages.resizeTable),
@@ -15,6 +15,7 @@ import { getParentOfTypeCount, getPositionAfterTopParentNodeOfType } from '@atla
15
15
  import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
16
16
  import { ResizerBreakoutModeLabel } from '@atlaskit/editor-common/resizer';
17
17
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
18
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
18
19
  import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
19
20
  import { hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
20
21
  import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
@@ -677,9 +678,16 @@ var tablePlugin = function tablePlugin(_ref) {
677
678
  },
678
679
  usePluginHook: function usePluginHook(_ref24) {
679
680
  var editorView = _ref24.editorView;
680
- var _useSharedPluginState = useSharedPluginState(api, ['editorViewMode']),
681
+ var _useSharedPluginState = useSharedPluginState(api, ['editorViewMode'], {
682
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
683
+ }),
681
684
  editorViewModeState = _useSharedPluginState.editorViewModeState;
682
- var mode = editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
685
+
686
+ // mode
687
+ var modeSelector = useSharedPluginStateSelector(api, 'editorViewMode.mode', {
688
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
689
+ });
690
+ var mode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? modeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
683
691
  useEffect(function () {
684
692
  var state = editorView.state,
685
693
  dispatch = editorView.dispatch;
@@ -9,10 +9,12 @@ import { injectIntl } from 'react-intl-next';
9
9
  import { browser } from '@atlaskit/editor-common/browser';
10
10
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
11
11
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
12
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
12
13
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
13
14
  import { findTable, TableMap } from '@atlaskit/editor-tables';
14
15
  import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
15
16
  import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';
17
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
16
18
  import { getPluginState as getDnDPluginState } from '../../pm-plugins/drag-and-drop/plugin-factory';
17
19
  import { getPluginState } from '../../pm-plugins/plugin-factory';
18
20
  import { findDuplicatePosition, hasMergedCellsInSelection } from '../../pm-plugins/utils/merged-cells';
@@ -260,8 +262,22 @@ var DragHandleComponentWithSharedState = function DragHandleComponentWithSharedS
260
262
  editorView = _ref5.editorView,
261
263
  intl = _ref5.intl,
262
264
  api = _ref5.api;
263
- var _ref6 = useSharedPluginState(api, ['table']),
265
+ var _ref6 = useSharedPluginState(api, ['table'], {
266
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
267
+ }),
264
268
  tableState = _ref6.tableState;
269
+
270
+ // hoveredColumns
271
+ var hoveredColumnsSelector = useSharedPluginStateSelector(api, 'table.hoveredColumns', {
272
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
273
+ });
274
+ var hoveredColumns = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? hoveredColumnsSelector : tableState === null || tableState === void 0 ? void 0 : tableState.hoveredColumns;
275
+
276
+ // hoveredRows
277
+ var hoveredRowsSelector = useSharedPluginStateSelector(api, 'table.hoveredRows', {
278
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
279
+ });
280
+ var hoveredRows = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? hoveredRowsSelector : tableState === null || tableState === void 0 ? void 0 : tableState.hoveredRows;
265
281
  return /*#__PURE__*/React.createElement(DragHandleComponent, {
266
282
  isDragMenuTarget: isDragMenuTarget,
267
283
  tableLocalId: tableLocalId,
@@ -278,8 +294,8 @@ var DragHandleComponentWithSharedState = function DragHandleComponentWithSharedS
278
294
  onClick: onClick,
279
295
  editorView: editorView,
280
296
  intl: intl,
281
- hoveredColumns: tableState === null || tableState === void 0 ? void 0 : tableState.hoveredColumns,
282
- hoveredRows: tableState === null || tableState === void 0 ? void 0 : tableState.hoveredRows
297
+ hoveredColumns: hoveredColumns,
298
+ hoveredRows: hoveredRows
283
299
  });
284
300
  };
285
301
  export var DragHandle = injectIntl(DragHandleComponent);
@@ -5,14 +5,23 @@
5
5
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
6
6
  import { Global, jsx } from '@emotion/react';
7
7
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
8
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
9
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
10
  import { tableStyles } from './common-styles';
9
11
  export var GlobalStylesWrapper = function GlobalStylesWrapper(_ref) {
10
12
  var featureFlags = _ref.featureFlags,
11
13
  isDragAndDropEnabledOption = _ref.isDragAndDropEnabledOption,
12
14
  api = _ref.api;
13
- var _useSharedPluginState = useSharedPluginState(api, ['editorViewMode']),
15
+ // mode
16
+ var _useSharedPluginState = useSharedPluginState(api, ['editorViewMode'], {
17
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
18
+ }),
14
19
  editorViewModeState = _useSharedPluginState.editorViewModeState;
15
- var isLivePageViewMode = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
20
+ var modeSelector = useSharedPluginStateSelector(api, 'editorViewMode.mode', {
21
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
22
+ });
23
+ var mode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? modeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
24
+ var isLivePageViewMode = mode === 'view';
16
25
  return jsx(Global, {
17
26
  styles: tableStyles({
18
27
  featureFlags: featureFlags,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "10.9.5",
3
+ "version": "10.9.6",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -12,6 +12,7 @@ import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
12
12
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
13
13
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
14
14
  import type { EditorContainerWidth } from '@atlaskit/editor-common/types';
15
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
15
16
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
16
17
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
17
18
  import {
@@ -20,6 +21,7 @@ import {
20
21
  akEditorMobileBreakoutPoint,
21
22
  } from '@atlaskit/editor-shared-styles';
22
23
  import { fg } from '@atlaskit/platform-feature-flags';
24
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
23
25
 
24
26
  import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../pm-plugins/commands/commands-with-analytics';
25
27
  import { getPluginState } from '../pm-plugins/plugin-factory';
@@ -28,7 +30,7 @@ import {
28
30
  TABLE_OFFSET_IN_COMMENT_EDITOR,
29
31
  } from '../pm-plugins/table-resizing/utils/consts';
30
32
  import { ALIGN_CENTER, ALIGN_START } from '../pm-plugins/utils/alignment';
31
- import type { PluginInjectionAPI, TableSharedState } from '../types';
33
+ import type { PluginInjectionAPI } from '../types';
32
34
  import { TableCssClassName as ClassName } from '../types';
33
35
 
34
36
  import { getAlignmentStyle } from './table-container-styles';
@@ -77,11 +79,46 @@ const AlignmentTableContainer = ({
77
79
  editorView,
78
80
  }: PropsWithChildren<AlignmentTableContainerProps>) => {
79
81
  const alignment = node.attrs.layout !== ALIGN_START ? ALIGN_CENTER : ALIGN_START;
80
- const { tableState } = useSharedPluginState(pluginInjectionApi, ['table']);
82
+ const { tableState } = useSharedPluginState(pluginInjectionApi, ['table'], {
83
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
84
+ });
85
+
86
+ // isFullWidthModeEnabled
87
+ const isTableFullWidthModeEnabledSelector = useSharedPluginStateSelector(
88
+ pluginInjectionApi,
89
+ 'table.isFullWidthModeEnabled',
90
+ {
91
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
92
+ },
93
+ );
94
+ const isFullWidthModeEnabled = editorExperiment(
95
+ 'platform_editor_usesharedpluginstateselector',
96
+ true,
97
+ )
98
+ ? isTableFullWidthModeEnabledSelector
99
+ : tableState?.isFullWidthModeEnabled;
100
+
101
+ // wasFullWidthModeEnabled
102
+ const wasFullWidthModeEnabledSelector = useSharedPluginStateSelector(
103
+ pluginInjectionApi,
104
+ 'table.wasFullWidthModeEnabled',
105
+ {
106
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
107
+ },
108
+ );
109
+ const wasFullWidthModeEnabled = editorExperiment(
110
+ 'platform_editor_usesharedpluginstateselector',
111
+ true,
112
+ )
113
+ ? wasFullWidthModeEnabledSelector
114
+ : tableState?.wasFullWidthModeEnabled;
81
115
 
82
116
  useEffect(() => {
83
- if (tableState && editorView && getPos) {
84
- const { wasFullWidthModeEnabled, isFullWidthModeEnabled } = tableState;
117
+ if (editorExperiment('platform_editor_usesharedpluginstateselector', false) && !tableState) {
118
+ return;
119
+ }
120
+
121
+ if (editorView && getPos) {
85
122
  const { state, dispatch } = editorView;
86
123
 
87
124
  if (
@@ -109,7 +146,7 @@ const AlignmentTableContainer = ({
109
146
  }
110
147
  }
111
148
  // eslint-disable-next-line react-hooks/exhaustive-deps
112
- }, [editorView, tableState, node]);
149
+ }, [editorView, tableState, isFullWidthModeEnabled, wasFullWidthModeEnabled, node]);
113
150
 
114
151
  const style = useMemo(() => {
115
152
  return getAlignmentStyle(alignment);
@@ -202,8 +239,25 @@ export const ResizableTableContainer = React.memo(
202
239
  const containerRef = useRef<HTMLDivElement | null>(null);
203
240
  const tableWidthRef = useRef<number>(akEditorDefaultLayoutWidth);
204
241
  const [resizing, setIsResizing] = useState(false);
205
- const { tableState } = useSharedPluginState(pluginInjectionApi, ['table']);
206
- const { isFullWidthModeEnabled } = tableState as TableSharedState;
242
+
243
+ const { tableState } = useSharedPluginState(pluginInjectionApi, ['table'], {
244
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
245
+ });
246
+
247
+ // isFullWidthModeEnabled
248
+ const isFullWidthModeEnabledSelector = useSharedPluginStateSelector(
249
+ pluginInjectionApi,
250
+ 'table.isFullWidthModeEnabled',
251
+ {
252
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
253
+ },
254
+ );
255
+ const isFullWidthModeEnabled = editorExperiment(
256
+ 'platform_editor_usesharedpluginstateselector',
257
+ true,
258
+ )
259
+ ? isFullWidthModeEnabledSelector
260
+ : tableState?.isFullWidthModeEnabled;
207
261
 
208
262
  const updateContainerHeight = useCallback((height: number | 'auto') => {
209
263
  // current StickyHeader State is not stable to be fetch.
@@ -277,7 +331,17 @@ export const ResizableTableContainer = React.memo(
277
331
  );
278
332
 
279
333
  const tableWidth = getTableContainerWidth(node);
280
- const { editorViewModeState } = useSharedPluginState(pluginInjectionApi, ['editorViewMode']);
334
+ const { editorViewModeState } = useSharedPluginState(pluginInjectionApi, ['editorViewMode'], {
335
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
336
+ });
337
+
338
+ // mode
339
+ const modeSelector = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.mode', {
340
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
341
+ });
342
+ const mode = editorExperiment('platform_editor_usesharedpluginstateselector', true)
343
+ ? modeSelector
344
+ : editorViewModeState?.mode;
281
345
 
282
346
  let responsiveContainerWidth = 0;
283
347
  const resizeHandleSpacing = 12;
@@ -341,7 +405,10 @@ export const ResizableTableContainer = React.memo(
341
405
  isCommentEditor,
342
406
  };
343
407
 
344
- const isLivePageViewMode = editorViewModeState?.mode === 'view';
408
+ const isLivePageViewMode =
409
+ (editorExperiment('platform_editor_usesharedpluginstateselector', true)
410
+ ? mode
411
+ : editorViewModeState?.mode) === 'view';
345
412
 
346
413
  return (
347
414
  <AlignmentTableContainerWrapper
@@ -19,6 +19,7 @@ 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';
22
23
  import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
23
24
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
24
25
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
@@ -26,6 +27,7 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
26
27
  import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
27
28
  import { findTable } from '@atlaskit/editor-tables/utils';
28
29
  import { fg } from '@atlaskit/platform-feature-flags';
30
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
29
31
  import { token } from '@atlaskit/tokens';
30
32
 
31
33
  import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../pm-plugins/commands/commands-with-analytics';
@@ -211,8 +213,21 @@ export const TableResizer = ({
211
213
  const isResizing = useRef(false);
212
214
  const areResizeMetaKeysPressed = useRef(false);
213
215
  const resizerRef = useRef<ResizerNextHandler>(null);
214
- const { tableState } = useSharedPluginState(pluginInjectionApi, ['table']);
215
- const { widthToWidest } = tableState as TableSharedStateInternal;
216
+ const { tableState } = useSharedPluginState(pluginInjectionApi, ['table'], {
217
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
218
+ });
219
+
220
+ // widthToWidest
221
+ const widthToWidestSelector = useSharedPluginStateSelector(
222
+ pluginInjectionApi,
223
+ 'table.widthToWidest' as never,
224
+ {
225
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
226
+ },
227
+ ) as TableSharedStateInternal['widthToWidest'];
228
+ const widthToWidest = editorExperiment('platform_editor_usesharedpluginstateselector', true)
229
+ ? widthToWidestSelector
230
+ : (tableState as TableSharedStateInternal).widthToWidest;
216
231
 
217
232
  // used to reposition tooltip when table is resizing via keyboard
218
233
  const updateTooltip = React.useRef<() => void>();
@@ -254,9 +269,9 @@ export const TableResizer = ({
254
269
  const excludeGuidelineConfig = useMemo(
255
270
  () => ({
256
271
  innerGuidelines: !!isTableAlignmentEnabled,
257
- breakoutPoints: !!(isTableAlignmentEnabled && tableState?.isFullWidthModeEnabled),
272
+ breakoutPoints: !!(isTableAlignmentEnabled && isFullWidthModeEnabled),
258
273
  }),
259
- [tableState, isTableAlignmentEnabled],
274
+ [isFullWidthModeEnabled, isTableAlignmentEnabled],
260
275
  );
261
276
 
262
277
  const updateActiveGuidelines = useCallback(
@@ -31,6 +31,7 @@ import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
31
31
  import { ResizerBreakoutModeLabel } from '@atlaskit/editor-common/resizer';
32
32
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
33
33
  import type { Command, EditorPlugin, GetEditorContainerWidth } from '@atlaskit/editor-common/types';
34
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
34
35
  import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
35
36
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
36
37
  import { hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
@@ -873,8 +874,17 @@ const tablePlugin: TablePlugin = ({ config: options, api }) => {
873
874
  )(pluginConfig(options?.tableOptions)),
874
875
  },
875
876
  usePluginHook({ editorView }) {
876
- const { editorViewModeState } = useSharedPluginState(api, ['editorViewMode']);
877
- const mode = editorViewModeState?.mode;
877
+ const { editorViewModeState } = useSharedPluginState(api, ['editorViewMode'], {
878
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
879
+ });
880
+
881
+ // mode
882
+ const modeSelector = useSharedPluginStateSelector(api, 'editorViewMode.mode', {
883
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
884
+ });
885
+ const mode = editorExperiment('platform_editor_usesharedpluginstateselector', true)
886
+ ? modeSelector
887
+ : editorViewModeState?.mode;
878
888
 
879
889
  useEffect(() => {
880
890
  const { state, dispatch } = editorView;
@@ -11,11 +11,13 @@ 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';
14
15
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
15
16
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
16
17
  import { findTable, TableMap } from '@atlaskit/editor-tables';
17
18
  import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
18
19
  import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';
20
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
19
21
  import { token } from '@atlaskit/tokens';
20
22
 
21
23
  import { getPluginState as getDnDPluginState } from '../../pm-plugins/drag-and-drop/plugin-factory';
@@ -327,10 +329,32 @@ const DragHandleComponentWithSharedState = ({
327
329
  intl,
328
330
  api,
329
331
  }: DragHandleWithSharedStateProps & WrappedComponentProps) => {
330
- const { tableState } = useSharedPluginState(api, ['table']) as {
332
+ const { tableState } = useSharedPluginState(api, ['table'], {
333
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
334
+ }) as {
331
335
  tableState?: TableSharedStateInternal;
332
336
  };
333
337
 
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'];
346
+ const hoveredColumns = editorExperiment('platform_editor_usesharedpluginstateselector', true)
347
+ ? hoveredColumnsSelector
348
+ : tableState?.hoveredColumns;
349
+
350
+ // hoveredRows
351
+ const hoveredRowsSelector = useSharedPluginStateSelector(api, 'table.hoveredRows' as never, {
352
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
353
+ }) as TableSharedStateInternal['hoveredRows'];
354
+ const hoveredRows = editorExperiment('platform_editor_usesharedpluginstateselector', true)
355
+ ? hoveredRowsSelector
356
+ : tableState?.hoveredRows;
357
+
334
358
  return (
335
359
  <DragHandleComponent
336
360
  isDragMenuTarget={isDragMenuTarget}
@@ -348,8 +372,8 @@ const DragHandleComponentWithSharedState = ({
348
372
  onClick={onClick}
349
373
  editorView={editorView}
350
374
  intl={intl}
351
- hoveredColumns={tableState?.hoveredColumns}
352
- hoveredRows={tableState?.hoveredRows}
375
+ hoveredColumns={hoveredColumns}
376
+ hoveredRows={hoveredRows}
353
377
  />
354
378
  );
355
379
  };
@@ -7,6 +7,8 @@ import { Global, jsx } from '@emotion/react';
7
7
 
8
8
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
9
9
  import type { FeatureFlags } from '@atlaskit/editor-common/types';
10
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
11
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
10
12
 
11
13
  import type { PluginInjectionAPI } from '../types';
12
14
 
@@ -21,8 +23,18 @@ export const GlobalStylesWrapper = ({
21
23
  isDragAndDropEnabledOption?: boolean;
22
24
  api?: PluginInjectionAPI;
23
25
  }) => {
24
- const { editorViewModeState } = useSharedPluginState(api, ['editorViewMode']);
25
- const isLivePageViewMode = editorViewModeState?.mode === 'view';
26
+ // mode
27
+ const { editorViewModeState } = useSharedPluginState(api, ['editorViewMode'], {
28
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
29
+ });
30
+ const modeSelector = useSharedPluginStateSelector(api, 'editorViewMode.mode', {
31
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
32
+ });
33
+ const mode = editorExperiment('platform_editor_usesharedpluginstateselector', true)
34
+ ? modeSelector
35
+ : editorViewModeState?.mode;
36
+
37
+ const isLivePageViewMode = mode === 'view';
26
38
  return (
27
39
  <Global
28
40
  styles={tableStyles({