@atlaskit/editor-plugin-table 10.5.12 → 10.6.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 10.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#134914](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/134914)
8
+ [`4395d5ae9ba96`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4395d5ae9ba96) -
9
+ ED-27326 Add distribute columns to cell controls
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
3
15
  ## 10.5.12
4
16
 
5
17
  ### Patch Changes
@@ -36,9 +36,12 @@ var _tableCellMerge = _interopRequireDefault(require("@atlaskit/icon/core/table-
36
36
  var _tableCellSplit = _interopRequireDefault(require("@atlaskit/icon/core/table-cell-split"));
37
37
  var _tableColumnAddRight = _interopRequireDefault(require("@atlaskit/icon/core/table-column-add-right"));
38
38
  var _tableColumnDelete = _interopRequireDefault(require("@atlaskit/icon/core/table-column-delete"));
39
+ var _tableColumnsDistribute = _interopRequireDefault(require("@atlaskit/icon/core/table-columns-distribute"));
39
40
  var _tableRowAddBelow = _interopRequireDefault(require("@atlaskit/icon/core/table-row-add-below"));
40
41
  var _tableRowDelete = _interopRequireDefault(require("@atlaskit/icon/core/table-row-delete"));
42
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
41
43
  var _primitives = require("@atlaskit/primitives");
44
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
42
45
  var _commands = require("../../pm-plugins/commands");
43
46
  var _commandsWithAnalytics = require("../../pm-plugins/commands/commands-with-analytics");
44
47
  var _pluginFactory = require("../../pm-plugins/plugin-factory");
@@ -179,6 +182,20 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
179
182
  };
180
183
  }
181
184
  });
185
+ // Used in the NewContextMenuItems object
186
+ (0, _defineProperty2.default)(_this, "newDistributeColumnsItem", function () {
187
+ var formatMessage = _this.props.intl.formatMessage;
188
+ return _this.createDistributeColumnsItemInternal({
189
+ elemBefore: (0, _react2.jsx)(_primitives.Box, {
190
+ xcss: elementBeforeIconStyles
191
+ }, (0, _react2.jsx)(_tableColumnsDistribute.default, {
192
+ color: "currentColor",
193
+ spacing: "spacious",
194
+ label: formatMessage(_messages.tableMessages.distributeColumns),
195
+ LEGACY_fallbackIcon: _MergeCellsIcon.MergeCellsIcon
196
+ }))
197
+ });
198
+ });
182
199
  (0, _defineProperty2.default)(_this, "createMergeSplitCellItems", function () {
183
200
  var _this$props2 = _this.props,
184
201
  allowMergeCells = _this$props2.allowMergeCells,
@@ -372,33 +389,37 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
372
389
  })) : undefined
373
390
  };
374
391
  });
375
- (0, _defineProperty2.default)(_this, "createDistributeColumnsItem", function () {
392
+ (0, _defineProperty2.default)(_this, "createDistributeColumnsItemInternal", function (partialMenuItem) {
393
+ var _newResizeState$chang;
376
394
  var _this$props8 = _this.props,
377
395
  selectionRect = _this$props8.selectionRect,
378
- formatMessage = _this$props8.intl.formatMessage,
379
396
  editorView = _this$props8.editorView,
380
397
  getEditorContainerWidth = _this$props8.getEditorContainerWidth,
381
- getEditorFeatureFlags = _this$props8.getEditorFeatureFlags;
398
+ getEditorFeatureFlags = _this$props8.getEditorFeatureFlags,
399
+ formatMessage = _this$props8.intl.formatMessage;
382
400
  var _getPluginState8 = (0, _pluginFactory.getPluginState)(editorView.state),
383
- isDragAndDropEnabled = _getPluginState8.isDragAndDropEnabled,
384
- allowDistributeColumns = _getPluginState8.pluginConfig.allowDistributeColumns;
401
+ _getPluginState8$isTa = _getPluginState8.isTableScalingEnabled,
402
+ isTableScalingEnabled = _getPluginState8$isTa === void 0 ? false : _getPluginState8$isTa;
403
+ var _ref = getEditorFeatureFlags ? getEditorFeatureFlags() : {},
404
+ _ref$tableWithFixedCo = _ref.tableWithFixedColumnWidthsOption,
405
+ tableWithFixedColumnWidthsOption = _ref$tableWithFixedCo === void 0 ? false : _ref$tableWithFixedCo;
406
+ var newResizeState = (0, _resizeState.getNewResizeStateFromSelectedColumns)(selectionRect, editorView.state, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled, tableWithFixedColumnWidthsOption);
407
+ var wouldChange = (_newResizeState$chang = newResizeState === null || newResizeState === void 0 ? void 0 : newResizeState.changed) !== null && _newResizeState$chang !== void 0 ? _newResizeState$chang : false;
408
+ return _objectSpread({
409
+ content: formatMessage(_messages.tableMessages.distributeColumns),
410
+ value: {
411
+ name: 'distribute_columns'
412
+ },
413
+ isDisabled: !wouldChange
414
+ }, partialMenuItem);
415
+ });
416
+ (0, _defineProperty2.default)(_this, "createDistributeColumnsItem", function () {
417
+ var editorView = _this.props.editorView;
418
+ var _getPluginState9 = (0, _pluginFactory.getPluginState)(editorView.state),
419
+ isDragAndDropEnabled = _getPluginState9.isDragAndDropEnabled,
420
+ allowDistributeColumns = _getPluginState9.pluginConfig.allowDistributeColumns;
385
421
  if (allowDistributeColumns && !isDragAndDropEnabled) {
386
- var _newResizeState$chang;
387
- var _getPluginState9 = (0, _pluginFactory.getPluginState)(editorView.state),
388
- _getPluginState9$isTa = _getPluginState9.isTableScalingEnabled,
389
- isTableScalingEnabled = _getPluginState9$isTa === void 0 ? false : _getPluginState9$isTa;
390
- var _ref = getEditorFeatureFlags ? getEditorFeatureFlags() : {},
391
- _ref$tableWithFixedCo = _ref.tableWithFixedColumnWidthsOption,
392
- tableWithFixedColumnWidthsOption = _ref$tableWithFixedCo === void 0 ? false : _ref$tableWithFixedCo;
393
- var newResizeState = (0, _resizeState.getNewResizeStateFromSelectedColumns)(selectionRect, editorView.state, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled, tableWithFixedColumnWidthsOption);
394
- var wouldChange = (_newResizeState$chang = newResizeState === null || newResizeState === void 0 ? void 0 : newResizeState.changed) !== null && _newResizeState$chang !== void 0 ? _newResizeState$chang : false;
395
- return {
396
- content: formatMessage(_messages.tableMessages.distributeColumns),
397
- value: {
398
- name: 'distribute_columns'
399
- },
400
- isDisabled: !wouldChange
401
- };
422
+ return _this.createDistributeColumnsItemInternal();
402
423
  }
403
424
  return null;
404
425
  });
@@ -467,6 +488,9 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
467
488
  (_items$0$items = items[0].items).push.apply(_items$0$items, (0, _toConsumableArray2.default)(mergeSplitCellItems));
468
489
  items[1].items.push(insertColumnItem);
469
490
  items[1].items.push(insertRowItem);
491
+ if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_2')) {
492
+ items[1].items.push(_this.newDistributeColumnsItem());
493
+ }
470
494
  items[1].items.push(clearCellsItem);
471
495
  items[1].items.push(deleteColumnItem);
472
496
  items[1].items.push(deleteRowItem);
@@ -28,9 +28,12 @@ import TableCellMergeIcon from '@atlaskit/icon/core/table-cell-merge';
28
28
  import TableCellSplitIcon from '@atlaskit/icon/core/table-cell-split';
29
29
  import TableColumnAddRightIcon from '@atlaskit/icon/core/table-column-add-right';
30
30
  import TableColumnDeleteIcon from '@atlaskit/icon/core/table-column-delete';
31
+ import TableColumnsDistributeIcon from '@atlaskit/icon/core/table-columns-distribute';
31
32
  import TableRowAddBelowIcon from '@atlaskit/icon/core/table-row-add-below';
32
33
  import TableRowDeleteIcon from '@atlaskit/icon/core/table-row-delete';
34
+ import { fg } from '@atlaskit/platform-feature-flags';
33
35
  import { Box, xcss } from '@atlaskit/primitives';
36
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
34
37
  import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, setFocusToCellMenu, toggleContextualMenu } from '../../pm-plugins/commands';
35
38
  import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics } from '../../pm-plugins/commands/commands-with-analytics';
36
39
  import { getPluginState } from '../../pm-plugins/plugin-factory';
@@ -165,6 +168,24 @@ export class ContextualMenu extends Component {
165
168
  };
166
169
  }
167
170
  });
171
+ // Used in the NewContextMenuItems object
172
+ _defineProperty(this, "newDistributeColumnsItem", () => {
173
+ const {
174
+ intl: {
175
+ formatMessage
176
+ }
177
+ } = this.props;
178
+ return this.createDistributeColumnsItemInternal({
179
+ elemBefore: jsx(Box, {
180
+ xcss: elementBeforeIconStyles
181
+ }, jsx(TableColumnsDistributeIcon, {
182
+ color: "currentColor",
183
+ spacing: "spacious",
184
+ label: formatMessage(messages.distributeColumns),
185
+ LEGACY_fallbackIcon: MergeCellsIcon
186
+ }))
187
+ });
188
+ });
168
189
  _defineProperty(this, "createMergeSplitCellItems", () => {
169
190
  const {
170
191
  allowMergeCells,
@@ -390,15 +411,37 @@ export class ContextualMenu extends Component {
390
411
  })) : undefined
391
412
  };
392
413
  });
393
- _defineProperty(this, "createDistributeColumnsItem", () => {
414
+ _defineProperty(this, "createDistributeColumnsItemInternal", partialMenuItem => {
415
+ var _newResizeState$chang;
394
416
  const {
395
417
  selectionRect,
418
+ editorView,
419
+ getEditorContainerWidth,
420
+ getEditorFeatureFlags,
396
421
  intl: {
397
422
  formatMessage
423
+ }
424
+ } = this.props;
425
+ const {
426
+ isTableScalingEnabled = false
427
+ } = getPluginState(editorView.state);
428
+ const {
429
+ tableWithFixedColumnWidthsOption = false
430
+ } = getEditorFeatureFlags ? getEditorFeatureFlags() : {};
431
+ const newResizeState = getNewResizeStateFromSelectedColumns(selectionRect, editorView.state, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled, tableWithFixedColumnWidthsOption);
432
+ const wouldChange = (_newResizeState$chang = newResizeState === null || newResizeState === void 0 ? void 0 : newResizeState.changed) !== null && _newResizeState$chang !== void 0 ? _newResizeState$chang : false;
433
+ return {
434
+ content: formatMessage(messages.distributeColumns),
435
+ value: {
436
+ name: 'distribute_columns'
398
437
  },
399
- editorView,
400
- getEditorContainerWidth,
401
- getEditorFeatureFlags
438
+ isDisabled: !wouldChange,
439
+ ...partialMenuItem
440
+ };
441
+ });
442
+ _defineProperty(this, "createDistributeColumnsItem", () => {
443
+ const {
444
+ editorView
402
445
  } = this.props;
403
446
  const {
404
447
  isDragAndDropEnabled,
@@ -407,22 +450,7 @@ export class ContextualMenu extends Component {
407
450
  }
408
451
  } = getPluginState(editorView.state);
409
452
  if (allowDistributeColumns && !isDragAndDropEnabled) {
410
- var _newResizeState$chang;
411
- const {
412
- isTableScalingEnabled = false
413
- } = getPluginState(editorView.state);
414
- const {
415
- tableWithFixedColumnWidthsOption = false
416
- } = getEditorFeatureFlags ? getEditorFeatureFlags() : {};
417
- const newResizeState = getNewResizeStateFromSelectedColumns(selectionRect, editorView.state, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled, tableWithFixedColumnWidthsOption);
418
- const wouldChange = (_newResizeState$chang = newResizeState === null || newResizeState === void 0 ? void 0 : newResizeState.changed) !== null && _newResizeState$chang !== void 0 ? _newResizeState$chang : false;
419
- return {
420
- content: formatMessage(messages.distributeColumns),
421
- value: {
422
- name: 'distribute_columns'
423
- },
424
- isDisabled: !wouldChange
425
- };
453
+ return this.createDistributeColumnsItemInternal();
426
454
  }
427
455
  return null;
428
456
  });
@@ -496,6 +524,9 @@ export class ContextualMenu extends Component {
496
524
  items[0].items.push(...mergeSplitCellItems);
497
525
  items[1].items.push(insertColumnItem);
498
526
  items[1].items.push(insertRowItem);
527
+ if (editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_2')) {
528
+ items[1].items.push(this.newDistributeColumnsItem());
529
+ }
499
530
  items[1].items.push(clearCellsItem);
500
531
  items[1].items.push(deleteColumnItem);
501
532
  items[1].items.push(deleteRowItem);
@@ -38,9 +38,12 @@ import TableCellMergeIcon from '@atlaskit/icon/core/table-cell-merge';
38
38
  import TableCellSplitIcon from '@atlaskit/icon/core/table-cell-split';
39
39
  import TableColumnAddRightIcon from '@atlaskit/icon/core/table-column-add-right';
40
40
  import TableColumnDeleteIcon from '@atlaskit/icon/core/table-column-delete';
41
+ import TableColumnsDistributeIcon from '@atlaskit/icon/core/table-columns-distribute';
41
42
  import TableRowAddBelowIcon from '@atlaskit/icon/core/table-row-add-below';
42
43
  import TableRowDeleteIcon from '@atlaskit/icon/core/table-row-delete';
44
+ import { fg } from '@atlaskit/platform-feature-flags';
43
45
  import { Box, xcss } from '@atlaskit/primitives';
46
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
44
47
  import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, setFocusToCellMenu, toggleContextualMenu } from '../../pm-plugins/commands';
45
48
  import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics } from '../../pm-plugins/commands/commands-with-analytics';
46
49
  import { getPluginState } from '../../pm-plugins/plugin-factory';
@@ -172,6 +175,20 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
172
175
  };
173
176
  }
174
177
  });
178
+ // Used in the NewContextMenuItems object
179
+ _defineProperty(_this, "newDistributeColumnsItem", function () {
180
+ var formatMessage = _this.props.intl.formatMessage;
181
+ return _this.createDistributeColumnsItemInternal({
182
+ elemBefore: jsx(Box, {
183
+ xcss: elementBeforeIconStyles
184
+ }, jsx(TableColumnsDistributeIcon, {
185
+ color: "currentColor",
186
+ spacing: "spacious",
187
+ label: formatMessage(messages.distributeColumns),
188
+ LEGACY_fallbackIcon: MergeCellsIcon
189
+ }))
190
+ });
191
+ });
175
192
  _defineProperty(_this, "createMergeSplitCellItems", function () {
176
193
  var _this$props2 = _this.props,
177
194
  allowMergeCells = _this$props2.allowMergeCells,
@@ -365,33 +382,37 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
365
382
  })) : undefined
366
383
  };
367
384
  });
368
- _defineProperty(_this, "createDistributeColumnsItem", function () {
385
+ _defineProperty(_this, "createDistributeColumnsItemInternal", function (partialMenuItem) {
386
+ var _newResizeState$chang;
369
387
  var _this$props8 = _this.props,
370
388
  selectionRect = _this$props8.selectionRect,
371
- formatMessage = _this$props8.intl.formatMessage,
372
389
  editorView = _this$props8.editorView,
373
390
  getEditorContainerWidth = _this$props8.getEditorContainerWidth,
374
- getEditorFeatureFlags = _this$props8.getEditorFeatureFlags;
391
+ getEditorFeatureFlags = _this$props8.getEditorFeatureFlags,
392
+ formatMessage = _this$props8.intl.formatMessage;
375
393
  var _getPluginState8 = getPluginState(editorView.state),
376
- isDragAndDropEnabled = _getPluginState8.isDragAndDropEnabled,
377
- allowDistributeColumns = _getPluginState8.pluginConfig.allowDistributeColumns;
394
+ _getPluginState8$isTa = _getPluginState8.isTableScalingEnabled,
395
+ isTableScalingEnabled = _getPluginState8$isTa === void 0 ? false : _getPluginState8$isTa;
396
+ var _ref = getEditorFeatureFlags ? getEditorFeatureFlags() : {},
397
+ _ref$tableWithFixedCo = _ref.tableWithFixedColumnWidthsOption,
398
+ tableWithFixedColumnWidthsOption = _ref$tableWithFixedCo === void 0 ? false : _ref$tableWithFixedCo;
399
+ var newResizeState = getNewResizeStateFromSelectedColumns(selectionRect, editorView.state, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled, tableWithFixedColumnWidthsOption);
400
+ var wouldChange = (_newResizeState$chang = newResizeState === null || newResizeState === void 0 ? void 0 : newResizeState.changed) !== null && _newResizeState$chang !== void 0 ? _newResizeState$chang : false;
401
+ return _objectSpread({
402
+ content: formatMessage(messages.distributeColumns),
403
+ value: {
404
+ name: 'distribute_columns'
405
+ },
406
+ isDisabled: !wouldChange
407
+ }, partialMenuItem);
408
+ });
409
+ _defineProperty(_this, "createDistributeColumnsItem", function () {
410
+ var editorView = _this.props.editorView;
411
+ var _getPluginState9 = getPluginState(editorView.state),
412
+ isDragAndDropEnabled = _getPluginState9.isDragAndDropEnabled,
413
+ allowDistributeColumns = _getPluginState9.pluginConfig.allowDistributeColumns;
378
414
  if (allowDistributeColumns && !isDragAndDropEnabled) {
379
- var _newResizeState$chang;
380
- var _getPluginState9 = getPluginState(editorView.state),
381
- _getPluginState9$isTa = _getPluginState9.isTableScalingEnabled,
382
- isTableScalingEnabled = _getPluginState9$isTa === void 0 ? false : _getPluginState9$isTa;
383
- var _ref = getEditorFeatureFlags ? getEditorFeatureFlags() : {},
384
- _ref$tableWithFixedCo = _ref.tableWithFixedColumnWidthsOption,
385
- tableWithFixedColumnWidthsOption = _ref$tableWithFixedCo === void 0 ? false : _ref$tableWithFixedCo;
386
- var newResizeState = getNewResizeStateFromSelectedColumns(selectionRect, editorView.state, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled, tableWithFixedColumnWidthsOption);
387
- var wouldChange = (_newResizeState$chang = newResizeState === null || newResizeState === void 0 ? void 0 : newResizeState.changed) !== null && _newResizeState$chang !== void 0 ? _newResizeState$chang : false;
388
- return {
389
- content: formatMessage(messages.distributeColumns),
390
- value: {
391
- name: 'distribute_columns'
392
- },
393
- isDisabled: !wouldChange
394
- };
415
+ return _this.createDistributeColumnsItemInternal();
395
416
  }
396
417
  return null;
397
418
  });
@@ -460,6 +481,9 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
460
481
  (_items$0$items = items[0].items).push.apply(_items$0$items, _toConsumableArray(mergeSplitCellItems));
461
482
  items[1].items.push(insertColumnItem);
462
483
  items[1].items.push(insertRowItem);
484
+ if (editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_2')) {
485
+ items[1].items.push(_this.newDistributeColumnsItem());
486
+ }
463
487
  items[1].items.push(clearCellsItem);
464
488
  items[1].items.push(deleteColumnItem);
465
489
  items[1].items.push(deleteRowItem);
@@ -42,12 +42,14 @@ export declare class ContextualMenu extends Component<Props & WrappedComponentPr
42
42
  render(): jsx.JSX.Element;
43
43
  private handleSubMenuRef;
44
44
  private createBackgroundColorItem;
45
+ private newDistributeColumnsItem;
45
46
  private createMergeSplitCellItems;
46
47
  private createInsertColumnItem;
47
48
  private createInsertRowItem;
48
49
  private createClearCellsItem;
49
50
  private createDeleteColumnItem;
50
51
  private createDeleteRowItem;
52
+ private createDistributeColumnsItemInternal;
51
53
  private createDistributeColumnsItem;
52
54
  private createSortColumnItems;
53
55
  private createOriginalContextMenuItems;
@@ -42,12 +42,14 @@ export declare class ContextualMenu extends Component<Props & WrappedComponentPr
42
42
  render(): jsx.JSX.Element;
43
43
  private handleSubMenuRef;
44
44
  private createBackgroundColorItem;
45
+ private newDistributeColumnsItem;
45
46
  private createMergeSplitCellItems;
46
47
  private createInsertColumnItem;
47
48
  private createInsertRowItem;
48
49
  private createClearCellsItem;
49
50
  private createDeleteColumnItem;
50
51
  private createDeleteRowItem;
52
+ private createDistributeColumnsItemInternal;
51
53
  private createDistributeColumnsItem;
52
54
  private createSortColumnItems;
53
55
  private createOriginalContextMenuItems;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "10.5.12",
3
+ "version": "10.6.0",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -194,6 +194,9 @@
194
194
  },
195
195
  "platform_editor_controls_patch_1": {
196
196
  "type": "boolean"
197
+ },
198
+ "platform_editor_controls_patch_2": {
199
+ "type": "boolean"
197
200
  }
198
201
  }
199
202
  }
@@ -589,7 +589,6 @@ export const TableResizer = ({
589
589
  : node.attrs.layout,
590
590
  });
591
591
 
592
-
593
592
  // Ignored via go/ees005
594
593
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
595
594
  const newNode = tr.doc.nodeAt(pos)!;
@@ -51,9 +51,12 @@ import TableCellMergeIcon from '@atlaskit/icon/core/table-cell-merge';
51
51
  import TableCellSplitIcon from '@atlaskit/icon/core/table-cell-split';
52
52
  import TableColumnAddRightIcon from '@atlaskit/icon/core/table-column-add-right';
53
53
  import TableColumnDeleteIcon from '@atlaskit/icon/core/table-column-delete';
54
+ import TableColumnsDistributeIcon from '@atlaskit/icon/core/table-columns-distribute';
54
55
  import TableRowAddBelowIcon from '@atlaskit/icon/core/table-row-add-below';
55
56
  import TableRowDeleteIcon from '@atlaskit/icon/core/table-row-delete';
57
+ import { fg } from '@atlaskit/platform-feature-flags';
56
58
  import { Box, xcss } from '@atlaskit/primitives';
59
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
57
60
 
58
61
  import {
59
62
  clearHoverSelection,
@@ -314,6 +317,25 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
314
317
  }
315
318
  };
316
319
 
320
+ // Used in the NewContextMenuItems object
321
+ private newDistributeColumnsItem = () => {
322
+ const {
323
+ intl: { formatMessage },
324
+ } = this.props;
325
+ return this.createDistributeColumnsItemInternal({
326
+ elemBefore: (
327
+ <Box xcss={elementBeforeIconStyles}>
328
+ <TableColumnsDistributeIcon
329
+ color="currentColor"
330
+ spacing="spacious"
331
+ label={formatMessage(messages.distributeColumns)}
332
+ LEGACY_fallbackIcon={MergeCellsIcon}
333
+ />
334
+ </Box>
335
+ ),
336
+ });
337
+ };
338
+
317
339
  private createMergeSplitCellItems = () => {
318
340
  const {
319
341
  allowMergeCells,
@@ -515,40 +537,47 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
515
537
  } as MenuItem;
516
538
  };
517
539
 
518
- private createDistributeColumnsItem = () => {
540
+ private createDistributeColumnsItemInternal = (partialMenuItem?: Partial<MenuItem>) => {
519
541
  const {
520
542
  selectionRect,
521
- intl: { formatMessage },
522
543
  editorView,
523
544
  getEditorContainerWidth,
524
545
  getEditorFeatureFlags,
546
+ intl: { formatMessage },
525
547
  } = this.props;
548
+
549
+ const { isTableScalingEnabled = false } = getPluginState(editorView.state);
550
+ const { tableWithFixedColumnWidthsOption = false } = getEditorFeatureFlags
551
+ ? getEditorFeatureFlags()
552
+ : {};
553
+
554
+ const newResizeState = getNewResizeStateFromSelectedColumns(
555
+ selectionRect,
556
+ editorView.state,
557
+ editorView.domAtPos.bind(editorView),
558
+ getEditorContainerWidth,
559
+ isTableScalingEnabled,
560
+ tableWithFixedColumnWidthsOption,
561
+ );
562
+
563
+ const wouldChange = newResizeState?.changed ?? false;
564
+
565
+ return {
566
+ content: formatMessage(messages.distributeColumns),
567
+ value: { name: 'distribute_columns' },
568
+ isDisabled: !wouldChange,
569
+ ...partialMenuItem,
570
+ } as MenuItem;
571
+ };
572
+
573
+ private createDistributeColumnsItem = () => {
574
+ const { editorView } = this.props;
526
575
  const {
527
576
  isDragAndDropEnabled,
528
577
  pluginConfig: { allowDistributeColumns },
529
578
  } = getPluginState(editorView.state);
530
579
  if (allowDistributeColumns && !isDragAndDropEnabled) {
531
- const { isTableScalingEnabled = false } = getPluginState(editorView.state);
532
- const { tableWithFixedColumnWidthsOption = false } = getEditorFeatureFlags
533
- ? getEditorFeatureFlags()
534
- : {};
535
-
536
- const newResizeState = getNewResizeStateFromSelectedColumns(
537
- selectionRect,
538
- editorView.state,
539
- editorView.domAtPos.bind(editorView),
540
- getEditorContainerWidth,
541
- isTableScalingEnabled,
542
- tableWithFixedColumnWidthsOption,
543
- );
544
-
545
- const wouldChange = newResizeState?.changed ?? false;
546
-
547
- return {
548
- content: formatMessage(messages.distributeColumns),
549
- value: { name: 'distribute_columns' },
550
- isDisabled: !wouldChange,
551
- } as MenuItem;
580
+ return this.createDistributeColumnsItemInternal();
552
581
  }
553
582
  return null;
554
583
  };
@@ -637,6 +666,12 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
637
666
  items[0].items.push(...mergeSplitCellItems);
638
667
  items[1].items.push(insertColumnItem);
639
668
  items[1].items.push(insertRowItem);
669
+ if (
670
+ editorExperiment('platform_editor_controls', 'variant1') &&
671
+ fg('platform_editor_controls_patch_2')
672
+ ) {
673
+ items[1].items.push(this.newDistributeColumnsItem());
674
+ }
640
675
  items[1].items.push(clearCellsItem);
641
676
  items[1].items.push(deleteColumnItem);
642
677
  items[1].items.push(deleteRowItem);