@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
@@ -4,8 +4,10 @@ import classNames from 'classnames';
4
4
  import { CHANGE_ALIGNMENT_REASON, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
5
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
6
6
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
7
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
7
8
  import { akEditorDefaultLayoutWidth, akEditorGutterPaddingDynamic, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
8
9
  import { fg } from '@atlaskit/platform-feature-flags';
10
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
9
11
  import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../pm-plugins/commands/commands-with-analytics';
10
12
  import { getPluginState } from '../pm-plugins/plugin-factory';
11
13
  import { TABLE_MAX_WIDTH, TABLE_OFFSET_IN_COMMENT_EDITOR } from '../pm-plugins/table-resizing/utils/consts';
@@ -42,13 +44,26 @@ const AlignmentTableContainer = ({
42
44
  const alignment = node.attrs.layout !== ALIGN_START ? ALIGN_CENTER : ALIGN_START;
43
45
  const {
44
46
  tableState
45
- } = useSharedPluginState(pluginInjectionApi, ['table']);
47
+ } = useSharedPluginState(pluginInjectionApi, ['table'], {
48
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
49
+ });
50
+
51
+ // isFullWidthModeEnabled
52
+ const isTableFullWidthModeEnabledSelector = useSharedPluginStateSelector(pluginInjectionApi, 'table.isFullWidthModeEnabled', {
53
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
54
+ });
55
+ const isFullWidthModeEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isTableFullWidthModeEnabledSelector : tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled;
56
+
57
+ // wasFullWidthModeEnabled
58
+ const wasFullWidthModeEnabledSelector = useSharedPluginStateSelector(pluginInjectionApi, 'table.wasFullWidthModeEnabled', {
59
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
60
+ });
61
+ const wasFullWidthModeEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? wasFullWidthModeEnabledSelector : tableState === null || tableState === void 0 ? void 0 : tableState.wasFullWidthModeEnabled;
46
62
  useEffect(() => {
47
- if (tableState && editorView && getPos) {
48
- const {
49
- wasFullWidthModeEnabled,
50
- isFullWidthModeEnabled
51
- } = tableState;
63
+ if (editorExperiment('platform_editor_usesharedpluginstateselector', false) && !tableState) {
64
+ return;
65
+ }
66
+ if (editorView && getPos) {
52
67
  const {
53
68
  state,
54
69
  dispatch
@@ -66,7 +81,7 @@ const AlignmentTableContainer = ({
66
81
  }
67
82
  }
68
83
  // eslint-disable-next-line react-hooks/exhaustive-deps
69
- }, [editorView, tableState, node]);
84
+ }, [editorView, tableState, isFullWidthModeEnabled, wasFullWidthModeEnabled, node]);
70
85
  const style = useMemo(() => {
71
86
  return getAlignmentStyle(alignment);
72
87
  }, [alignment]);
@@ -129,10 +144,15 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
129
144
  const [resizing, setIsResizing] = useState(false);
130
145
  const {
131
146
  tableState
132
- } = useSharedPluginState(pluginInjectionApi, ['table']);
133
- const {
134
- isFullWidthModeEnabled
135
- } = tableState;
147
+ } = useSharedPluginState(pluginInjectionApi, ['table'], {
148
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
149
+ });
150
+
151
+ // isFullWidthModeEnabled
152
+ const isFullWidthModeEnabledSelector = useSharedPluginStateSelector(pluginInjectionApi, 'table.isFullWidthModeEnabled', {
153
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
154
+ });
155
+ const isFullWidthModeEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isFullWidthModeEnabledSelector : tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled;
136
156
  const updateContainerHeight = useCallback(height => {
137
157
  var _containerRef$current;
138
158
  // current StickyHeader State is not stable to be fetch.
@@ -188,7 +208,15 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
188
208
  const tableWidth = getTableContainerWidth(node);
189
209
  const {
190
210
  editorViewModeState
191
- } = useSharedPluginState(pluginInjectionApi, ['editorViewMode']);
211
+ } = useSharedPluginState(pluginInjectionApi, ['editorViewMode'], {
212
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
213
+ });
214
+
215
+ // mode
216
+ const modeSelector = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.mode', {
217
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
218
+ });
219
+ const mode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? modeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
192
220
  let responsiveContainerWidth = 0;
193
221
  const resizeHandleSpacing = 12;
194
222
  // When Full width editor enabled, a Mac OS user can change "ak-editor-content-area" width by
@@ -239,7 +267,7 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
239
267
  onResizeStop,
240
268
  isCommentEditor
241
269
  };
242
- const isLivePageViewMode = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
270
+ const isLivePageViewMode = (editorExperiment('platform_editor_usesharedpluginstateselector', true) ? mode : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
243
271
  return /*#__PURE__*/React.createElement(AlignmentTableContainerWrapper, {
244
272
  isTableAlignmentEnabled: isTableAlignmentEnabled,
245
273
  node: node,
@@ -9,10 +9,12 @@ import { focusTableResizer, ToolTipContent } from '@atlaskit/editor-common/keyma
9
9
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
10
10
  import { logException } from '@atlaskit/editor-common/monitoring';
11
11
  import { ResizerNext } from '@atlaskit/editor-common/resizer';
12
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
12
13
  import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
13
14
  import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
14
15
  import { findTable } from '@atlaskit/editor-tables/utils';
15
16
  import { fg } from '@atlaskit/platform-feature-flags';
17
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
16
18
  import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../pm-plugins/commands/commands-with-analytics';
17
19
  import { updateWidthToWidest } from '../pm-plugins/commands/misc';
18
20
  import { META_KEYS } from '../pm-plugins/table-analytics';
@@ -124,10 +126,15 @@ export const TableResizer = ({
124
126
  const resizerRef = useRef(null);
125
127
  const {
126
128
  tableState
127
- } = useSharedPluginState(pluginInjectionApi, ['table']);
128
- const {
129
- widthToWidest
130
- } = tableState;
129
+ } = useSharedPluginState(pluginInjectionApi, ['table'], {
130
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
131
+ });
132
+
133
+ // widthToWidest
134
+ const widthToWidestSelector = useSharedPluginStateSelector(pluginInjectionApi, 'table.widthToWidest', {
135
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
136
+ });
137
+ const widthToWidest = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? widthToWidestSelector : tableState.widthToWidest;
131
138
 
132
139
  // used to reposition tooltip when table is resizing via keyboard
133
140
  const updateTooltip = React.useRef();
@@ -167,8 +174,8 @@ export const TableResizer = ({
167
174
  } = useMeasureFramerate();
168
175
  const excludeGuidelineConfig = useMemo(() => ({
169
176
  innerGuidelines: !!isTableAlignmentEnabled,
170
- breakoutPoints: !!(isTableAlignmentEnabled && tableState !== null && tableState !== void 0 && tableState.isFullWidthModeEnabled)
171
- }), [tableState, isTableAlignmentEnabled]);
177
+ breakoutPoints: !!(isTableAlignmentEnabled && isFullWidthModeEnabled)
178
+ }), [isFullWidthModeEnabled, isTableAlignmentEnabled]);
172
179
  const updateActiveGuidelines = useCallback(({
173
180
  gap,
174
181
  keys
@@ -12,6 +12,7 @@ import { getParentOfTypeCount, getPositionAfterTopParentNodeOfType } from '@atla
12
12
  import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
13
13
  import { ResizerBreakoutModeLabel } from '@atlaskit/editor-common/resizer';
14
14
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
15
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
15
16
  import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
16
17
  import { hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
17
18
  import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
@@ -681,8 +682,15 @@ const tablePlugin = ({
681
682
  }) {
682
683
  const {
683
684
  editorViewModeState
684
- } = useSharedPluginState(api, ['editorViewMode']);
685
- const mode = editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
685
+ } = useSharedPluginState(api, ['editorViewMode'], {
686
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
687
+ });
688
+
689
+ // mode
690
+ const modeSelector = useSharedPluginStateSelector(api, 'editorViewMode.mode', {
691
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
692
+ });
693
+ const mode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? modeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
686
694
  useEffect(() => {
687
695
  const {
688
696
  state,
@@ -7,10 +7,12 @@ import { injectIntl } from 'react-intl-next';
7
7
  import { browser } from '@atlaskit/editor-common/browser';
8
8
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
9
9
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
10
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
10
11
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
11
12
  import { findTable, TableMap } from '@atlaskit/editor-tables';
12
13
  import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
13
14
  import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';
15
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
14
16
  import { getPluginState as getDnDPluginState } from '../../pm-plugins/drag-and-drop/plugin-factory';
15
17
  import { getPluginState } from '../../pm-plugins/plugin-factory';
16
18
  import { findDuplicatePosition, hasMergedCellsInSelection } from '../../pm-plugins/utils/merged-cells';
@@ -268,7 +270,21 @@ const DragHandleComponentWithSharedState = ({
268
270
  }) => {
269
271
  const {
270
272
  tableState
271
- } = useSharedPluginState(api, ['table']);
273
+ } = useSharedPluginState(api, ['table'], {
274
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
275
+ });
276
+
277
+ // hoveredColumns
278
+ const hoveredColumnsSelector = useSharedPluginStateSelector(api, 'table.hoveredColumns', {
279
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
280
+ });
281
+ const hoveredColumns = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? hoveredColumnsSelector : tableState === null || tableState === void 0 ? void 0 : tableState.hoveredColumns;
282
+
283
+ // hoveredRows
284
+ const hoveredRowsSelector = useSharedPluginStateSelector(api, 'table.hoveredRows', {
285
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
286
+ });
287
+ const hoveredRows = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? hoveredRowsSelector : tableState === null || tableState === void 0 ? void 0 : tableState.hoveredRows;
272
288
  return /*#__PURE__*/React.createElement(DragHandleComponent, {
273
289
  isDragMenuTarget: isDragMenuTarget,
274
290
  tableLocalId: tableLocalId,
@@ -285,8 +301,8 @@ const DragHandleComponentWithSharedState = ({
285
301
  onClick: onClick,
286
302
  editorView: editorView,
287
303
  intl: intl,
288
- hoveredColumns: tableState === null || tableState === void 0 ? void 0 : tableState.hoveredColumns,
289
- hoveredRows: tableState === null || tableState === void 0 ? void 0 : tableState.hoveredRows
304
+ hoveredColumns: hoveredColumns,
305
+ hoveredRows: hoveredRows
290
306
  });
291
307
  };
292
308
  export const DragHandle = injectIntl(DragHandleComponent);
@@ -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';
@@ -42,9 +44,17 @@ export const ColumnControls = ({
42
44
  }) => {
43
45
  var _colWidths$map$join;
44
46
  const columnControlsRef = useRef(null);
47
+
48
+ // selection
45
49
  const {
46
50
  selectionState
47
- } = useSharedPluginState(api, ['selection']);
51
+ } = useSharedPluginState(api, ['selection'], {
52
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
53
+ });
54
+ const selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection', {
55
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
56
+ });
57
+ const selection = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectionsSelector : selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection;
48
58
  const widths = (_colWidths$map$join = colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(width =>
49
59
  // when there is sticky header, a `margin-right: -1px` applied to `tr.sticky th` so it causes colWidths to be 1px wider
50
60
  // we need to reduce the width by 1px to avoid misalignment of column controls.
@@ -52,7 +62,7 @@ export const ColumnControls = ({
52
62
  // TODO: ED-26961 - reusing getRowsParams here because it's generic enough to work for columns -> rename
53
63
  const columnParams = getRowsParams(colWidths !== null && colWidths !== void 0 ? colWidths : []);
54
64
  const colIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex;
55
- const selectedColIndexes = getSelectedColumns((selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection) || editorView.state.selection);
65
+ const selectedColIndexes = getSelectedColumns(selection || editorView.state.selection);
56
66
  const firstRow = tableRef.querySelector('tr');
57
67
  const hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
58
68
  const 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
  const DragCornerControlsComponent = ({
@@ -67,9 +69,16 @@ const DragCornerControlsComponentWithSelection = ({
67
69
  },
68
70
  api
69
71
  }) => {
72
+ // selection
70
73
  const {
71
74
  selectionState
72
- } = useSharedPluginState(api, ['selection']);
75
+ } = useSharedPluginState(api, ['selection'], {
76
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
77
+ });
78
+ const selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection', {
79
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
80
+ });
81
+ const selection = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectionsSelector : selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection;
73
82
  const handleOnClick = () => {
74
83
  const {
75
84
  state,
@@ -85,15 +94,15 @@ const DragCornerControlsComponentWithSelection = ({
85
94
  clearHoverSelection()(state, dispatch);
86
95
  };
87
96
  const isActive = useMemo(() => {
88
- if (!(selectionState !== null && selectionState !== void 0 && selectionState.selection)) {
97
+ if (!selection) {
89
98
  return;
90
99
  }
91
- const table = findTable(selectionState.selection);
100
+ const table = findTable(selection);
92
101
  if (!table) {
93
102
  return false;
94
103
  }
95
- return isTableSelected(selectionState.selection);
96
- }, [selectionState]);
104
+ return isTableSelected(selection);
105
+ }, [selection]);
97
106
  if (isResizing) {
98
107
  return null;
99
108
  }
@@ -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 const FloatingControlsWithSelection = ({
@@ -16,9 +18,16 @@ export const FloatingControlsWithSelection = ({
16
18
  tableActive,
17
19
  api
18
20
  }) => {
21
+ // selection
19
22
  const {
20
23
  selectionState
21
- } = useSharedPluginState(api, ['selection']);
24
+ } = useSharedPluginState(api, ['selection'], {
25
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
26
+ });
27
+ const selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection', {
28
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
29
+ });
30
+ const selection = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectionsSelector : selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection;
22
31
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CornerControls, {
23
32
  editorView: editorView,
24
33
  tableRef: tableRef,
@@ -29,7 +38,7 @@ export const FloatingControlsWithSelection = ({
29
38
  hoveredRows: hoveredRows,
30
39
  stickyTop: tableActive ? stickyTop : undefined
31
40
  }), /*#__PURE__*/React.createElement(RowControls, {
32
- selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection,
41
+ selection: selection,
33
42
  editorView: editorView,
34
43
  tableRef: tableRef,
35
44
  hoverRows: hoverRows,
@@ -133,7 +133,7 @@ export default class NumberColumn extends Component {
133
133
  onMouseOver: () => updateCellHoverLocation(index)
134
134
  }, hasHeaderRow ? index > 0 ? index : null : index + 1) :
135
135
  /*#__PURE__*/
136
- // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
136
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions, @atlassian/a11y/interactive-element-not-keyboard-focusable
137
137
  React.createElement("div", {
138
138
  // Ignored via go/ees005
139
139
  // eslint-disable-next-line react/no-array-index-key
@@ -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
  };
@@ -5,16 +5,25 @@
5
5
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
6
6
  import { Global, jsx } from '@emotion/react';
7
7
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
8
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
9
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
10
  import { tableStyles } from './common-styles';
9
11
  export const GlobalStylesWrapper = ({
10
12
  featureFlags,
11
13
  isDragAndDropEnabledOption,
12
14
  api
13
15
  }) => {
16
+ // mode
14
17
  const {
15
18
  editorViewModeState
16
- } = useSharedPluginState(api, ['editorViewMode']);
17
- const isLivePageViewMode = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
19
+ } = useSharedPluginState(api, ['editorViewMode'], {
20
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
21
+ });
22
+ const modeSelector = useSharedPluginStateSelector(api, 'editorViewMode.mode', {
23
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
24
+ });
25
+ const mode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? modeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
26
+ const isLivePageViewMode = mode === 'view';
18
27
  return jsx(Global, {
19
28
  styles: tableStyles({
20
29
  featureFlags,
@@ -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
@@ -5,8 +5,10 @@ import classNames from 'classnames';
5
5
  import { CHANGE_ALIGNMENT_REASON, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
6
6
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
7
7
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
8
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
8
9
  import { akEditorDefaultLayoutWidth, akEditorGutterPaddingDynamic, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
9
10
  import { fg } from '@atlaskit/platform-feature-flags';
11
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
10
12
  import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../pm-plugins/commands/commands-with-analytics';
11
13
  import { getPluginState } from '../pm-plugins/plugin-factory';
12
14
  import { TABLE_MAX_WIDTH, TABLE_OFFSET_IN_COMMENT_EDITOR } from '../pm-plugins/table-resizing/utils/consts';
@@ -39,12 +41,27 @@ var AlignmentTableContainer = function AlignmentTableContainer(_ref2) {
39
41
  getPos = _ref2.getPos,
40
42
  editorView = _ref2.editorView;
41
43
  var alignment = node.attrs.layout !== ALIGN_START ? ALIGN_CENTER : ALIGN_START;
42
- var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['table']),
44
+ var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['table'], {
45
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
46
+ }),
43
47
  tableState = _useSharedPluginState.tableState;
48
+
49
+ // isFullWidthModeEnabled
50
+ var isTableFullWidthModeEnabledSelector = useSharedPluginStateSelector(pluginInjectionApi, 'table.isFullWidthModeEnabled', {
51
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
52
+ });
53
+ var isFullWidthModeEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isTableFullWidthModeEnabledSelector : tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled;
54
+
55
+ // wasFullWidthModeEnabled
56
+ var wasFullWidthModeEnabledSelector = useSharedPluginStateSelector(pluginInjectionApi, 'table.wasFullWidthModeEnabled', {
57
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
58
+ });
59
+ var wasFullWidthModeEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? wasFullWidthModeEnabledSelector : tableState === null || tableState === void 0 ? void 0 : tableState.wasFullWidthModeEnabled;
44
60
  useEffect(function () {
45
- if (tableState && editorView && getPos) {
46
- var wasFullWidthModeEnabled = tableState.wasFullWidthModeEnabled,
47
- isFullWidthModeEnabled = tableState.isFullWidthModeEnabled;
61
+ if (editorExperiment('platform_editor_usesharedpluginstateselector', false) && !tableState) {
62
+ return;
63
+ }
64
+ if (editorView && getPos) {
48
65
  var state = editorView.state,
49
66
  dispatch = editorView.dispatch;
50
67
  if (wasFullWidthModeEnabled && isFullWidthModeEnabled !== undefined && !isFullWidthModeEnabled && alignment !== ALIGN_CENTER && node.attrs.width > akEditorDefaultLayoutWidth) {
@@ -60,7 +77,7 @@ var AlignmentTableContainer = function AlignmentTableContainer(_ref2) {
60
77
  }
61
78
  }
62
79
  // eslint-disable-next-line react-hooks/exhaustive-deps
63
- }, [editorView, tableState, node]);
80
+ }, [editorView, tableState, isFullWidthModeEnabled, wasFullWidthModeEnabled, node]);
64
81
  var style = useMemo(function () {
65
82
  return getAlignmentStyle(alignment);
66
83
  }, [alignment]);
@@ -122,10 +139,16 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref4) {
122
139
  _useState2 = _slicedToArray(_useState, 2),
123
140
  resizing = _useState2[0],
124
141
  setIsResizing = _useState2[1];
125
- var _useSharedPluginState2 = useSharedPluginState(pluginInjectionApi, ['table']),
142
+ var _useSharedPluginState2 = useSharedPluginState(pluginInjectionApi, ['table'], {
143
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
144
+ }),
126
145
  tableState = _useSharedPluginState2.tableState;
127
- var _ref5 = tableState,
128
- isFullWidthModeEnabled = _ref5.isFullWidthModeEnabled;
146
+
147
+ // isFullWidthModeEnabled
148
+ var isFullWidthModeEnabledSelector = useSharedPluginStateSelector(pluginInjectionApi, 'table.isFullWidthModeEnabled', {
149
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
150
+ });
151
+ var isFullWidthModeEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isFullWidthModeEnabledSelector : tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled;
129
152
  var updateContainerHeight = useCallback(function (height) {
130
153
  var _containerRef$current;
131
154
  // current StickyHeader State is not stable to be fetch.
@@ -179,8 +202,16 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref4) {
179
202
  return (_pluginInjectionApi$c = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.core) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$s = pluginInjectionApi.selection) === null || _pluginInjectionApi$s === void 0 ? void 0 : _pluginInjectionApi$s.commands.displayGapCursor(toggle))) !== null && _pluginInjectionApi$c !== void 0 ? _pluginInjectionApi$c : false;
180
203
  }, [pluginInjectionApi]);
181
204
  var tableWidth = getTableContainerWidth(node);
182
- var _useSharedPluginState3 = useSharedPluginState(pluginInjectionApi, ['editorViewMode']),
205
+ var _useSharedPluginState3 = useSharedPluginState(pluginInjectionApi, ['editorViewMode'], {
206
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
207
+ }),
183
208
  editorViewModeState = _useSharedPluginState3.editorViewModeState;
209
+
210
+ // mode
211
+ var modeSelector = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.mode', {
212
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
213
+ });
214
+ var mode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? modeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
184
215
  var responsiveContainerWidth = 0;
185
216
  var resizeHandleSpacing = 12;
186
217
  // When Full width editor enabled, a Mac OS user can change "ak-editor-content-area" width by
@@ -231,7 +262,7 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref4) {
231
262
  onResizeStop: onResizeStop,
232
263
  isCommentEditor: isCommentEditor
233
264
  };
234
- var isLivePageViewMode = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
265
+ var isLivePageViewMode = (editorExperiment('platform_editor_usesharedpluginstateselector', true) ? mode : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
235
266
  return /*#__PURE__*/React.createElement(AlignmentTableContainerWrapper, {
236
267
  isTableAlignmentEnabled: isTableAlignmentEnabled,
237
268
  node: node,
@@ -276,28 +307,28 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref4) {
276
307
  node: node
277
308
  }, children)) : null));
278
309
  });
279
- export var TableContainer = function TableContainer(_ref6) {
280
- var children = _ref6.children,
281
- node = _ref6.node,
282
- className = _ref6.className,
283
- _ref6$containerWidth = _ref6.containerWidth,
284
- editorWidth = _ref6$containerWidth.width,
285
- lineLength = _ref6$containerWidth.lineLength,
286
- editorView = _ref6.editorView,
287
- getPos = _ref6.getPos,
288
- tableRef = _ref6.tableRef,
289
- isNested = _ref6.isNested,
290
- tableWrapperHeight = _ref6.tableWrapperHeight,
291
- isResizing = _ref6.isResizing,
292
- pluginInjectionApi = _ref6.pluginInjectionApi,
293
- isWholeTableInDanger = _ref6.isWholeTableInDanger,
294
- isTableResizingEnabled = _ref6.isTableResizingEnabled,
295
- isTableScalingEnabled = _ref6.isTableScalingEnabled,
296
- isTableWithFixedColumnWidthsOptionEnabled = _ref6.isTableWithFixedColumnWidthsOptionEnabled,
297
- isTableAlignmentEnabled = _ref6.isTableAlignmentEnabled,
298
- shouldUseIncreasedScalingPercent = _ref6.shouldUseIncreasedScalingPercent,
299
- isCommentEditor = _ref6.isCommentEditor,
300
- isChromelessEditor = _ref6.isChromelessEditor;
310
+ export var TableContainer = function TableContainer(_ref5) {
311
+ var children = _ref5.children,
312
+ node = _ref5.node,
313
+ className = _ref5.className,
314
+ _ref5$containerWidth = _ref5.containerWidth,
315
+ editorWidth = _ref5$containerWidth.width,
316
+ lineLength = _ref5$containerWidth.lineLength,
317
+ editorView = _ref5.editorView,
318
+ getPos = _ref5.getPos,
319
+ tableRef = _ref5.tableRef,
320
+ isNested = _ref5.isNested,
321
+ tableWrapperHeight = _ref5.tableWrapperHeight,
322
+ isResizing = _ref5.isResizing,
323
+ pluginInjectionApi = _ref5.pluginInjectionApi,
324
+ isWholeTableInDanger = _ref5.isWholeTableInDanger,
325
+ isTableResizingEnabled = _ref5.isTableResizingEnabled,
326
+ isTableScalingEnabled = _ref5.isTableScalingEnabled,
327
+ isTableWithFixedColumnWidthsOptionEnabled = _ref5.isTableWithFixedColumnWidthsOptionEnabled,
328
+ isTableAlignmentEnabled = _ref5.isTableAlignmentEnabled,
329
+ shouldUseIncreasedScalingPercent = _ref5.shouldUseIncreasedScalingPercent,
330
+ isCommentEditor = _ref5.isCommentEditor,
331
+ isChromelessEditor = _ref5.isChromelessEditor;
301
332
  if (isTableResizingEnabled && !isNested) {
302
333
  return /*#__PURE__*/React.createElement(ResizableTableContainer
303
334
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766