@atlaskit/editor-plugin-table 7.6.3 → 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 (45) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/commands/misc.js +3 -2
  3. package/dist/cjs/nodeviews/TableContainer.js +32 -20
  4. package/dist/cjs/nodeviews/TableResizer.js +39 -27
  5. package/dist/cjs/plugin.js +2 -1
  6. package/dist/cjs/toolbar.js +5 -4
  7. package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +16 -16
  8. package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +3 -3
  9. package/dist/cjs/ui/FloatingDragMenu/DropdownMenu.js +21 -28
  10. package/dist/cjs/utils/guidelines.js +1 -1
  11. package/dist/es2019/commands/misc.js +6 -2
  12. package/dist/es2019/nodeviews/TableContainer.js +17 -3
  13. package/dist/es2019/nodeviews/TableResizer.js +26 -16
  14. package/dist/es2019/plugin.js +2 -1
  15. package/dist/es2019/toolbar.js +5 -4
  16. package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +16 -16
  17. package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +3 -3
  18. package/dist/es2019/ui/FloatingDragMenu/DropdownMenu.js +20 -27
  19. package/dist/es2019/utils/guidelines.js +1 -1
  20. package/dist/esm/commands/misc.js +3 -2
  21. package/dist/esm/nodeviews/TableContainer.js +32 -20
  22. package/dist/esm/nodeviews/TableResizer.js +40 -28
  23. package/dist/esm/plugin.js +2 -1
  24. package/dist/esm/toolbar.js +5 -4
  25. package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +16 -16
  26. package/dist/esm/ui/FloatingDragMenu/DragMenu.js +3 -3
  27. package/dist/esm/ui/FloatingDragMenu/DropdownMenu.js +21 -28
  28. package/dist/esm/utils/guidelines.js +1 -1
  29. package/dist/types/commands/misc.d.ts +2 -1
  30. package/dist/types/nodeviews/TableResizer.d.ts +3 -1
  31. package/dist/types/types.d.ts +6 -3
  32. package/dist/types-ts4.5/commands/misc.d.ts +2 -1
  33. package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +3 -1
  34. package/dist/types-ts4.5/types.d.ts +6 -3
  35. package/package.json +2 -5
  36. package/src/commands/misc.ts +6 -3
  37. package/src/nodeviews/TableContainer.tsx +18 -3
  38. package/src/nodeviews/TableResizer.tsx +34 -20
  39. package/src/plugin.tsx +1 -0
  40. package/src/toolbar.tsx +20 -19
  41. package/src/types.ts +6 -2
  42. package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +66 -112
  43. package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -12
  44. package/src/ui/FloatingDragMenu/DropdownMenu.tsx +19 -28
  45. package/src/utils/guidelines.ts +5 -4
@@ -1,5 +1,6 @@
1
1
  import React, { forwardRef, useCallback, useRef, useState } from 'react';
2
2
  import classNames from 'classnames';
3
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
4
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
4
5
  import { calcTableWidth } from '@atlaskit/editor-common/styles';
5
6
  import { akEditorDefaultLayoutWidth, akEditorGutterPadding, akEditorMediaResizeHandlerPaddingWide, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
@@ -29,7 +30,7 @@ export const InnerContainer = /*#__PURE__*/forwardRef(({
29
30
  className: className,
30
31
  "data-number-column": node.attrs.isNumberColumnEnabled,
31
32
  "data-layout": node.attrs.layout,
32
- "data-test-id": "table-container"
33
+ "data-testid": "table-container"
33
34
  }, children);
34
35
  });
35
36
  export const ResizableTableContainer = /*#__PURE__*/React.memo(({
@@ -46,6 +47,7 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
46
47
  tableWrapperHeight,
47
48
  isWholeTableInDanger
48
49
  }) => {
50
+ var _node$attrs$localId, _node$attrs;
49
51
  const containerRef = useRef(null);
50
52
  const tableWidthRef = useRef(akEditorDefaultLayoutWidth);
51
53
  const [resizing, setIsResizing] = useState(false);
@@ -102,9 +104,20 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
102
104
  return (_pluginInjectionApi$c = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c2 = pluginInjectionApi.core) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? 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;
103
105
  }, [pluginInjectionApi]);
104
106
  const tableWidth = getTableContainerWidth(node);
107
+ const {
108
+ tableState
109
+ } = useSharedPluginState(pluginInjectionApi, ['table']);
110
+ const {
111
+ widthToWidest
112
+ } = tableState;
113
+ const currentTableNodeLocalId = (_node$attrs$localId = node === null || node === void 0 ? 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 : '';
114
+
105
115
  // 76 is currently an accepted padding value considering the spacing for resizer handle
106
116
  const responsiveContainerWidth = isTableScalingEnabled ? containerWidth - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide / 2 : containerWidth - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide;
107
- const width = Math.min(tableWidth, responsiveContainerWidth);
117
+ let width = Math.min(tableWidth, responsiveContainerWidth);
118
+ if (isTableScalingEnabled && currentTableNodeLocalId && widthToWidest && widthToWidest[currentTableNodeLocalId]) {
119
+ width = TABLE_MAX_WIDTH;
120
+ }
108
121
  if (!isResizing) {
109
122
  tableWidthRef.current = width;
110
123
  }
@@ -122,7 +135,8 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
122
135
  attachAnalyticsEvent,
123
136
  displayGapCursor,
124
137
  isTableScalingEnabled,
125
- isWholeTableInDanger
138
+ isWholeTableInDanger,
139
+ pluginInjectionApi
126
140
  };
127
141
  if (getBooleanFF('platform.editor.resizing-table-height-improvement')) {
128
142
  tableResizerProps = {
@@ -4,17 +4,16 @@ import rafSchd from 'raf-schd';
4
4
  import { useIntl } from 'react-intl-next';
5
5
  import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
6
6
  import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
7
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
7
8
  import { focusTableResizer, ToolTipContent } from '@atlaskit/editor-common/keymaps';
8
9
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
9
10
  import { ResizerNext } from '@atlaskit/editor-common/resizer';
10
11
  import { browser } from '@atlaskit/editor-common/utils';
11
- import { akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
12
12
  import { findTable } from '@atlaskit/editor-tables/utils';
13
13
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
14
14
  import { updateWidthToWidest } from '../commands/misc';
15
- import { getPluginState } from '../pm-plugins/plugin-factory';
16
15
  import { META_KEYS } from '../pm-plugins/table-analytics';
17
- import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTable } from '../pm-plugins/table-resizing/utils';
16
+ import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTable, TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
18
17
  import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
19
18
  import { TABLE_GUIDELINE_VISIBLE_ADJUSTMENT, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE, TABLE_SNAP_GAP } from '../ui/consts';
20
19
  import { generateResizedPayload, generateResizeFrameRatePayloads, useMeasureFramerate } from '../utils/analytics';
@@ -86,14 +85,22 @@ export const TableResizer = ({
86
85
  attachAnalyticsEvent,
87
86
  displayGapCursor,
88
87
  isTableScalingEnabled,
89
- isWholeTableInDanger
88
+ isWholeTableInDanger,
89
+ pluginInjectionApi
90
90
  }) => {
91
91
  var _findTable, _editorView$state;
92
92
  const currentGap = useRef(0);
93
93
  // track resizing state - use ref over state to avoid re-render
94
94
  const isResizing = useRef(false);
95
95
  const areResizeMetaKeysPressed = useRef(false);
96
+ const [localTableWidth, setLocalTableWidth] = useState(width);
96
97
  const resizerRef = useRef(null);
98
+ const {
99
+ tableState
100
+ } = useSharedPluginState(pluginInjectionApi, ['table']);
101
+ const {
102
+ widthToWidest
103
+ } = tableState;
97
104
 
98
105
  // used to reposition tooltip when table is resizing via keyboard
99
106
  const updateTooltip = React.useRef();
@@ -181,7 +188,7 @@ export const TableResizer = ({
181
188
  }
182
189
  }, [startMeasure, editorView, displayGapCursor, isTableScalingEnabled, containerWidth, displayGuideline, onResizeStart]);
183
190
  const handleResize = useCallback((originalState, delta) => {
184
- var _defaultGuidelinesFor, _defaultGuidelinesFor2;
191
+ var _node$attrs$localId, _node$attrs, _widestGuideline$posi;
185
192
  countFrames();
186
193
  const newWidth = originalState.width + delta.width;
187
194
  let pos;
@@ -208,15 +215,20 @@ export const TableResizer = ({
208
215
  state,
209
216
  dispatch
210
217
  } = editorView;
211
- const widestGuideLineWidthString = (_defaultGuidelinesFor = defaultGuidelinesForPreserveTable(containerWidth)[16].key) === null || _defaultGuidelinesFor === void 0 ? void 0 : (_defaultGuidelinesFor2 = _defaultGuidelinesFor.match(/[\d]*[.]{0,1}[\d]+/g)) === null || _defaultGuidelinesFor2 === void 0 ? void 0 : _defaultGuidelinesFor2.join('');
212
- const widestGuideLineWidth = parseInt(widestGuideLineWidthString || '', 10);
213
- const shouldUpdateWidthToWidest = !!(isTableScalingEnabled && defaultGuidelinesForPreserveTable(containerWidth).length === 17 && widestGuideLineWidth - newWidth <= 1);
214
- updateWidthToWidest(shouldUpdateWidthToWidest)(state, dispatch);
215
- updateWidth(shouldUpdateWidthToWidest ? akEditorFullWidthLayoutWidth : newWidth);
218
+ const currentTableNodeLocalId = (_node$attrs$localId = node === null || node === void 0 ? 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 : '';
219
+ const widestGuideline = defaultGuidelinesForPreserveTable(containerWidth).filter(guideline => guideline.isFullWidth)[0];
220
+ const widestGuideLineWidth = widestGuideline ? (((_widestGuideline$posi = widestGuideline.position) === null || _widestGuideline$posi === void 0 ? void 0 : _widestGuideline$posi.x) || 0) * 2 : null;
221
+ const shouldUpdateWidthToWidest = !!(isTableScalingEnabled && widestGuideLineWidth && Math.abs(widestGuideLineWidth - newWidth) <= 1);
222
+ shouldUpdateWidthToWidest ? setLocalTableWidth(TABLE_MAX_WIDTH) : setLocalTableWidth(newWidth);
223
+ updateWidthToWidest({
224
+ [currentTableNodeLocalId]: shouldUpdateWidthToWidest
225
+ })(state, dispatch);
226
+ updateWidth(shouldUpdateWidthToWidest ? TABLE_MAX_WIDTH : newWidth);
216
227
  return newWidth;
217
228
  }, [countFrames, isTableScalingEnabled, tableRef, node, editorView, updateActiveGuidelines, containerWidth, updateWidth, getPos]);
218
229
  const scheduleResize = useMemo(() => rafSchd(handleResize), [handleResize]);
219
230
  const handleResizeStop = useCallback((originalState, delta) => {
231
+ var _node$attrs$localId2, _node$attrs2;
220
232
  isResizing.current = false;
221
233
  let newWidth = originalState.width + delta.width;
222
234
  const {
@@ -224,10 +236,8 @@ export const TableResizer = ({
224
236
  dispatch
225
237
  } = editorView;
226
238
  const pos = getPos();
227
- const {
228
- widthToWidest
229
- } = getPluginState(editorView.state);
230
- newWidth = widthToWidest ? akEditorFullWidthLayoutWidth : newWidth;
239
+ const currentTableNodeLocalId = (_node$attrs$localId2 = node === null || node === void 0 ? 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 : '';
240
+ newWidth = widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId] ? TABLE_MAX_WIDTH : newWidth;
231
241
  let tr = state.tr.setMeta(tableWidthPluginKey, {
232
242
  resizing: false
233
243
  });
@@ -273,7 +283,7 @@ export const TableResizer = ({
273
283
  onResizeStop();
274
284
  }
275
285
  return newWidth;
276
- }, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop, isTableScalingEnabled]);
286
+ }, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop, isTableScalingEnabled, widthToWidest]);
277
287
  const handleTableSizeChangeOnKeypress = useCallback(step => {
278
288
  const newWidth = width + step;
279
289
  if (newWidth > maxWidth || newWidth < resizerMinWidth) {
@@ -378,7 +388,7 @@ export const TableResizer = ({
378
388
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ResizerNext, {
379
389
  ref: resizerRef,
380
390
  enable: handles,
381
- width: width,
391
+ width: localTableWidth,
382
392
  handleAlignmentMethod: "sticky",
383
393
  handleSize: handleSize,
384
394
  handleStyles: handleStyles,
@@ -84,7 +84,8 @@ const tablesPlugin = ({
84
84
  isWholeTableInDanger: tablePluginState.isWholeTableInDanger,
85
85
  // IMPORTANT: Need to continue to pass tableNode to control re-renders
86
86
  // TableComponent listens for node attribute changes to update colgroups
87
- tableNode: tablePluginState.tableNode
87
+ tableNode: tablePluginState.tableNode,
88
+ widthToWidest: tablePluginState.widthToWidest
88
89
  };
89
90
  },
90
91
  actions: {
@@ -14,7 +14,6 @@ import { findCellRectClosestToPos, findTable, getSelectionRect, isSelectionType,
14
14
  import DistributeColumnIcon from '@atlaskit/icon/glyph/editor/layout-three-equal';
15
15
  import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
16
16
  import TableOptionsIcon from '@atlaskit/icon/glyph/preferences';
17
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
18
17
  import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, hoverTable, removeDescendantNodes } from './commands';
19
18
  import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, deleteTableWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, wrapTableInExpandWithAnalytics } from './commands-with-analytics';
20
19
  import { getPluginState } from './pm-plugins/plugin-factory';
@@ -54,7 +53,7 @@ export const 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',
@@ -287,6 +286,7 @@ export const getClosestSelectionOrTableRect = state => {
287
286
  return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : tableRect;
288
287
  };
289
288
  export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView) => config => (state, intl) => {
289
+ var _tableObject$node$att, _tableObject$node, _tableObject$node$att2;
290
290
  const tableObject = findTable(state.selection);
291
291
  const pluginState = getPluginState(state);
292
292
  const resizeState = tableResizingPluginKey.getState(state);
@@ -298,7 +298,8 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
298
298
  isTableScalingEnabled,
299
299
  widthToWidest
300
300
  } = pluginState;
301
- if (isTableScalingEnabled && isWidthResizing && widthToWidest) {
301
+ const currentTableNodeLocalId = (_tableObject$node$att = tableObject === null || tableObject === void 0 ? void 0 : (_tableObject$node = tableObject.node) === null || _tableObject$node === void 0 ? void 0 : (_tableObject$node$att2 = _tableObject$node.attrs) === null || _tableObject$node$att2 === void 0 ? void 0 : _tableObject$node$att2.localId) !== null && _tableObject$node$att !== void 0 ? _tableObject$node$att : '';
302
+ if (isTableScalingEnabled && isWidthResizing && widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId]) {
302
303
  const {
303
304
  stickyScrollbar
304
305
  } = getEditorFeatureFlags();
@@ -351,7 +352,7 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
351
352
  let cellItems;
352
353
  cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled);
353
354
  let 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
  const colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI);
356
357
 
357
358
  // Check if we need to show confirm dialog for delete button
@@ -70,11 +70,11 @@ export class ContextualMenu extends Component {
70
70
  const node = isOpen && targetCellPosition ? state.doc.nodeAt(targetCellPosition) : null;
71
71
  const background = hexToEditorBackgroundPaletteColor((node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff');
72
72
  return {
73
- content: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? formatMessage(messages.backgroundColor) : formatMessage(messages.cellBackground),
73
+ content: isDragAndDropEnabled ? formatMessage(messages.backgroundColor) : formatMessage(messages.cellBackground),
74
74
  value: {
75
75
  name: 'background'
76
76
  },
77
- elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx("span", {
77
+ elemBefore: isDragAndDropEnabled ? jsx("span", {
78
78
  css: elementBeforeIconStyles
79
79
  }, jsx(EditorBackgroundColorIcon, {
80
80
  label: formatMessage(messages.backgroundColor),
@@ -84,7 +84,7 @@ export class ContextualMenu extends Component {
84
84
  className: DropdownMenuSharedCssClassName.SUBMENU
85
85
  }, jsx("div", {
86
86
  css: cellColourPreviewStyles(background),
87
- className: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? ClassName.CONTEXTUAL_MENU_ICON_SMALL : ClassName.CONTEXTUAL_MENU_ICON
87
+ className: isDragAndDropEnabled ? ClassName.CONTEXTUAL_MENU_ICON_SMALL : ClassName.CONTEXTUAL_MENU_ICON
88
88
  }), isSubmenuOpen && jsx("div", {
89
89
  className: ClassName.CONTEXTUAL_SUBMENU,
90
90
  ref: this.handleSubMenuRef
@@ -122,7 +122,7 @@ export class ContextualMenu extends Component {
122
122
  name: 'merge'
123
123
  },
124
124
  isDisabled: !canMergeCells(state.tr),
125
- elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx("span", {
125
+ elemBefore: isDragAndDropEnabled ? jsx("span", {
126
126
  css: elementBeforeIconStyles
127
127
  }, jsx(MergeCellsIcon, null)) : undefined
128
128
  }, {
@@ -131,7 +131,7 @@ export class ContextualMenu extends Component {
131
131
  name: 'split'
132
132
  },
133
133
  isDisabled: !splitCell(state),
134
- elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx("span", {
134
+ elemBefore: isDragAndDropEnabled ? jsx("span", {
135
135
  css: elementBeforeIconStyles
136
136
  }, jsx(SplitCellIcon, null)) : undefined
137
137
  }];
@@ -149,14 +149,14 @@ export class ContextualMenu extends Component {
149
149
  isDragAndDropEnabled
150
150
  } = getPluginState(editorView.state);
151
151
  return {
152
- content: formatMessage(isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? messages.addColumnRight : messages.insertColumn),
152
+ content: formatMessage(isDragAndDropEnabled ? messages.addColumnRight : messages.insertColumn),
153
153
  value: {
154
154
  name: 'insert_column'
155
155
  },
156
156
  elemAfter: jsx("div", {
157
157
  css: shortcutStyle
158
158
  }, tooltip(addColumnAfter)),
159
- elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx("span", {
159
+ elemBefore: isDragAndDropEnabled ? jsx("span", {
160
160
  css: elementBeforeIconStyles
161
161
  }, jsx(AddColRightIcon, null)) : undefined
162
162
  };
@@ -172,14 +172,14 @@ export class ContextualMenu extends Component {
172
172
  isDragAndDropEnabled
173
173
  } = getPluginState(editorView.state);
174
174
  return {
175
- content: formatMessage(isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? messages.addRowBelow : messages.insertRow),
175
+ content: formatMessage(isDragAndDropEnabled ? messages.addRowBelow : messages.insertRow),
176
176
  value: {
177
177
  name: 'insert_row'
178
178
  },
179
179
  elemAfter: jsx("div", {
180
180
  css: shortcutStyle
181
181
  }, tooltip(addRowAfter)),
182
- elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx("span", {
182
+ elemBefore: isDragAndDropEnabled ? jsx("span", {
183
183
  css: elementBeforeIconStyles
184
184
  }, jsx(AddRowBelowIcon, null)) : undefined
185
185
  };
@@ -213,7 +213,7 @@ export class ContextualMenu extends Component {
213
213
  elemAfter: jsx("div", {
214
214
  css: shortcutStyle
215
215
  }, tooltip(backspace)),
216
- elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx("span", {
216
+ elemBefore: isDragAndDropEnabled ? jsx("span", {
217
217
  css: elementBeforeIconStyles
218
218
  }, jsx(CrossCircleIcon, {
219
219
  label: formatMessage(messages.clearCells, {
@@ -245,7 +245,7 @@ export class ContextualMenu extends Component {
245
245
  value: {
246
246
  name: 'delete_column'
247
247
  },
248
- elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx("span", {
248
+ elemBefore: isDragAndDropEnabled ? jsx("span", {
249
249
  css: elementBeforeIconStyles
250
250
  }, jsx(RemoveIcon, {
251
251
  label: formatMessage(messages.removeColumns, {
@@ -277,7 +277,7 @@ export class ContextualMenu extends Component {
277
277
  value: {
278
278
  name: 'delete_row'
279
279
  },
280
- elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx("span", {
280
+ elemBefore: isDragAndDropEnabled ? jsx("span", {
281
281
  css: elementBeforeIconStyles
282
282
  }, jsx(RemoveIcon, {
283
283
  label: formatMessage(messages.removeRows, {
@@ -301,7 +301,7 @@ export class ContextualMenu extends Component {
301
301
  allowDistributeColumns
302
302
  }
303
303
  } = getPluginState(editorView.state);
304
- if (allowDistributeColumns && (!isDragAndDropEnabled || !getBooleanFF('platform.editor.table.new-cell-context-menu-styling'))) {
304
+ if (allowDistributeColumns && !isDragAndDropEnabled) {
305
305
  var _newResizeState$chang;
306
306
  const {
307
307
  isTableScalingEnabled = false
@@ -329,7 +329,7 @@ export class ContextualMenu extends Component {
329
329
  const {
330
330
  isDragAndDropEnabled
331
331
  } = getPluginState(editorView.state);
332
- if (allowColumnSorting && (!isDragAndDropEnabled || !getBooleanFF('platform.editor.table.new-cell-context-menu-styling'))) {
332
+ if (allowColumnSorting && !isDragAndDropEnabled) {
333
333
  const hasMergedCellsInTable = getMergedCellsPositions(editorView.state.tr).length > 0;
334
334
  const warning = hasMergedCellsInTable ? {
335
335
  tooltipDescription: formatMessage(messages.canNotSortTable),
@@ -568,7 +568,7 @@ export class ContextualMenu extends Component {
568
568
  const {
569
569
  isDragAndDropEnabled
570
570
  } = getPluginState(editorView.state);
571
- const items = isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? this.createNewContextMenuItems() : this.createOriginalContextMenuItems();
571
+ const items = isDragAndDropEnabled ? this.createNewContextMenuItems() : this.createOriginalContextMenuItems();
572
572
  return jsx("div", {
573
573
  "data-testid": "table-cell-contextual-menu",
574
574
  onMouseLeave: this.closeSubmenu
@@ -591,7 +591,7 @@ export class ContextualMenu extends Component {
591
591
  fitWidth: isDragAndDropEnabled ? contextualMenuDropdownWidthDnD : contextualMenuDropdownWidth,
592
592
  boundariesElement: boundariesElement,
593
593
  offset: offset,
594
- section: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') && getBooleanFF('platform.editor.menu.group-items') ? {
594
+ section: isDragAndDropEnabled && getBooleanFF('platform.editor.menu.group-items') ? {
595
595
  hasSeparator: true
596
596
  } : undefined
597
597
  }));
@@ -448,20 +448,20 @@ export const DragMenu = /*#__PURE__*/React.memo(({
448
448
  if (!menuItems) {
449
449
  return null;
450
450
  }
451
- if (allowBackgroundColor && getBooleanFF('platform.editor.table.new-cell-context-menu-styling')) {
451
+ if (allowBackgroundColor) {
452
452
  menuItems[0].items.unshift(createBackgroundColorMenuItem());
453
453
  }
454
454
 
455
455
  // If first row, add toggle for Header row, default is true
456
456
  // If first column, add toggle for Header column, default is false
457
- if (getBooleanFF('platform.editor.table.new-cell-context-menu-styling') && index === 0) {
457
+ if (index === 0) {
458
458
  menuItems.push({
459
459
  items: [createHeaderRowColumnMenuItem(direction)]
460
460
  });
461
461
  }
462
462
 
463
463
  // All rows, add toggle for numbered rows, default is false
464
- if (getBooleanFF('platform.editor.table.new-cell-context-menu-styling') && direction === 'row') {
464
+ if (direction === 'row') {
465
465
  index === 0 ? menuItems[menuItems.length - 1].items.push(createRowNumbersMenuItem()) : menuItems.push({
466
466
  items: [createRowNumbersMenuItem()]
467
467
  });
@@ -5,7 +5,6 @@ import { ArrowKeyNavigationProvider, ArrowKeyNavigationType, DropdownMenuItem }
5
5
  import { withReactEditorViewOuterListeners } from '@atlaskit/editor-common/ui-react';
6
6
  import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
7
7
  import { MenuGroup, Section } from '@atlaskit/menu';
8
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
9
8
  import { dragMenuDropdownWidth } from '../consts';
10
9
  const DropListWithOutsideListeners = withReactEditorViewOuterListeners(DropList);
11
10
  export const DropdownMenu = ({
@@ -106,37 +105,31 @@ export const DropdownMenu = ({
106
105
  // The logic below normalises the index value based on the number
107
106
  // of menu items with 2 focusable elements, and adjusts the index to ensure
108
107
  // the correct menu item is sent in onItemActivated callback
109
- if (getBooleanFF('platform.editor.table.new-cell-context-menu-styling')) {
110
- const keys = ['row_numbers', 'header_row', 'header_column'];
111
- let doubleItemCount = 0;
112
- const firstIndex = results.findIndex(value => keys.includes(value.key));
113
- if (firstIndex === -1 || index <= firstIndex) {
108
+ const keys = ['row_numbers', 'header_row', 'header_column'];
109
+ let doubleItemCount = 0;
110
+ const firstIndex = results.findIndex(value => keys.includes(value.key));
111
+ if (firstIndex === -1 || index <= firstIndex) {
112
+ onItemActivated && onItemActivated({
113
+ item: results[index]
114
+ });
115
+ return;
116
+ }
117
+ for (let i = firstIndex; i < results.length; i += 1) {
118
+ if (keys.includes(results[i].key)) {
119
+ doubleItemCount += 1;
120
+ }
121
+ if (firstIndex % 2 === 0 && index - doubleItemCount === i) {
114
122
  onItemActivated && onItemActivated({
115
- item: results[index]
123
+ item: results[i]
116
124
  });
117
125
  return;
118
126
  }
119
- for (let i = firstIndex; i < results.length; i += 1) {
120
- if (keys.includes(results[i].key)) {
121
- doubleItemCount += 1;
122
- }
123
- if (firstIndex % 2 === 0 && index - doubleItemCount === i) {
124
- onItemActivated && onItemActivated({
125
- item: results[i]
126
- });
127
- return;
128
- }
129
- if (firstIndex % 2 === 1 && index - doubleItemCount === i) {
130
- onItemActivated && onItemActivated({
131
- item: results[i]
132
- });
133
- return;
134
- }
127
+ if (firstIndex % 2 === 1 && index - doubleItemCount === i) {
128
+ onItemActivated && onItemActivated({
129
+ item: results[i]
130
+ });
131
+ return;
135
132
  }
136
- } else {
137
- onItemActivated && onItemActivated({
138
- item: results[index]
139
- });
140
133
  }
141
134
  }
142
135
  }, innerMenu())));
@@ -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
  });
@@ -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,
@@ -107,9 +109,18 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
107
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;
108
110
  }, [pluginInjectionApi]);
109
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
+
110
118
  // 76 is currently an accepted padding value considering the spacing for resizer handle
111
119
  var responsiveContainerWidth = isTableScalingEnabled ? containerWidth - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide / 2 : containerWidth - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide;
112
120
  var width = Math.min(tableWidth, responsiveContainerWidth);
121
+ if (isTableScalingEnabled && currentTableNodeLocalId && widthToWidest && widthToWidest[currentTableNodeLocalId]) {
122
+ width = TABLE_MAX_WIDTH;
123
+ }
113
124
  if (!isResizing) {
114
125
  tableWidthRef.current = width;
115
126
  }
@@ -127,7 +138,8 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
127
138
  attachAnalyticsEvent: attachAnalyticsEvent,
128
139
  displayGapCursor: displayGapCursor,
129
140
  isTableScalingEnabled: isTableScalingEnabled,
130
- isWholeTableInDanger: isWholeTableInDanger
141
+ isWholeTableInDanger: isWholeTableInDanger,
142
+ pluginInjectionApi: pluginInjectionApi
131
143
  };
132
144
  if (getBooleanFF('platform.editor.resizing-table-height-improvement')) {
133
145
  tableResizerProps = _objectSpread(_objectSpread({}, tableResizerProps), {}, {
@@ -152,24 +164,24 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
152
164
  node: node
153
165
  }, children))));
154
166
  });
155
- export var TableContainer = function TableContainer(_ref3) {
156
- var children = _ref3.children,
157
- node = _ref3.node,
158
- className = _ref3.className,
159
- _ref3$containerWidth = _ref3.containerWidth,
160
- lineLength = _ref3$containerWidth.lineLength,
161
- editorWidth = _ref3$containerWidth.width,
162
- isTableResizingEnabled = _ref3.isTableResizingEnabled,
163
- isBreakoutEnabled = _ref3.isBreakoutEnabled,
164
- editorView = _ref3.editorView,
165
- getPos = _ref3.getPos,
166
- tableRef = _ref3.tableRef,
167
- isNested = _ref3.isNested,
168
- tableWrapperHeight = _ref3.tableWrapperHeight,
169
- isResizing = _ref3.isResizing,
170
- pluginInjectionApi = _ref3.pluginInjectionApi,
171
- isTableScalingEnabled = _ref3.isTableScalingEnabled,
172
- isWholeTableInDanger = _ref3.isWholeTableInDanger;
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;
173
185
  if (isTableResizingEnabled && !isNested) {
174
186
  return /*#__PURE__*/React.createElement(ResizableTableContainer, {
175
187
  className: className,