@atlaskit/editor-plugin-table 10.9.4 → 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.
Files changed (46) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/nodeviews/TableContainer.js +63 -32
  3. package/dist/cjs/nodeviews/TableResizer.js +18 -10
  4. package/dist/cjs/tablePlugin.js +10 -2
  5. package/dist/cjs/ui/DragHandle/index.js +19 -3
  6. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +12 -2
  7. package/dist/cjs/ui/TableFloatingControls/CornerControls/DragCornerControls.js +14 -5
  8. package/dist/cjs/ui/TableFloatingControls/FloatingControlsWithSelection.js +11 -2
  9. package/dist/cjs/ui/TableFloatingControls/NumberColumn/index.js +1 -1
  10. package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +11 -2
  11. package/dist/cjs/ui/global-styles.js +11 -2
  12. package/dist/cjs/ui/icons/SortingIconWrapper.js +12 -2
  13. package/dist/es2019/nodeviews/TableContainer.js +41 -13
  14. package/dist/es2019/nodeviews/TableResizer.js +13 -6
  15. package/dist/es2019/tablePlugin.js +10 -2
  16. package/dist/es2019/ui/DragHandle/index.js +19 -3
  17. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +12 -2
  18. package/dist/es2019/ui/TableFloatingControls/CornerControls/DragCornerControls.js +14 -5
  19. package/dist/es2019/ui/TableFloatingControls/FloatingControlsWithSelection.js +11 -2
  20. package/dist/es2019/ui/TableFloatingControls/NumberColumn/index.js +1 -1
  21. package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +11 -2
  22. package/dist/es2019/ui/global-styles.js +11 -2
  23. package/dist/es2019/ui/icons/SortingIconWrapper.js +12 -2
  24. package/dist/esm/nodeviews/TableContainer.js +63 -32
  25. package/dist/esm/nodeviews/TableResizer.js +18 -10
  26. package/dist/esm/tablePlugin.js +10 -2
  27. package/dist/esm/ui/DragHandle/index.js +19 -3
  28. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +12 -2
  29. package/dist/esm/ui/TableFloatingControls/CornerControls/DragCornerControls.js +14 -5
  30. package/dist/esm/ui/TableFloatingControls/FloatingControlsWithSelection.js +11 -2
  31. package/dist/esm/ui/TableFloatingControls/NumberColumn/index.js +1 -1
  32. package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +11 -2
  33. package/dist/esm/ui/global-styles.js +11 -2
  34. package/dist/esm/ui/icons/SortingIconWrapper.js +12 -2
  35. package/package.json +1 -1
  36. package/src/nodeviews/TableContainer.tsx +76 -9
  37. package/src/nodeviews/TableResizer.tsx +19 -4
  38. package/src/tablePlugin.tsx +12 -2
  39. package/src/ui/DragHandle/index.tsx +27 -3
  40. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +15 -5
  41. package/src/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +16 -5
  42. package/src/ui/TableFloatingControls/FloatingControlsWithSelection.tsx +13 -2
  43. package/src/ui/TableFloatingControls/NumberColumn/index.tsx +4 -4
  44. package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +13 -2
  45. package/src/ui/global-styles.tsx +14 -2
  46. package/src/ui/icons/SortingIconWrapper.tsx +15 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
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
+
11
+ ## 10.9.5
12
+
13
+ ### Patch Changes
14
+
15
+ - [#145710](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/145710)
16
+ [`0cccd72c0228f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0cccd72c0228f) -
17
+ ED-27559 Enable useSharedPluginStateSelector in Table
18
+
3
19
  ## 10.9.4
4
20
 
5
21
  ### 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);
@@ -8,10 +8,12 @@ exports.ColumnControls = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _hooks = require("@atlaskit/editor-common/hooks");
10
10
  var _styles = require("@atlaskit/editor-common/styles");
11
+ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
11
12
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
12
13
  var _editorTables = require("@atlaskit/editor-tables");
13
14
  var _utils = require("@atlaskit/editor-tables/utils");
14
15
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
15
17
  var _commands = require("../../../pm-plugins/commands");
16
18
  var _commands2 = require("../../../pm-plugins/drag-and-drop/commands");
17
19
  var _rowControls = require("../../../pm-plugins/utils/row-controls");
@@ -50,8 +52,16 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
50
52
  getScrollOffset = _ref.getScrollOffset,
51
53
  api = _ref.api;
52
54
  var columnControlsRef = (0, _react.useRef)(null);
53
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['selection']),
55
+
56
+ // selection
57
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['selection'], {
58
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
59
+ }),
54
60
  selectionState = _useSharedPluginState.selectionState;
61
+ var selectionsSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selection.selection', {
62
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
63
+ });
64
+ var selection = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? selectionsSelector : selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection;
55
65
  var widths = (_colWidths$map$join = colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(function (width) {
56
66
  return (
57
67
  // when there is sticky header, a `margin-right: -1px` applied to `tr.sticky th` so it causes colWidths to be 1px wider
@@ -62,7 +72,7 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
62
72
  // TODO: ED-26961 - reusing getRowsParams here because it's generic enough to work for columns -> rename
63
73
  var columnParams = (0, _rowControls.getRowsParams)(colWidths !== null && colWidths !== void 0 ? colWidths : []);
64
74
  var colIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex;
65
- var selectedColIndexes = getSelectedColumns((selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection) || editorView.state.selection);
75
+ var selectedColIndexes = getSelectedColumns(selection || editorView.state.selection);
66
76
  var firstRow = tableRef.querySelector('tr');
67
77
  var hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
68
78
  var rowControlStickyTop = 45;
@@ -11,7 +11,9 @@ var _classnames = _interopRequireDefault(require("classnames"));
11
11
  var _reactIntlNext = require("react-intl-next");
12
12
  var _hooks = require("@atlaskit/editor-common/hooks");
13
13
  var _messages = require("@atlaskit/editor-common/messages");
14
+ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
14
15
  var _utils = require("@atlaskit/editor-tables/utils");
16
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
15
17
  var _commands = require("../../../pm-plugins/commands");
16
18
  var _types = require("../../../types");
17
19
  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); }
@@ -65,8 +67,15 @@ var DragCornerControlsComponentWithSelection = function DragCornerControlsCompon
65
67
  isResizing = _ref2.isResizing,
66
68
  formatMessage = _ref2.intl.formatMessage,
67
69
  api = _ref2.api;
68
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['selection']),
70
+ // selection
71
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['selection'], {
72
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
73
+ }),
69
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;
70
79
  var handleOnClick = function handleOnClick() {
71
80
  var state = editorView.state,
72
81
  dispatch = editorView.dispatch;
@@ -78,15 +87,15 @@ var DragCornerControlsComponentWithSelection = function DragCornerControlsCompon
78
87
  (0, _commands.clearHoverSelection)()(state, dispatch);
79
88
  };
80
89
  var isActive = (0, _react.useMemo)(function () {
81
- if (!(selectionState !== null && selectionState !== void 0 && selectionState.selection)) {
90
+ if (!selection) {
82
91
  return;
83
92
  }
84
- var table = (0, _utils.findTable)(selectionState.selection);
93
+ var table = (0, _utils.findTable)(selection);
85
94
  if (!table) {
86
95
  return false;
87
96
  }
88
- return (0, _utils.isTableSelected)(selectionState.selection);
89
- }, [selectionState]);
97
+ return (0, _utils.isTableSelected)(selection);
98
+ }, [selection]);
90
99
  if (isResizing) {
91
100
  return null;
92
101
  }
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.FloatingControlsWithSelection = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _hooks = require("@atlaskit/editor-common/hooks");
10
+ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
11
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
10
12
  var _ClassicCornerControls = require("./CornerControls/ClassicCornerControls");
11
13
  var _ClassicControls = require("./RowControls/ClassicControls");
12
14
  var FloatingControlsWithSelection = exports.FloatingControlsWithSelection = function FloatingControlsWithSelection(_ref) {
@@ -22,8 +24,15 @@ var FloatingControlsWithSelection = exports.FloatingControlsWithSelection = func
22
24
  selectRow = _ref.selectRow,
23
25
  tableActive = _ref.tableActive,
24
26
  api = _ref.api;
25
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['selection']),
27
+ // selection
28
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['selection'], {
29
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
30
+ }),
26
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;
27
36
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ClassicCornerControls.CornerControls, {
28
37
  editorView: editorView,
29
38
  tableRef: tableRef,
@@ -34,7 +43,7 @@ var FloatingControlsWithSelection = exports.FloatingControlsWithSelection = func
34
43
  hoveredRows: hoveredRows,
35
44
  stickyTop: tableActive ? stickyTop : undefined
36
45
  }), /*#__PURE__*/_react.default.createElement(_ClassicControls.RowControls, {
37
- selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection,
46
+ selection: selection,
38
47
  editorView: editorView,
39
48
  tableRef: tableRef,
40
49
  hoverRows: hoverRows,
@@ -148,7 +148,7 @@ var NumberColumn = exports.default = /*#__PURE__*/function (_Component) {
148
148
  }
149
149
  }, hasHeaderRow ? index > 0 ? index : null : index + 1) :
150
150
  /*#__PURE__*/
151
- // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
151
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions, @atlassian/a11y/interactive-element-not-keyboard-focusable
152
152
  _react.default.createElement("div", {
153
153
  // Ignored via go/ees005
154
154
  // eslint-disable-next-line react/no-array-index-key
@@ -9,10 +9,12 @@ exports.DragControlsWithSelection = exports.DragControls = void 0;
9
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
10
  var _react = _interopRequireWildcard(require("react"));
11
11
  var _hooks = require("@atlaskit/editor-common/hooks");
12
+ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
12
13
  var _editorTables = require("@atlaskit/editor-tables");
13
14
  var _utils = require("@atlaskit/editor-tables/utils");
14
15
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
15
16
  var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
17
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
16
18
  var _commands = require("../../../pm-plugins/commands");
17
19
  var _commands2 = require("../../../pm-plugins/drag-and-drop/commands");
18
20
  var _pluginFactory = require("../../../pm-plugins/plugin-factory");
@@ -302,8 +304,15 @@ var DragControlsWithSelection = exports.DragControlsWithSelection = function Dra
302
304
  selectRows = _ref5.selectRows,
303
305
  updateCellHoverLocation = _ref5.updateCellHoverLocation,
304
306
  api = _ref5.api;
305
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['selection']),
307
+ // selection
308
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['selection'], {
309
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
310
+ }),
306
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;
307
316
  return /*#__PURE__*/_react.default.createElement(DragControls, {
308
317
  editorView: editorView,
309
318
  tableRef: tableRef,
@@ -319,6 +328,6 @@ var DragControlsWithSelection = exports.DragControlsWithSelection = function Dra
319
328
  selectRows: selectRows,
320
329
  updateCellHoverLocation: updateCellHoverLocation,
321
330
  api: api,
322
- selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
331
+ selection: selection
323
332
  });
324
333
  };
@@ -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,
@@ -8,10 +8,20 @@ exports.SortingIconWrapper = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _hooks = require("@atlaskit/editor-common/hooks");
10
10
  var _table = require("@atlaskit/editor-common/table");
11
+ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
12
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
11
13
  var SortingIconWrapper = exports.SortingIconWrapper = function SortingIconWrapper(props) {
12
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(props.api, ['editorViewMode']),
14
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(props.api, ['editorViewMode'], {
15
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
16
+ }),
13
17
  editorViewModeState = _useSharedPluginState.editorViewModeState;
14
- if ((editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'edit') {
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;
24
+ if (mode === 'edit') {
15
25
  return null;
16
26
  }
17
27
  // Ignored via go/ees005