@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
@@ -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);
@@ -3,10 +3,12 @@
3
3
  import React, { useCallback, useMemo, useRef } from 'react';
4
4
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
5
5
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
6
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
6
7
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
7
8
  import { CellSelection } from '@atlaskit/editor-tables';
8
9
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
9
10
  import { fg } from '@atlaskit/platform-feature-flags';
11
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
10
12
  import { clearHoverSelection, hoverCell, hoverColumns, selectColumn, selectColumns } from '../../../pm-plugins/commands';
11
13
  import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
12
14
  import { getRowsParams } from '../../../pm-plugins/utils/row-controls';
@@ -41,8 +43,16 @@ export var ColumnControls = function ColumnControls(_ref) {
41
43
  getScrollOffset = _ref.getScrollOffset,
42
44
  api = _ref.api;
43
45
  var columnControlsRef = useRef(null);
44
- var _useSharedPluginState = useSharedPluginState(api, ['selection']),
46
+
47
+ // selection
48
+ var _useSharedPluginState = useSharedPluginState(api, ['selection'], {
49
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
50
+ }),
45
51
  selectionState = _useSharedPluginState.selectionState;
52
+ var selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection', {
53
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
54
+ });
55
+ var selection = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectionsSelector : selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection;
46
56
  var widths = (_colWidths$map$join = colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(function (width) {
47
57
  return (
48
58
  // when there is sticky header, a `margin-right: -1px` applied to `tr.sticky th` so it causes colWidths to be 1px wider
@@ -53,7 +63,7 @@ export var ColumnControls = function ColumnControls(_ref) {
53
63
  // TODO: ED-26961 - reusing getRowsParams here because it's generic enough to work for columns -> rename
54
64
  var columnParams = getRowsParams(colWidths !== null && colWidths !== void 0 ? colWidths : []);
55
65
  var colIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex;
56
- var selectedColIndexes = getSelectedColumns((selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection) || editorView.state.selection);
66
+ var selectedColIndexes = getSelectedColumns(selection || editorView.state.selection);
57
67
  var firstRow = tableRef.querySelector('tr');
58
68
  var hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
59
69
  var rowControlStickyTop = 45;
@@ -3,7 +3,9 @@ import classnames from 'classnames';
3
3
  import { injectIntl } from 'react-intl-next';
4
4
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
5
5
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
6
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
6
7
  import { findTable, isTableSelected, selectTable } from '@atlaskit/editor-tables/utils';
8
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
9
  import { clearHoverSelection } from '../../../pm-plugins/commands';
8
10
  import { TableCssClassName as ClassName } from '../../../types';
9
11
  var DragCornerControlsComponent = function DragCornerControlsComponent(_ref) {
@@ -55,8 +57,15 @@ var DragCornerControlsComponentWithSelection = function DragCornerControlsCompon
55
57
  isResizing = _ref2.isResizing,
56
58
  formatMessage = _ref2.intl.formatMessage,
57
59
  api = _ref2.api;
58
- var _useSharedPluginState = useSharedPluginState(api, ['selection']),
60
+ // selection
61
+ var _useSharedPluginState = useSharedPluginState(api, ['selection'], {
62
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
63
+ }),
59
64
  selectionState = _useSharedPluginState.selectionState;
65
+ var selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection', {
66
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
67
+ });
68
+ var selection = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectionsSelector : selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection;
60
69
  var handleOnClick = function handleOnClick() {
61
70
  var state = editorView.state,
62
71
  dispatch = editorView.dispatch;
@@ -68,15 +77,15 @@ var DragCornerControlsComponentWithSelection = function DragCornerControlsCompon
68
77
  clearHoverSelection()(state, dispatch);
69
78
  };
70
79
  var isActive = useMemo(function () {
71
- if (!(selectionState !== null && selectionState !== void 0 && selectionState.selection)) {
80
+ if (!selection) {
72
81
  return;
73
82
  }
74
- var table = findTable(selectionState.selection);
83
+ var table = findTable(selection);
75
84
  if (!table) {
76
85
  return false;
77
86
  }
78
- return isTableSelected(selectionState.selection);
79
- }, [selectionState]);
87
+ return isTableSelected(selection);
88
+ }, [selection]);
80
89
  if (isResizing) {
81
90
  return null;
82
91
  }
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
2
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
4
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
3
5
  import { CornerControls } from './CornerControls/ClassicCornerControls';
4
6
  import { RowControls } from './RowControls/ClassicControls';
5
7
  export var FloatingControlsWithSelection = function FloatingControlsWithSelection(_ref) {
@@ -15,8 +17,15 @@ export var FloatingControlsWithSelection = function FloatingControlsWithSelectio
15
17
  selectRow = _ref.selectRow,
16
18
  tableActive = _ref.tableActive,
17
19
  api = _ref.api;
18
- var _useSharedPluginState = useSharedPluginState(api, ['selection']),
20
+ // selection
21
+ var _useSharedPluginState = useSharedPluginState(api, ['selection'], {
22
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
23
+ }),
19
24
  selectionState = _useSharedPluginState.selectionState;
25
+ var selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection', {
26
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
27
+ });
28
+ var selection = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectionsSelector : selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection;
20
29
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CornerControls, {
21
30
  editorView: editorView,
22
31
  tableRef: tableRef,
@@ -27,7 +36,7 @@ export var FloatingControlsWithSelection = function FloatingControlsWithSelectio
27
36
  hoveredRows: hoveredRows,
28
37
  stickyTop: tableActive ? stickyTop : undefined
29
38
  }), /*#__PURE__*/React.createElement(RowControls, {
30
- selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection,
39
+ selection: selection,
31
40
  editorView: editorView,
32
41
  tableRef: tableRef,
33
42
  hoverRows: hoverRows,
@@ -138,7 +138,7 @@ var NumberColumn = /*#__PURE__*/function (_Component) {
138
138
  }
139
139
  }, hasHeaderRow ? index > 0 ? index : null : index + 1) :
140
140
  /*#__PURE__*/
141
- // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
141
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions, @atlassian/a11y/interactive-element-not-keyboard-focusable
142
142
  React.createElement("div", {
143
143
  // Ignored via go/ees005
144
144
  // eslint-disable-next-line react/no-array-index-key
@@ -3,10 +3,12 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
 
4
4
  import React, { Fragment, useCallback, useEffect, useMemo, useState } from 'react';
5
5
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
6
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
6
7
  import { CellSelection } from '@atlaskit/editor-tables';
7
8
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
8
9
  import { fg } from '@atlaskit/platform-feature-flags';
9
10
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
11
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
10
12
  import { clearHoverSelection } from '../../../pm-plugins/commands';
11
13
  import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
12
14
  import { getPluginState as getTablePluginState } from '../../../pm-plugins/plugin-factory';
@@ -292,8 +294,15 @@ export var DragControlsWithSelection = function DragControlsWithSelection(_ref5)
292
294
  selectRows = _ref5.selectRows,
293
295
  updateCellHoverLocation = _ref5.updateCellHoverLocation,
294
296
  api = _ref5.api;
295
- var _useSharedPluginState = useSharedPluginState(api, ['selection']),
297
+ // selection
298
+ var _useSharedPluginState = useSharedPluginState(api, ['selection'], {
299
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
300
+ }),
296
301
  selectionState = _useSharedPluginState.selectionState;
302
+ var selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection', {
303
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
304
+ });
305
+ var selection = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectionsSelector : selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection;
297
306
  return /*#__PURE__*/React.createElement(DragControls, {
298
307
  editorView: editorView,
299
308
  tableRef: tableRef,
@@ -309,6 +318,6 @@ export var DragControlsWithSelection = function DragControlsWithSelection(_ref5)
309
318
  selectRows: selectRows,
310
319
  updateCellHoverLocation: updateCellHoverLocation,
311
320
  api: api,
312
- selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
321
+ selection: selection
313
322
  });
314
323
  };
@@ -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,
@@ -1,10 +1,20 @@
1
1
  import React from 'react';
2
2
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
3
  import { SortingIcon } from '@atlaskit/editor-common/table';
4
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
5
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
6
  export var SortingIconWrapper = function SortingIconWrapper(props) {
5
- var _useSharedPluginState = useSharedPluginState(props.api, ['editorViewMode']),
7
+ var _useSharedPluginState = useSharedPluginState(props.api, ['editorViewMode'], {
8
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
9
+ }),
6
10
  editorViewModeState = _useSharedPluginState.editorViewModeState;
7
- if ((editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'edit') {
11
+
12
+ // mode
13
+ var modeSelector = useSharedPluginStateSelector(props.api, 'editorViewMode.mode', {
14
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
15
+ });
16
+ var mode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? modeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
17
+ if (mode === 'edit') {
8
18
  return null;
9
19
  }
10
20
  // Ignored via go/ees005
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "10.9.4",
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;