@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 7.6.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#84595](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/84595) [`412b82018310`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/412b82018310) - ED-22555: Added isFullWidth to GuidelineConfig and use it as a signal
8
+ - Updated dependencies
9
+
10
+ ## 7.6.3
11
+
12
+ ### Patch Changes
13
+
14
+ - [#82198](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/82198) [`fb41831c5371`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fb41831c5371) - Remove WithPluginState behind a feature flag and introduce basic gemini tests
15
+
3
16
  ## 7.6.2
4
17
 
5
18
  ### Patch Changes
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.updateWidthToWidest = exports.updateResizeHandleDecorations = exports.triggerUnlessTableHeader = exports.transformSliceToRemoveColumnsWidths = exports.transformSliceToAddTableHeaders = exports.transformSliceRemoveCellBackgroundColor = exports.showInsertRowButton = exports.showInsertColumnButton = exports.setTableRef = exports.setMultipleCellAttrs = exports.setEditorFocus = exports.setCellAttr = exports.selectRows = exports.selectRow = exports.selectColumns = exports.selectColumn = exports.removeResizeHandleDecorations = exports.moveCursorBackward = exports.isInsideFirstCellOfRowOrColumn = exports.hideInsertColumnOrRowButton = exports.getTableSelectionType = exports.getTableElementMoveTypeBySlice = exports.deleteTableIfSelected = exports.deleteTable = exports.countCellsInSlice = exports.convertFirstRowToHeader = exports.autoSizeTable = exports.addResizeHandleDecorations = exports.addBoldInEmptyHeaderCells = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
10
11
  var _utils = require("@atlaskit/editor-common/utils");
11
12
  var _state = require("@atlaskit/editor-prosemirror/state");
12
13
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
@@ -566,13 +567,13 @@ var updateWidthToWidest = exports.updateWidthToWidest = function updateWidthToWi
566
567
  return (0, _pluginFactory.createCommand)(function (state) {
567
568
  var _getPluginState4 = (0, _pluginFactory.getPluginState)(state),
568
569
  prevWidthToWidest = _getPluginState4.widthToWidest;
569
- if (prevWidthToWidest === widthToWidest) {
570
+ if ((0, _isEqual.default)(widthToWidest, prevWidthToWidest)) {
570
571
  return false;
571
572
  }
572
573
  return {
573
574
  type: 'UPDATE_TABLE_WIDTH_TO_WIDEST',
574
575
  data: {
575
- widthToWidest: widthToWidest
576
+ widthToWidest: _objectSpread(_objectSpread({}, prevWidthToWidest), widthToWidest)
576
577
  }
577
578
  };
578
579
  });
@@ -505,9 +505,12 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
505
505
  options = _this$props10.options,
506
506
  isTableScalingEnabled = _this$props10.isTableScalingEnabled,
507
507
  getPos = _this$props10.getPos;
508
- var _getPluginState = (0, _pluginFactory.getPluginState)(view.state),
509
- isInDanger = _getPluginState.isInDanger;
508
+ var isInDanger = this.props.isInDanger;
510
509
  var table = (0, _utils2.findTable)(view.state.selection);
510
+ if (!(0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.use-shared-state-hook')) {
511
+ var pluginState = (0, _pluginFactory.getPluginState)(view.state);
512
+ isInDanger = pluginState.isInDanger;
513
+ }
511
514
  if (isTableScalingEnabled) {
512
515
  this.handleColgroupUpdates();
513
516
  }
@@ -609,16 +612,24 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
609
612
  isDragAndDropEnabled = _this$props11.isDragAndDropEnabled,
610
613
  getEditorFeatureFlags = _this$props11.getEditorFeatureFlags,
611
614
  isTableScalingEnabled = _this$props11.isTableScalingEnabled;
615
+ var _this$props12 = this.props,
616
+ isInDanger = _this$props12.isInDanger,
617
+ hoveredRows = _this$props12.hoveredRows,
618
+ hoveredCell = _this$props12.hoveredCell,
619
+ isTableHovered = _this$props12.isTableHovered,
620
+ isWholeTableInDanger = _this$props12.isWholeTableInDanger;
612
621
  var _this$state3 = this.state,
613
622
  showBeforeShadow = _this$state3.showBeforeShadow,
614
623
  showAfterShadow = _this$state3.showAfterShadow;
615
624
  var node = getNode();
616
- // doesn't work well with WithPluginState
617
- var _getPluginState2 = (0, _pluginFactory.getPluginState)(view.state),
618
- isInDanger = _getPluginState2.isInDanger,
619
- hoveredRows = _getPluginState2.hoveredRows,
620
- hoveredCell = _getPluginState2.hoveredCell,
621
- isTableHovered = _getPluginState2.isTableHovered;
625
+ if (!(0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.use-shared-state-hook')) {
626
+ var pluginState = (0, _pluginFactory.getPluginState)(view.state);
627
+ isInDanger = pluginState.isInDanger;
628
+ hoveredRows = pluginState.hoveredRows;
629
+ hoveredCell = pluginState.hoveredCell;
630
+ isTableHovered = pluginState.isTableHovered;
631
+ isWholeTableInDanger = pluginState.isWholeTableInDanger;
632
+ }
622
633
  var tableRef = this.table || undefined;
623
634
  var headerRow = tableRef ? tableRef.querySelector('tr[data-header-row]') : undefined;
624
635
  var hasHeaderRow = (0, _utils5.containsHeaderRow)(node);
@@ -643,7 +654,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
643
654
  selection: view.state.selection,
644
655
  headerRowHeight: headerRow ? headerRow.offsetHeight : undefined,
645
656
  stickyHeader: this.state.stickyHeader,
646
- tableWrapperWidth: this.state.tableWrapperWidth
657
+ tableWrapperWidth: this.state.tableWrapperWidth,
658
+ api: pluginInjectionApi
647
659
  });
648
660
  var tableContainerWidth = (0, _nodeWidth.getTableContainerWidth)(node);
649
661
  var colControls = isDragAndDropEnabled ? /*#__PURE__*/_react.default.createElement(_TableFloatingColumnControls.default, {
@@ -670,7 +682,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
670
682
  var _this4$wrapper;
671
683
  return ((_this4$wrapper = _this4.wrapper) === null || _this4$wrapper === void 0 ? void 0 : _this4$wrapper.scrollLeft) || 0;
672
684
  },
673
- tableWrapperHeight: this.state.tableWrapperHeight
685
+ tableWrapperHeight: this.state.tableWrapperHeight,
686
+ api: pluginInjectionApi
674
687
  }) : null;
675
688
  var shadowPadding = allowControls && tableActive ? -_editorSharedStyles.akEditorTableToolbarSize : _styles.tableMarginSides;
676
689
  var shadowStyle = (0, _memoizeOne.default)(function (visible) {
@@ -707,7 +720,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
707
720
  tableWrapperHeight: this.state.tableWrapperHeight,
708
721
  isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled,
709
722
  isResizing: isResizing,
710
- isTableScalingEnabled: isTableScalingEnabled
723
+ isTableScalingEnabled: isTableScalingEnabled,
724
+ isWholeTableInDanger: isWholeTableInDanger
711
725
  }, /*#__PURE__*/_react.default.createElement("div", {
712
726
  className: _types.TableCssClassName.TABLE_STICKY_SENTINEL_TOP,
713
727
  "data-testid": "sticky-sentinel-top"
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.TableComponentWithSharedState = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _hooks = require("@atlaskit/editor-common/hooks");
10
+ var _editorTables = require("@atlaskit/editor-tables");
11
+ var _TableComponent = _interopRequireDefault(require("./TableComponent"));
12
+ /**
13
+ * Use useSharedPluginState to control re-renders from plugin dependencies
14
+ */
15
+ var TableComponentWithSharedState = exports.TableComponentWithSharedState = function TableComponentWithSharedState(_ref) {
16
+ var view = _ref.view,
17
+ options = _ref.options,
18
+ getNode = _ref.getNode,
19
+ dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
20
+ api = _ref.api,
21
+ getEditorFeatureFlags = _ref.getEditorFeatureFlags,
22
+ eventDispatcher = _ref.eventDispatcher,
23
+ allowColumnResizing = _ref.allowColumnResizing,
24
+ allowControls = _ref.allowControls,
25
+ getPos = _ref.getPos,
26
+ forwardRef = _ref.forwardRef;
27
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['width', 'table', 'media']),
28
+ widthState = _useSharedPluginState.widthState,
29
+ tableState = _useSharedPluginState.tableState,
30
+ mediaState = _useSharedPluginState.mediaState;
31
+ if (!tableState) {
32
+ return null;
33
+ }
34
+ var _ref2 = tableState,
35
+ isTableResizing = _ref2.isTableResizing,
36
+ isHeaderColumnEnabled = _ref2.isHeaderColumnEnabled,
37
+ isHeaderRowEnabled = _ref2.isHeaderRowEnabled,
38
+ ordering = _ref2.ordering,
39
+ isResizing = _ref2.isResizing,
40
+ isInDanger = _ref2.isInDanger,
41
+ hoveredCell = _ref2.hoveredCell,
42
+ hoveredRows = _ref2.hoveredRows,
43
+ isTableHovered = _ref2.isTableHovered,
44
+ isWholeTableInDanger = _ref2.isWholeTableInDanger;
45
+
46
+ /**
47
+ * ED-19810
48
+ * There is a getPos issue coming from this code. We need to apply this workaround for now and apply a patch
49
+ * directly to confluence since this bug is now in production.
50
+ */
51
+ var currentTablePos;
52
+ try {
53
+ currentTablePos = getPos ? getPos() : undefined;
54
+ } catch (e) {
55
+ currentTablePos = undefined;
56
+ }
57
+ var selectedTable = (0, _editorTables.findTable)(view.state.selection);
58
+ var tablePos = selectedTable && selectedTable.start - 1;
59
+ var tableActive = typeof currentTablePos === 'number' && typeof tablePos === 'number' && currentTablePos === tablePos && !isTableResizing;
60
+ return /*#__PURE__*/_react.default.createElement(_TableComponent.default, {
61
+ view: view,
62
+ allowColumnResizing: allowColumnResizing,
63
+ eventDispatcher: eventDispatcher,
64
+ getPos: getPos,
65
+ isMediaFullscreen: mediaState === null || mediaState === void 0 ? void 0 : mediaState.isFullscreen,
66
+ options: options,
67
+ allowControls: !!allowControls,
68
+ isHeaderRowEnabled: isHeaderRowEnabled,
69
+ isHeaderColumnEnabled: isHeaderColumnEnabled,
70
+ isDragAndDropEnabled: options === null || options === void 0 ? void 0 : options.isDragAndDropEnabled,
71
+ isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
72
+ tableActive: tableActive,
73
+ ordering: ordering,
74
+ isResizing: isResizing,
75
+ getNode: getNode,
76
+ containerWidth: widthState,
77
+ contentDOM: forwardRef,
78
+ getEditorFeatureFlags: getEditorFeatureFlags,
79
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
80
+ pluginInjectionApi: api,
81
+ isInDanger: !!isInDanger,
82
+ hoveredRows: hoveredRows,
83
+ hoveredCell: hoveredCell,
84
+ isTableHovered: isTableHovered,
85
+ isWholeTableInDanger: isWholeTableInDanger
86
+ });
87
+ };
@@ -10,6 +10,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
10
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
11
  var _react = _interopRequireWildcard(require("react"));
12
12
  var _classnames = _interopRequireDefault(require("classnames"));
13
+ var _hooks = require("@atlaskit/editor-common/hooks");
13
14
  var _nodeWidth = require("@atlaskit/editor-common/node-width");
14
15
  var _styles = require("@atlaskit/editor-common/styles");
15
16
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
@@ -42,10 +43,11 @@ var InnerContainer = exports.InnerContainer = /*#__PURE__*/(0, _react.forwardRef
42
43
  className: className,
43
44
  "data-number-column": node.attrs.isNumberColumnEnabled,
44
45
  "data-layout": node.attrs.layout,
45
- "data-test-id": "table-container"
46
+ "data-testid": "table-container"
46
47
  }, children);
47
48
  });
48
49
  var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_react.default.memo(function (_ref2) {
50
+ var _node$attrs$localId, _node$attrs;
49
51
  var children = _ref2.children,
50
52
  className = _ref2.className,
51
53
  node = _ref2.node,
@@ -56,7 +58,8 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
56
58
  isResizing = _ref2.isResizing,
57
59
  pluginInjectionApi = _ref2.pluginInjectionApi,
58
60
  isTableScalingEnabled = _ref2.isTableScalingEnabled,
59
- tableWrapperHeight = _ref2.tableWrapperHeight;
61
+ tableWrapperHeight = _ref2.tableWrapperHeight,
62
+ isWholeTableInDanger = _ref2.isWholeTableInDanger;
60
63
  var containerRef = (0, _react.useRef)(null);
61
64
  var tableWidthRef = (0, _react.useRef)(_editorSharedStyles.akEditorDefaultLayoutWidth);
62
65
  var _useState = (0, _react.useState)(false),
@@ -116,9 +119,18 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
116
119
  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;
117
120
  }, [pluginInjectionApi]);
118
121
  var tableWidth = (0, _nodeWidth.getTableContainerWidth)(node);
122
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['table']),
123
+ tableState = _useSharedPluginState.tableState;
124
+ var _ref3 = tableState,
125
+ widthToWidest = _ref3.widthToWidest;
126
+ 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 : '';
127
+
119
128
  // 76 is currently an accepted padding value considering the spacing for resizer handle
120
129
  var responsiveContainerWidth = isTableScalingEnabled ? containerWidth - _editorSharedStyles.akEditorGutterPadding * 2 - _editorSharedStyles.akEditorMediaResizeHandlerPaddingWide / 2 : containerWidth - _editorSharedStyles.akEditorGutterPadding * 2 - _editorSharedStyles.akEditorMediaResizeHandlerPaddingWide;
121
130
  var width = Math.min(tableWidth, responsiveContainerWidth);
131
+ if (isTableScalingEnabled && currentTableNodeLocalId && widthToWidest && widthToWidest[currentTableNodeLocalId]) {
132
+ width = _utils.TABLE_MAX_WIDTH;
133
+ }
122
134
  if (!isResizing) {
123
135
  tableWidthRef.current = width;
124
136
  }
@@ -135,7 +147,9 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
135
147
  displayGuideline: displayGuideline,
136
148
  attachAnalyticsEvent: attachAnalyticsEvent,
137
149
  displayGapCursor: displayGapCursor,
138
- isTableScalingEnabled: isTableScalingEnabled
150
+ isTableScalingEnabled: isTableScalingEnabled,
151
+ isWholeTableInDanger: isWholeTableInDanger,
152
+ pluginInjectionApi: pluginInjectionApi
139
153
  };
140
154
  if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.resizing-table-height-improvement')) {
141
155
  tableResizerProps = _objectSpread(_objectSpread({}, tableResizerProps), {}, {
@@ -160,23 +174,24 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
160
174
  node: node
161
175
  }, children))));
162
176
  });
163
- var TableContainer = exports.TableContainer = function TableContainer(_ref3) {
164
- var children = _ref3.children,
165
- node = _ref3.node,
166
- className = _ref3.className,
167
- _ref3$containerWidth = _ref3.containerWidth,
168
- lineLength = _ref3$containerWidth.lineLength,
169
- editorWidth = _ref3$containerWidth.width,
170
- isTableResizingEnabled = _ref3.isTableResizingEnabled,
171
- isBreakoutEnabled = _ref3.isBreakoutEnabled,
172
- editorView = _ref3.editorView,
173
- getPos = _ref3.getPos,
174
- tableRef = _ref3.tableRef,
175
- isNested = _ref3.isNested,
176
- tableWrapperHeight = _ref3.tableWrapperHeight,
177
- isResizing = _ref3.isResizing,
178
- pluginInjectionApi = _ref3.pluginInjectionApi,
179
- isTableScalingEnabled = _ref3.isTableScalingEnabled;
177
+ var TableContainer = exports.TableContainer = function TableContainer(_ref4) {
178
+ var children = _ref4.children,
179
+ node = _ref4.node,
180
+ className = _ref4.className,
181
+ _ref4$containerWidth = _ref4.containerWidth,
182
+ lineLength = _ref4$containerWidth.lineLength,
183
+ editorWidth = _ref4$containerWidth.width,
184
+ isTableResizingEnabled = _ref4.isTableResizingEnabled,
185
+ isBreakoutEnabled = _ref4.isBreakoutEnabled,
186
+ editorView = _ref4.editorView,
187
+ getPos = _ref4.getPos,
188
+ tableRef = _ref4.tableRef,
189
+ isNested = _ref4.isNested,
190
+ tableWrapperHeight = _ref4.tableWrapperHeight,
191
+ isResizing = _ref4.isResizing,
192
+ pluginInjectionApi = _ref4.pluginInjectionApi,
193
+ isTableScalingEnabled = _ref4.isTableScalingEnabled,
194
+ isWholeTableInDanger = _ref4.isWholeTableInDanger;
180
195
  if (isTableResizingEnabled && !isNested) {
181
196
  return /*#__PURE__*/_react.default.createElement(ResizableTableContainer, {
182
197
  className: className,
@@ -188,7 +203,8 @@ var TableContainer = exports.TableContainer = function TableContainer(_ref3) {
188
203
  tableWrapperHeight: tableWrapperHeight,
189
204
  isResizing: isResizing,
190
205
  pluginInjectionApi: pluginInjectionApi,
191
- isTableScalingEnabled: isTableScalingEnabled
206
+ isTableScalingEnabled: isTableScalingEnabled,
207
+ isWholeTableInDanger: isWholeTableInDanger
192
208
  }, children);
193
209
  }
194
210
  var tableWidth = isBreakoutEnabled ? (0, _styles.calcTableWidth)(node.attrs.layout, editorWidth) : 'inherit';
@@ -14,15 +14,14 @@ var _rafSchd = _interopRequireDefault(require("raf-schd"));
14
14
  var _reactIntlNext = require("react-intl-next");
15
15
  var _analytics = require("@atlaskit/editor-common/analytics");
16
16
  var _guideline = require("@atlaskit/editor-common/guideline");
17
+ var _hooks = require("@atlaskit/editor-common/hooks");
17
18
  var _keymaps = require("@atlaskit/editor-common/keymaps");
18
19
  var _messages = require("@atlaskit/editor-common/messages");
19
20
  var _resizer = require("@atlaskit/editor-common/resizer");
20
21
  var _utils = require("@atlaskit/editor-common/utils");
21
- var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
22
22
  var _utils2 = require("@atlaskit/editor-tables/utils");
23
23
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
24
24
  var _misc = require("../commands/misc");
25
- var _pluginFactory = require("../pm-plugins/plugin-factory");
26
25
  var _tableAnalytics = require("../pm-plugins/table-analytics");
27
26
  var _utils3 = require("../pm-plugins/table-resizing/utils");
28
27
  var _tableWidth = require("../pm-plugins/table-width");
@@ -100,28 +99,38 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
100
99
  displayGuideline = _ref.displayGuideline,
101
100
  attachAnalyticsEvent = _ref.attachAnalyticsEvent,
102
101
  displayGapCursor = _ref.displayGapCursor,
103
- isTableScalingEnabled = _ref.isTableScalingEnabled;
102
+ isTableScalingEnabled = _ref.isTableScalingEnabled,
103
+ isWholeTableInDanger = _ref.isWholeTableInDanger,
104
+ pluginInjectionApi = _ref.pluginInjectionApi;
104
105
  var currentGap = (0, _react.useRef)(0);
105
106
  // track resizing state - use ref over state to avoid re-render
106
107
  var isResizing = (0, _react.useRef)(false);
107
108
  var areResizeMetaKeysPressed = (0, _react.useRef)(false);
109
+ var _useState = (0, _react.useState)(width),
110
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
111
+ localTableWidth = _useState2[0],
112
+ setLocalTableWidth = _useState2[1];
108
113
  var resizerRef = (0, _react.useRef)(null);
114
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['table']),
115
+ tableState = _useSharedPluginState.tableState;
116
+ var _ref2 = tableState,
117
+ widthToWidest = _ref2.widthToWidest;
109
118
 
110
119
  // used to reposition tooltip when table is resizing via keyboard
111
120
  var updateTooltip = _react.default.useRef();
112
- var _useState = (0, _react.useState)(false),
113
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
114
- snappingEnabled = _useState2[0],
115
- setSnappingEnabled = _useState2[1];
121
+ var _useState3 = (0, _react.useState)(false),
122
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
123
+ snappingEnabled = _useState4[0],
124
+ setSnappingEnabled = _useState4[1];
116
125
 
117
126
  // we don't want to update aria-live region on each width change, it might provide bad experience for screen reader users
118
- var _useState3 = (0, _react.useState)({
127
+ var _useState5 = (0, _react.useState)({
119
128
  type: 'none',
120
129
  width: width
121
130
  }),
122
- _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
123
- screenReaderResizeInformation = _useState4[0],
124
- setScreenReaderResizeInformation = _useState4[1];
131
+ _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
132
+ screenReaderResizeInformation = _useState6[0],
133
+ setScreenReaderResizeInformation = _useState6[1];
125
134
  var _useIntl = (0, _reactIntlNext.useIntl)(),
126
135
  formatMessage = _useIntl.formatMessage;
127
136
  var screenReaderResizeAnnouncerMessages = {
@@ -136,15 +145,13 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
136
145
  var isTableSelected = ((_findTable = (0, _utils2.findTable)((_editorView$state = editorView.state) === null || _editorView$state === void 0 ? void 0 : _editorView$state.selection)) === null || _findTable === void 0 ? void 0 : _findTable.pos) === getPos();
137
146
  var resizerMinWidth = getResizerMinWidth(node);
138
147
  var handleSize = getResizerHandleHeight(tableRef);
139
- var _getPluginState = (0, _pluginFactory.getPluginState)(editorView.state),
140
- isWholeTableInDanger = _getPluginState.isWholeTableInDanger;
141
148
  var _useMeasureFramerate = (0, _analytics2.useMeasureFramerate)(),
142
149
  startMeasure = _useMeasureFramerate.startMeasure,
143
150
  endMeasure = _useMeasureFramerate.endMeasure,
144
151
  countFrames = _useMeasureFramerate.countFrames;
145
- var updateActiveGuidelines = (0, _react.useCallback)(function (_ref2) {
146
- var gap = _ref2.gap,
147
- keys = _ref2.keys;
152
+ var updateActiveGuidelines = (0, _react.useCallback)(function (_ref3) {
153
+ var gap = _ref3.gap,
154
+ keys = _ref3.keys;
148
155
  if (gap !== currentGap.current) {
149
156
  currentGap.current = gap;
150
157
  var visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? (0, _guidelines.defaultGuidelinesForPreserveTable)(containerWidth) : _guidelines.defaultGuidelines, containerWidth);
@@ -192,7 +199,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
192
199
  }
193
200
  }, [startMeasure, editorView, displayGapCursor, isTableScalingEnabled, containerWidth, displayGuideline, onResizeStart]);
194
201
  var handleResize = (0, _react.useCallback)(function (originalState, delta) {
195
- var _defaultGuidelinesFor;
202
+ var _node$attrs$localId, _node$attrs, _widestGuideline$posi;
196
203
  countFrames();
197
204
  var newWidth = originalState.width + delta.width;
198
205
  var pos;
@@ -217,25 +224,29 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
217
224
  // set the width of the table to 1800 pixels.
218
225
  var state = editorView.state,
219
226
  dispatch = editorView.dispatch;
220
- var widestGuideLineWidthString = (_defaultGuidelinesFor = (0, _guidelines.defaultGuidelinesForPreserveTable)(containerWidth)[16].key) === null || _defaultGuidelinesFor === void 0 || (_defaultGuidelinesFor = _defaultGuidelinesFor.match(/[\d]*[.]{0,1}[\d]+/g)) === null || _defaultGuidelinesFor === void 0 ? void 0 : _defaultGuidelinesFor.join('');
221
- var widestGuideLineWidth = parseInt(widestGuideLineWidthString || '', 10);
222
- var shouldUpdateWidthToWidest = !!(isTableScalingEnabled && (0, _guidelines.defaultGuidelinesForPreserveTable)(containerWidth).length === 17 && widestGuideLineWidth - newWidth <= 1);
223
- (0, _misc.updateWidthToWidest)(shouldUpdateWidthToWidest)(state, dispatch);
224
- updateWidth(shouldUpdateWidthToWidest ? _editorSharedStyles.akEditorFullWidthLayoutWidth : newWidth);
227
+ 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 : '';
228
+ var widestGuideline = (0, _guidelines.defaultGuidelinesForPreserveTable)(containerWidth).filter(function (guideline) {
229
+ return guideline.isFullWidth;
230
+ })[0];
231
+ var widestGuideLineWidth = widestGuideline ? (((_widestGuideline$posi = widestGuideline.position) === null || _widestGuideline$posi === void 0 ? void 0 : _widestGuideline$posi.x) || 0) * 2 : null;
232
+ var shouldUpdateWidthToWidest = !!(isTableScalingEnabled && widestGuideLineWidth && Math.abs(widestGuideLineWidth - newWidth) <= 1);
233
+ shouldUpdateWidthToWidest ? setLocalTableWidth(_utils3.TABLE_MAX_WIDTH) : setLocalTableWidth(newWidth);
234
+ (0, _misc.updateWidthToWidest)((0, _defineProperty2.default)({}, currentTableNodeLocalId, shouldUpdateWidthToWidest))(state, dispatch);
235
+ updateWidth(shouldUpdateWidthToWidest ? _utils3.TABLE_MAX_WIDTH : newWidth);
225
236
  return newWidth;
226
237
  }, [countFrames, isTableScalingEnabled, tableRef, node, editorView, updateActiveGuidelines, containerWidth, updateWidth, getPos]);
227
238
  var scheduleResize = (0, _react.useMemo)(function () {
228
239
  return (0, _rafSchd.default)(handleResize);
229
240
  }, [handleResize]);
230
241
  var handleResizeStop = (0, _react.useCallback)(function (originalState, delta) {
242
+ var _node$attrs$localId2, _node$attrs2;
231
243
  isResizing.current = false;
232
244
  var newWidth = originalState.width + delta.width;
233
245
  var state = editorView.state,
234
246
  dispatch = editorView.dispatch;
235
247
  var pos = getPos();
236
- var _getPluginState2 = (0, _pluginFactory.getPluginState)(editorView.state),
237
- widthToWidest = _getPluginState2.widthToWidest;
238
- newWidth = widthToWidest ? _editorSharedStyles.akEditorFullWidthLayoutWidth : newWidth;
248
+ 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 : '';
249
+ newWidth = widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId] ? _utils3.TABLE_MAX_WIDTH : newWidth;
239
250
  var tr = state.tr.setMeta(_tableWidth.pluginKey, {
240
251
  resizing: false
241
252
  });
@@ -280,7 +291,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
280
291
  onResizeStop();
281
292
  }
282
293
  return newWidth;
283
- }, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop, isTableScalingEnabled]);
294
+ }, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop, isTableScalingEnabled, widthToWidest]);
284
295
  var handleTableSizeChangeOnKeypress = (0, _react.useCallback)(function (step) {
285
296
  var newWidth = width + step;
286
297
  if (newWidth > maxWidth || newWidth < resizerMinWidth) {
@@ -385,7 +396,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
385
396
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_resizer.ResizerNext, {
386
397
  ref: resizerRef,
387
398
  enable: handles,
388
- width: width,
399
+ width: localTableWidth,
389
400
  handleAlignmentMethod: "sticky",
390
401
  handleSize: handleSize,
391
402
  handleStyles: handleStyles,
@@ -402,8 +413,8 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
402
413
  needExtendedResizeZone: !isTableSelected,
403
414
  appearance: isTableSelected && isWholeTableInDanger ? 'danger' : undefined,
404
415
  handleHighlight: "shadow",
405
- handleTooltipContent: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-table-resizing_uapcv') ? function (_ref3) {
406
- var update = _ref3.update;
416
+ handleTooltipContent: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-table-resizing_uapcv') ? function (_ref4) {
417
+ var update = _ref4.update;
407
418
  updateTooltip.current = update;
408
419
  return /*#__PURE__*/_react.default.createElement(_keymaps.ToolTipContent, {
409
420
  description: formatMessage(_messages.tableMessages.resizeTable),
@@ -22,6 +22,7 @@ var _withPluginState = require("@atlaskit/editor-common/with-plugin-state");
22
22
  var _model = require("@atlaskit/editor-prosemirror/model");
23
23
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
24
24
  var _tableMap = require("@atlaskit/editor-tables/table-map");
25
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
25
26
  var _createPluginConfig = require("../create-plugin-config");
26
27
  var _dragAndDrop = require("../pm-plugins/drag-and-drop");
27
28
  var _pluginFactory = require("../pm-plugins/plugin-factory");
@@ -31,6 +32,7 @@ var _utils = require("../pm-plugins/table-resizing/utils");
31
32
  var _tableWidth = require("../pm-plugins/table-width");
32
33
  var _utils2 = require("../utils");
33
34
  var _TableComponent = _interopRequireDefault(require("./TableComponent"));
35
+ var _TableComponentWithSharedState = require("./TableComponentWithSharedState");
34
36
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
35
37
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
36
38
  var tableAttributes = function tableAttributes(node) {
@@ -123,6 +125,22 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
123
125
  key: "render",
124
126
  value: function render(props, forwardRef) {
125
127
  var _this3 = this;
128
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.use-shared-state-hook')) {
129
+ return /*#__PURE__*/_react.default.createElement(_TableComponentWithSharedState.TableComponentWithSharedState, {
130
+ forwardRef: forwardRef,
131
+ getNode: this.getNode,
132
+ view: props.view,
133
+ options: props.options,
134
+ eventDispatcher: props.eventDispatcher,
135
+ api: props.pluginInjectionApi,
136
+ allowColumnResizing: props.allowColumnResizing,
137
+ allowControls: props.allowControls,
138
+ getPos: props.getPos,
139
+ getEditorFeatureFlags: props.getEditorFeatureFlags,
140
+ dispatchAnalyticsEvent: props.dispatchAnalyticsEvent
141
+ });
142
+ }
143
+
126
144
  // TODO: ED-15663
127
145
  // Please, do not copy or use this kind of code below
128
146
  // @ts-ignore
@@ -268,12 +286,14 @@ var createTableView = exports.createTableView = function createTableView(node, v
268
286
  isDragAndDropEnabled = _getPluginState2.isDragAndDropEnabled,
269
287
  isTableScalingEnabled = _getPluginState2.isTableScalingEnabled;
270
288
  var _getPluginConfig = (0, _createPluginConfig.pluginConfig)(pluginConfig),
271
- allowColumnResizing = _getPluginConfig.allowColumnResizing;
289
+ allowColumnResizing = _getPluginConfig.allowColumnResizing,
290
+ allowControls = _getPluginConfig.allowControls;
272
291
  var hasIntlContext = true;
273
292
  return new TableView({
274
293
  node: node,
275
294
  view: view,
276
295
  allowColumnResizing: allowColumnResizing,
296
+ allowControls: allowControls,
277
297
  portalProviderAPI: portalProviderAPI,
278
298
  eventDispatcher: eventDispatcher,
279
299
  getPos: getPos,
@@ -45,6 +45,9 @@ var _utils2 = require("./utils");
45
45
  var defaultGetEditorFeatureFlags = function defaultGetEditorFeatureFlags() {
46
46
  return {};
47
47
  };
48
+
49
+ // TODO: duplicating type instead of importing media plugin causing a circular dependency
50
+
48
51
  /**
49
52
  * Table plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
50
53
  * from `@atlaskit/editor-core`.
@@ -67,10 +70,30 @@ var tablesPlugin = function tablesPlugin(_ref) {
67
70
  name: 'table',
68
71
  // Use getSharedState to store fullWidthEnabled and wasFullWidthModeEnabled to guarantee access
69
72
  // to most up to date values - passing to createPluginState will not re-initialise the state
70
- getSharedState: function getSharedState() {
73
+ getSharedState: function getSharedState(editorState) {
74
+ if (!editorState) {
75
+ return undefined;
76
+ }
77
+ var tablePluginState = (0, _pluginFactory.getPluginState)(editorState);
78
+ var tableResizingPluginState = (0, _tableResizing.getPluginState)(editorState);
79
+ var tableWidthResizingPluginState = _tableWidth.pluginKey.getState(editorState);
71
80
  return {
72
81
  isFullWidthModeEnabled: !!(options !== null && options !== void 0 && options.fullWidthEnabled),
73
- wasFullWidthModeEnabled: !!(options !== null && options !== void 0 && options.wasFullWidthEnabled)
82
+ wasFullWidthModeEnabled: !!(options !== null && options !== void 0 && options.wasFullWidthEnabled),
83
+ isHeaderRowEnabled: tablePluginState.isHeaderRowEnabled,
84
+ isHeaderColumnEnabled: tablePluginState.isHeaderColumnEnabled,
85
+ ordering: tablePluginState.ordering,
86
+ isResizing: !!(tableResizingPluginState !== null && tableResizingPluginState !== void 0 && tableResizingPluginState.dragging || tableWidthResizingPluginState !== null && tableWidthResizingPluginState !== void 0 && tableWidthResizingPluginState.resizing),
87
+ isTableResizing: tableWidthResizingPluginState === null || tableWidthResizingPluginState === void 0 ? void 0 : tableWidthResizingPluginState.resizing,
88
+ isInDanger: tablePluginState.isInDanger,
89
+ hoveredRows: tablePluginState.hoveredRows,
90
+ hoveredCell: tablePluginState.hoveredCell,
91
+ isTableHovered: tablePluginState.isTableHovered,
92
+ isWholeTableInDanger: tablePluginState.isWholeTableInDanger,
93
+ // IMPORTANT: Need to continue to pass tableNode to control re-renders
94
+ // TableComponent listens for node attribute changes to update colgroups
95
+ tableNode: tablePluginState.tableNode,
96
+ widthToWidest: tablePluginState.widthToWidest
74
97
  };
75
98
  },
76
99
  actions: {
@@ -22,7 +22,6 @@ var _utils3 = require("@atlaskit/editor-tables/utils");
22
22
  var _layoutThreeEqual = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/layout-three-equal"));
23
23
  var _remove = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/remove"));
24
24
  var _preferences = _interopRequireDefault(require("@atlaskit/icon/glyph/preferences"));
25
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
26
25
  var _commands = require("./commands");
27
26
  var _commandsWithAnalytics = require("./commands-with-analytics");
28
27
  var _pluginFactory = require("./pm-plugins/plugin-factory");
@@ -65,7 +64,7 @@ var getToolbarMenuConfig = exports.getToolbarMenuConfig = function getToolbarMen
65
64
  disabled: !state.canCollapseTable,
66
65
  hidden: !config.allowCollapse
67
66
  }];
68
- if (state.isDragAndDropEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.new-cell-context-menu-styling')) {
67
+ if (state.isDragAndDropEnabled) {
69
68
  return {
70
69
  id: 'editor.table.tableOptions',
71
70
  type: 'dropdown',
@@ -301,6 +300,7 @@ var getClosestSelectionOrTableRect = exports.getClosestSelectionOrTableRect = fu
301
300
  var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView) {
302
301
  return function (config) {
303
302
  return function (state, intl) {
303
+ var _tableObject$node$att, _tableObject$node;
304
304
  var tableObject = (0, _utils3.findTable)(state.selection);
305
305
  var pluginState = (0, _pluginFactory.getPluginState)(state);
306
306
  var resizeState = _tableResizing.pluginKey.getState(state);
@@ -310,7 +310,8 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
310
310
  var isWidthResizing = tableWidthState === null || tableWidthState === void 0 ? void 0 : tableWidthState.resizing;
311
311
  var isTableScalingEnabled = pluginState.isTableScalingEnabled,
312
312
  widthToWidest = pluginState.widthToWidest;
313
- if (isTableScalingEnabled && isWidthResizing && widthToWidest) {
313
+ 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 : '';
314
+ if (isTableScalingEnabled && isWidthResizing && widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId]) {
314
315
  var _getEditorFeatureFlag = getEditorFeatureFlags(),
315
316
  stickyScrollbar = _getEditorFeatureFlag.stickyScrollbar;
316
317
  var nodeType = state.schema.nodes.table;
@@ -362,7 +363,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
362
363
  var cellItems;
363
364
  cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, _isTableScalingEnabled);
364
365
  var columnSettingsItems;
365
- columnSettingsItems = pluginState.isDragAndDropEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.new-cell-context-menu-styling') ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, _isTableScalingEnabled) : [];
366
+ columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, _isTableScalingEnabled) : [];
366
367
  var colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI);
367
368
 
368
369
  // Check if we need to show confirm dialog for delete button
package/dist/cjs/types.js CHANGED
@@ -16,6 +16,9 @@ var RESIZE_HANDLE_AREA_DECORATION_GAP = exports.RESIZE_HANDLE_AREA_DECORATION_GA
16
16
  * @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-6877 Internal documentation for deprecation (no external access)}
17
17
  **/
18
18
 
19
+ // override getPluginState but do not expose publicly as this type is experimental and will change
20
+ // in the future
21
+
19
22
  /*
20
23
  * This type represents the start and end from a cell in a column,
21
24
  * for example, on this table the cell C1 will have