@atlaskit/editor-plugin-table 10.6.8 → 10.6.9

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,15 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 10.6.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [#139053](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/139053)
8
+ [`c1c6278a78c4a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c1c6278a78c4a) -
9
+ [ux] Adds a new temporary floating toolbar's config option to hide any toolbars when any table's
10
+ menu is opend.
11
+ - Updated dependencies
12
+
3
13
  ## 10.6.8
4
14
 
5
15
  ### Patch Changes
@@ -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,48 @@ 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_4')) {
378
+ var _api$editorViewMode;
379
+ var isDragHandleMenuOpened = false;
380
+ var isTableRowOrColumnDragged = false;
381
+ if (options !== null && options !== void 0 && options.dragAndDropEnabled) {
382
+ var _getDragDropPluginSta = (0, _pluginFactory.getPluginState)(state),
383
+ _getDragDropPluginSta2 = _getDragDropPluginSta.isDragMenuOpen,
384
+ isDragMenuOpen = _getDragDropPluginSta2 === void 0 ? false : _getDragDropPluginSta2,
385
+ _getDragDropPluginSta3 = _getDragDropPluginSta.isDragging,
386
+ isDragging = _getDragDropPluginSta3 === void 0 ? false : _getDragDropPluginSta3;
387
+ isDragHandleMenuOpened = isDragMenuOpen;
388
+ isTableRowOrColumnDragged = isDragging;
389
+ }
390
+ var isTableOrColumnResizing = !!(resizeState !== null && resizeState !== void 0 && resizeState.dragging || tableWidthState !== null && tableWidthState !== void 0 && tableWidthState.resizing);
391
+ var isTableMenuOpened = pluginState.isContextualMenuOpen || isDragHandleMenuOpened;
392
+ var isViewMode = (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'view';
393
+ var shouldSuppressAllToolbars = !pluginState.editorHasFocus && !isViewMode || isTableMenuOpened || isTableOrColumnResizing || isTableRowOrColumnDragged;
394
+ if (shouldSuppressAllToolbars) {
395
+ return {
396
+ title: toolbarTitle,
397
+ items: [],
398
+ nodeType: nodeType,
399
+ __suppressAllToolbars: true
400
+ };
401
+ }
402
+ }
374
403
 
375
404
  // We don't want to show floating toolbar while resizing the table
376
405
  var isWidthResizing = tableWidthState === null || tableWidthState === void 0 ? void 0 : tableWidthState.resizing;
377
406
  if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
378
- var nodeType = state.schema.nodes.table;
379
407
  var isNested = pluginState.tablePos && (0, _nodes.isTableNested)(state, pluginState.tablePos);
380
408
  var isTableScalingWithFixedColumnWidthsOptionShown = isTableScalingEnabled && isTableFixedColumnWidthsOptionEnabled && !isNested;
381
409
  var areTableColumWidthsFixed = tableObject.node.attrs.displayMode === 'fixed';
@@ -463,7 +491,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
463
491
  } : undefined;
464
492
  };
465
493
  return {
466
- title: 'Table floating controls',
494
+ title: toolbarTitle,
467
495
  getDomRef: getDomRef,
468
496
  nodeType: nodeType,
469
497
  offset: [0, 18],
@@ -581,7 +609,7 @@ var getColumnSettingItems = function getColumnSettingItems(editorState, editorVi
581
609
  var isTableScalingEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
582
610
  var isTableFixedColumnWidthsOptionEnabled = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
583
611
  var isCommentEditor = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false;
584
- var pluginState = (0, _pluginFactory.getPluginState)(editorState);
612
+ var pluginState = (0, _pluginFactory2.getPluginState)(editorState);
585
613
  var selectionOrTableRect = getClosestSelectionOrTableRect(editorState);
586
614
  if (!selectionOrTableRect || !editorView) {
587
615
  return [];
@@ -617,7 +645,7 @@ var getColumnSettingItems = function getColumnSettingItems(editorState, editorVi
617
645
  var getColorPicker = function getColorPicker(state, menu, _ref5, editorAnalyticsAPI, getEditorView) {
618
646
  var _node$attrs;
619
647
  var formatMessage = _ref5.formatMessage;
620
- var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
648
+ var _getPluginState2 = (0, _pluginFactory2.getPluginState)(state),
621
649
  targetCellPosition = _getPluginState2.targetCellPosition,
622
650
  pluginConfig = _getPluginState2.pluginConfig;
623
651
  if (!pluginConfig.allowBackgroundColor) {
@@ -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,43 @@ 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_4')) {
357
+ var _api$editorViewMode, _api$editorViewMode$s;
358
+ let isDragHandleMenuOpened = false;
359
+ let isTableRowOrColumnDragged = false;
360
+ if (options !== null && options !== void 0 && options.dragAndDropEnabled) {
361
+ const {
362
+ isDragMenuOpen = false,
363
+ isDragging = false
364
+ } = getDragDropPluginState(state);
365
+ isDragHandleMenuOpened = isDragMenuOpen;
366
+ isTableRowOrColumnDragged = isDragging;
367
+ }
368
+ const isTableOrColumnResizing = !!(resizeState !== null && resizeState !== void 0 && resizeState.dragging || tableWidthState !== null && tableWidthState !== void 0 && tableWidthState.resizing);
369
+ const isTableMenuOpened = pluginState.isContextualMenuOpen || isDragHandleMenuOpened;
370
+ const isViewMode = (api === null || api === void 0 ? void 0 : (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : (_api$editorViewMode$s = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode$s === void 0 ? void 0 : _api$editorViewMode$s.mode) === 'view';
371
+ const shouldSuppressAllToolbars = !pluginState.editorHasFocus && !isViewMode || isTableMenuOpened || isTableOrColumnResizing || isTableRowOrColumnDragged;
372
+ if (shouldSuppressAllToolbars) {
373
+ return {
374
+ title: toolbarTitle,
375
+ items: [],
376
+ nodeType,
377
+ __suppressAllToolbars: true
378
+ };
379
+ }
380
+ }
353
381
 
354
382
  // We don't want to show floating toolbar while resizing the table
355
383
  const isWidthResizing = tableWidthState === null || tableWidthState === void 0 ? void 0 : tableWidthState.resizing;
356
384
  if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
357
- const nodeType = state.schema.nodes.table;
358
385
  const isNested = pluginState.tablePos && isTableNested(state, pluginState.tablePos);
359
386
  const isTableScalingWithFixedColumnWidthsOptionShown = isTableScalingEnabled && isTableFixedColumnWidthsOptionEnabled && !isNested;
360
387
  const areTableColumWidthsFixed = tableObject.node.attrs.displayMode === 'fixed';
@@ -433,7 +460,7 @@ export const getToolbarConfig = (getEditorContainerWidth, api, editorAnalyticsAP
433
460
  onBlur: clearHoverSelection()
434
461
  } : undefined;
435
462
  return {
436
- title: 'Table floating controls',
463
+ title: toolbarTitle,
437
464
  getDomRef,
438
465
  nodeType,
439
466
  offset: [0, 18],
@@ -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,38 @@ 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_4')) {
370
+ var _api$editorViewMode;
371
+ var isDragHandleMenuOpened = false;
372
+ var isTableRowOrColumnDragged = false;
373
+ if (options !== null && options !== void 0 && options.dragAndDropEnabled) {
374
+ var _getDragDropPluginSta = getDragDropPluginState(state),
375
+ _getDragDropPluginSta2 = _getDragDropPluginSta.isDragMenuOpen,
376
+ isDragMenuOpen = _getDragDropPluginSta2 === void 0 ? false : _getDragDropPluginSta2,
377
+ _getDragDropPluginSta3 = _getDragDropPluginSta.isDragging,
378
+ isDragging = _getDragDropPluginSta3 === void 0 ? false : _getDragDropPluginSta3;
379
+ isDragHandleMenuOpened = isDragMenuOpen;
380
+ isTableRowOrColumnDragged = isDragging;
381
+ }
382
+ var isTableOrColumnResizing = !!(resizeState !== null && resizeState !== void 0 && resizeState.dragging || tableWidthState !== null && tableWidthState !== void 0 && tableWidthState.resizing);
383
+ var isTableMenuOpened = pluginState.isContextualMenuOpen || isDragHandleMenuOpened;
384
+ var isViewMode = (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'view';
385
+ var shouldSuppressAllToolbars = !pluginState.editorHasFocus && !isViewMode || isTableMenuOpened || isTableOrColumnResizing || isTableRowOrColumnDragged;
386
+ if (shouldSuppressAllToolbars) {
387
+ return {
388
+ title: toolbarTitle,
389
+ items: [],
390
+ nodeType: nodeType,
391
+ __suppressAllToolbars: true
392
+ };
393
+ }
394
+ }
366
395
 
367
396
  // We don't want to show floating toolbar while resizing the table
368
397
  var isWidthResizing = tableWidthState === null || tableWidthState === void 0 ? void 0 : tableWidthState.resizing;
369
398
  if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
370
- var nodeType = state.schema.nodes.table;
371
399
  var isNested = pluginState.tablePos && isTableNested(state, pluginState.tablePos);
372
400
  var isTableScalingWithFixedColumnWidthsOptionShown = isTableScalingEnabled && isTableFixedColumnWidthsOptionEnabled && !isNested;
373
401
  var areTableColumWidthsFixed = tableObject.node.attrs.displayMode === 'fixed';
@@ -455,7 +483,7 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
455
483
  } : undefined;
456
484
  };
457
485
  return {
458
- title: 'Table floating controls',
486
+ title: toolbarTitle,
459
487
  getDomRef: getDomRef,
460
488
  nodeType: nodeType,
461
489
  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.8",
3
+ "version": "10.6.9",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -32,7 +32,7 @@
32
32
  "@atlaskit/adf-schema": "^47.6.0",
33
33
  "@atlaskit/button": "^23.0.0",
34
34
  "@atlaskit/custom-steps": "^0.11.0",
35
- "@atlaskit/editor-common": "^103.1.0",
35
+ "@atlaskit/editor-common": "^103.2.0",
36
36
  "@atlaskit/editor-palette": "^2.1.0",
37
37
  "@atlaskit/editor-plugin-accessibility-utils": "^2.0.0",
38
38
  "@atlaskit/editor-plugin-analytics": "^2.2.0",
@@ -197,6 +197,9 @@
197
197
  },
198
198
  "platform_editor_controls_patch_2": {
199
199
  "type": "boolean"
200
+ },
201
+ "platform_editor_controls_patch_4": {
202
+ "type": "boolean"
200
203
  }
201
204
  }
202
205
  }
@@ -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,45 @@ 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_4')
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 isViewMode = api?.editorViewMode?.sharedState.currentState()?.mode === 'view';
512
+
513
+ const shouldSuppressAllToolbars =
514
+ (!pluginState.editorHasFocus && !isViewMode) ||
515
+ isTableMenuOpened ||
516
+ isTableOrColumnResizing ||
517
+ isTableRowOrColumnDragged;
518
+
519
+ if (shouldSuppressAllToolbars) {
520
+ return {
521
+ title: toolbarTitle,
522
+ items: [],
523
+ nodeType,
524
+ __suppressAllToolbars: true,
525
+ };
526
+ }
527
+ }
495
528
 
496
529
  // We don't want to show floating toolbar while resizing the table
497
530
  const isWidthResizing = tableWidthState?.resizing;
498
531
 
499
532
  if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
500
- const nodeType = state.schema.nodes.table;
501
533
  const isNested = pluginState.tablePos && isTableNested(state, pluginState.tablePos);
502
534
  const isTableScalingWithFixedColumnWidthsOptionShown =
503
535
  isTableScalingEnabled && isTableFixedColumnWidthsOptionEnabled && !isNested;
@@ -645,7 +677,7 @@ export const getToolbarConfig =
645
677
  : undefined;
646
678
 
647
679
  return {
648
- title: 'Table floating controls',
680
+ title: toolbarTitle,
649
681
  getDomRef,
650
682
  nodeType,
651
683
  offset: [0, 18],