@atlaskit/editor-plugin-table 10.9.19 → 10.9.21

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 (54) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cjs/nodeviews/TableComponentWithSharedState.js +91 -78
  3. package/dist/cjs/nodeviews/TableContainer.js +41 -37
  4. package/dist/cjs/nodeviews/TableResizer.js +15 -11
  5. package/dist/cjs/tablePlugin.js +14 -10
  6. package/dist/cjs/ui/ContentComponent.js +21 -64
  7. package/dist/cjs/ui/DragHandle/index.js +19 -17
  8. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +14 -11
  9. package/dist/cjs/ui/TableFloatingControls/CornerControls/DragCornerControls.js +14 -10
  10. package/dist/cjs/ui/TableFloatingControls/FloatingControlsWithSelection.js +14 -10
  11. package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +14 -10
  12. package/dist/cjs/ui/global-styles.js +14 -10
  13. package/dist/cjs/ui/icons/SortingIconWrapper.js +14 -11
  14. package/dist/cjs/ui/toolbar.js +5 -0
  15. package/dist/es2019/nodeviews/TableComponentWithSharedState.js +92 -78
  16. package/dist/es2019/nodeviews/TableContainer.js +44 -39
  17. package/dist/es2019/nodeviews/TableResizer.js +17 -12
  18. package/dist/es2019/tablePlugin.js +16 -11
  19. package/dist/es2019/ui/ContentComponent.js +21 -64
  20. package/dist/es2019/ui/DragHandle/index.js +21 -18
  21. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +16 -12
  22. package/dist/es2019/ui/TableFloatingControls/CornerControls/DragCornerControls.js +16 -11
  23. package/dist/es2019/ui/TableFloatingControls/FloatingControlsWithSelection.js +16 -11
  24. package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +16 -11
  25. package/dist/es2019/ui/global-styles.js +16 -11
  26. package/dist/es2019/ui/icons/SortingIconWrapper.js +16 -12
  27. package/dist/es2019/ui/toolbar.js +5 -0
  28. package/dist/esm/nodeviews/TableComponentWithSharedState.js +92 -79
  29. package/dist/esm/nodeviews/TableContainer.js +42 -38
  30. package/dist/esm/nodeviews/TableResizer.js +16 -12
  31. package/dist/esm/tablePlugin.js +15 -11
  32. package/dist/esm/ui/ContentComponent.js +21 -64
  33. package/dist/esm/ui/DragHandle/index.js +20 -18
  34. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +15 -12
  35. package/dist/esm/ui/TableFloatingControls/CornerControls/DragCornerControls.js +15 -11
  36. package/dist/esm/ui/TableFloatingControls/FloatingControlsWithSelection.js +15 -11
  37. package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +15 -11
  38. package/dist/esm/ui/global-styles.js +15 -11
  39. package/dist/esm/ui/icons/SortingIconWrapper.js +15 -12
  40. package/dist/esm/ui/toolbar.js +5 -0
  41. package/package.json +8 -5
  42. package/src/nodeviews/TableComponentWithSharedState.tsx +97 -125
  43. package/src/nodeviews/TableContainer.tsx +59 -67
  44. package/src/nodeviews/TableResizer.tsx +21 -17
  45. package/src/tablePlugin.tsx +24 -13
  46. package/src/ui/ContentComponent.tsx +19 -64
  47. package/src/ui/DragHandle/index.tsx +24 -24
  48. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +21 -14
  49. package/src/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +20 -12
  50. package/src/ui/TableFloatingControls/FloatingControlsWithSelection.tsx +20 -13
  51. package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +20 -13
  52. package/src/ui/global-styles.tsx +20 -13
  53. package/src/ui/icons/SortingIconWrapper.tsx +20 -14
  54. package/src/ui/toolbar.tsx +7 -0
@@ -1,14 +1,13 @@
1
1
  /* eslint-disable @atlaskit/design-system/prefer-primitives */
2
2
 
3
3
  import React, { useCallback, useMemo, useRef } from 'react';
4
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
5
5
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
6
6
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
7
7
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
8
8
  import { CellSelection } from '@atlaskit/editor-tables';
9
9
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
10
10
  import { fg } from '@atlaskit/platform-feature-flags';
11
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
12
11
  import { clearHoverSelection, hoverCell, hoverColumns, selectColumn, selectColumns } from '../../../pm-plugins/commands';
13
12
  import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
14
13
  import { getRowsParams } from '../../../pm-plugins/utils/row-controls';
@@ -25,6 +24,18 @@ var getSelectedColumns = function getSelectedColumns(selection) {
25
24
  }
26
25
  return [];
27
26
  };
27
+ var useSharedState = sharedPluginStateHookMigratorFactory(function (api) {
28
+ var selection = useSharedPluginStateSelector(api, 'selection.selection');
29
+ return {
30
+ selection: selection
31
+ };
32
+ }, function (api) {
33
+ var _useSharedPluginState = useSharedPluginState(api, ['selection']),
34
+ selectionState = _useSharedPluginState.selectionState;
35
+ return {
36
+ selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
37
+ };
38
+ });
28
39
  export var ColumnControls = function ColumnControls(_ref) {
29
40
  var _colWidths$map$join;
30
41
  var editorView = _ref.editorView,
@@ -43,16 +54,8 @@ export var ColumnControls = function ColumnControls(_ref) {
43
54
  getScrollOffset = _ref.getScrollOffset,
44
55
  api = _ref.api;
45
56
  var columnControlsRef = useRef(null);
46
-
47
- // selection
48
- var _useSharedPluginState = useSharedPluginState(api, ['selection'], {
49
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
50
- }),
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;
57
+ var _useSharedState = useSharedState(api),
58
+ selection = _useSharedState.selection;
56
59
  var widths = (_colWidths$map$join = colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(function (width) {
57
60
  return (
58
61
  // when there is sticky header, a `margin-right: -1px` applied to `tr.sticky th` so it causes colWidths to be 1px wider
@@ -1,11 +1,10 @@
1
1
  import React, { useMemo } from 'react';
2
2
  import classnames from 'classnames';
3
3
  import { injectIntl } from 'react-intl-next';
4
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
5
5
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
6
6
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
7
7
  import { findTable, isTableSelected, selectTable } from '@atlaskit/editor-tables/utils';
8
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
9
8
  import { clearHoverSelection } from '../../../pm-plugins/commands';
10
9
  import { TableCssClassName as ClassName } from '../../../types';
11
10
  var DragCornerControlsComponent = function DragCornerControlsComponent(_ref) {
@@ -51,21 +50,26 @@ var DragCornerControlsComponent = function DragCornerControlsComponent(_ref) {
51
50
  className: ClassName.DRAG_CORNER_BUTTON_INNER
52
51
  }));
53
52
  };
53
+ var useSharedState = sharedPluginStateHookMigratorFactory(function (api) {
54
+ var selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection');
55
+ return {
56
+ selection: selectionsSelector
57
+ };
58
+ }, function (api) {
59
+ var _useSharedPluginState = useSharedPluginState(api, ['selection']),
60
+ selectionState = _useSharedPluginState.selectionState;
61
+ return {
62
+ selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
63
+ };
64
+ });
54
65
  var DragCornerControlsComponentWithSelection = function DragCornerControlsComponentWithSelection(_ref2) {
55
66
  var editorView = _ref2.editorView,
56
67
  isInDanger = _ref2.isInDanger,
57
68
  isResizing = _ref2.isResizing,
58
69
  formatMessage = _ref2.intl.formatMessage,
59
70
  api = _ref2.api;
60
- // selection
61
- var _useSharedPluginState = useSharedPluginState(api, ['selection'], {
62
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
63
- }),
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;
71
+ var _useSharedState = useSharedState(api),
72
+ selection = _useSharedState.selection;
69
73
  var handleOnClick = function handleOnClick() {
70
74
  var state = editorView.state,
71
75
  dispatch = editorView.dispatch;
@@ -1,9 +1,20 @@
1
1
  import React from 'react';
2
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
2
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
3
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
4
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
4
  import { CornerControls } from './CornerControls/ClassicCornerControls';
6
5
  import { RowControls } from './RowControls/ClassicControls';
6
+ var useSharedState = sharedPluginStateHookMigratorFactory(function (api) {
7
+ var selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection');
8
+ return {
9
+ selection: selectionsSelector
10
+ };
11
+ }, function (api) {
12
+ var _useSharedPluginState = useSharedPluginState(api, ['selection']),
13
+ selectionState = _useSharedPluginState.selectionState;
14
+ return {
15
+ selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
16
+ };
17
+ });
7
18
  export var FloatingControlsWithSelection = function FloatingControlsWithSelection(_ref) {
8
19
  var editorView = _ref.editorView,
9
20
  tableRef = _ref.tableRef,
@@ -17,15 +28,8 @@ export var FloatingControlsWithSelection = function FloatingControlsWithSelectio
17
28
  selectRow = _ref.selectRow,
18
29
  tableActive = _ref.tableActive,
19
30
  api = _ref.api;
20
- // selection
21
- var _useSharedPluginState = useSharedPluginState(api, ['selection'], {
22
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
23
- }),
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;
31
+ var _useSharedState = useSharedState(api),
32
+ selection = _useSharedState.selection;
29
33
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CornerControls, {
30
34
  editorView: editorView,
31
35
  tableRef: tableRef,
@@ -2,13 +2,12 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  /* eslint-disable @atlaskit/design-system/prefer-primitives */
3
3
 
4
4
  import React, { Fragment, useCallback, useEffect, useMemo, useState } from 'react';
5
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
5
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
6
6
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
7
7
  import { CellSelection } from '@atlaskit/editor-tables';
8
8
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
9
9
  import { fg } from '@atlaskit/platform-feature-flags';
10
10
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
11
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
12
11
  import { clearHoverSelection } from '../../../pm-plugins/commands';
13
12
  import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
14
13
  import { getPluginState as getTablePluginState } from '../../../pm-plugins/plugin-factory';
@@ -279,6 +278,18 @@ export var DragControls = function DragControls(_ref) {
279
278
  }), rowHandles())
280
279
  );
281
280
  };
281
+ var useSharedState = sharedPluginStateHookMigratorFactory(function (api) {
282
+ var selectionsSelector = useSharedPluginStateSelector(api, 'selection.selection');
283
+ return {
284
+ selection: selectionsSelector
285
+ };
286
+ }, function (api) {
287
+ var _useSharedPluginState = useSharedPluginState(api, ['selection']),
288
+ selectionState = _useSharedPluginState.selectionState;
289
+ return {
290
+ selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
291
+ };
292
+ });
282
293
  export var DragControlsWithSelection = function DragControlsWithSelection(_ref5) {
283
294
  var editorView = _ref5.editorView,
284
295
  tableRef = _ref5.tableRef,
@@ -294,15 +305,8 @@ export var DragControlsWithSelection = function DragControlsWithSelection(_ref5)
294
305
  selectRows = _ref5.selectRows,
295
306
  updateCellHoverLocation = _ref5.updateCellHoverLocation,
296
307
  api = _ref5.api;
297
- // selection
298
- var _useSharedPluginState = useSharedPluginState(api, ['selection'], {
299
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
300
- }),
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;
308
+ var _useSharedState = useSharedState(api),
309
+ selection = _useSharedState.selection;
306
310
  return /*#__PURE__*/React.createElement(DragControls, {
307
311
  editorView: editorView,
308
312
  tableRef: tableRef,
@@ -4,23 +4,27 @@
4
4
  */
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
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
7
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
8
8
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
9
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
10
9
  import { tableStyles } from './common-styles';
10
+ var useSharedState = sharedPluginStateHookMigratorFactory(function (api) {
11
+ var mode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
12
+ return {
13
+ mode: mode
14
+ };
15
+ }, function (api) {
16
+ var _useSharedPluginState = useSharedPluginState(api, ['editorViewMode']),
17
+ editorViewModeState = _useSharedPluginState.editorViewModeState;
18
+ return {
19
+ mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode
20
+ };
21
+ });
11
22
  export var GlobalStylesWrapper = function GlobalStylesWrapper(_ref) {
12
23
  var featureFlags = _ref.featureFlags,
13
24
  isDragAndDropEnabledOption = _ref.isDragAndDropEnabledOption,
14
25
  api = _ref.api;
15
- // mode
16
- var _useSharedPluginState = useSharedPluginState(api, ['editorViewMode'], {
17
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
18
- }),
19
- editorViewModeState = _useSharedPluginState.editorViewModeState;
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;
26
+ var _useSharedState = useSharedState(api),
27
+ mode = _useSharedState.mode;
24
28
  var isLivePageViewMode = mode === 'view';
25
29
  return jsx(Global, {
26
30
  styles: tableStyles({
@@ -1,19 +1,22 @@
1
1
  import React from 'react';
2
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
2
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
3
  import { SortingIcon } from '@atlaskit/editor-common/table';
4
4
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
5
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
6
- export var SortingIconWrapper = function SortingIconWrapper(props) {
7
- var _useSharedPluginState = useSharedPluginState(props.api, ['editorViewMode'], {
8
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
9
- }),
5
+ var useSharedState = sharedPluginStateHookMigratorFactory(function (api) {
6
+ var mode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
7
+ return {
8
+ mode: mode
9
+ };
10
+ }, function (api) {
11
+ var _useSharedPluginState = useSharedPluginState(api, ['editorViewMode']),
10
12
  editorViewModeState = _useSharedPluginState.editorViewModeState;
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;
13
+ return {
14
+ mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode
15
+ };
16
+ });
17
+ export var SortingIconWrapper = function SortingIconWrapper(props) {
18
+ var _useSharedState = useSharedState(props.api),
19
+ mode = _useSharedState.mode;
17
20
  if (mode === 'edit') {
18
21
  return null;
19
22
  }
@@ -487,6 +487,10 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
487
487
  };
488
488
  };
489
489
  var shouldGroupWithoutSeparators = editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_6');
490
+
491
+ // testId is required to show focus on trigger button on ESC key press
492
+ // see hideOnEsc in platform/packages/editor/editor-plugin-floating-toolbar/src/ui/Dropdown.tsx
493
+ var overflowDropdownTestId = fg('platform_editor_controls_patch_8') ? 'table-overflow-dropdown-trigger' : undefined;
490
494
  return {
491
495
  title: toolbarTitle,
492
496
  getDomRef: getDomRef,
@@ -507,6 +511,7 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
507
511
  fullHeight: true
508
512
  }, {
509
513
  type: 'overflow-dropdown',
514
+ testId: overflowDropdownTestId,
510
515
  dropdownWidth: 220,
511
516
  options: [{
512
517
  type: 'custom',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "10.9.19",
3
+ "version": "10.9.21",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -32,14 +32,14 @@
32
32
  "@atlaskit/adf-schema": "^47.6.0",
33
33
  "@atlaskit/button": "^23.0.0",
34
34
  "@atlaskit/custom-steps": "^0.11.0",
35
- "@atlaskit/editor-common": "^104.1.0",
35
+ "@atlaskit/editor-common": "^105.2.0",
36
36
  "@atlaskit/editor-palette": "^2.1.0",
37
37
  "@atlaskit/editor-plugin-accessibility-utils": "^2.0.0",
38
- "@atlaskit/editor-plugin-analytics": "^2.2.0",
38
+ "@atlaskit/editor-plugin-analytics": "^2.3.0",
39
39
  "@atlaskit/editor-plugin-batch-attribute-updates": "^2.1.0",
40
40
  "@atlaskit/editor-plugin-content-insertion": "^2.1.0",
41
41
  "@atlaskit/editor-plugin-editor-viewmode": "^3.1.0",
42
- "@atlaskit/editor-plugin-extension": "5.3.6",
42
+ "@atlaskit/editor-plugin-extension": "5.3.7",
43
43
  "@atlaskit/editor-plugin-guideline": "^2.0.0",
44
44
  "@atlaskit/editor-plugin-selection": "^2.2.0",
45
45
  "@atlaskit/editor-plugin-width": "^3.0.0",
@@ -54,7 +54,7 @@
54
54
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
55
55
  "@atlaskit/primitives": "^14.7.0",
56
56
  "@atlaskit/theme": "^18.0.0",
57
- "@atlaskit/tmp-editor-statsig": "^4.19.0",
57
+ "@atlaskit/tmp-editor-statsig": "^4.21.0",
58
58
  "@atlaskit/toggle": "^15.0.0",
59
59
  "@atlaskit/tokens": "^4.8.0",
60
60
  "@atlaskit/tooltip": "^20.0.0",
@@ -209,6 +209,9 @@
209
209
  },
210
210
  "platform_editor_r18_fix_selection_resync": {
211
211
  "type": "boolean"
212
+ },
213
+ "platform_editor_controls_patch_8": {
214
+ "type": "boolean"
212
215
  }
213
216
  }
214
217
  }
@@ -2,7 +2,10 @@ import React from 'react';
2
2
 
3
3
  import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
4
4
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
5
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
5
+ import {
6
+ sharedPluginStateHookMigratorFactory,
7
+ useSharedPluginState,
8
+ } from '@atlaskit/editor-common/hooks';
6
9
  import type { GetEditorFeatureFlags, getPosHandlerNode } from '@atlaskit/editor-common/types';
7
10
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
8
11
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
@@ -36,6 +39,80 @@ type TableComponentWithSharedStateProps = {
36
39
  allowTableResizing?: boolean;
37
40
  };
38
41
 
42
+ const useSharedState = sharedPluginStateHookMigratorFactory(
43
+ (api: PluginInjectionAPI | undefined) => {
44
+ // tableState
45
+ const isTableResizing = useInternalTablePluginStateSelector(api, 'isTableResizing');
46
+ const isHeaderColumnEnabled = useInternalTablePluginStateSelector(api, 'isHeaderColumnEnabled');
47
+ const isHeaderRowEnabled = useInternalTablePluginStateSelector(api, 'isHeaderRowEnabled');
48
+ const ordering = useInternalTablePluginStateSelector(api, 'ordering');
49
+ const isResizing = useInternalTablePluginStateSelector(api, 'isResizing');
50
+ const isInDanger = useInternalTablePluginStateSelector(api, 'isInDanger');
51
+ const hoveredCell = useInternalTablePluginStateSelector(api, 'hoveredCell');
52
+ const hoveredRows = useInternalTablePluginStateSelector(api, 'hoveredRows');
53
+ const isTableHovered = useInternalTablePluginStateSelector(api, 'isTableHovered');
54
+ const isWholeTableInDanger = useInternalTablePluginStateSelector(api, 'isWholeTableInDanger');
55
+
56
+ // mediaState
57
+ const isFullscreen = useSharedPluginStateSelector(api, 'media.isFullscreen');
58
+
59
+ // selectionState
60
+ const selection = useSharedPluginStateSelector(api, 'selection.selection');
61
+
62
+ // editorViewModeState
63
+ const mode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
64
+
65
+ // widthState
66
+ const width = useSharedPluginStateSelector(api, 'width.width');
67
+ const lineLength = useSharedPluginStateSelector(api, 'width.lineLength');
68
+
69
+ return {
70
+ tableState: undefined,
71
+ widthState: undefined,
72
+ isTableResizing,
73
+ isHeaderColumnEnabled,
74
+ isHeaderRowEnabled,
75
+ ordering,
76
+ isResizing,
77
+ isInDanger,
78
+ hoveredCell,
79
+ hoveredRows,
80
+ isTableHovered,
81
+ isWholeTableInDanger,
82
+ isFullscreen,
83
+ selection,
84
+ mode,
85
+ width,
86
+ lineLength,
87
+ };
88
+ },
89
+ (api: PluginInjectionAPI | undefined) => {
90
+ const { widthState, tableState, mediaState, selectionState, editorViewModeState } =
91
+ useSharedPluginState(api, ['width', 'table', 'media', 'selection', 'editorViewMode']);
92
+ const tableStateInternal = tableState as TableSharedStateInternal | undefined;
93
+
94
+ return {
95
+ tableState,
96
+ widthState,
97
+ isTableResizing: tableStateInternal?.isTableResizing,
98
+ isHeaderColumnEnabled: tableStateInternal?.isHeaderColumnEnabled,
99
+ isHeaderRowEnabled: tableStateInternal?.isHeaderRowEnabled,
100
+ ordering: tableStateInternal?.ordering,
101
+ isResizing: tableStateInternal?.isResizing,
102
+ isInDanger: tableStateInternal?.isInDanger,
103
+ hoveredCell: tableStateInternal?.hoveredCell,
104
+ hoveredRows: tableStateInternal?.hoveredRows,
105
+ isTableHovered: tableStateInternal?.isTableHovered,
106
+ isWholeTableInDanger: tableStateInternal?.isWholeTableInDanger,
107
+ isFullscreen: mediaState?.isFullscreen,
108
+ selection: selectionState?.selection,
109
+ mode: editorViewModeState?.mode,
110
+ width: widthState?.width,
111
+ lineLength: widthState?.lineLength,
112
+ };
113
+ },
114
+ );
115
+
39
116
  /**
40
117
  * Use useSharedPluginState to control re-renders from plugin dependencies
41
118
  */
@@ -54,136 +131,31 @@ export const TableComponentWithSharedState = ({
54
131
  allowTableAlignment,
55
132
  allowTableResizing,
56
133
  }: TableComponentWithSharedStateProps) => {
57
- const { widthState, tableState, mediaState, selectionState, editorViewModeState } =
58
- useSharedPluginState(api, ['width', 'table', 'media', 'selection', 'editorViewMode'], {
59
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true),
60
- });
61
-
62
- const isTableResizingSelector = useInternalTablePluginStateSelector(api, 'isTableResizing', {
63
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
64
- });
65
- const isHeaderColumnEnabledSelector = useInternalTablePluginStateSelector(
66
- api,
67
- 'isHeaderColumnEnabled',
68
- {
69
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
70
- },
71
- );
72
- const isHeaderRowEnabledSelector = useInternalTablePluginStateSelector(
73
- api,
74
- 'isHeaderRowEnabled',
75
- {
76
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
77
- },
78
- );
79
- const orderingSelector = useInternalTablePluginStateSelector(api, 'ordering', {
80
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
81
- });
82
- const isResizingSelector = useInternalTablePluginStateSelector(api, 'isResizing', {
83
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
84
- });
85
- const isInDangerSelector = useInternalTablePluginStateSelector(api, 'isInDanger', {
86
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
87
- });
88
- const hoveredCellSelector = useInternalTablePluginStateSelector(api, 'hoveredCell', {
89
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
90
- });
91
- const hoveredRowsSelector = useInternalTablePluginStateSelector(api, 'hoveredRows', {
92
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
93
- });
94
- const isTableHoveredSelector = useInternalTablePluginStateSelector(api, 'isTableHovered', {
95
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
96
- });
97
- const isWholeTableInDangerSelector = useInternalTablePluginStateSelector(
98
- api,
99
- 'isWholeTableInDanger',
100
- {
101
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
102
- },
103
- );
104
-
105
- // mediaState
106
- const isFullscreenSelector = useSharedPluginStateSelector(api, 'media.isFullscreen', {
107
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
108
- });
109
- const isFullscreen = editorExperiment('platform_editor_usesharedpluginstateselector', true)
110
- ? isFullscreenSelector
111
- : mediaState?.isFullscreen;
112
-
113
- // selectionState
114
- const selectionSelector = useSharedPluginStateSelector(api, 'selection.selection', {
115
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
116
- });
117
- const selection = editorExperiment('platform_editor_usesharedpluginstateselector', true)
118
- ? selectionSelector
119
- : selectionState?.selection;
120
-
121
- // editorViewModeState
122
- const editorViewModeSelector = useSharedPluginStateSelector(api, 'editorViewMode.mode', {
123
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
124
- });
125
- const mode = editorExperiment('platform_editor_usesharedpluginstateselector', true)
126
- ? editorViewModeSelector
127
- : editorViewModeState?.mode;
134
+ const {
135
+ tableState,
136
+ widthState,
137
+ mode,
138
+ hoveredCell,
139
+ hoveredRows,
140
+ isFullscreen,
141
+ isHeaderColumnEnabled,
142
+ isHeaderRowEnabled,
143
+ isInDanger,
144
+ isResizing,
145
+ isTableHovered,
146
+ isTableResizing,
147
+ isWholeTableInDanger,
148
+ lineLength,
149
+ ordering,
150
+ selection,
151
+ width,
152
+ } = useSharedState(api);
128
153
  const isLivePageViewMode = mode === 'view';
129
154
 
130
- // widthState
131
- const widthSelector = useSharedPluginStateSelector(api, 'width.width', {
132
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
133
- });
134
- const width = editorExperiment('platform_editor_usesharedpluginstateselector', true)
135
- ? widthSelector
136
- : widthState?.width;
137
-
138
- const lineLengthSelector = useSharedPluginStateSelector(api, 'width.lineLength', {
139
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false),
140
- });
141
- const lineLength = editorExperiment('platform_editor_usesharedpluginstateselector', true)
142
- ? lineLengthSelector
143
- : widthState?.lineLength;
144
-
145
155
  if (editorExperiment('platform_editor_usesharedpluginstateselector', false) && !tableState) {
146
156
  return null;
147
157
  }
148
158
 
149
- // tableState
150
- const isTableResizing = editorExperiment('platform_editor_usesharedpluginstateselector', true)
151
- ? isTableResizingSelector
152
- : (tableState as TableSharedStateInternal).isTableResizing;
153
- const isHeaderColumnEnabled = editorExperiment(
154
- 'platform_editor_usesharedpluginstateselector',
155
- true,
156
- )
157
- ? isHeaderColumnEnabledSelector
158
- : (tableState as TableSharedStateInternal).isHeaderColumnEnabled;
159
- const isHeaderRowEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true)
160
- ? isHeaderRowEnabledSelector
161
- : (tableState as TableSharedStateInternal).isHeaderRowEnabled;
162
- const ordering = editorExperiment('platform_editor_usesharedpluginstateselector', true)
163
- ? orderingSelector
164
- : (tableState as TableSharedStateInternal).ordering;
165
- const isResizing = editorExperiment('platform_editor_usesharedpluginstateselector', true)
166
- ? isResizingSelector
167
- : (tableState as TableSharedStateInternal).isResizing;
168
- const isInDanger = editorExperiment('platform_editor_usesharedpluginstateselector', true)
169
- ? isInDangerSelector
170
- : (tableState as TableSharedStateInternal).isInDanger;
171
- const hoveredCell = editorExperiment('platform_editor_usesharedpluginstateselector', true)
172
- ? hoveredCellSelector
173
- : (tableState as TableSharedStateInternal).hoveredCell;
174
- const hoveredRows = editorExperiment('platform_editor_usesharedpluginstateselector', true)
175
- ? hoveredRowsSelector
176
- : (tableState as TableSharedStateInternal).hoveredRows;
177
- const isTableHovered = editorExperiment('platform_editor_usesharedpluginstateselector', true)
178
- ? isTableHoveredSelector
179
- : (tableState as TableSharedStateInternal).isTableHovered;
180
- const isWholeTableInDanger = editorExperiment(
181
- 'platform_editor_usesharedpluginstateselector',
182
- true,
183
- )
184
- ? isWholeTableInDangerSelector
185
- : (tableState as TableSharedStateInternal).isWholeTableInDanger;
186
-
187
159
  /**
188
160
  * ED-19810
189
161
  * There is a getPos issue coming from this code. We need to apply this workaround for now and apply a patch