@atlaskit/editor-plugin-table 7.7.3 → 7.8.0

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 (59) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cjs/commands/display-mode.js +23 -0
  3. package/dist/cjs/commands/index.js +8 -1
  4. package/dist/cjs/nodeviews/table.js +2 -1
  5. package/dist/cjs/plugin.js +3 -2
  6. package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +19 -5
  7. package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +5 -0
  8. package/dist/cjs/toolbar.js +43 -12
  9. package/dist/cjs/ui/icons/DisplayModeIcon.js +46 -0
  10. package/dist/cjs/ui/icons/index.js +7 -0
  11. package/dist/es2019/commands/display-mode.js +17 -0
  12. package/dist/es2019/commands/index.js +2 -1
  13. package/dist/es2019/nodeviews/table.js +2 -1
  14. package/dist/es2019/plugin.js +4 -3
  15. package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +19 -5
  16. package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +5 -0
  17. package/dist/es2019/toolbar.js +41 -12
  18. package/dist/es2019/ui/icons/DisplayModeIcon.js +39 -0
  19. package/dist/es2019/ui/icons/index.js +1 -0
  20. package/dist/esm/commands/display-mode.js +16 -0
  21. package/dist/esm/commands/index.js +2 -1
  22. package/dist/esm/nodeviews/table.js +2 -1
  23. package/dist/esm/plugin.js +4 -3
  24. package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +19 -5
  25. package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +5 -0
  26. package/dist/esm/toolbar.js +44 -13
  27. package/dist/esm/ui/icons/DisplayModeIcon.js +39 -0
  28. package/dist/esm/ui/icons/index.js +1 -0
  29. package/dist/types/commands/display-mode.d.ts +2 -0
  30. package/dist/types/commands/index.d.ts +1 -0
  31. package/dist/types/commands/toggle.d.ts +1 -1
  32. package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +3 -3
  33. package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +1 -2
  34. package/dist/types/toolbar.d.ts +2 -1
  35. package/dist/types/ui/icons/DisplayModeIcon.d.ts +4 -0
  36. package/dist/types/ui/icons/index.d.ts +1 -0
  37. package/dist/types-ts4.5/commands/display-mode.d.ts +2 -0
  38. package/dist/types-ts4.5/commands/index.d.ts +1 -0
  39. package/dist/types-ts4.5/commands/toggle.d.ts +1 -1
  40. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +3 -3
  41. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +1 -2
  42. package/dist/types-ts4.5/toolbar.d.ts +2 -1
  43. package/dist/types-ts4.5/ui/icons/DisplayModeIcon.d.ts +4 -0
  44. package/dist/types-ts4.5/ui/icons/index.d.ts +1 -0
  45. package/package.json +16 -13
  46. package/src/commands/display-mode.ts +19 -0
  47. package/src/commands/index.ts +1 -0
  48. package/src/commands/toggle.ts +1 -1
  49. package/src/commands-with-analytics.ts +3 -2
  50. package/src/nodeviews/table.tsx +1 -0
  51. package/src/plugin.tsx +15 -2
  52. package/src/pm-plugins/table-resizing/utils/misc.ts +3 -3
  53. package/src/pm-plugins/table-resizing/utils/resize-column.ts +35 -7
  54. package/src/pm-plugins/table-resizing/utils/resize-state.ts +6 -5
  55. package/src/toolbar.tsx +56 -22
  56. package/src/transforms/fix-tables.ts +1 -2
  57. package/src/types.ts +5 -0
  58. package/src/ui/icons/DisplayModeIcon.tsx +41 -0
  59. package/src/ui/icons/index.ts +1 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 7.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#91934](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/91934) [`b76a78c6a199`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b76a78c6a199) - bumped editor-prosemirror version to 4.0.0
8
+
9
+ ### Patch Changes
10
+
11
+ - [#93082](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/93082) [`fb0cc922f8e4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fb0cc922f8e4) - fix resizing offset not match when extend to overflow in handle and mouse
12
+ - Updated dependencies
13
+
14
+ ## 7.7.4
15
+
16
+ ### Patch Changes
17
+
18
+ - [#92426](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/92426) [`32c76c7c225c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/32c76c7c225c) - Bump adf-schema to 35.9.2 to support table alignment options
19
+ - [#90659](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/90659) [`fc633861cff4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fc633861cff4) - [ux] Adds lock button on table's floating toolbar.
20
+ - Updated dependencies
21
+
3
22
  ## 7.7.3
4
23
 
5
24
  ### Patch Changes
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.setTableDisplayMode = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _utils = require("@atlaskit/editor-tables/utils");
10
+ 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; }
11
+ 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) { (0, _defineProperty2.default)(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; }
12
+ var setTableDisplayMode = exports.setTableDisplayMode = function setTableDisplayMode(_ref) {
13
+ var tr = _ref.tr;
14
+ var table = (0, _utils.findTable)(tr.selection);
15
+ if (!table) {
16
+ return null;
17
+ }
18
+ var displayMode = table.node.attrs.displayMode;
19
+ tr.setNodeMarkup(table.pos, tr.doc.type.schema.nodes.table, _objectSpread(_objectSpread({}, table.node.attrs), {}, {
20
+ displayMode: !displayMode || displayMode === 'default' ? 'fixed' : 'default'
21
+ }));
22
+ return tr.setMeta('scrollIntoView', false);
23
+ };
@@ -171,6 +171,12 @@ Object.defineProperty(exports, "setMultipleCellAttrs", {
171
171
  return _misc.setMultipleCellAttrs;
172
172
  }
173
173
  });
174
+ Object.defineProperty(exports, "setTableDisplayMode", {
175
+ enumerable: true,
176
+ get: function get() {
177
+ return _displayMode.setTableDisplayMode;
178
+ }
179
+ });
174
180
  Object.defineProperty(exports, "setTableHovered", {
175
181
  enumerable: true,
176
182
  get: function get() {
@@ -262,4 +268,5 @@ var _clear = require("./clear");
262
268
  var _misc = require("./misc");
263
269
  var _sort = require("./sort");
264
270
  var _goToNextCell = require("./go-to-next-cell");
265
- var _referentiality = require("./referentiality");
271
+ var _referentiality = require("./referentiality");
272
+ var _displayMode = require("./display-mode");
@@ -41,7 +41,8 @@ var tableAttributes = function tableAttributes(node) {
41
41
  'data-layout': node.attrs.layout,
42
42
  'data-autosize': node.attrs.__autoSize,
43
43
  'data-table-local-id': node.attrs.localId || '',
44
- 'data-table-width': node.attrs.width
44
+ 'data-table-width': node.attrs.width,
45
+ 'data-table-display-mode': node.attrs.displayMode
45
46
  };
46
47
  };
47
48
  var getInlineWidth = function getInlineWidth(node, options, state, pos) {
@@ -116,9 +116,10 @@ var tablesPlugin = function tablesPlugin(_ref) {
116
116
  insertTableWithSize: (0, _insert.insertTableWithSize)(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
117
117
  },
118
118
  nodes: function nodes() {
119
+ var tableNode = options !== null && options !== void 0 && options.isTableScalingEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button') ? _adfSchema.tableStage0 : _adfSchema.table;
119
120
  return [{
120
121
  name: 'table',
121
- node: _adfSchema.table
122
+ node: tableNode
122
123
  }, {
123
124
  name: 'tableHeader',
124
125
  node: _adfSchema.tableHeader
@@ -428,7 +429,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
428
429
  },
429
430
  floatingToolbar: (0, _toolbar.getToolbarConfig)(defaultGetEditorContainerWidth, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, function () {
430
431
  return editorViewRef.current;
431
- })((0, _createPluginConfig.pluginConfig)(options === null || options === void 0 ? void 0 : options.tableOptions))
432
+ }, options)((0, _createPluginConfig.pluginConfig)(options === null || options === void 0 ? void 0 : options.tableOptions))
432
433
  }
433
434
  };
434
435
  };
@@ -15,8 +15,24 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
15
15
  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) { (0, _defineProperty2.default)(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; } // Resize a given column by an amount from the current state
16
16
  var resizeColumn = exports.resizeColumn = function resizeColumn(resizeState, colIndex, amount, tableRef, tableNode, selectedColumns) {
17
17
  var isTableScalingEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
18
+ // If table resize to show overflowed content, we need to re calculate the resize amount because now offset = amount amount instead of amount * 2
18
19
  var scalePercent = 1;
19
- var resizeAmount = (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.colum-resizing-improvements') ? amount * 2 : amount;
20
+ var resizeAmount;
21
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.colum-resizing-improvements')) {
22
+ var _tableRef$closest;
23
+ // when table initially not overflow, but enter overflow, we need to calculate the resize amount by two part, before and after overflow, before overflow should be double, after should not be double.
24
+ var tableWidth = tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientWidth;
25
+ var tableContainerWidth = (_tableRef$closest = tableRef.closest('.resizer-item')) === null || _tableRef$closest === void 0 ? void 0 : _tableRef$closest.clientWidth;
26
+ var isOverflowed = !!(tableWidth && tableContainerWidth && tableWidth > tableContainerWidth);
27
+ resizeAmount = amount * 2;
28
+ if (isOverflowed) {
29
+ resizeAmount = amount < 0 ? amount : resizeAmount - (tableNode.attrs.width + resizeAmount - tableContainerWidth) / 2;
30
+ } else {
31
+ resizeAmount = amount > 0 && tableContainerWidth ? resizeAmount - (tableNode.attrs.width + resizeAmount - tableContainerWidth) / 2 : resizeAmount;
32
+ }
33
+ } else {
34
+ resizeAmount = amount;
35
+ }
20
36
 
21
37
  // This need to be clean up if clean up the FF, we will not need this scale logic because now full table width changed/updated in resizeColumn
22
38
  if (isTableScalingEnabled && !(0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.colum-resizing-improvements')) {
@@ -24,7 +40,7 @@ var resizeColumn = exports.resizeColumn = function resizeColumn(resizeState, col
24
40
  resizeAmount = amount / scalePercent;
25
41
  }
26
42
  var newState = (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.colum-resizing-improvements') ? (0, _resizeLogic.updateAffectedColumn)(resizeState, colIndex, resizeAmount) : resizeAmount > 0 ? (0, _resizeLogic.growColumn)(resizeState, colIndex, resizeAmount, selectedColumns) : resizeAmount < 0 ? (0, _resizeLogic.shrinkColumn)(resizeState, colIndex, resizeAmount, selectedColumns) : resizeState;
27
- (0, _resizeState.updateColgroup)(newState, tableRef, tableNode, isTableScalingEnabled);
43
+ (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.colum-resizing-improvements') ? (0, _resizeState.updateColgroup)(newState, tableRef, tableNode, false) : (0, _resizeState.updateColgroup)(newState, tableRef, tableNode, isTableScalingEnabled);
28
44
  if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.colum-resizing-improvements')) {
29
45
  // use the difference in width from affected column to update overall table width
30
46
  var delta = newState.cols[colIndex].width - resizeState.cols[colIndex].width;
@@ -35,9 +51,7 @@ var resizeColumn = exports.resizeColumn = function resizeColumn(resizeState, col
35
51
  }
36
52
  return newState;
37
53
  };
38
- var updateTable = function updateTable(resizeAmount, tableRef, tableNode
39
- // isTableScalingEnabled: boolean,
40
- ) {
54
+ var updateTable = function updateTable(resizeAmount, tableRef, tableNode) {
41
55
  var currentWidth = (0, _misc.getTableContainerElementWidth)(tableNode);
42
56
  var resizingContainer = tableRef.closest(".".concat(_types.TableCssClassName.TABLE_RESIZER_CONTAINER));
43
57
  var resizingItem = resizingContainer === null || resizingContainer === void 0 ? void 0 : resizingContainer.querySelector('.resizer-item');
@@ -94,6 +94,11 @@ var getResizeState = exports.getResizeState = function getResizeState(_ref) {
94
94
  var updateColgroup = exports.updateColgroup = function updateColgroup(state, tableRef, tableNode, isTableScalingEnabled) {
95
95
  var cols = tableRef.querySelectorAll('col');
96
96
  var columnsCount = cols.length;
97
+ /**
98
+ updateColgroup will update whole table scale when click the column resize handle, this behavior will affect when table overflowed, when now resize handle been dragged and extend to make table overflowed, table will show overflow. This need to be confirmed because it conflict with how isTableScalingEnabled work.
99
+ We don't want to scale the table when resizing columns, only when viewpoint shrinks the table.
100
+ We need to remove !isColumnResizing if we handled auto scale table when mouseUp event.
101
+ * */
97
102
  if (isTableScalingEnabled && tableNode) {
98
103
  var scalePercent = (0, _misc.getTableScalingPercent)(tableNode, tableRef);
99
104
  state.cols.filter(function (column) {
@@ -12,6 +12,7 @@ var _customSteps = require("@atlaskit/custom-steps");
12
12
  var _analytics = require("@atlaskit/editor-common/analytics");
13
13
  var _keymaps = require("@atlaskit/editor-common/keymaps");
14
14
  var _messages = _interopRequireWildcard(require("@atlaskit/editor-common/messages"));
15
+ var _preset = require("@atlaskit/editor-common/preset");
15
16
  var _uiColor = require("@atlaskit/editor-common/ui-color");
16
17
  var _utils = require("@atlaskit/editor-common/utils");
17
18
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
@@ -31,6 +32,7 @@ var _resizeState = require("./pm-plugins/table-resizing/utils/resize-state");
31
32
  var _tableWidth = require("./pm-plugins/table-width");
32
33
  var _transforms = require("./transforms");
33
34
  var _types = require("./types");
35
+ var _icons = require("./ui/icons");
34
36
  var _TableFullWidthLabel = require("./ui/TableFullWidthLabel");
35
37
  var _utils4 = require("./utils");
36
38
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
@@ -311,7 +313,7 @@ var getClosestSelectionOrTableRect = exports.getClosestSelectionOrTableRect = fu
311
313
  var tableRect = new _tableMap.Rect(0, 0, map.width, map.height);
312
314
  return (0, _utils3.isSelectionType)(selection, 'cell') ? (0, _utils3.getSelectionRect)(selection) : tableRect;
313
315
  };
314
- var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView) {
316
+ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView, options) {
315
317
  return function (config) {
316
318
  return function (state, intl) {
317
319
  var _tableObject$node$att, _tableObject$node;
@@ -325,7 +327,9 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
325
327
  var isTableScalingEnabled = pluginState.isTableScalingEnabled,
326
328
  widthToWidest = pluginState.widthToWidest;
327
329
  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 : '';
328
- if (isTableScalingEnabled && isWidthResizing && widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId]) {
330
+ if (isTableScalingEnabled &&
331
+ // TODO ED-21670: check if need options.isTableScalingEnabled
332
+ isWidthResizing && widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId]) {
329
333
  var _getEditorFeatureFlag = getEditorFeatureFlags(),
330
334
  stickyScrollbar = _getEditorFeatureFlag.stickyScrollbar;
331
335
  var nodeType = state.schema.nodes.table;
@@ -373,11 +377,12 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
373
377
  var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
374
378
  var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
375
379
  _getPluginState2$isTa = _getPluginState2.isTableScalingEnabled,
376
- _isTableScalingEnabled = _getPluginState2$isTa === void 0 ? false : _getPluginState2$isTa;
380
+ _isTableScalingEnabled = _getPluginState2$isTa === void 0 ? false : _getPluginState2$isTa; // TODO ED-21670: check if we need options.isTableScalingEnabled and not an acutual state of displayNode attr on the table
381
+
377
382
  var cellItems;
378
383
  cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, _isTableScalingEnabled);
379
384
  var columnSettingsItems;
380
- columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, _isTableScalingEnabled) : [];
385
+ columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, options, _isTableScalingEnabled) : [];
381
386
  var colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI);
382
387
 
383
388
  // Check if we need to show confirm dialog for delete button
@@ -504,32 +509,58 @@ var getDistributeConfig = exports.getDistributeConfig = function getDistributeCo
504
509
 
505
510
  // this create the button group for distribute column and also fixed column width
506
511
  // fixed column button should be in this function call in the future
507
- var getColumnSettingItems = function getColumnSettingItems(editorState, editorView, _ref4, getEditorContainerWidth, editorAnalyticsAPI) {
512
+ var getColumnSettingItems = function getColumnSettingItems(editorState, editorView, _ref4, getEditorContainerWidth, editorAnalyticsAPI, options) {
508
513
  var _newResizeStateWithAn2, _pluginState$pluginCo3;
509
514
  var formatMessage = _ref4.formatMessage;
510
- var isTableScalingEnabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
515
+ var isTableScalingEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
511
516
  var pluginState = (0, _pluginFactory.getPluginState)(editorState);
512
517
  var selectionOrTableRect = getClosestSelectionOrTableRect(editorState);
513
518
  if (!selectionOrTableRect || !editorView) {
514
519
  return [];
515
520
  }
516
- var newResizeStateWithAnalytics = (0, _resizeState.getNewResizeStateFromSelectedColumns)(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled);
521
+ var newResizeStateWithAnalytics = (0, _resizeState.getNewResizeStateFromSelectedColumns)(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled // TODO ED-21670: Here should be actual state of tableNode's displayMode attr
522
+ );
517
523
  var wouldChange = (_newResizeStateWithAn2 = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn2 !== void 0 ? _newResizeStateWithAn2 : false;
524
+ var items = [];
525
+ var isTableScalingLockBtnEnabled = (options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button');
526
+ if (isTableScalingLockBtnEnabled) {
527
+ var _pluginState$tableNod;
528
+ var areColumnWidthsLocked = (pluginState === null || pluginState === void 0 || (_pluginState$tableNod = pluginState.tableNode) === null || _pluginState$tableNod === void 0 ? void 0 : _pluginState$tableNod.attrs.displayMode) === 'fixed';
529
+ var title = areColumnWidthsLocked ? formatMessage(_messages.tableMessages.unlockColumnWidths) : formatMessage(_messages.tableMessages.lockColumnWidths);
530
+ items.push({
531
+ id: 'editor.table.lockColumns',
532
+ type: 'button',
533
+ title: title,
534
+ icon: function icon() {
535
+ return (0, _react.jsx)(_icons.DisplayModeIcon, {
536
+ size: "medium",
537
+ label: title
538
+ });
539
+ },
540
+ onClick: (0, _preset.editorCommandToPMCommand)(_commands.setTableDisplayMode),
541
+ selected: areColumnWidthsLocked,
542
+ testId: 'table-lock-column-widths-btn'
543
+ });
544
+ }
518
545
  if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo3 = pluginState.pluginConfig) !== null && _pluginState$pluginCo3 !== void 0 && _pluginState$pluginCo3.allowDistributeColumns && pluginState.isDragAndDropEnabled) {
519
- return [{
546
+ items.push({
520
547
  id: 'editor.table.distributeColumns',
521
548
  type: 'button',
522
549
  title: formatMessage(_messages.tableMessages.distributeColumns),
523
550
  icon: _layoutThreeEqual.default,
524
551
  onClick: function onClick(state, dispatch, view) {
525
- return getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled)(state, dispatch, view);
552
+ return getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled // TODO ED-21670: Maybe here too we an actual state of tableNode's displayMode attr
553
+ )(state, dispatch, view);
526
554
  },
527
555
  disabled: !wouldChange
528
- }, {
556
+ });
557
+ }
558
+ if (items.length !== 0) {
559
+ items.push({
529
560
  type: 'separator'
530
- }];
561
+ });
531
562
  }
532
- return [];
563
+ return items;
533
564
  };
534
565
  var getColorPicker = function getColorPicker(state, menu, _ref5, editorAnalyticsAPI) {
535
566
  var _node$attrs;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.DisplayModeIcon = exports.DisplayModeGlyth = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _react = _interopRequireDefault(require("react"));
10
+ var _icon = _interopRequireDefault(require("@atlaskit/icon"));
11
+ var DisplayModeGlyth = exports.DisplayModeGlyth = function DisplayModeGlyth(props) {
12
+ return /*#__PURE__*/_react.default.createElement("svg", (0, _extends2.default)({
13
+ width: "24",
14
+ height: "24",
15
+ viewBox: "0 0 24 24",
16
+ fill: "none",
17
+ xmlns: "http://www.w3.org/2000/svg"
18
+ }, props), /*#__PURE__*/_react.default.createElement("rect", {
19
+ x: "4",
20
+ y: "5",
21
+ width: "4",
22
+ height: "14",
23
+ rx: "1",
24
+ fill: "currentColor"
25
+ }), /*#__PURE__*/_react.default.createElement("path", {
26
+ fillRule: "evenodd",
27
+ clipRule: "evenodd",
28
+ d: "M11 5C10.4477 5 10 5.44772 10 6V9.10102C11.0503 8.02921 12.4424 7.29368 14 7.07089V6C14 5.44772 13.5523 5 13 5H11Z",
29
+ fill: "currentColor"
30
+ }), /*#__PURE__*/_react.default.createElement("path", {
31
+ fillRule: "evenodd",
32
+ clipRule: "evenodd",
33
+ d: "M17 5C16.4477 5 16 5.44772 16 6V7.07089C17.5576 7.29368 18.9497 8.02921 20 9.10102V6C20 5.44772 19.5523 5 19 5H17Z",
34
+ fill: "currentColor"
35
+ }), /*#__PURE__*/_react.default.createElement("path", {
36
+ fillRule: "evenodd",
37
+ clipRule: "evenodd",
38
+ d: "M21 14C21 17.3137 18.3137 20 15 20C11.6863 20 9 17.3137 9 14C9 10.6863 11.6863 8 15 8C18.3137 8 21 10.6863 21 14ZM12 15C12 14.4477 12.4477 14 13 14V12C13 10.8954 13.8954 10 15 10C16.1046 10 17 10.8954 17 12V14C17.5523 14 18 14.4477 18 15V17C18 17.5523 17.5523 18 17 18H13C12.4477 18 12 17.5523 12 17V15ZM16 14V12C16 11.4477 15.5523 11 15 11C14.4477 11 14 11.4477 14 12V14H16Z",
39
+ fill: "currentColor"
40
+ }));
41
+ };
42
+ var DisplayModeIcon = exports.DisplayModeIcon = function DisplayModeIcon(props) {
43
+ return /*#__PURE__*/_react.default.createElement(_icon.default, (0, _extends2.default)({
44
+ glyph: DisplayModeGlyth
45
+ }, props));
46
+ };
@@ -27,6 +27,12 @@ Object.defineProperty(exports, "AddRowBelowIcon", {
27
27
  return _AddRowBelowIcon.AddRowBelowIcon;
28
28
  }
29
29
  });
30
+ Object.defineProperty(exports, "DisplayModeIcon", {
31
+ enumerable: true,
32
+ get: function get() {
33
+ return _DisplayModeIcon.DisplayModeIcon;
34
+ }
35
+ });
30
36
  Object.defineProperty(exports, "DragHandleDisabledIcon", {
31
37
  enumerable: true,
32
38
  get: function get() {
@@ -66,6 +72,7 @@ Object.defineProperty(exports, "SplitCellIcon", {
66
72
  var _DragHandleIcon = require("./DragHandleIcon");
67
73
  var _DragInMotionIcon = require("./DragInMotionIcon");
68
74
  var _DragHandleDisabledIcon = require("./DragHandleDisabledIcon");
75
+ var _DisplayModeIcon = require("./DisplayModeIcon");
69
76
  var _MinimisedHandle = require("./MinimisedHandle");
70
77
  var _MergeCellsIcon = require("./MergeCellsIcon");
71
78
  var _SplitCellIcon = require("./SplitCellIcon");
@@ -0,0 +1,17 @@
1
+ import { findTable } from '@atlaskit/editor-tables/utils';
2
+ export const setTableDisplayMode = ({
3
+ tr
4
+ }) => {
5
+ const table = findTable(tr.selection);
6
+ if (!table) {
7
+ return null;
8
+ }
9
+ const {
10
+ displayMode
11
+ } = table.node.attrs;
12
+ tr.setNodeMarkup(table.pos, tr.doc.type.schema.nodes.table, {
13
+ ...table.node.attrs,
14
+ displayMode: !displayMode || displayMode === 'default' ? 'fixed' : 'default'
15
+ });
16
+ return tr.setMeta('scrollIntoView', false);
17
+ };
@@ -5,4 +5,5 @@ export { clearMultipleCells } from './clear';
5
5
  export { autoSizeTable, convertFirstRowToHeader, deleteTable, hideInsertColumnOrRowButton, moveCursorBackward, selectColumn, selectColumns, selectRow, selectRows, setCellAttr, setEditorFocus, setMultipleCellAttrs, setTableRef, showInsertColumnButton, showInsertRowButton, transformSliceToAddTableHeaders, triggerUnlessTableHeader, addBoldInEmptyHeaderCells, addResizeHandleDecorations, updateWidthToWidest } from './misc';
6
6
  export { sortByColumn } from './sort';
7
7
  export { goToNextCell } from './go-to-next-cell';
8
- export { removeDescendantNodes } from './referentiality';
8
+ export { removeDescendantNodes } from './referentiality';
9
+ export { setTableDisplayMode } from './display-mode';
@@ -23,7 +23,8 @@ const tableAttributes = node => {
23
23
  'data-layout': node.attrs.layout,
24
24
  'data-autosize': node.attrs.__autoSize,
25
25
  'data-table-local-id': node.attrs.localId || '',
26
- 'data-table-width': node.attrs.width
26
+ 'data-table-width': node.attrs.width,
27
+ 'data-table-display-mode': node.attrs.displayMode
27
28
  };
28
29
  };
29
30
  const getInlineWidth = (node, options, state, pos) => {
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { table, tableCell, tableHeader, tableRow } from '@atlaskit/adf-schema';
2
+ import { table, tableCell, tableHeader, tableRow, tableStage0 } from '@atlaskit/adf-schema';
3
3
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
4
4
  import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
5
5
  import { IconTable } from '@atlaskit/editor-common/icons';
@@ -106,9 +106,10 @@ const tablesPlugin = ({
106
106
  insertTableWithSize: insertTableWithSize(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
107
107
  },
108
108
  nodes() {
109
+ const tableNode = options !== null && options !== void 0 && options.isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') ? tableStage0 : table;
109
110
  return [{
110
111
  name: 'table',
111
- node: table
112
+ node: tableNode
112
113
  }, {
113
114
  name: 'tableHeader',
114
115
  node: tableHeader
@@ -419,7 +420,7 @@ const tablesPlugin = ({
419
420
  return tr;
420
421
  }
421
422
  }],
422
- floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, () => editorViewRef.current)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
423
+ floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, () => editorViewRef.current, options)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
423
424
  }
424
425
  };
425
426
  };
@@ -6,8 +6,24 @@ import { getTableContainerElementWidth, getTableScalingPercent } from './misc';
6
6
  import { growColumn, shrinkColumn, updateAffectedColumn } from './resize-logic';
7
7
  import { updateColgroup } from './resize-state';
8
8
  export const resizeColumn = (resizeState, colIndex, amount, tableRef, tableNode, selectedColumns, isTableScalingEnabled = false) => {
9
+ // If table resize to show overflowed content, we need to re calculate the resize amount because now offset = amount amount instead of amount * 2
9
10
  let scalePercent = 1;
10
- let resizeAmount = getBooleanFF('platform.editor.table.colum-resizing-improvements') ? amount * 2 : amount;
11
+ let resizeAmount;
12
+ if (getBooleanFF('platform.editor.table.colum-resizing-improvements')) {
13
+ var _tableRef$closest;
14
+ // when table initially not overflow, but enter overflow, we need to calculate the resize amount by two part, before and after overflow, before overflow should be double, after should not be double.
15
+ const tableWidth = tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientWidth;
16
+ const tableContainerWidth = (_tableRef$closest = tableRef.closest('.resizer-item')) === null || _tableRef$closest === void 0 ? void 0 : _tableRef$closest.clientWidth;
17
+ const isOverflowed = !!(tableWidth && tableContainerWidth && tableWidth > tableContainerWidth);
18
+ resizeAmount = amount * 2;
19
+ if (isOverflowed) {
20
+ resizeAmount = amount < 0 ? amount : resizeAmount - (tableNode.attrs.width + resizeAmount - tableContainerWidth) / 2;
21
+ } else {
22
+ resizeAmount = amount > 0 && tableContainerWidth ? resizeAmount - (tableNode.attrs.width + resizeAmount - tableContainerWidth) / 2 : resizeAmount;
23
+ }
24
+ } else {
25
+ resizeAmount = amount;
26
+ }
11
27
 
12
28
  // This need to be clean up if clean up the FF, we will not need this scale logic because now full table width changed/updated in resizeColumn
13
29
  if (isTableScalingEnabled && !getBooleanFF('platform.editor.table.colum-resizing-improvements')) {
@@ -15,7 +31,7 @@ export const resizeColumn = (resizeState, colIndex, amount, tableRef, tableNode,
15
31
  resizeAmount = amount / scalePercent;
16
32
  }
17
33
  const newState = getBooleanFF('platform.editor.table.colum-resizing-improvements') ? updateAffectedColumn(resizeState, colIndex, resizeAmount) : resizeAmount > 0 ? growColumn(resizeState, colIndex, resizeAmount, selectedColumns) : resizeAmount < 0 ? shrinkColumn(resizeState, colIndex, resizeAmount, selectedColumns) : resizeState;
18
- updateColgroup(newState, tableRef, tableNode, isTableScalingEnabled);
34
+ getBooleanFF('platform.editor.table.colum-resizing-improvements') ? updateColgroup(newState, tableRef, tableNode, false) : updateColgroup(newState, tableRef, tableNode, isTableScalingEnabled);
19
35
  if (getBooleanFF('platform.editor.table.colum-resizing-improvements')) {
20
36
  // use the difference in width from affected column to update overall table width
21
37
  const delta = newState.cols[colIndex].width - resizeState.cols[colIndex].width;
@@ -27,9 +43,7 @@ export const resizeColumn = (resizeState, colIndex, amount, tableRef, tableNode,
27
43
  }
28
44
  return newState;
29
45
  };
30
- const updateTable = (resizeAmount, tableRef, tableNode
31
- // isTableScalingEnabled: boolean,
32
- ) => {
46
+ const updateTable = (resizeAmount, tableRef, tableNode) => {
33
47
  const currentWidth = getTableContainerElementWidth(tableNode);
34
48
  const resizingContainer = tableRef.closest(`.${ClassName.TABLE_RESIZER_CONTAINER}`);
35
49
  const resizingItem = resizingContainer === null || resizingContainer === void 0 ? void 0 : resizingContainer.querySelector('.resizer-item');
@@ -74,6 +74,11 @@ export const getResizeState = ({
74
74
  export const updateColgroup = (state, tableRef, tableNode, isTableScalingEnabled) => {
75
75
  const cols = tableRef.querySelectorAll('col');
76
76
  const columnsCount = cols.length;
77
+ /**
78
+ updateColgroup will update whole table scale when click the column resize handle, this behavior will affect when table overflowed, when now resize handle been dragged and extend to make table overflowed, table will show overflow. This need to be confirmed because it conflict with how isTableScalingEnabled work.
79
+ We don't want to scale the table when resizing columns, only when viewpoint shrinks the table.
80
+ We need to remove !isColumnResizing if we handled auto scale table when mouseUp event.
81
+ * */
77
82
  if (isTableScalingEnabled && tableNode) {
78
83
  const scalePercent = getTableScalingPercent(tableNode, tableRef);
79
84
  state.cols.filter(column => column && !!column.width) // if width is 0, we dont want to apply that.
@@ -4,6 +4,7 @@ import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
4
4
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
5
  import { addColumnAfter, addRowAfter, backspace, tooltip } from '@atlaskit/editor-common/keymaps';
6
6
  import commonMessages, { tableMessages as messages } from '@atlaskit/editor-common/messages';
7
+ import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
7
8
  import { cellBackgroundColorPalette, DEFAULT_BORDER_COLOR } from '@atlaskit/editor-common/ui-color';
8
9
  import { closestElement, getChildrenInfo, getNodeName, isReferencedSource } from '@atlaskit/editor-common/utils';
9
10
  import { findParentDomRefOfType } from '@atlaskit/editor-prosemirror/utils';
@@ -15,7 +16,7 @@ import DistributeColumnIcon from '@atlaskit/icon/glyph/editor/layout-three-equal
15
16
  import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
16
17
  import TableOptionsIcon from '@atlaskit/icon/glyph/preferences';
17
18
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
18
- import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, hoverTable, removeDescendantNodes } from './commands';
19
+ import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, hoverTable, removeDescendantNodes, setTableDisplayMode } from './commands';
19
20
  import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, deleteTableWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, wrapTableInExpandWithAnalytics } from './commands-with-analytics';
20
21
  import { getPluginState } from './pm-plugins/plugin-factory';
21
22
  import { pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
@@ -23,6 +24,7 @@ import { getNewResizeStateFromSelectedColumns } from './pm-plugins/table-resizin
23
24
  import { pluginKey as tableWidthPluginKey } from './pm-plugins/table-width';
24
25
  import { canMergeCells } from './transforms';
25
26
  import { TableCssClassName } from './types';
27
+ import { DisplayModeIcon } from './ui/icons';
26
28
  import { FullWidthDisplay } from './ui/TableFullWidthLabel';
27
29
  import { getMergedCellsPositions, getSelectedColumnIndexes, getSelectedRowIndexes } from './utils';
28
30
  export const getToolbarMenuConfig = (config, state, {
@@ -299,7 +301,7 @@ export const getClosestSelectionOrTableRect = state => {
299
301
  const tableRect = new Rect(0, 0, map.width, map.height);
300
302
  return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : tableRect;
301
303
  };
302
- export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView) => config => (state, intl) => {
304
+ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView, options) => config => (state, intl) => {
303
305
  var _tableObject$node$att, _tableObject$node, _tableObject$node$att2;
304
306
  const tableObject = findTable(state.selection);
305
307
  const pluginState = getPluginState(state);
@@ -313,7 +315,9 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
313
315
  widthToWidest
314
316
  } = pluginState;
315
317
  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 : '';
316
- if (isTableScalingEnabled && isWidthResizing && widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId]) {
318
+ if (isTableScalingEnabled &&
319
+ // TODO ED-21670: check if need options.isTableScalingEnabled
320
+ isWidthResizing && widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId]) {
317
321
  const {
318
322
  stickyScrollbar
319
323
  } = getEditorFeatureFlags();
@@ -362,11 +366,12 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
362
366
  const menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
363
367
  const {
364
368
  isTableScalingEnabled = false
365
- } = getPluginState(state);
369
+ } = getPluginState(state); // TODO ED-21670: check if we need options.isTableScalingEnabled and not an acutual state of displayNode attr on the table
370
+
366
371
  let cellItems;
367
372
  cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled);
368
373
  let columnSettingsItems;
369
- columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled) : [];
374
+ columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, options, isTableScalingEnabled) : [];
370
375
  const colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI);
371
376
 
372
377
  // Check if we need to show confirm dialog for delete button
@@ -484,28 +489,52 @@ export const getDistributeConfig = (getEditorContainerWidth, editorAnalyticsAPI,
484
489
  // fixed column button should be in this function call in the future
485
490
  const getColumnSettingItems = (editorState, editorView, {
486
491
  formatMessage
487
- }, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled = false) => {
492
+ }, getEditorContainerWidth, editorAnalyticsAPI, options, isTableScalingEnabled = false) => {
488
493
  var _newResizeStateWithAn2, _pluginState$pluginCo3;
489
494
  const pluginState = getPluginState(editorState);
490
495
  const selectionOrTableRect = getClosestSelectionOrTableRect(editorState);
491
496
  if (!selectionOrTableRect || !editorView) {
492
497
  return [];
493
498
  }
494
- const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled);
499
+ const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled // TODO ED-21670: Here should be actual state of tableNode's displayMode attr
500
+ );
495
501
  const wouldChange = (_newResizeStateWithAn2 = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn2 !== void 0 ? _newResizeStateWithAn2 : false;
502
+ const items = [];
503
+ const isTableScalingLockBtnEnabled = (options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
504
+ if (isTableScalingLockBtnEnabled) {
505
+ var _pluginState$tableNod;
506
+ const areColumnWidthsLocked = (pluginState === null || pluginState === void 0 ? void 0 : (_pluginState$tableNod = pluginState.tableNode) === null || _pluginState$tableNod === void 0 ? void 0 : _pluginState$tableNod.attrs.displayMode) === 'fixed';
507
+ const title = areColumnWidthsLocked ? formatMessage(messages.unlockColumnWidths) : formatMessage(messages.lockColumnWidths);
508
+ items.push({
509
+ id: 'editor.table.lockColumns',
510
+ type: 'button',
511
+ title,
512
+ icon: () => jsx(DisplayModeIcon, {
513
+ size: "medium",
514
+ label: title
515
+ }),
516
+ onClick: editorCommandToPMCommand(setTableDisplayMode),
517
+ selected: areColumnWidthsLocked,
518
+ testId: 'table-lock-column-widths-btn'
519
+ });
520
+ }
496
521
  if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo3 = pluginState.pluginConfig) !== null && _pluginState$pluginCo3 !== void 0 && _pluginState$pluginCo3.allowDistributeColumns && pluginState.isDragAndDropEnabled) {
497
- return [{
522
+ items.push({
498
523
  id: 'editor.table.distributeColumns',
499
524
  type: 'button',
500
525
  title: formatMessage(messages.distributeColumns),
501
526
  icon: DistributeColumnIcon,
502
- onClick: (state, dispatch, view) => getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled)(state, dispatch, view),
527
+ onClick: (state, dispatch, view) => getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled // TODO ED-21670: Maybe here too we an actual state of tableNode's displayMode attr
528
+ )(state, dispatch, view),
503
529
  disabled: !wouldChange
504
- }, {
530
+ });
531
+ }
532
+ if (items.length !== 0) {
533
+ items.push({
505
534
  type: 'separator'
506
- }];
535
+ });
507
536
  }
508
- return [];
537
+ return items;
509
538
  };
510
539
  const getColorPicker = (state, menu, {
511
540
  formatMessage