@atlaskit/editor-plugin-table 7.6.2 → 7.6.4

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 (119) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/commands/misc.js +3 -2
  3. package/dist/cjs/nodeviews/TableComponent.js +25 -11
  4. package/dist/cjs/nodeviews/TableComponentWithSharedState.js +87 -0
  5. package/dist/cjs/nodeviews/TableContainer.js +37 -21
  6. package/dist/cjs/nodeviews/TableResizer.js +40 -29
  7. package/dist/cjs/nodeviews/table.js +21 -1
  8. package/dist/cjs/plugin.js +25 -2
  9. package/dist/cjs/toolbar.js +5 -4
  10. package/dist/cjs/types.js +3 -0
  11. package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +16 -16
  12. package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +3 -3
  13. package/dist/cjs/ui/FloatingDragMenu/DropdownMenu.js +21 -28
  14. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +6 -2
  15. package/dist/cjs/ui/TableFloatingColumnControls/index.js +5 -2
  16. package/dist/cjs/ui/TableFloatingControls/CornerControls/DragCornerControls.js +48 -1
  17. package/dist/cjs/ui/TableFloatingControls/CornerControls/index.js +6 -0
  18. package/dist/cjs/ui/TableFloatingControls/FloatingControlsWithSelection.js +47 -0
  19. package/dist/cjs/ui/TableFloatingControls/RowControls/ClassicControls.js +3 -2
  20. package/dist/cjs/ui/TableFloatingControls/index.js +25 -3
  21. package/dist/cjs/ui/common-styles.js +11 -6
  22. package/dist/cjs/utils/guidelines.js +1 -1
  23. package/dist/es2019/commands/misc.js +6 -2
  24. package/dist/es2019/nodeviews/TableComponent.js +27 -12
  25. package/dist/es2019/nodeviews/TableComponentWithSharedState.js +83 -0
  26. package/dist/es2019/nodeviews/TableContainer.js +24 -6
  27. package/dist/es2019/nodeviews/TableResizer.js +27 -19
  28. package/dist/es2019/nodeviews/table.js +21 -1
  29. package/dist/es2019/plugin.js +26 -3
  30. package/dist/es2019/toolbar.js +5 -4
  31. package/dist/es2019/types.js +3 -0
  32. package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +16 -16
  33. package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +3 -3
  34. package/dist/es2019/ui/FloatingDragMenu/DropdownMenu.js +20 -27
  35. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +7 -2
  36. package/dist/es2019/ui/TableFloatingColumnControls/index.js +5 -2
  37. package/dist/es2019/ui/TableFloatingControls/CornerControls/DragCornerControls.js +55 -0
  38. package/dist/es2019/ui/TableFloatingControls/CornerControls/index.js +1 -1
  39. package/dist/es2019/ui/TableFloatingControls/FloatingControlsWithSelection.js +42 -0
  40. package/dist/es2019/ui/TableFloatingControls/RowControls/ClassicControls.js +3 -2
  41. package/dist/es2019/ui/TableFloatingControls/index.js +26 -4
  42. package/dist/es2019/ui/common-styles.js +589 -588
  43. package/dist/es2019/utils/guidelines.js +1 -1
  44. package/dist/esm/commands/misc.js +3 -2
  45. package/dist/esm/nodeviews/TableComponent.js +25 -11
  46. package/dist/esm/nodeviews/TableComponentWithSharedState.js +80 -0
  47. package/dist/esm/nodeviews/TableContainer.js +37 -21
  48. package/dist/esm/nodeviews/TableResizer.js +41 -30
  49. package/dist/esm/nodeviews/table.js +21 -1
  50. package/dist/esm/plugin.js +26 -3
  51. package/dist/esm/toolbar.js +5 -4
  52. package/dist/esm/types.js +3 -0
  53. package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +16 -16
  54. package/dist/esm/ui/FloatingDragMenu/DragMenu.js +3 -3
  55. package/dist/esm/ui/FloatingDragMenu/DropdownMenu.js +21 -28
  56. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +6 -2
  57. package/dist/esm/ui/TableFloatingColumnControls/index.js +5 -2
  58. package/dist/esm/ui/TableFloatingControls/CornerControls/DragCornerControls.js +47 -0
  59. package/dist/esm/ui/TableFloatingControls/CornerControls/index.js +1 -1
  60. package/dist/esm/ui/TableFloatingControls/FloatingControlsWithSelection.js +40 -0
  61. package/dist/esm/ui/TableFloatingControls/RowControls/ClassicControls.js +3 -2
  62. package/dist/esm/ui/TableFloatingControls/index.js +26 -4
  63. package/dist/esm/ui/common-styles.js +10 -5
  64. package/dist/esm/utils/guidelines.js +1 -1
  65. package/dist/types/commands/misc.d.ts +2 -1
  66. package/dist/types/nodeviews/TableComponent.d.ts +7 -2
  67. package/dist/types/nodeviews/TableComponentWithSharedState.d.ts +27 -0
  68. package/dist/types/nodeviews/TableContainer.d.ts +4 -2
  69. package/dist/types/nodeviews/TableResizer.d.ts +4 -1
  70. package/dist/types/nodeviews/types.d.ts +1 -0
  71. package/dist/types/plugin.d.ts +11 -7
  72. package/dist/types/types.d.ts +13 -4
  73. package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +113 -1
  74. package/dist/types/ui/TableFloatingColumnControls/index.d.ts +3 -2
  75. package/dist/types/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +223 -0
  76. package/dist/types/ui/TableFloatingControls/CornerControls/index.d.ts +1 -1
  77. package/dist/types/ui/TableFloatingControls/FloatingControlsWithSelection.d.ts +20 -0
  78. package/dist/types/ui/TableFloatingControls/RowControls/ClassicControls.d.ts +2 -0
  79. package/dist/types/ui/TableFloatingControls/index.d.ts +113 -1
  80. package/dist/types/ui/common-styles.d.ts +3 -0
  81. package/dist/types-ts4.5/commands/misc.d.ts +2 -1
  82. package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +7 -2
  83. package/dist/types-ts4.5/nodeviews/TableComponentWithSharedState.d.ts +27 -0
  84. package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +4 -2
  85. package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +4 -1
  86. package/dist/types-ts4.5/nodeviews/types.d.ts +1 -0
  87. package/dist/types-ts4.5/plugin.d.ts +11 -7
  88. package/dist/types-ts4.5/types.d.ts +13 -4
  89. package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +144 -1
  90. package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +3 -2
  91. package/dist/types-ts4.5/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +285 -0
  92. package/dist/types-ts4.5/ui/TableFloatingControls/CornerControls/index.d.ts +1 -1
  93. package/dist/types-ts4.5/ui/TableFloatingControls/FloatingControlsWithSelection.d.ts +20 -0
  94. package/dist/types-ts4.5/ui/TableFloatingControls/RowControls/ClassicControls.d.ts +2 -0
  95. package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +144 -1
  96. package/dist/types-ts4.5/ui/common-styles.d.ts +3 -0
  97. package/package.json +6 -6
  98. package/src/commands/misc.ts +6 -3
  99. package/src/nodeviews/TableComponent.tsx +36 -7
  100. package/src/nodeviews/TableComponentWithSharedState.tsx +125 -0
  101. package/src/nodeviews/TableContainer.tsx +24 -3
  102. package/src/nodeviews/TableResizer.tsx +36 -21
  103. package/src/nodeviews/table.tsx +22 -1
  104. package/src/nodeviews/types.ts +1 -0
  105. package/src/plugin.tsx +47 -6
  106. package/src/toolbar.tsx +20 -19
  107. package/src/types.ts +33 -4
  108. package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +66 -112
  109. package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -12
  110. package/src/ui/FloatingDragMenu/DropdownMenu.tsx +19 -28
  111. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +10 -2
  112. package/src/ui/TableFloatingColumnControls/index.tsx +13 -1
  113. package/src/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +58 -0
  114. package/src/ui/TableFloatingControls/CornerControls/index.tsx +4 -1
  115. package/src/ui/TableFloatingControls/FloatingControlsWithSelection.tsx +68 -0
  116. package/src/ui/TableFloatingControls/RowControls/ClassicControls.tsx +4 -1
  117. package/src/ui/TableFloatingControls/index.tsx +42 -8
  118. package/src/ui/common-styles.ts +611 -610
  119. package/src/utils/guidelines.ts +5 -4
@@ -4,4 +4,4 @@ import { calculateDefaultSnappings, calculateDefaultTablePreserveSnappings } fro
4
4
  // NOTE: We have to take 1 pixel off every length due to the fact that the tbody is 1px smaller then the table container.
5
5
  // If we don't do this then the guidelines will not align correctly to the edge of the table
6
6
  export const defaultGuidelines = createFixedGuidelinesFromLengths([0, ...calculateDefaultSnappings(-1)]);
7
- export const defaultGuidelinesForPreserveTable = editorContainerWidth => createFixedGuidelinesFromLengths([0, ...calculateDefaultTablePreserveSnappings(-1, editorContainerWidth)]);
7
+ export const defaultGuidelinesForPreserveTable = editorContainerWidth => createFixedGuidelinesFromLengths([0, ...calculateDefaultTablePreserveSnappings(-1, editorContainerWidth)], undefined, true);
@@ -2,6 +2,7 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ import isEqual from 'lodash/isEqual';
5
6
  import { closestElement, isParagraph, isTextSelection, mapSlice } from '@atlaskit/editor-common/utils';
6
7
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
7
8
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
@@ -559,13 +560,13 @@ export var updateWidthToWidest = function updateWidthToWidest(widthToWidest) {
559
560
  return createCommand(function (state) {
560
561
  var _getPluginState4 = getPluginState(state),
561
562
  prevWidthToWidest = _getPluginState4.widthToWidest;
562
- if (prevWidthToWidest === widthToWidest) {
563
+ if (isEqual(widthToWidest, prevWidthToWidest)) {
563
564
  return false;
564
565
  }
565
566
  return {
566
567
  type: 'UPDATE_TABLE_WIDTH_TO_WIDEST',
567
568
  data: {
568
- widthToWidest: widthToWidest
569
+ widthToWidest: _objectSpread(_objectSpread({}, prevWidthToWidest), widthToWidest)
569
570
  }
570
571
  };
571
572
  });
@@ -498,9 +498,12 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
498
498
  options = _this$props10.options,
499
499
  isTableScalingEnabled = _this$props10.isTableScalingEnabled,
500
500
  getPos = _this$props10.getPos;
501
- var _getPluginState = getPluginState(view.state),
502
- isInDanger = _getPluginState.isInDanger;
501
+ var isInDanger = this.props.isInDanger;
503
502
  var table = findTable(view.state.selection);
503
+ if (!getBooleanFF('platform.editor.table.use-shared-state-hook')) {
504
+ var pluginState = getPluginState(view.state);
505
+ isInDanger = pluginState.isInDanger;
506
+ }
504
507
  if (isTableScalingEnabled) {
505
508
  this.handleColgroupUpdates();
506
509
  }
@@ -602,16 +605,24 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
602
605
  isDragAndDropEnabled = _this$props11.isDragAndDropEnabled,
603
606
  getEditorFeatureFlags = _this$props11.getEditorFeatureFlags,
604
607
  isTableScalingEnabled = _this$props11.isTableScalingEnabled;
608
+ var _this$props12 = this.props,
609
+ isInDanger = _this$props12.isInDanger,
610
+ hoveredRows = _this$props12.hoveredRows,
611
+ hoveredCell = _this$props12.hoveredCell,
612
+ isTableHovered = _this$props12.isTableHovered,
613
+ isWholeTableInDanger = _this$props12.isWholeTableInDanger;
605
614
  var _this$state3 = this.state,
606
615
  showBeforeShadow = _this$state3.showBeforeShadow,
607
616
  showAfterShadow = _this$state3.showAfterShadow;
608
617
  var node = getNode();
609
- // doesn't work well with WithPluginState
610
- var _getPluginState2 = getPluginState(view.state),
611
- isInDanger = _getPluginState2.isInDanger,
612
- hoveredRows = _getPluginState2.hoveredRows,
613
- hoveredCell = _getPluginState2.hoveredCell,
614
- isTableHovered = _getPluginState2.isTableHovered;
618
+ if (!getBooleanFF('platform.editor.table.use-shared-state-hook')) {
619
+ var pluginState = getPluginState(view.state);
620
+ isInDanger = pluginState.isInDanger;
621
+ hoveredRows = pluginState.hoveredRows;
622
+ hoveredCell = pluginState.hoveredCell;
623
+ isTableHovered = pluginState.isTableHovered;
624
+ isWholeTableInDanger = pluginState.isWholeTableInDanger;
625
+ }
615
626
  var tableRef = this.table || undefined;
616
627
  var headerRow = tableRef ? tableRef.querySelector('tr[data-header-row]') : undefined;
617
628
  var hasHeaderRow = containsHeaderRow(node);
@@ -636,7 +647,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
636
647
  selection: view.state.selection,
637
648
  headerRowHeight: headerRow ? headerRow.offsetHeight : undefined,
638
649
  stickyHeader: this.state.stickyHeader,
639
- tableWrapperWidth: this.state.tableWrapperWidth
650
+ tableWrapperWidth: this.state.tableWrapperWidth,
651
+ api: pluginInjectionApi
640
652
  });
641
653
  var tableContainerWidth = getTableContainerWidth(node);
642
654
  var colControls = isDragAndDropEnabled ? /*#__PURE__*/React.createElement(TableFloatingColumnControls, {
@@ -663,7 +675,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
663
675
  var _this4$wrapper;
664
676
  return ((_this4$wrapper = _this4.wrapper) === null || _this4$wrapper === void 0 ? void 0 : _this4$wrapper.scrollLeft) || 0;
665
677
  },
666
- tableWrapperHeight: this.state.tableWrapperHeight
678
+ tableWrapperHeight: this.state.tableWrapperHeight,
679
+ api: pluginInjectionApi
667
680
  }) : null;
668
681
  var shadowPadding = allowControls && tableActive ? -tableToolbarSize : tableMarginSides;
669
682
  var shadowStyle = memoizeOne(function (visible) {
@@ -700,7 +713,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
700
713
  tableWrapperHeight: this.state.tableWrapperHeight,
701
714
  isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled,
702
715
  isResizing: isResizing,
703
- isTableScalingEnabled: isTableScalingEnabled
716
+ isTableScalingEnabled: isTableScalingEnabled,
717
+ isWholeTableInDanger: isWholeTableInDanger
704
718
  }, /*#__PURE__*/React.createElement("div", {
705
719
  className: ClassName.TABLE_STICKY_SENTINEL_TOP,
706
720
  "data-testid": "sticky-sentinel-top"
@@ -0,0 +1,80 @@
1
+ import React from 'react';
2
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
+ import { findTable } from '@atlaskit/editor-tables';
4
+ import TableComponent from './TableComponent';
5
+ /**
6
+ * Use useSharedPluginState to control re-renders from plugin dependencies
7
+ */
8
+ export var TableComponentWithSharedState = function TableComponentWithSharedState(_ref) {
9
+ var view = _ref.view,
10
+ options = _ref.options,
11
+ getNode = _ref.getNode,
12
+ dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
13
+ api = _ref.api,
14
+ getEditorFeatureFlags = _ref.getEditorFeatureFlags,
15
+ eventDispatcher = _ref.eventDispatcher,
16
+ allowColumnResizing = _ref.allowColumnResizing,
17
+ allowControls = _ref.allowControls,
18
+ getPos = _ref.getPos,
19
+ forwardRef = _ref.forwardRef;
20
+ var _useSharedPluginState = useSharedPluginState(api, ['width', 'table', 'media']),
21
+ widthState = _useSharedPluginState.widthState,
22
+ tableState = _useSharedPluginState.tableState,
23
+ mediaState = _useSharedPluginState.mediaState;
24
+ if (!tableState) {
25
+ return null;
26
+ }
27
+ var _ref2 = tableState,
28
+ isTableResizing = _ref2.isTableResizing,
29
+ isHeaderColumnEnabled = _ref2.isHeaderColumnEnabled,
30
+ isHeaderRowEnabled = _ref2.isHeaderRowEnabled,
31
+ ordering = _ref2.ordering,
32
+ isResizing = _ref2.isResizing,
33
+ isInDanger = _ref2.isInDanger,
34
+ hoveredCell = _ref2.hoveredCell,
35
+ hoveredRows = _ref2.hoveredRows,
36
+ isTableHovered = _ref2.isTableHovered,
37
+ isWholeTableInDanger = _ref2.isWholeTableInDanger;
38
+
39
+ /**
40
+ * ED-19810
41
+ * There is a getPos issue coming from this code. We need to apply this workaround for now and apply a patch
42
+ * directly to confluence since this bug is now in production.
43
+ */
44
+ var currentTablePos;
45
+ try {
46
+ currentTablePos = getPos ? getPos() : undefined;
47
+ } catch (e) {
48
+ currentTablePos = undefined;
49
+ }
50
+ var selectedTable = findTable(view.state.selection);
51
+ var tablePos = selectedTable && selectedTable.start - 1;
52
+ var tableActive = typeof currentTablePos === 'number' && typeof tablePos === 'number' && currentTablePos === tablePos && !isTableResizing;
53
+ return /*#__PURE__*/React.createElement(TableComponent, {
54
+ view: view,
55
+ allowColumnResizing: allowColumnResizing,
56
+ eventDispatcher: eventDispatcher,
57
+ getPos: getPos,
58
+ isMediaFullscreen: mediaState === null || mediaState === void 0 ? void 0 : mediaState.isFullscreen,
59
+ options: options,
60
+ allowControls: !!allowControls,
61
+ isHeaderRowEnabled: isHeaderRowEnabled,
62
+ isHeaderColumnEnabled: isHeaderColumnEnabled,
63
+ isDragAndDropEnabled: options === null || options === void 0 ? void 0 : options.isDragAndDropEnabled,
64
+ isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
65
+ tableActive: tableActive,
66
+ ordering: ordering,
67
+ isResizing: isResizing,
68
+ getNode: getNode,
69
+ containerWidth: widthState,
70
+ contentDOM: forwardRef,
71
+ getEditorFeatureFlags: getEditorFeatureFlags,
72
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
73
+ pluginInjectionApi: api,
74
+ isInDanger: !!isInDanger,
75
+ hoveredRows: hoveredRows,
76
+ hoveredCell: hoveredCell,
77
+ isTableHovered: isTableHovered,
78
+ isWholeTableInDanger: isWholeTableInDanger
79
+ });
80
+ };
@@ -4,6 +4,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
5
  import React, { forwardRef, useCallback, useRef, useState } from 'react';
6
6
  import classNames from 'classnames';
7
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
7
8
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
8
9
  import { calcTableWidth } from '@atlaskit/editor-common/styles';
9
10
  import { akEditorDefaultLayoutWidth, akEditorGutterPadding, akEditorMediaResizeHandlerPaddingWide, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
@@ -32,10 +33,11 @@ export var InnerContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
32
33
  className: className,
33
34
  "data-number-column": node.attrs.isNumberColumnEnabled,
34
35
  "data-layout": node.attrs.layout,
35
- "data-test-id": "table-container"
36
+ "data-testid": "table-container"
36
37
  }, children);
37
38
  });
38
39
  export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
40
+ var _node$attrs$localId, _node$attrs;
39
41
  var children = _ref2.children,
40
42
  className = _ref2.className,
41
43
  node = _ref2.node,
@@ -46,7 +48,8 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
46
48
  isResizing = _ref2.isResizing,
47
49
  pluginInjectionApi = _ref2.pluginInjectionApi,
48
50
  isTableScalingEnabled = _ref2.isTableScalingEnabled,
49
- tableWrapperHeight = _ref2.tableWrapperHeight;
51
+ tableWrapperHeight = _ref2.tableWrapperHeight,
52
+ isWholeTableInDanger = _ref2.isWholeTableInDanger;
50
53
  var containerRef = useRef(null);
51
54
  var tableWidthRef = useRef(akEditorDefaultLayoutWidth);
52
55
  var _useState = useState(false),
@@ -106,9 +109,18 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
106
109
  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;
107
110
  }, [pluginInjectionApi]);
108
111
  var tableWidth = getTableContainerWidth(node);
112
+ var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['table']),
113
+ tableState = _useSharedPluginState.tableState;
114
+ var _ref3 = tableState,
115
+ widthToWidest = _ref3.widthToWidest;
116
+ var currentTableNodeLocalId = (_node$attrs$localId = node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.localId) !== null && _node$attrs$localId !== void 0 ? _node$attrs$localId : '';
117
+
109
118
  // 76 is currently an accepted padding value considering the spacing for resizer handle
110
119
  var responsiveContainerWidth = isTableScalingEnabled ? containerWidth - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide / 2 : containerWidth - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide;
111
120
  var width = Math.min(tableWidth, responsiveContainerWidth);
121
+ if (isTableScalingEnabled && currentTableNodeLocalId && widthToWidest && widthToWidest[currentTableNodeLocalId]) {
122
+ width = TABLE_MAX_WIDTH;
123
+ }
112
124
  if (!isResizing) {
113
125
  tableWidthRef.current = width;
114
126
  }
@@ -125,7 +137,9 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
125
137
  displayGuideline: displayGuideline,
126
138
  attachAnalyticsEvent: attachAnalyticsEvent,
127
139
  displayGapCursor: displayGapCursor,
128
- isTableScalingEnabled: isTableScalingEnabled
140
+ isTableScalingEnabled: isTableScalingEnabled,
141
+ isWholeTableInDanger: isWholeTableInDanger,
142
+ pluginInjectionApi: pluginInjectionApi
129
143
  };
130
144
  if (getBooleanFF('platform.editor.resizing-table-height-improvement')) {
131
145
  tableResizerProps = _objectSpread(_objectSpread({}, tableResizerProps), {}, {
@@ -150,23 +164,24 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
150
164
  node: node
151
165
  }, children))));
152
166
  });
153
- export var TableContainer = function TableContainer(_ref3) {
154
- var children = _ref3.children,
155
- node = _ref3.node,
156
- className = _ref3.className,
157
- _ref3$containerWidth = _ref3.containerWidth,
158
- lineLength = _ref3$containerWidth.lineLength,
159
- editorWidth = _ref3$containerWidth.width,
160
- isTableResizingEnabled = _ref3.isTableResizingEnabled,
161
- isBreakoutEnabled = _ref3.isBreakoutEnabled,
162
- editorView = _ref3.editorView,
163
- getPos = _ref3.getPos,
164
- tableRef = _ref3.tableRef,
165
- isNested = _ref3.isNested,
166
- tableWrapperHeight = _ref3.tableWrapperHeight,
167
- isResizing = _ref3.isResizing,
168
- pluginInjectionApi = _ref3.pluginInjectionApi,
169
- isTableScalingEnabled = _ref3.isTableScalingEnabled;
167
+ export var TableContainer = function TableContainer(_ref4) {
168
+ var children = _ref4.children,
169
+ node = _ref4.node,
170
+ className = _ref4.className,
171
+ _ref4$containerWidth = _ref4.containerWidth,
172
+ lineLength = _ref4$containerWidth.lineLength,
173
+ editorWidth = _ref4$containerWidth.width,
174
+ isTableResizingEnabled = _ref4.isTableResizingEnabled,
175
+ isBreakoutEnabled = _ref4.isBreakoutEnabled,
176
+ editorView = _ref4.editorView,
177
+ getPos = _ref4.getPos,
178
+ tableRef = _ref4.tableRef,
179
+ isNested = _ref4.isNested,
180
+ tableWrapperHeight = _ref4.tableWrapperHeight,
181
+ isResizing = _ref4.isResizing,
182
+ pluginInjectionApi = _ref4.pluginInjectionApi,
183
+ isTableScalingEnabled = _ref4.isTableScalingEnabled,
184
+ isWholeTableInDanger = _ref4.isWholeTableInDanger;
170
185
  if (isTableResizingEnabled && !isNested) {
171
186
  return /*#__PURE__*/React.createElement(ResizableTableContainer, {
172
187
  className: className,
@@ -178,7 +193,8 @@ export var TableContainer = function TableContainer(_ref3) {
178
193
  tableWrapperHeight: tableWrapperHeight,
179
194
  isResizing: isResizing,
180
195
  pluginInjectionApi: pluginInjectionApi,
181
- isTableScalingEnabled: isTableScalingEnabled
196
+ isTableScalingEnabled: isTableScalingEnabled,
197
+ isWholeTableInDanger: isWholeTableInDanger
182
198
  }, children);
183
199
  }
184
200
  var tableWidth = isBreakoutEnabled ? calcTableWidth(node.attrs.layout, editorWidth) : 'inherit';
@@ -8,17 +8,16 @@ import rafSchd from 'raf-schd';
8
8
  import { useIntl } from 'react-intl-next';
9
9
  import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
10
10
  import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
11
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
11
12
  import { focusTableResizer, ToolTipContent } from '@atlaskit/editor-common/keymaps';
12
13
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
13
14
  import { ResizerNext } from '@atlaskit/editor-common/resizer';
14
15
  import { browser } from '@atlaskit/editor-common/utils';
15
- import { akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
16
16
  import { findTable } from '@atlaskit/editor-tables/utils';
17
17
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
18
18
  import { updateWidthToWidest } from '../commands/misc';
19
- import { getPluginState } from '../pm-plugins/plugin-factory';
20
19
  import { META_KEYS } from '../pm-plugins/table-analytics';
21
- import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTable } from '../pm-plugins/table-resizing/utils';
20
+ import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTable, TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
22
21
  import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
23
22
  import { TABLE_GUIDELINE_VISIBLE_ADJUSTMENT, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE, TABLE_SNAP_GAP } from '../ui/consts';
24
23
  import { generateResizedPayload, generateResizeFrameRatePayloads, useMeasureFramerate } from '../utils/analytics';
@@ -90,28 +89,38 @@ export var TableResizer = function TableResizer(_ref) {
90
89
  displayGuideline = _ref.displayGuideline,
91
90
  attachAnalyticsEvent = _ref.attachAnalyticsEvent,
92
91
  displayGapCursor = _ref.displayGapCursor,
93
- isTableScalingEnabled = _ref.isTableScalingEnabled;
92
+ isTableScalingEnabled = _ref.isTableScalingEnabled,
93
+ isWholeTableInDanger = _ref.isWholeTableInDanger,
94
+ pluginInjectionApi = _ref.pluginInjectionApi;
94
95
  var currentGap = useRef(0);
95
96
  // track resizing state - use ref over state to avoid re-render
96
97
  var isResizing = useRef(false);
97
98
  var areResizeMetaKeysPressed = useRef(false);
99
+ var _useState = useState(width),
100
+ _useState2 = _slicedToArray(_useState, 2),
101
+ localTableWidth = _useState2[0],
102
+ setLocalTableWidth = _useState2[1];
98
103
  var resizerRef = useRef(null);
104
+ var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['table']),
105
+ tableState = _useSharedPluginState.tableState;
106
+ var _ref2 = tableState,
107
+ widthToWidest = _ref2.widthToWidest;
99
108
 
100
109
  // used to reposition tooltip when table is resizing via keyboard
101
110
  var updateTooltip = React.useRef();
102
- var _useState = useState(false),
103
- _useState2 = _slicedToArray(_useState, 2),
104
- snappingEnabled = _useState2[0],
105
- setSnappingEnabled = _useState2[1];
111
+ var _useState3 = useState(false),
112
+ _useState4 = _slicedToArray(_useState3, 2),
113
+ snappingEnabled = _useState4[0],
114
+ setSnappingEnabled = _useState4[1];
106
115
 
107
116
  // we don't want to update aria-live region on each width change, it might provide bad experience for screen reader users
108
- var _useState3 = useState({
117
+ var _useState5 = useState({
109
118
  type: 'none',
110
119
  width: width
111
120
  }),
112
- _useState4 = _slicedToArray(_useState3, 2),
113
- screenReaderResizeInformation = _useState4[0],
114
- setScreenReaderResizeInformation = _useState4[1];
121
+ _useState6 = _slicedToArray(_useState5, 2),
122
+ screenReaderResizeInformation = _useState6[0],
123
+ setScreenReaderResizeInformation = _useState6[1];
115
124
  var _useIntl = useIntl(),
116
125
  formatMessage = _useIntl.formatMessage;
117
126
  var screenReaderResizeAnnouncerMessages = {
@@ -126,15 +135,13 @@ export var TableResizer = function TableResizer(_ref) {
126
135
  var isTableSelected = ((_findTable = findTable((_editorView$state = editorView.state) === null || _editorView$state === void 0 ? void 0 : _editorView$state.selection)) === null || _findTable === void 0 ? void 0 : _findTable.pos) === getPos();
127
136
  var resizerMinWidth = getResizerMinWidth(node);
128
137
  var handleSize = getResizerHandleHeight(tableRef);
129
- var _getPluginState = getPluginState(editorView.state),
130
- isWholeTableInDanger = _getPluginState.isWholeTableInDanger;
131
138
  var _useMeasureFramerate = useMeasureFramerate(),
132
139
  startMeasure = _useMeasureFramerate.startMeasure,
133
140
  endMeasure = _useMeasureFramerate.endMeasure,
134
141
  countFrames = _useMeasureFramerate.countFrames;
135
- var updateActiveGuidelines = useCallback(function (_ref2) {
136
- var gap = _ref2.gap,
137
- keys = _ref2.keys;
142
+ var updateActiveGuidelines = useCallback(function (_ref3) {
143
+ var gap = _ref3.gap,
144
+ keys = _ref3.keys;
138
145
  if (gap !== currentGap.current) {
139
146
  currentGap.current = gap;
140
147
  var visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, containerWidth);
@@ -182,7 +189,7 @@ export var TableResizer = function TableResizer(_ref) {
182
189
  }
183
190
  }, [startMeasure, editorView, displayGapCursor, isTableScalingEnabled, containerWidth, displayGuideline, onResizeStart]);
184
191
  var handleResize = useCallback(function (originalState, delta) {
185
- var _defaultGuidelinesFor;
192
+ var _node$attrs$localId, _node$attrs, _widestGuideline$posi;
186
193
  countFrames();
187
194
  var newWidth = originalState.width + delta.width;
188
195
  var pos;
@@ -207,25 +214,29 @@ export var TableResizer = function TableResizer(_ref) {
207
214
  // set the width of the table to 1800 pixels.
208
215
  var state = editorView.state,
209
216
  dispatch = editorView.dispatch;
210
- var widestGuideLineWidthString = (_defaultGuidelinesFor = defaultGuidelinesForPreserveTable(containerWidth)[16].key) === null || _defaultGuidelinesFor === void 0 || (_defaultGuidelinesFor = _defaultGuidelinesFor.match(/[\d]*[.]{0,1}[\d]+/g)) === null || _defaultGuidelinesFor === void 0 ? void 0 : _defaultGuidelinesFor.join('');
211
- var widestGuideLineWidth = parseInt(widestGuideLineWidthString || '', 10);
212
- var shouldUpdateWidthToWidest = !!(isTableScalingEnabled && defaultGuidelinesForPreserveTable(containerWidth).length === 17 && widestGuideLineWidth - newWidth <= 1);
213
- updateWidthToWidest(shouldUpdateWidthToWidest)(state, dispatch);
214
- updateWidth(shouldUpdateWidthToWidest ? akEditorFullWidthLayoutWidth : newWidth);
217
+ var currentTableNodeLocalId = (_node$attrs$localId = node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.localId) !== null && _node$attrs$localId !== void 0 ? _node$attrs$localId : '';
218
+ var widestGuideline = defaultGuidelinesForPreserveTable(containerWidth).filter(function (guideline) {
219
+ return guideline.isFullWidth;
220
+ })[0];
221
+ var widestGuideLineWidth = widestGuideline ? (((_widestGuideline$posi = widestGuideline.position) === null || _widestGuideline$posi === void 0 ? void 0 : _widestGuideline$posi.x) || 0) * 2 : null;
222
+ var shouldUpdateWidthToWidest = !!(isTableScalingEnabled && widestGuideLineWidth && Math.abs(widestGuideLineWidth - newWidth) <= 1);
223
+ shouldUpdateWidthToWidest ? setLocalTableWidth(TABLE_MAX_WIDTH) : setLocalTableWidth(newWidth);
224
+ updateWidthToWidest(_defineProperty({}, currentTableNodeLocalId, shouldUpdateWidthToWidest))(state, dispatch);
225
+ updateWidth(shouldUpdateWidthToWidest ? TABLE_MAX_WIDTH : newWidth);
215
226
  return newWidth;
216
227
  }, [countFrames, isTableScalingEnabled, tableRef, node, editorView, updateActiveGuidelines, containerWidth, updateWidth, getPos]);
217
228
  var scheduleResize = useMemo(function () {
218
229
  return rafSchd(handleResize);
219
230
  }, [handleResize]);
220
231
  var handleResizeStop = useCallback(function (originalState, delta) {
232
+ var _node$attrs$localId2, _node$attrs2;
221
233
  isResizing.current = false;
222
234
  var newWidth = originalState.width + delta.width;
223
235
  var state = editorView.state,
224
236
  dispatch = editorView.dispatch;
225
237
  var pos = getPos();
226
- var _getPluginState2 = getPluginState(editorView.state),
227
- widthToWidest = _getPluginState2.widthToWidest;
228
- newWidth = widthToWidest ? akEditorFullWidthLayoutWidth : newWidth;
238
+ var currentTableNodeLocalId = (_node$attrs$localId2 = node === null || node === void 0 || (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.localId) !== null && _node$attrs$localId2 !== void 0 ? _node$attrs$localId2 : '';
239
+ newWidth = widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId] ? TABLE_MAX_WIDTH : newWidth;
229
240
  var tr = state.tr.setMeta(tableWidthPluginKey, {
230
241
  resizing: false
231
242
  });
@@ -270,7 +281,7 @@ export var TableResizer = function TableResizer(_ref) {
270
281
  onResizeStop();
271
282
  }
272
283
  return newWidth;
273
- }, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop, isTableScalingEnabled]);
284
+ }, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop, isTableScalingEnabled, widthToWidest]);
274
285
  var handleTableSizeChangeOnKeypress = useCallback(function (step) {
275
286
  var newWidth = width + step;
276
287
  if (newWidth > maxWidth || newWidth < resizerMinWidth) {
@@ -375,7 +386,7 @@ export var TableResizer = function TableResizer(_ref) {
375
386
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ResizerNext, {
376
387
  ref: resizerRef,
377
388
  enable: handles,
378
- width: width,
389
+ width: localTableWidth,
379
390
  handleAlignmentMethod: "sticky",
380
391
  handleSize: handleSize,
381
392
  handleStyles: handleStyles,
@@ -392,8 +403,8 @@ export var TableResizer = function TableResizer(_ref) {
392
403
  needExtendedResizeZone: !isTableSelected,
393
404
  appearance: isTableSelected && isWholeTableInDanger ? 'danger' : undefined,
394
405
  handleHighlight: "shadow",
395
- handleTooltipContent: getBooleanFF('platform.editor.a11y-table-resizing_uapcv') ? function (_ref3) {
396
- var update = _ref3.update;
406
+ handleTooltipContent: getBooleanFF('platform.editor.a11y-table-resizing_uapcv') ? function (_ref4) {
407
+ var update = _ref4.update;
397
408
  updateTooltip.current = update;
398
409
  return /*#__PURE__*/React.createElement(ToolTipContent, {
399
410
  description: formatMessage(messages.resizeTable),
@@ -17,6 +17,7 @@ import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
17
17
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
18
18
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
19
19
  import { TableMap } from '@atlaskit/editor-tables/table-map';
20
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
20
21
  import { pluginConfig as getPluginConfig } from '../create-plugin-config';
21
22
  import { pluginKey as tableDragAndDropPluginKey } from '../pm-plugins/drag-and-drop';
22
23
  import { getPluginState } from '../pm-plugins/plugin-factory';
@@ -26,6 +27,7 @@ import { generateColgroup } from '../pm-plugins/table-resizing/utils';
26
27
  import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
27
28
  import { isTableNested } from '../utils';
28
29
  import TableComponent from './TableComponent';
30
+ import { TableComponentWithSharedState } from './TableComponentWithSharedState';
29
31
  var tableAttributes = function tableAttributes(node) {
30
32
  return {
31
33
  'data-number-column': node.attrs.isNumberColumnEnabled,
@@ -116,6 +118,22 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
116
118
  key: "render",
117
119
  value: function render(props, forwardRef) {
118
120
  var _this3 = this;
121
+ if (getBooleanFF('platform.editor.table.use-shared-state-hook')) {
122
+ return /*#__PURE__*/React.createElement(TableComponentWithSharedState, {
123
+ forwardRef: forwardRef,
124
+ getNode: this.getNode,
125
+ view: props.view,
126
+ options: props.options,
127
+ eventDispatcher: props.eventDispatcher,
128
+ api: props.pluginInjectionApi,
129
+ allowColumnResizing: props.allowColumnResizing,
130
+ allowControls: props.allowControls,
131
+ getPos: props.getPos,
132
+ getEditorFeatureFlags: props.getEditorFeatureFlags,
133
+ dispatchAnalyticsEvent: props.dispatchAnalyticsEvent
134
+ });
135
+ }
136
+
119
137
  // TODO: ED-15663
120
138
  // Please, do not copy or use this kind of code below
121
139
  // @ts-ignore
@@ -262,12 +280,14 @@ export var createTableView = function createTableView(node, view, getPos, portal
262
280
  isDragAndDropEnabled = _getPluginState2.isDragAndDropEnabled,
263
281
  isTableScalingEnabled = _getPluginState2.isTableScalingEnabled;
264
282
  var _getPluginConfig = getPluginConfig(pluginConfig),
265
- allowColumnResizing = _getPluginConfig.allowColumnResizing;
283
+ allowColumnResizing = _getPluginConfig.allowColumnResizing,
284
+ allowControls = _getPluginConfig.allowControls;
266
285
  var hasIntlContext = true;
267
286
  return new TableView({
268
287
  node: node,
269
288
  view: view,
270
289
  allowColumnResizing: allowColumnResizing,
290
+ allowControls: allowControls,
271
291
  portalProviderAPI: portalProviderAPI,
272
292
  eventDispatcher: eventDispatcher,
273
293
  getPos: getPos,
@@ -24,7 +24,7 @@ import { createPlugin as createTableSafariDeleteCompositionTextIssueWorkaroundPl
24
24
  import { createPlugin as createStickyHeadersPlugin, findStickyHeaderForTable, pluginKey as stickyHeadersPluginKey } from './pm-plugins/sticky-headers';
25
25
  import { createPlugin as createTableOverflowAnalyticsPlugin } from './pm-plugins/table-analytics';
26
26
  import { createPlugin as createTableLocalIdPlugin } from './pm-plugins/table-local-id';
27
- import { createPlugin as createFlexiResizingPlugin, pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
27
+ import { createPlugin as createFlexiResizingPlugin, getPluginState as getFlexiResizingPlugin, pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
28
28
  import { tableSelectionKeymapPlugin } from './pm-plugins/table-selection-keymap';
29
29
  import { createPlugin as createTableWidthPlugin, pluginKey as tableWidthPluginKey } from './pm-plugins/table-width';
30
30
  import { getToolbarConfig } from './toolbar';
@@ -38,6 +38,9 @@ import { createTableWithWidth, isLayoutSupported } from './utils';
38
38
  var defaultGetEditorFeatureFlags = function defaultGetEditorFeatureFlags() {
39
39
  return {};
40
40
  };
41
+
42
+ // TODO: duplicating type instead of importing media plugin causing a circular dependency
43
+
41
44
  /**
42
45
  * Table plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
43
46
  * from `@atlaskit/editor-core`.
@@ -60,10 +63,30 @@ var tablesPlugin = function tablesPlugin(_ref) {
60
63
  name: 'table',
61
64
  // Use getSharedState to store fullWidthEnabled and wasFullWidthModeEnabled to guarantee access
62
65
  // to most up to date values - passing to createPluginState will not re-initialise the state
63
- getSharedState: function getSharedState() {
66
+ getSharedState: function getSharedState(editorState) {
67
+ if (!editorState) {
68
+ return undefined;
69
+ }
70
+ var tablePluginState = getPluginState(editorState);
71
+ var tableResizingPluginState = getFlexiResizingPlugin(editorState);
72
+ var tableWidthResizingPluginState = tableWidthPluginKey.getState(editorState);
64
73
  return {
65
74
  isFullWidthModeEnabled: !!(options !== null && options !== void 0 && options.fullWidthEnabled),
66
- wasFullWidthModeEnabled: !!(options !== null && options !== void 0 && options.wasFullWidthEnabled)
75
+ wasFullWidthModeEnabled: !!(options !== null && options !== void 0 && options.wasFullWidthEnabled),
76
+ isHeaderRowEnabled: tablePluginState.isHeaderRowEnabled,
77
+ isHeaderColumnEnabled: tablePluginState.isHeaderColumnEnabled,
78
+ ordering: tablePluginState.ordering,
79
+ isResizing: !!(tableResizingPluginState !== null && tableResizingPluginState !== void 0 && tableResizingPluginState.dragging || tableWidthResizingPluginState !== null && tableWidthResizingPluginState !== void 0 && tableWidthResizingPluginState.resizing),
80
+ isTableResizing: tableWidthResizingPluginState === null || tableWidthResizingPluginState === void 0 ? void 0 : tableWidthResizingPluginState.resizing,
81
+ isInDanger: tablePluginState.isInDanger,
82
+ hoveredRows: tablePluginState.hoveredRows,
83
+ hoveredCell: tablePluginState.hoveredCell,
84
+ isTableHovered: tablePluginState.isTableHovered,
85
+ isWholeTableInDanger: tablePluginState.isWholeTableInDanger,
86
+ // IMPORTANT: Need to continue to pass tableNode to control re-renders
87
+ // TableComponent listens for node attribute changes to update colgroups
88
+ tableNode: tablePluginState.tableNode,
89
+ widthToWidest: tablePluginState.widthToWidest
67
90
  };
68
91
  },
69
92
  actions: {
@@ -15,7 +15,6 @@ import { findCellRectClosestToPos, findTable, getSelectionRect, isSelectionType,
15
15
  import DistributeColumnIcon from '@atlaskit/icon/glyph/editor/layout-three-equal';
16
16
  import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
17
17
  import TableOptionsIcon from '@atlaskit/icon/glyph/preferences';
18
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
19
18
  import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, hoverTable, removeDescendantNodes } from './commands';
20
19
  import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, deleteTableWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, wrapTableInExpandWithAnalytics } from './commands-with-analytics';
21
20
  import { getPluginState } from './pm-plugins/plugin-factory';
@@ -54,7 +53,7 @@ export var getToolbarMenuConfig = function getToolbarMenuConfig(config, state, _
54
53
  disabled: !state.canCollapseTable,
55
54
  hidden: !config.allowCollapse
56
55
  }];
57
- if (state.isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling')) {
56
+ if (state.isDragAndDropEnabled) {
58
57
  return {
59
58
  id: 'editor.table.tableOptions',
60
59
  type: 'dropdown',
@@ -290,6 +289,7 @@ export var getClosestSelectionOrTableRect = function getClosestSelectionOrTableR
290
289
  export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView) {
291
290
  return function (config) {
292
291
  return function (state, intl) {
292
+ var _tableObject$node$att, _tableObject$node;
293
293
  var tableObject = findTable(state.selection);
294
294
  var pluginState = getPluginState(state);
295
295
  var resizeState = tableResizingPluginKey.getState(state);
@@ -299,7 +299,8 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
299
299
  var isWidthResizing = tableWidthState === null || tableWidthState === void 0 ? void 0 : tableWidthState.resizing;
300
300
  var isTableScalingEnabled = pluginState.isTableScalingEnabled,
301
301
  widthToWidest = pluginState.widthToWidest;
302
- if (isTableScalingEnabled && isWidthResizing && widthToWidest) {
302
+ var currentTableNodeLocalId = (_tableObject$node$att = tableObject === null || tableObject === void 0 || (_tableObject$node = tableObject.node) === null || _tableObject$node === void 0 || (_tableObject$node = _tableObject$node.attrs) === null || _tableObject$node === void 0 ? void 0 : _tableObject$node.localId) !== null && _tableObject$node$att !== void 0 ? _tableObject$node$att : '';
303
+ if (isTableScalingEnabled && isWidthResizing && widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId]) {
303
304
  var _getEditorFeatureFlag = getEditorFeatureFlags(),
304
305
  stickyScrollbar = _getEditorFeatureFlag.stickyScrollbar;
305
306
  var nodeType = state.schema.nodes.table;
@@ -351,7 +352,7 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
351
352
  var cellItems;
352
353
  cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, _isTableScalingEnabled);
353
354
  var columnSettingsItems;
354
- columnSettingsItems = pluginState.isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, _isTableScalingEnabled) : [];
355
+ columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, _isTableScalingEnabled) : [];
355
356
  var colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI);
356
357
 
357
358
  // Check if we need to show confirm dialog for delete button
package/dist/esm/types.js CHANGED
@@ -9,6 +9,9 @@ export var RESIZE_HANDLE_AREA_DECORATION_GAP = 30;
9
9
  * @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-6877 Internal documentation for deprecation (no external access)}
10
10
  **/
11
11
 
12
+ // override getPluginState but do not expose publicly as this type is experimental and will change
13
+ // in the future
14
+
12
15
  /*
13
16
  * This type represents the start and end from a cell in a column,
14
17
  * for example, on this table the cell C1 will have