@atlaskit/editor-plugin-table 10.9.3 → 10.9.5

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 (30) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/nodeviews/TableComponentWithSharedState.js +72 -19
  3. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +12 -2
  4. package/dist/cjs/ui/TableFloatingControls/CornerControls/DragCornerControls.js +14 -5
  5. package/dist/cjs/ui/TableFloatingControls/FloatingControlsWithSelection.js +11 -2
  6. package/dist/cjs/ui/TableFloatingControls/NumberColumn/index.js +1 -1
  7. package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +11 -2
  8. package/dist/cjs/ui/icons/SortingIconWrapper.js +12 -2
  9. package/dist/es2019/nodeviews/TableComponentWithSharedState.js +72 -20
  10. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +12 -2
  11. package/dist/es2019/ui/TableFloatingControls/CornerControls/DragCornerControls.js +14 -5
  12. package/dist/es2019/ui/TableFloatingControls/FloatingControlsWithSelection.js +11 -2
  13. package/dist/es2019/ui/TableFloatingControls/NumberColumn/index.js +1 -1
  14. package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +11 -2
  15. package/dist/es2019/ui/icons/SortingIconWrapper.js +12 -2
  16. package/dist/esm/nodeviews/TableComponentWithSharedState.js +72 -19
  17. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +12 -2
  18. package/dist/esm/ui/TableFloatingControls/CornerControls/DragCornerControls.js +14 -5
  19. package/dist/esm/ui/TableFloatingControls/FloatingControlsWithSelection.js +11 -2
  20. package/dist/esm/ui/TableFloatingControls/NumberColumn/index.js +1 -1
  21. package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +11 -2
  22. package/dist/esm/ui/icons/SortingIconWrapper.js +12 -2
  23. package/package.json +1 -1
  24. package/src/nodeviews/TableComponentWithSharedState.tsx +127 -21
  25. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +15 -5
  26. package/src/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +16 -5
  27. package/src/ui/TableFloatingControls/FloatingControlsWithSelection.tsx +13 -2
  28. package/src/ui/TableFloatingControls/NumberColumn/index.tsx +4 -4
  29. package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +13 -2
  30. package/src/ui/icons/SortingIconWrapper.tsx +15 -2
@@ -2,10 +2,12 @@
2
2
 
3
3
  import React, { Fragment, useCallback, useEffect, useMemo, useState } from 'react';
4
4
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
5
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
5
6
  import { CellSelection } from '@atlaskit/editor-tables';
6
7
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
7
8
  import { fg } from '@atlaskit/platform-feature-flags';
8
9
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
10
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
9
11
  import { clearHoverSelection } from '../../../pm-plugins/commands';
10
12
  import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
11
13
  import { getPluginState as getTablePluginState } from '../../../pm-plugins/plugin-factory';
@@ -291,9 +293,16 @@ export const DragControlsWithSelection = ({
291
293
  updateCellHoverLocation,
292
294
  api
293
295
  }) => {
296
+ // selection
294
297
  const {
295
298
  selectionState
296
- } = useSharedPluginState(api, ['selection']);
299
+ } = useSharedPluginState(api, ['selection'], {
300
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
301
+ });
302
+ const selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection', {
303
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
304
+ });
305
+ const 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 const DragControlsWithSelection = ({
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
  };
@@ -1,11 +1,21 @@
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 const SortingIconWrapper = props => {
5
7
  const {
6
8
  editorViewModeState
7
- } = useSharedPluginState(props.api, ['editorViewMode']);
8
- if ((editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'edit') {
9
+ } = useSharedPluginState(props.api, ['editorViewMode'], {
10
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
11
+ });
12
+
13
+ // mode
14
+ const modeSelector = useSharedPluginStateSelector(props.api, 'editorViewMode.mode', {
15
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
16
+ });
17
+ const mode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? modeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
18
+ if (mode === 'edit') {
9
19
  return null;
10
20
  }
11
21
  // Ignored via go/ees005
@@ -1,11 +1,20 @@
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';
3
4
  import { findTable } from '@atlaskit/editor-tables';
5
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
6
  import TableComponent from './TableComponent';
5
7
 
6
8
  // Ignored via go/ees005
7
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
10
 
11
+ var useSharedTablePluginStateSelector = function useSharedTablePluginStateSelector(api, key) {
12
+ var value = useSharedPluginStateSelector(api, "table.".concat(key), {
13
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
14
+ });
15
+ return value;
16
+ };
17
+
9
18
  /**
10
19
  * Use useSharedPluginState to control re-renders from plugin dependencies
11
20
  */
@@ -23,27 +32,68 @@ export var TableComponentWithSharedState = function TableComponentWithSharedStat
23
32
  forwardRef = _ref.forwardRef,
24
33
  allowTableAlignment = _ref.allowTableAlignment,
25
34
  allowTableResizing = _ref.allowTableResizing;
26
- var _useSharedPluginState = useSharedPluginState(api, ['width', 'table', 'media', 'selection', 'editorViewMode']),
35
+ var _useSharedPluginState = useSharedPluginState(api, ['width', 'table', 'media', 'selection', 'editorViewMode'], {
36
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
37
+ }),
27
38
  widthState = _useSharedPluginState.widthState,
28
39
  tableState = _useSharedPluginState.tableState,
29
40
  mediaState = _useSharedPluginState.mediaState,
30
41
  selectionState = _useSharedPluginState.selectionState,
31
42
  editorViewModeState = _useSharedPluginState.editorViewModeState;
32
- var isLivePageViewMode = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
33
- if (!tableState) {
43
+ var isTableResizingSelector = useSharedTablePluginStateSelector(api, 'isTableResizing');
44
+ var isHeaderColumnEnabledSelector = useSharedTablePluginStateSelector(api, 'isHeaderColumnEnabled');
45
+ var isHeaderRowEnabledSelector = useSharedTablePluginStateSelector(api, 'isHeaderRowEnabled');
46
+ var orderingSelector = useSharedTablePluginStateSelector(api, 'ordering');
47
+ var isResizingSelector = useSharedTablePluginStateSelector(api, 'isResizing');
48
+ var isInDangerSelector = useSharedTablePluginStateSelector(api, 'isInDanger');
49
+ var hoveredCellSelector = useSharedTablePluginStateSelector(api, 'hoveredCell');
50
+ var hoveredRowsSelector = useSharedTablePluginStateSelector(api, 'hoveredRows');
51
+ var isTableHoveredSelector = useSharedTablePluginStateSelector(api, 'isTableHovered');
52
+ var isWholeTableInDangerSelector = useSharedTablePluginStateSelector(api, 'isWholeTableInDanger');
53
+
54
+ // mediaState
55
+ var isFullscreenSelector = useSharedPluginStateSelector(api, 'media.isFullscreen', {
56
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
57
+ });
58
+ var isFullscreen = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isFullscreenSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.isFullscreen;
59
+
60
+ // selectionState
61
+ var selectionSelector = useSharedPluginStateSelector(api, 'selection.selection', {
62
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
63
+ });
64
+ var selection = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectionSelector : selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection;
65
+
66
+ // editorViewModeState
67
+ var editorViewModeSelector = useSharedPluginStateSelector(api, 'editorViewMode.mode', {
68
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
69
+ });
70
+ var mode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? editorViewModeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
71
+ var isLivePageViewMode = mode === 'view';
72
+
73
+ // widthState
74
+ var widthSelector = useSharedPluginStateSelector(api, 'width.width', {
75
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
76
+ });
77
+ var width = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? widthSelector : widthState === null || widthState === void 0 ? void 0 : widthState.width;
78
+ var lineLengthSelector = useSharedPluginStateSelector(api, 'width.lineLength', {
79
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
80
+ });
81
+ var lineLength = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? lineLengthSelector : widthState === null || widthState === void 0 ? void 0 : widthState.lineLength;
82
+ if (editorExperiment('platform_editor_usesharedpluginstateselector', false) && !tableState) {
34
83
  return null;
35
84
  }
36
- var _ref2 = tableState,
37
- isTableResizing = _ref2.isTableResizing,
38
- isHeaderColumnEnabled = _ref2.isHeaderColumnEnabled,
39
- isHeaderRowEnabled = _ref2.isHeaderRowEnabled,
40
- ordering = _ref2.ordering,
41
- isResizing = _ref2.isResizing,
42
- isInDanger = _ref2.isInDanger,
43
- hoveredCell = _ref2.hoveredCell,
44
- hoveredRows = _ref2.hoveredRows,
45
- isTableHovered = _ref2.isTableHovered,
46
- isWholeTableInDanger = _ref2.isWholeTableInDanger;
85
+
86
+ // tableState
87
+ var isTableResizing = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isTableResizingSelector : tableState.isTableResizing;
88
+ var isHeaderColumnEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isHeaderColumnEnabledSelector : tableState.isHeaderColumnEnabled;
89
+ var isHeaderRowEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isHeaderRowEnabledSelector : tableState.isHeaderRowEnabled;
90
+ var ordering = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? orderingSelector : tableState.ordering;
91
+ var isResizing = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isResizingSelector : tableState.isResizing;
92
+ var isInDanger = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isInDangerSelector : tableState.isInDanger;
93
+ var hoveredCell = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? hoveredCellSelector : tableState.hoveredCell;
94
+ var hoveredRows = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? hoveredRowsSelector : tableState.hoveredRows;
95
+ var isTableHovered = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isTableHoveredSelector : tableState.isTableHovered;
96
+ var isWholeTableInDanger = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isWholeTableInDangerSelector : tableState.isWholeTableInDanger;
47
97
 
48
98
  /**
49
99
  * ED-19810
@@ -64,7 +114,7 @@ export var TableComponentWithSharedState = function TableComponentWithSharedStat
64
114
  allowColumnResizing: allowColumnResizing,
65
115
  eventDispatcher: eventDispatcher,
66
116
  getPos: getPos,
67
- isMediaFullscreen: mediaState === null || mediaState === void 0 ? void 0 : mediaState.isFullscreen,
117
+ isMediaFullscreen: isFullscreen,
68
118
  options: options,
69
119
  allowControls: allowControls,
70
120
  isHeaderRowEnabled: isHeaderRowEnabled,
@@ -76,11 +126,14 @@ export var TableComponentWithSharedState = function TableComponentWithSharedStat
76
126
  tableActive: tableActive && !isLivePageViewMode,
77
127
  ordering: ordering,
78
128
  isResizing: isResizing,
79
- getNode: getNode
129
+ getNode: getNode,
130
+ containerWidth: editorExperiment('platform_editor_usesharedpluginstateselector', true) ? {
131
+ width: width !== null && width !== void 0 ? width : 0,
132
+ lineLength: lineLength
133
+ } :
80
134
  // Ignored via go/ees005
81
135
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
82
- ,
83
- containerWidth: widthState,
136
+ widthState,
84
137
  contentDOM: forwardRef,
85
138
  getEditorFeatureFlags: getEditorFeatureFlags,
86
139
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
@@ -90,6 +143,6 @@ export var TableComponentWithSharedState = function TableComponentWithSharedStat
90
143
  hoveredCell: hoveredCell,
91
144
  isTableHovered: isTableHovered,
92
145
  isWholeTableInDanger: isWholeTableInDanger,
93
- selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
146
+ selection: selection
94
147
  });
95
148
  };
@@ -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
  };
@@ -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.3",
3
+ "version": "10.9.5",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -3,11 +3,18 @@ import React from 'react';
3
3
  import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
4
4
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
5
5
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
6
- import type { GetEditorFeatureFlags, getPosHandlerNode } from '@atlaskit/editor-common/types';
6
+ import type {
7
+ ExtractInjectionAPI,
8
+ GetEditorFeatureFlags,
9
+ getPosHandlerNode,
10
+ } from '@atlaskit/editor-common/types';
11
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
7
12
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
8
13
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
9
14
  import { findTable } from '@atlaskit/editor-tables';
15
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
10
16
 
17
+ import { TablePlugin } from '../tablePluginType';
11
18
  import type { PluginInjectionAPI, TableSharedStateInternal } from '../types';
12
19
 
13
20
  import TableComponent from './TableComponent';
@@ -33,6 +40,16 @@ type TableComponentWithSharedStateProps = {
33
40
  allowTableResizing?: boolean;
34
41
  };
35
42
 
43
+ const useSharedTablePluginStateSelector = <K extends keyof TableSharedStateInternal>(
44
+ api: ExtractInjectionAPI<TablePlugin> | undefined,
45
+ key: K,
46
+ ) => {
47
+ const value = useSharedPluginStateSelector(api, `table.${key}` as never, {
48
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
49
+ }) as TableSharedStateInternal[K];
50
+ return value;
51
+ };
52
+
36
53
  /**
37
54
  * Use useSharedPluginState to control re-renders from plugin dependencies
38
55
  */
@@ -52,26 +69,108 @@ export const TableComponentWithSharedState = ({
52
69
  allowTableResizing,
53
70
  }: TableComponentWithSharedStateProps) => {
54
71
  const { widthState, tableState, mediaState, selectionState, editorViewModeState } =
55
- useSharedPluginState(api, ['width', 'table', 'media', 'selection', 'editorViewMode']);
72
+ useSharedPluginState(api, ['width', 'table', 'media', 'selection', 'editorViewMode'], {
73
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
74
+ });
75
+
76
+ const isTableResizingSelector = useSharedTablePluginStateSelector(api, 'isTableResizing');
77
+ const isHeaderColumnEnabledSelector = useSharedTablePluginStateSelector(
78
+ api,
79
+ 'isHeaderColumnEnabled',
80
+ );
81
+ const isHeaderRowEnabledSelector = useSharedTablePluginStateSelector(api, 'isHeaderRowEnabled');
82
+ const orderingSelector = useSharedTablePluginStateSelector(api, 'ordering');
83
+ const isResizingSelector = useSharedTablePluginStateSelector(api, 'isResizing');
84
+ const isInDangerSelector = useSharedTablePluginStateSelector(api, 'isInDanger');
85
+ const hoveredCellSelector = useSharedTablePluginStateSelector(api, 'hoveredCell');
86
+ const hoveredRowsSelector = useSharedTablePluginStateSelector(api, 'hoveredRows');
87
+ const isTableHoveredSelector = useSharedTablePluginStateSelector(api, 'isTableHovered');
88
+ const isWholeTableInDangerSelector = useSharedTablePluginStateSelector(
89
+ api,
90
+ 'isWholeTableInDanger',
91
+ );
92
+
93
+ // mediaState
94
+ const isFullscreenSelector = useSharedPluginStateSelector(api, 'media.isFullscreen', {
95
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
96
+ });
97
+ const isFullscreen = editorExperiment('platform_editor_usesharedpluginstateselector', true)
98
+ ? isFullscreenSelector
99
+ : mediaState?.isFullscreen;
100
+
101
+ // selectionState
102
+ const selectionSelector = useSharedPluginStateSelector(api, 'selection.selection', {
103
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
104
+ });
105
+ const selection = editorExperiment('platform_editor_usesharedpluginstateselector', true)
106
+ ? selectionSelector
107
+ : selectionState?.selection;
108
+
109
+ // editorViewModeState
110
+ const editorViewModeSelector = useSharedPluginStateSelector(api, 'editorViewMode.mode', {
111
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
112
+ });
113
+ const mode = editorExperiment('platform_editor_usesharedpluginstateselector', true)
114
+ ? editorViewModeSelector
115
+ : editorViewModeState?.mode;
116
+ const isLivePageViewMode = mode === 'view';
117
+
118
+ // widthState
119
+ const widthSelector = useSharedPluginStateSelector(api, 'width.width', {
120
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
121
+ });
122
+ const width = editorExperiment('platform_editor_usesharedpluginstateselector', true)
123
+ ? widthSelector
124
+ : widthState?.width;
56
125
 
57
- const isLivePageViewMode = editorViewModeState?.mode === 'view';
126
+ const lineLengthSelector = useSharedPluginStateSelector(api, 'width.lineLength', {
127
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
128
+ });
129
+ const lineLength = editorExperiment('platform_editor_usesharedpluginstateselector', true)
130
+ ? lineLengthSelector
131
+ : widthState?.lineLength;
58
132
 
59
- if (!tableState) {
133
+ if (editorExperiment('platform_editor_usesharedpluginstateselector', false) && !tableState) {
60
134
  return null;
61
135
  }
62
136
 
63
- const {
64
- isTableResizing,
65
- isHeaderColumnEnabled,
66
- isHeaderRowEnabled,
67
- ordering,
68
- isResizing,
69
- isInDanger,
70
- hoveredCell,
71
- hoveredRows,
72
- isTableHovered,
73
- isWholeTableInDanger,
74
- } = tableState as TableSharedStateInternal;
137
+ // tableState
138
+ const isTableResizing = editorExperiment('platform_editor_usesharedpluginstateselector', true)
139
+ ? isTableResizingSelector
140
+ : (tableState as TableSharedStateInternal).isTableResizing;
141
+ const isHeaderColumnEnabled = editorExperiment(
142
+ 'platform_editor_usesharedpluginstateselector',
143
+ true,
144
+ )
145
+ ? isHeaderColumnEnabledSelector
146
+ : (tableState as TableSharedStateInternal).isHeaderColumnEnabled;
147
+ const isHeaderRowEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true)
148
+ ? isHeaderRowEnabledSelector
149
+ : (tableState as TableSharedStateInternal).isHeaderRowEnabled;
150
+ const ordering = editorExperiment('platform_editor_usesharedpluginstateselector', true)
151
+ ? orderingSelector
152
+ : (tableState as TableSharedStateInternal).ordering;
153
+ const isResizing = editorExperiment('platform_editor_usesharedpluginstateselector', true)
154
+ ? isResizingSelector
155
+ : (tableState as TableSharedStateInternal).isResizing;
156
+ const isInDanger = editorExperiment('platform_editor_usesharedpluginstateselector', true)
157
+ ? isInDangerSelector
158
+ : (tableState as TableSharedStateInternal).isInDanger;
159
+ const hoveredCell = editorExperiment('platform_editor_usesharedpluginstateselector', true)
160
+ ? hoveredCellSelector
161
+ : (tableState as TableSharedStateInternal).hoveredCell;
162
+ const hoveredRows = editorExperiment('platform_editor_usesharedpluginstateselector', true)
163
+ ? hoveredRowsSelector
164
+ : (tableState as TableSharedStateInternal).hoveredRows;
165
+ const isTableHovered = editorExperiment('platform_editor_usesharedpluginstateselector', true)
166
+ ? isTableHoveredSelector
167
+ : (tableState as TableSharedStateInternal).isTableHovered;
168
+ const isWholeTableInDanger = editorExperiment(
169
+ 'platform_editor_usesharedpluginstateselector',
170
+ true,
171
+ )
172
+ ? isWholeTableInDangerSelector
173
+ : (tableState as TableSharedStateInternal).isWholeTableInDanger;
75
174
 
76
175
  /**
77
176
  * ED-19810
@@ -101,7 +200,7 @@ export const TableComponentWithSharedState = ({
101
200
  allowColumnResizing={allowColumnResizing}
102
201
  eventDispatcher={eventDispatcher}
103
202
  getPos={getPos}
104
- isMediaFullscreen={mediaState?.isFullscreen}
203
+ isMediaFullscreen={isFullscreen}
105
204
  options={options}
106
205
  allowControls={allowControls}
107
206
  isHeaderRowEnabled={isHeaderRowEnabled}
@@ -114,9 +213,16 @@ export const TableComponentWithSharedState = ({
114
213
  ordering={ordering}
115
214
  isResizing={isResizing}
116
215
  getNode={getNode}
117
- // Ignored via go/ees005
118
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
119
- containerWidth={widthState!}
216
+ containerWidth={
217
+ editorExperiment('platform_editor_usesharedpluginstateselector', true)
218
+ ? {
219
+ width: width ?? 0,
220
+ lineLength,
221
+ }
222
+ : // Ignored via go/ees005
223
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
224
+ widthState!
225
+ }
120
226
  contentDOM={forwardRef}
121
227
  getEditorFeatureFlags={getEditorFeatureFlags}
122
228
  dispatchAnalyticsEvent={dispatchAnalyticsEvent}
@@ -126,7 +232,7 @@ export const TableComponentWithSharedState = ({
126
232
  hoveredCell={hoveredCell}
127
233
  isTableHovered={isTableHovered}
128
234
  isWholeTableInDanger={isWholeTableInDanger}
129
- selection={selectionState?.selection}
235
+ selection={selection}
130
236
  />
131
237
  );
132
238
  };