@atlaskit/editor-plugin-table 10.6.5 → 10.6.7

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,24 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 10.6.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [#137753](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/137753)
8
+ [`fe189a7e249e9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fe189a7e249e9) -
9
+ EDITOR-317 Cleans up feature gate `platform_editor_nested_tables_resizing`
10
+ - Updated dependencies
11
+
12
+ ## 10.6.6
13
+
14
+ ### Patch Changes
15
+
16
+ - [#138280](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/138280)
17
+ [`f2eac0d6772c2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f2eac0d6772c2) -
18
+ [ux] Adds a new temporary floating toolbar's config option to hide any toolbars when any table's
19
+ menu is opened.
20
+ - Updated dependencies
21
+
3
22
  ## 10.6.5
4
23
 
5
24
  ### Patch Changes
@@ -8,7 +8,6 @@ var _analytics = require("@atlaskit/editor-common/analytics");
8
8
  var _styles = require("@atlaskit/editor-common/styles");
9
9
  var _tableMap = require("@atlaskit/editor-tables/table-map");
10
10
  var _utils = require("@atlaskit/editor-tables/utils");
11
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
11
  var _columnResize = require("../commands/column-resize");
13
12
  var _misc = require("../commands/misc");
14
13
  var _pluginFactory = require("../plugin-factory");
@@ -161,7 +160,7 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
161
160
  // There may be a more elegant solution to this, to avoid a jarring experience. This used to
162
161
  // be an equality check but that caused issues when a nested table would change (eg. when it
163
162
  // dynamically updates its width on resize)
164
- if ((0, _platformFeatureFlags.fg)('platform_editor_nested_tables_resizing') ? !(0, _nodes.tablesHaveDifferentNoOfColumns)(originalTable, table) : table.eq(originalTable)) {
163
+ if (!(0, _nodes.tablesHaveDifferentNoOfColumns)(originalTable, table)) {
165
164
  var _table$attrs;
166
165
  var map = _tableMap.TableMap.get(table);
167
166
  var colIndex = map.colCount($cell.pos - start) + ($cell.nodeAfter ? $cell.nodeAfter.attrs.colspan : 1) - 1;
@@ -10,7 +10,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
10
10
  var _nodeWidth = require("@atlaskit/editor-common/node-width");
11
11
  var _styles = require("@atlaskit/editor-common/styles");
12
12
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
13
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
14
13
  var _columnWidth = require("../../transforms/column-width");
15
14
  var _nodes = require("../../utils/nodes");
16
15
  var _misc = require("../utils/misc");
@@ -178,11 +177,9 @@ var scaleTable = exports.scaleTable = function scaleTable(tableRef, options, dom
178
177
  }
179
178
  if (resizeState) {
180
179
  tr = (0, _columnWidth.updateColumnWidths)(resizeState, node, start, api)(tr);
181
- if ((0, _platformFeatureFlags.fg)('platform_editor_nested_tables_resizing')) {
182
- // Avoid adding this transaction separately to the history as these are automatic updates
183
- // as a consequence of another action
184
- tr.setMeta('addToHistory', false);
185
- }
180
+ // Avoid adding this transaction separately to the history as these are automatic updates
181
+ // as a consequence of another action
182
+ tr.setMeta('addToHistory', false);
186
183
  if (tr.docChanged) {
187
184
  tr.setMeta('scrollIntoView', false);
188
185
  // TODO: ED-8995 - We need to do this check to reduce the number of race conditions when working with tables.
@@ -610,7 +610,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
610
610
  }
611
611
  }];
612
612
  },
613
- floatingToolbar: (0, _toolbar.getToolbarConfig)(defaultGetEditorContainerWidth, api, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, function () {
613
+ floatingToolbar: (0, _toolbar.getToolbarConfig)(defaultGetEditorContainerWidth, api, editorAnalyticsAPI, function () {
614
614
  return editorViewRef.current;
615
615
  }, options, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)((0, _createPluginConfig.pluginConfig)(options === null || options === void 0 ? void 0 : options.tableOptions))
616
616
  },
@@ -37,7 +37,8 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
37
37
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
38
38
  var _commands = require("../pm-plugins/commands");
39
39
  var _commandsWithAnalytics = require("../pm-plugins/commands/commands-with-analytics");
40
- var _pluginFactory = require("../pm-plugins/plugin-factory");
40
+ var _pluginFactory = require("../pm-plugins/drag-and-drop/plugin-factory");
41
+ var _pluginFactory2 = require("../pm-plugins/plugin-factory");
41
42
  var _pluginKey = require("../pm-plugins/table-resizing/plugin-key");
42
43
  var _misc = require("../pm-plugins/table-resizing/utils/misc");
43
44
  var _resizeState = require("../pm-plugins/table-resizing/utils/resize-state");
@@ -155,7 +156,7 @@ var getToolbarCellOptionsConfig = exports.getToolbarCellOptionsConfig = function
155
156
  left = initialSelectionRect.left;
156
157
  var numberOfColumns = right - left;
157
158
  var numberOfRows = bottom - top;
158
- var pluginState = (0, _pluginFactory.getPluginState)(editorState);
159
+ var pluginState = (0, _pluginFactory2.getPluginState)(editorState);
159
160
  var options = [{
160
161
  id: 'editor.table.insertColumn',
161
162
  title: formatMessage(_messages.tableMessages.insertColumn),
@@ -318,7 +319,7 @@ var getToolbarCellOptionsConfig = exports.getToolbarCellOptionsConfig = function
318
319
  0: Math.max(numberOfColumns, numberOfRows)
319
320
  }),
320
321
  onClick: function onClick(state, dispatch) {
321
- var _getPluginState = (0, _pluginFactory.getPluginState)(state),
322
+ var _getPluginState = (0, _pluginFactory2.getPluginState)(state),
322
323
  targetCellPosition = _getPluginState.targetCellPosition;
323
324
  (0, _commandsWithAnalytics.emptyMultipleCellsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.FLOATING_TB, targetCellPosition)(state, dispatch);
324
325
  return true;
@@ -361,21 +362,46 @@ var getClosestSelectionOrTableRect = function getClosestSelectionOrTableRect(sta
361
362
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
362
363
  return (0, _utils3.isSelectionType)(selection, 'cell') ? (0, _utils3.getSelectionRect)(selection) : tableRect;
363
364
  };
364
- var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, api, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView, options) {
365
- var isTableFixedColumnWidthsOptionEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
366
- var shouldUseIncreasedScalingPercent = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
365
+ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, api, editorAnalyticsAPI, getEditorView, options) {
366
+ var isTableFixedColumnWidthsOptionEnabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
367
+ var shouldUseIncreasedScalingPercent = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
367
368
  return function (config) {
368
369
  return function (state, intl) {
369
370
  var tableObject = (0, _utils3.findTable)(state.selection);
370
- var pluginState = (0, _pluginFactory.getPluginState)(state);
371
+ var pluginState = (0, _pluginFactory2.getPluginState)(state);
371
372
  var resizeState = _pluginKey.pluginKey.getState(state);
372
373
  var tableWidthState = _tableWidth.pluginKey.getState(state);
373
374
  var isTableScalingEnabled = (options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) || false;
375
+ var nodeType = state.schema.nodes.table;
376
+ var toolbarTitle = 'Table floating controls';
377
+ if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_3')) {
378
+ var isDragHandleMenuOpened = false;
379
+ var isTableRowOrColumnDragged = false;
380
+ if (options !== null && options !== void 0 && options.dragAndDropEnabled) {
381
+ var _getDragDropPluginSta = (0, _pluginFactory.getPluginState)(state),
382
+ _getDragDropPluginSta2 = _getDragDropPluginSta.isDragMenuOpen,
383
+ isDragMenuOpen = _getDragDropPluginSta2 === void 0 ? false : _getDragDropPluginSta2,
384
+ _getDragDropPluginSta3 = _getDragDropPluginSta.isDragging,
385
+ isDragging = _getDragDropPluginSta3 === void 0 ? false : _getDragDropPluginSta3;
386
+ isDragHandleMenuOpened = isDragMenuOpen;
387
+ isTableRowOrColumnDragged = isDragging;
388
+ }
389
+ var isTableOrColumnResizing = !!(resizeState !== null && resizeState !== void 0 && resizeState.dragging || tableWidthState !== null && tableWidthState !== void 0 && tableWidthState.resizing);
390
+ var isTableMenuOpened = pluginState.isContextualMenuOpen || isDragHandleMenuOpened;
391
+ var shouldSuppressAllToolbars = !pluginState.editorHasFocus || isTableMenuOpened || isTableOrColumnResizing || isTableRowOrColumnDragged;
392
+ if (shouldSuppressAllToolbars) {
393
+ return {
394
+ title: toolbarTitle,
395
+ items: [],
396
+ nodeType: nodeType,
397
+ __suppressAllToolbars: true
398
+ };
399
+ }
400
+ }
374
401
 
375
402
  // We don't want to show floating toolbar while resizing the table
376
403
  var isWidthResizing = tableWidthState === null || tableWidthState === void 0 ? void 0 : tableWidthState.resizing;
377
404
  if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
378
- var nodeType = state.schema.nodes.table;
379
405
  var isNested = pluginState.tablePos && (0, _nodes.isTableNested)(state, pluginState.tablePos);
380
406
  var isTableScalingWithFixedColumnWidthsOptionShown = isTableScalingEnabled && isTableFixedColumnWidthsOptionEnabled && !isNested;
381
407
  var areTableColumWidthsFixed = tableObject.node.attrs.displayMode === 'fixed';
@@ -463,7 +489,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
463
489
  } : undefined;
464
490
  };
465
491
  return {
466
- title: 'Table floating controls',
492
+ title: toolbarTitle,
467
493
  getDomRef: getDomRef,
468
494
  nodeType: nodeType,
469
495
  offset: [0, 18],
@@ -581,7 +607,7 @@ var getColumnSettingItems = function getColumnSettingItems(editorState, editorVi
581
607
  var isTableScalingEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
582
608
  var isTableFixedColumnWidthsOptionEnabled = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
583
609
  var isCommentEditor = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false;
584
- var pluginState = (0, _pluginFactory.getPluginState)(editorState);
610
+ var pluginState = (0, _pluginFactory2.getPluginState)(editorState);
585
611
  var selectionOrTableRect = getClosestSelectionOrTableRect(editorState);
586
612
  if (!selectionOrTableRect || !editorView) {
587
613
  return [];
@@ -617,7 +643,7 @@ var getColumnSettingItems = function getColumnSettingItems(editorState, editorVi
617
643
  var getColorPicker = function getColorPicker(state, menu, _ref5, editorAnalyticsAPI, getEditorView) {
618
644
  var _node$attrs;
619
645
  var formatMessage = _ref5.formatMessage;
620
- var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
646
+ var _getPluginState2 = (0, _pluginFactory2.getPluginState)(state),
621
647
  targetCellPosition = _getPluginState2.targetCellPosition,
622
648
  pluginConfig = _getPluginState2.pluginConfig;
623
649
  if (!pluginConfig.allowBackgroundColor) {
@@ -2,7 +2,6 @@ import { ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION, TABLE_OVERFLOW_
2
2
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
3
3
  import { TableMap } from '@atlaskit/editor-tables/table-map';
4
4
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
5
- import { fg } from '@atlaskit/platform-feature-flags';
6
5
  import { stopKeyboardColumnResizing } from '../commands/column-resize';
7
6
  import { updateResizeHandleDecorations } from '../commands/misc';
8
7
  import { getPluginState as getTablePluginState } from '../plugin-factory';
@@ -169,7 +168,7 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
169
168
  // There may be a more elegant solution to this, to avoid a jarring experience. This used to
170
169
  // be an equality check but that caused issues when a nested table would change (eg. when it
171
170
  // dynamically updates its width on resize)
172
- if (fg('platform_editor_nested_tables_resizing') ? !tablesHaveDifferentNoOfColumns(originalTable, table) : table.eq(originalTable)) {
171
+ if (!tablesHaveDifferentNoOfColumns(originalTable, table)) {
173
172
  var _table$attrs;
174
173
  const map = TableMap.get(table);
175
174
  const colIndex = map.colCount($cell.pos - start) + ($cell.nodeAfter ? $cell.nodeAfter.attrs.colspan : 1) - 1;
@@ -1,7 +1,6 @@
1
1
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
2
2
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
3
3
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
4
- import { fg } from '@atlaskit/platform-feature-flags';
5
4
  import { updateColumnWidths } from '../../transforms/column-width';
6
5
  import { getTableWidth } from '../../utils/nodes';
7
6
  import { getLayoutSize } from '../utils/misc';
@@ -164,11 +163,9 @@ export const scaleTable = (tableRef, options, domAtPos, api, isTableScalingEnabl
164
163
  }
165
164
  if (resizeState) {
166
165
  tr = updateColumnWidths(resizeState, node, start, api)(tr);
167
- if (fg('platform_editor_nested_tables_resizing')) {
168
- // Avoid adding this transaction separately to the history as these are automatic updates
169
- // as a consequence of another action
170
- tr.setMeta('addToHistory', false);
171
- }
166
+ // Avoid adding this transaction separately to the history as these are automatic updates
167
+ // as a consequence of another action
168
+ tr.setMeta('addToHistory', false);
172
169
  if (tr.docChanged) {
173
170
  tr.setMeta('scrollIntoView', false);
174
171
  // TODO: ED-8995 - We need to do this check to reduce the number of race conditions when working with tables.
@@ -605,7 +605,7 @@ const tablesPlugin = ({
605
605
  return tr;
606
606
  }
607
607
  }],
608
- floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, api, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, () => editorViewRef.current, options, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
608
+ floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, api, editorAnalyticsAPI, () => editorViewRef.current, options, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
609
609
  },
610
610
  usePluginHook({
611
611
  editorView
@@ -32,6 +32,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
32
32
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
33
33
  import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, hoverTable, removeDescendantNodes } from '../pm-plugins/commands';
34
34
  import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, deleteTableWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, setTableAlignmentWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics, toggleFixedColumnWidthsOptionAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, wrapTableInExpandWithAnalytics } from '../pm-plugins/commands/commands-with-analytics';
35
+ import { getPluginState as getDragDropPluginState } from '../pm-plugins/drag-and-drop/plugin-factory';
35
36
  import { getPluginState } from '../pm-plugins/plugin-factory';
36
37
  import { pluginKey as tableResizingPluginKey } from '../pm-plugins/table-resizing/plugin-key';
37
38
  import { getStaticTableScalingPercent } from '../pm-plugins/table-resizing/utils/misc';
@@ -344,17 +345,41 @@ const getClosestSelectionOrTableRect = state => {
344
345
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
345
346
  return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : tableRect;
346
347
  };
347
- export const getToolbarConfig = (getEditorContainerWidth, api, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView, options, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false) => config => (state, intl) => {
348
+ export const getToolbarConfig = (getEditorContainerWidth, api, editorAnalyticsAPI, getEditorView, options, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false) => config => (state, intl) => {
348
349
  const tableObject = findTable(state.selection);
349
350
  const pluginState = getPluginState(state);
350
351
  const resizeState = tableResizingPluginKey.getState(state);
351
352
  const tableWidthState = tableWidthPluginKey.getState(state);
352
353
  const isTableScalingEnabled = (options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) || false;
354
+ const nodeType = state.schema.nodes.table;
355
+ const toolbarTitle = 'Table floating controls';
356
+ if (editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_3')) {
357
+ let isDragHandleMenuOpened = false;
358
+ let isTableRowOrColumnDragged = false;
359
+ if (options !== null && options !== void 0 && options.dragAndDropEnabled) {
360
+ const {
361
+ isDragMenuOpen = false,
362
+ isDragging = false
363
+ } = getDragDropPluginState(state);
364
+ isDragHandleMenuOpened = isDragMenuOpen;
365
+ isTableRowOrColumnDragged = isDragging;
366
+ }
367
+ const isTableOrColumnResizing = !!(resizeState !== null && resizeState !== void 0 && resizeState.dragging || tableWidthState !== null && tableWidthState !== void 0 && tableWidthState.resizing);
368
+ const isTableMenuOpened = pluginState.isContextualMenuOpen || isDragHandleMenuOpened;
369
+ const shouldSuppressAllToolbars = !pluginState.editorHasFocus || isTableMenuOpened || isTableOrColumnResizing || isTableRowOrColumnDragged;
370
+ if (shouldSuppressAllToolbars) {
371
+ return {
372
+ title: toolbarTitle,
373
+ items: [],
374
+ nodeType,
375
+ __suppressAllToolbars: true
376
+ };
377
+ }
378
+ }
353
379
 
354
380
  // We don't want to show floating toolbar while resizing the table
355
381
  const isWidthResizing = tableWidthState === null || tableWidthState === void 0 ? void 0 : tableWidthState.resizing;
356
382
  if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
357
- const nodeType = state.schema.nodes.table;
358
383
  const isNested = pluginState.tablePos && isTableNested(state, pluginState.tablePos);
359
384
  const isTableScalingWithFixedColumnWidthsOptionShown = isTableScalingEnabled && isTableFixedColumnWidthsOptionEnabled && !isNested;
360
385
  const areTableColumWidthsFixed = tableObject.node.attrs.displayMode === 'fixed';
@@ -433,7 +458,7 @@ export const getToolbarConfig = (getEditorContainerWidth, api, editorAnalyticsAP
433
458
  onBlur: clearHoverSelection()
434
459
  } : undefined;
435
460
  return {
436
- title: 'Table floating controls',
461
+ title: toolbarTitle,
437
462
  getDomRef,
438
463
  nodeType,
439
464
  offset: [0, 18],
@@ -2,7 +2,6 @@ import { ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION, TABLE_OVERFLOW_
2
2
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
3
3
  import { TableMap } from '@atlaskit/editor-tables/table-map';
4
4
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
5
- import { fg } from '@atlaskit/platform-feature-flags';
6
5
  import { stopKeyboardColumnResizing } from '../commands/column-resize';
7
6
  import { updateResizeHandleDecorations } from '../commands/misc';
8
7
  import { getPluginState as getTablePluginState } from '../plugin-factory';
@@ -155,7 +154,7 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
155
154
  // There may be a more elegant solution to this, to avoid a jarring experience. This used to
156
155
  // be an equality check but that caused issues when a nested table would change (eg. when it
157
156
  // dynamically updates its width on resize)
158
- if (fg('platform_editor_nested_tables_resizing') ? !tablesHaveDifferentNoOfColumns(originalTable, table) : table.eq(originalTable)) {
157
+ if (!tablesHaveDifferentNoOfColumns(originalTable, table)) {
159
158
  var _table$attrs;
160
159
  var map = TableMap.get(table);
161
160
  var colIndex = map.colCount($cell.pos - start) + ($cell.nodeAfter ? $cell.nodeAfter.attrs.colspan : 1) - 1;
@@ -4,7 +4,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
5
5
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
6
6
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
7
- import { fg } from '@atlaskit/platform-feature-flags';
8
7
  import { updateColumnWidths } from '../../transforms/column-width';
9
8
  import { getTableWidth } from '../../utils/nodes';
10
9
  import { getLayoutSize } from '../utils/misc';
@@ -170,11 +169,9 @@ export var scaleTable = function scaleTable(tableRef, options, domAtPos, api) {
170
169
  }
171
170
  if (resizeState) {
172
171
  tr = updateColumnWidths(resizeState, node, start, api)(tr);
173
- if (fg('platform_editor_nested_tables_resizing')) {
174
- // Avoid adding this transaction separately to the history as these are automatic updates
175
- // as a consequence of another action
176
- tr.setMeta('addToHistory', false);
177
- }
172
+ // Avoid adding this transaction separately to the history as these are automatic updates
173
+ // as a consequence of another action
174
+ tr.setMeta('addToHistory', false);
178
175
  if (tr.docChanged) {
179
176
  tr.setMeta('scrollIntoView', false);
180
177
  // TODO: ED-8995 - We need to do this check to reduce the number of race conditions when working with tables.
@@ -601,7 +601,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
601
601
  }
602
602
  }];
603
603
  },
604
- floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, api, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, function () {
604
+ floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, api, editorAnalyticsAPI, function () {
605
605
  return editorViewRef.current;
606
606
  }, options, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
607
607
  },
@@ -36,6 +36,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
36
36
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
37
37
  import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, hoverTable, removeDescendantNodes } from '../pm-plugins/commands';
38
38
  import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, deleteTableWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, setTableAlignmentWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics, toggleFixedColumnWidthsOptionAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, wrapTableInExpandWithAnalytics } from '../pm-plugins/commands/commands-with-analytics';
39
+ import { getPluginState as getDragDropPluginState } from '../pm-plugins/drag-and-drop/plugin-factory';
39
40
  import { getPluginState } from '../pm-plugins/plugin-factory';
40
41
  import { pluginKey as tableResizingPluginKey } from '../pm-plugins/table-resizing/plugin-key';
41
42
  import { getStaticTableScalingPercent } from '../pm-plugins/table-resizing/utils/misc';
@@ -353,9 +354,9 @@ var getClosestSelectionOrTableRect = function getClosestSelectionOrTableRect(sta
353
354
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
354
355
  return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : tableRect;
355
356
  };
356
- export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, api, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView, options) {
357
- var isTableFixedColumnWidthsOptionEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
358
- var shouldUseIncreasedScalingPercent = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
357
+ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, api, editorAnalyticsAPI, getEditorView, options) {
358
+ var isTableFixedColumnWidthsOptionEnabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
359
+ var shouldUseIncreasedScalingPercent = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
359
360
  return function (config) {
360
361
  return function (state, intl) {
361
362
  var tableObject = findTable(state.selection);
@@ -363,11 +364,36 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
363
364
  var resizeState = tableResizingPluginKey.getState(state);
364
365
  var tableWidthState = tableWidthPluginKey.getState(state);
365
366
  var isTableScalingEnabled = (options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) || false;
367
+ var nodeType = state.schema.nodes.table;
368
+ var toolbarTitle = 'Table floating controls';
369
+ if (editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_3')) {
370
+ var isDragHandleMenuOpened = false;
371
+ var isTableRowOrColumnDragged = false;
372
+ if (options !== null && options !== void 0 && options.dragAndDropEnabled) {
373
+ var _getDragDropPluginSta = getDragDropPluginState(state),
374
+ _getDragDropPluginSta2 = _getDragDropPluginSta.isDragMenuOpen,
375
+ isDragMenuOpen = _getDragDropPluginSta2 === void 0 ? false : _getDragDropPluginSta2,
376
+ _getDragDropPluginSta3 = _getDragDropPluginSta.isDragging,
377
+ isDragging = _getDragDropPluginSta3 === void 0 ? false : _getDragDropPluginSta3;
378
+ isDragHandleMenuOpened = isDragMenuOpen;
379
+ isTableRowOrColumnDragged = isDragging;
380
+ }
381
+ var isTableOrColumnResizing = !!(resizeState !== null && resizeState !== void 0 && resizeState.dragging || tableWidthState !== null && tableWidthState !== void 0 && tableWidthState.resizing);
382
+ var isTableMenuOpened = pluginState.isContextualMenuOpen || isDragHandleMenuOpened;
383
+ var shouldSuppressAllToolbars = !pluginState.editorHasFocus || isTableMenuOpened || isTableOrColumnResizing || isTableRowOrColumnDragged;
384
+ if (shouldSuppressAllToolbars) {
385
+ return {
386
+ title: toolbarTitle,
387
+ items: [],
388
+ nodeType: nodeType,
389
+ __suppressAllToolbars: true
390
+ };
391
+ }
392
+ }
366
393
 
367
394
  // We don't want to show floating toolbar while resizing the table
368
395
  var isWidthResizing = tableWidthState === null || tableWidthState === void 0 ? void 0 : tableWidthState.resizing;
369
396
  if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
370
- var nodeType = state.schema.nodes.table;
371
397
  var isNested = pluginState.tablePos && isTableNested(state, pluginState.tablePos);
372
398
  var isTableScalingWithFixedColumnWidthsOptionShown = isTableScalingEnabled && isTableFixedColumnWidthsOptionEnabled && !isNested;
373
399
  var areTableColumWidthsFixed = tableObject.node.attrs.displayMode === 'fixed';
@@ -455,7 +481,7 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
455
481
  } : undefined;
456
482
  };
457
483
  return {
458
- title: 'Table floating controls',
484
+ title: toolbarTitle,
459
485
  getDomRef: getDomRef,
460
486
  nodeType: nodeType,
461
487
  offset: [0, 18],
@@ -1,5 +1,5 @@
1
1
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
- import type { Command, FloatingToolbarDropdown, FloatingToolbarHandler, FloatingToolbarItem, GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
2
+ import type { Command, FloatingToolbarDropdown, FloatingToolbarHandler, FloatingToolbarItem, GetEditorContainerWidth } from '@atlaskit/editor-common/types';
3
3
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
5
  import { Rect } from '@atlaskit/editor-tables/table-map';
@@ -8,4 +8,4 @@ import type { PluginConfig, PluginInjectionAPI, ToolbarMenuConfig, ToolbarMenuCo
8
8
  export declare const getToolbarMenuConfig: (config: ToolbarMenuConfig, state: ToolbarMenuState, { formatMessage }: ToolbarMenuContext, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, isTableScalingWithFixedColumnWidthsOptionShown?: boolean, areTableColumnWidthsFixed?: boolean) => FloatingToolbarItem<Command>;
9
9
  export declare const getToolbarCellOptionsConfig: (editorState: EditorState, editorView: EditorView | undefined | null, initialSelectionRect: Rect, { formatMessage }: ToolbarMenuContext, getEditorContainerWidth: GetEditorContainerWidth, api: PluginInjectionAPI | undefined | null, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, isTableScalingEnabled?: boolean, isTableFixedColumnWidthsOptionEnabled?: boolean, shouldUseIncreasedScalingPercent?: boolean, isCommentEditor?: boolean) => FloatingToolbarDropdown<Command>;
10
10
  export declare const getClosestSelectionRect: (state: EditorState) => Rect | undefined;
11
- export declare const getToolbarConfig: (getEditorContainerWidth: GetEditorContainerWidth, api: PluginInjectionAPI | undefined | null, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, getEditorFeatureFlags: GetEditorFeatureFlags, getEditorView: () => EditorView | null, options?: TablePluginOptions, isTableFixedColumnWidthsOptionEnabled?: boolean, shouldUseIncreasedScalingPercent?: boolean) => (config: PluginConfig) => FloatingToolbarHandler;
11
+ export declare const getToolbarConfig: (getEditorContainerWidth: GetEditorContainerWidth, api: PluginInjectionAPI | undefined | null, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, getEditorView: () => EditorView | null, options?: TablePluginOptions, isTableFixedColumnWidthsOptionEnabled?: boolean, shouldUseIncreasedScalingPercent?: boolean) => (config: PluginConfig) => FloatingToolbarHandler;
@@ -1,5 +1,5 @@
1
1
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
- import type { Command, FloatingToolbarDropdown, FloatingToolbarHandler, FloatingToolbarItem, GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
2
+ import type { Command, FloatingToolbarDropdown, FloatingToolbarHandler, FloatingToolbarItem, GetEditorContainerWidth } from '@atlaskit/editor-common/types';
3
3
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
5
  import { Rect } from '@atlaskit/editor-tables/table-map';
@@ -8,4 +8,4 @@ import type { PluginConfig, PluginInjectionAPI, ToolbarMenuConfig, ToolbarMenuCo
8
8
  export declare const getToolbarMenuConfig: (config: ToolbarMenuConfig, state: ToolbarMenuState, { formatMessage }: ToolbarMenuContext, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, isTableScalingWithFixedColumnWidthsOptionShown?: boolean, areTableColumnWidthsFixed?: boolean) => FloatingToolbarItem<Command>;
9
9
  export declare const getToolbarCellOptionsConfig: (editorState: EditorState, editorView: EditorView | undefined | null, initialSelectionRect: Rect, { formatMessage }: ToolbarMenuContext, getEditorContainerWidth: GetEditorContainerWidth, api: PluginInjectionAPI | undefined | null, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, isTableScalingEnabled?: boolean, isTableFixedColumnWidthsOptionEnabled?: boolean, shouldUseIncreasedScalingPercent?: boolean, isCommentEditor?: boolean) => FloatingToolbarDropdown<Command>;
10
10
  export declare const getClosestSelectionRect: (state: EditorState) => Rect | undefined;
11
- export declare const getToolbarConfig: (getEditorContainerWidth: GetEditorContainerWidth, api: PluginInjectionAPI | undefined | null, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, getEditorFeatureFlags: GetEditorFeatureFlags, getEditorView: () => EditorView | null, options?: TablePluginOptions, isTableFixedColumnWidthsOptionEnabled?: boolean, shouldUseIncreasedScalingPercent?: boolean) => (config: PluginConfig) => FloatingToolbarHandler;
11
+ export declare const getToolbarConfig: (getEditorContainerWidth: GetEditorContainerWidth, api: PluginInjectionAPI | undefined | null, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, getEditorView: () => EditorView | null, options?: TablePluginOptions, isTableFixedColumnWidthsOptionEnabled?: boolean, shouldUseIncreasedScalingPercent?: boolean) => (config: PluginConfig) => FloatingToolbarHandler;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "10.6.5",
3
+ "version": "10.6.7",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -132,9 +132,6 @@
132
132
  "platform_editor_live_page_prevent_table_recreation": {
133
133
  "type": "boolean"
134
134
  },
135
- "platform_editor_nested_tables_resizing": {
136
- "type": "boolean"
137
- },
138
135
  "platform_editor_disable_table_lnv": {
139
136
  "type": "boolean"
140
137
  },
@@ -200,6 +197,9 @@
200
197
  },
201
198
  "platform_editor_controls_patch_2": {
202
199
  "type": "boolean"
200
+ },
201
+ "platform_editor_controls_patch_3": {
202
+ "type": "boolean"
203
203
  }
204
204
  }
205
205
  }
@@ -13,7 +13,6 @@ import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/e
13
13
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
14
14
  import { TableMap } from '@atlaskit/editor-tables/table-map';
15
15
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
16
- import { fg } from '@atlaskit/platform-feature-flags';
17
16
 
18
17
  import type { PluginInjectionAPI } from '../../types';
19
18
  import { stopKeyboardColumnResizing } from '../commands/column-resize';
@@ -203,11 +202,7 @@ export const handleMouseDown = (
203
202
  // There may be a more elegant solution to this, to avoid a jarring experience. This used to
204
203
  // be an equality check but that caused issues when a nested table would change (eg. when it
205
204
  // dynamically updates its width on resize)
206
- if (
207
- fg('platform_editor_nested_tables_resizing')
208
- ? !tablesHaveDifferentNoOfColumns(originalTable, table)
209
- : table.eq(originalTable)
210
- ) {
205
+ if (!tablesHaveDifferentNoOfColumns(originalTable, table)) {
211
206
  const map = TableMap.get(table);
212
207
  const colIndex =
213
208
  map.colCount($cell.pos - start) +
@@ -4,7 +4,6 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
4
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
5
5
  import type { DomAtPos } from '@atlaskit/editor-prosemirror/utils';
6
6
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
7
- import { fg } from '@atlaskit/platform-feature-flags';
8
7
 
9
8
  import type { PluginInjectionAPI } from '../../../types';
10
9
  import { updateColumnWidths } from '../../transforms/column-width';
@@ -268,11 +267,9 @@ export const scaleTable =
268
267
 
269
268
  if (resizeState) {
270
269
  tr = updateColumnWidths(resizeState, node, start, api)(tr);
271
- if (fg('platform_editor_nested_tables_resizing')) {
272
- // Avoid adding this transaction separately to the history as these are automatic updates
273
- // as a consequence of another action
274
- tr.setMeta('addToHistory', false);
275
- }
270
+ // Avoid adding this transaction separately to the history as these are automatic updates
271
+ // as a consequence of another action
272
+ tr.setMeta('addToHistory', false);
276
273
 
277
274
  if (tr.docChanged) {
278
275
  tr.setMeta('scrollIntoView', false);
@@ -768,7 +768,6 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
768
768
  defaultGetEditorContainerWidth,
769
769
  api,
770
770
  editorAnalyticsAPI,
771
- options?.getEditorFeatureFlags || defaultGetEditorFeatureFlags,
772
771
  () => editorViewRef.current,
773
772
  options,
774
773
  isTableFixedColumnWidthsOptionEnabled,
@@ -23,7 +23,6 @@ import type {
23
23
  FloatingToolbarHandler,
24
24
  FloatingToolbarItem,
25
25
  GetEditorContainerWidth,
26
- GetEditorFeatureFlags,
27
26
  Icon,
28
27
  typeOption,
29
28
  } from '@atlaskit/editor-common/types';
@@ -87,6 +86,7 @@ import {
87
86
  toggleNumberColumnWithAnalytics,
88
87
  wrapTableInExpandWithAnalytics,
89
88
  } from '../pm-plugins/commands/commands-with-analytics';
89
+ import { getPluginState as getDragDropPluginState } from '../pm-plugins/drag-and-drop/plugin-factory';
90
90
  import { getPluginState } from '../pm-plugins/plugin-factory';
91
91
  import { pluginKey as tableResizingPluginKey } from '../pm-plugins/table-resizing/plugin-key';
92
92
  import { getStaticTableScalingPercent } from '../pm-plugins/table-resizing/utils/misc';
@@ -479,7 +479,6 @@ export const getToolbarConfig =
479
479
  getEditorContainerWidth: GetEditorContainerWidth,
480
480
  api: PluginInjectionAPI | undefined | null,
481
481
  editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
482
- getEditorFeatureFlags: GetEditorFeatureFlags,
483
482
  getEditorView: () => EditorView | null,
484
483
  options?: TablePluginOptions,
485
484
  isTableFixedColumnWidthsOptionEnabled = false,
@@ -492,12 +491,42 @@ export const getToolbarConfig =
492
491
  const resizeState = tableResizingPluginKey.getState(state);
493
492
  const tableWidthState = tableWidthPluginKey.getState(state);
494
493
  const isTableScalingEnabled = options?.isTableScalingEnabled || false;
494
+ const nodeType = state.schema.nodes.table;
495
+ const toolbarTitle = 'Table floating controls';
496
+
497
+ if (
498
+ editorExperiment('platform_editor_controls', 'variant1') &&
499
+ fg('platform_editor_controls_patch_3')
500
+ ) {
501
+ let isDragHandleMenuOpened = false;
502
+ let isTableRowOrColumnDragged = false;
503
+ if (options?.dragAndDropEnabled) {
504
+ const { isDragMenuOpen = false, isDragging = false } = getDragDropPluginState(state);
505
+ isDragHandleMenuOpened = isDragMenuOpen;
506
+ isTableRowOrColumnDragged = isDragging;
507
+ }
508
+
509
+ const isTableOrColumnResizing = !!(resizeState?.dragging || tableWidthState?.resizing);
510
+ const isTableMenuOpened = pluginState.isContextualMenuOpen || isDragHandleMenuOpened;
511
+ const shouldSuppressAllToolbars =
512
+ !pluginState.editorHasFocus ||
513
+ isTableMenuOpened ||
514
+ isTableOrColumnResizing ||
515
+ isTableRowOrColumnDragged;
516
+ if (shouldSuppressAllToolbars) {
517
+ return {
518
+ title: toolbarTitle,
519
+ items: [],
520
+ nodeType,
521
+ __suppressAllToolbars: true,
522
+ };
523
+ }
524
+ }
495
525
 
496
526
  // We don't want to show floating toolbar while resizing the table
497
527
  const isWidthResizing = tableWidthState?.resizing;
498
528
 
499
529
  if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
500
- const nodeType = state.schema.nodes.table;
501
530
  const isNested = pluginState.tablePos && isTableNested(state, pluginState.tablePos);
502
531
  const isTableScalingWithFixedColumnWidthsOptionShown =
503
532
  isTableScalingEnabled && isTableFixedColumnWidthsOptionEnabled && !isNested;
@@ -645,7 +674,7 @@ export const getToolbarConfig =
645
674
  : undefined;
646
675
 
647
676
  return {
648
- title: 'Table floating controls',
677
+ title: toolbarTitle,
649
678
  getDomRef,
650
679
  nodeType,
651
680
  offset: [0, 18],