@atlaskit/editor-plugin-table 10.8.3 → 10.9.2

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.
@@ -0,0 +1,176 @@
1
+ import React from 'react';
2
+ import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
3
+ import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
4
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
5
+ import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
6
+ import FloatingContextualButton from './FloatingContextualButton';
7
+ import FloatingContextualMenu from './FloatingContextualMenu';
8
+ import FloatingDeleteButton from './FloatingDeleteButton';
9
+ import FloatingDragMenu from './FloatingDragMenu';
10
+ // Ignored via go/ees005
11
+ // eslint-disable-next-line import/no-named-as-default
12
+ import FloatingInsertButton from './FloatingInsertButton';
13
+ import { FloatingToolbarLabel } from './FloatingToolbarLabel/FloatingToolbarLabel';
14
+ import { GlobalStylesWrapper } from './global-styles';
15
+ import { FullWidthDisplay } from './TableFullWidthLabel';
16
+ const useSharedTablePluginStateSelector = (api, key) => {
17
+ const value = useSharedPluginStateSelector(api, `table.${key}`);
18
+ return value;
19
+ };
20
+ const ContentComponentInternal = ({
21
+ api,
22
+ editorView,
23
+ dispatchAnalyticsEvent,
24
+ options,
25
+ popupsMountPoint,
26
+ popupsBoundariesElement,
27
+ popupsScrollableElement,
28
+ defaultGetEditorContainerWidth,
29
+ defaultGetEditorFeatureFlags
30
+ }) => {
31
+ var _api$analytics, _api$accessibilityUti;
32
+ const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
33
+ const ariaNotifyPlugin = api === null || api === void 0 ? void 0 : (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 ? void 0 : _api$accessibilityUti.actions.ariaNotify;
34
+ const resizingTableLocalId = useSharedTablePluginStateSelector(api, 'resizingTableLocalId');
35
+ const resizingTableRef = useSharedTablePluginStateSelector(api, 'resizingTableRef');
36
+ const isTableResizing = useSharedTablePluginStateSelector(api, 'isTableResizing');
37
+ const isResizing = useSharedTablePluginStateSelector(api, 'isResizing');
38
+ const widthToWidest = useSharedTablePluginStateSelector(api, 'widthToWidest');
39
+ const tableNode = useSharedTablePluginStateSelector(api, 'tableNode');
40
+ const targetCellPosition = useSharedTablePluginStateSelector(api, 'targetCellPosition');
41
+ const isContextualMenuOpen = useSharedTablePluginStateSelector(api, 'isContextualMenuOpen');
42
+ const tableRef = useSharedTablePluginStateSelector(api, 'tableRef');
43
+ const pluginConfig = useSharedTablePluginStateSelector(api, 'pluginConfig');
44
+ const insertColumnButtonIndex = useSharedTablePluginStateSelector(api, 'insertColumnButtonIndex');
45
+ const insertRowButtonIndex = useSharedTablePluginStateSelector(api, 'insertRowButtonIndex');
46
+ const isHeaderColumnEnabled = useSharedTablePluginStateSelector(api, 'isHeaderColumnEnabled');
47
+ const isHeaderRowEnabled = useSharedTablePluginStateSelector(api, 'isHeaderRowEnabled');
48
+ const isDragAndDropEnabled = useSharedTablePluginStateSelector(api, 'isDragAndDropEnabled');
49
+ const tableWrapperTarget = useSharedTablePluginStateSelector(api, 'tableWrapperTarget');
50
+ const isCellMenuOpenByKeyboard = useSharedTablePluginStateSelector(api, 'isCellMenuOpenByKeyboard');
51
+ const {
52
+ allowControls
53
+ } = pluginConfig;
54
+ const stickyHeader = useSharedTablePluginStateSelector(api, 'stickyHeader');
55
+ const dragMenuDirection = useSharedTablePluginStateSelector(api, 'dragMenuDirection');
56
+ const dragMenuIndex = useSharedTablePluginStateSelector(api, 'dragMenuIndex');
57
+ const isDragMenuOpen = useSharedTablePluginStateSelector(api, 'isDragMenuOpen');
58
+ return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && (tableRef || isCellMenuOpenByKeyboard) && !isResizing && options && options.allowContextualMenu && /*#__PURE__*/React.createElement(FloatingContextualButton, {
59
+ isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
60
+ editorView: editorView,
61
+ tableNode: tableNode,
62
+ mountPoint: popupsMountPoint,
63
+ targetCellPosition: targetCellPosition,
64
+ scrollableElement: popupsScrollableElement,
65
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
66
+ isContextualMenuOpen: isContextualMenuOpen,
67
+ stickyHeader: stickyHeader,
68
+ tableWrapper: tableWrapperTarget,
69
+ isCellMenuOpenByKeyboard: isCellMenuOpenByKeyboard
70
+ }), allowControls && /*#__PURE__*/React.createElement(FloatingInsertButton, {
71
+ tableNode: tableNode,
72
+ tableRef: tableRef,
73
+ insertColumnButtonIndex: insertColumnButtonIndex,
74
+ insertRowButtonIndex: insertRowButtonIndex,
75
+ isHeaderColumnEnabled: isHeaderColumnEnabled,
76
+ isHeaderRowEnabled: isHeaderRowEnabled,
77
+ isDragAndDropEnabled: isDragAndDropEnabled,
78
+ isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
79
+ editorView: editorView,
80
+ mountPoint: popupsMountPoint,
81
+ boundariesElement: popupsBoundariesElement,
82
+ scrollableElement: popupsScrollableElement,
83
+ hasStickyHeaders: stickyHeader && stickyHeader.sticky,
84
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
85
+ editorAnalyticsAPI: editorAnalyticsAPI,
86
+ getEditorContainerWidth: defaultGetEditorContainerWidth,
87
+ getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags,
88
+ isChromelessEditor: options === null || options === void 0 ? void 0 : options.isChromelessEditor,
89
+ api: api,
90
+ isCommentEditor: options === null || options === void 0 ? void 0 : options.isCommentEditor
91
+ }), (options === null || options === void 0 ? void 0 : options.allowContextualMenu) && /*#__PURE__*/React.createElement(FloatingContextualMenu, {
92
+ editorView: editorView,
93
+ mountPoint: popupsMountPoint,
94
+ boundariesElement: popupsBoundariesElement,
95
+ targetCellPosition: targetCellPosition,
96
+ isOpen: Boolean(isContextualMenuOpen) && !isResizing,
97
+ pluginConfig: pluginConfig,
98
+ editorAnalyticsAPI: editorAnalyticsAPI,
99
+ getEditorContainerWidth: defaultGetEditorContainerWidth,
100
+ getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags,
101
+ isCellMenuOpenByKeyboard: isCellMenuOpenByKeyboard,
102
+ isCommentEditor: options === null || options === void 0 ? void 0 : options.isCommentEditor,
103
+ api: api
104
+ }), isDragAndDropEnabled && /*#__PURE__*/React.createElement(FloatingDragMenu, {
105
+ editorView: editorView,
106
+ mountPoint: popupsMountPoint,
107
+ boundariesElement: popupsBoundariesElement,
108
+ tableRef: tableRef,
109
+ tableNode: tableNode,
110
+ targetCellPosition: targetCellPosition,
111
+ direction: dragMenuDirection,
112
+ index: dragMenuIndex,
113
+ isOpen: !!isDragMenuOpen && !isResizing,
114
+ getEditorContainerWidth: defaultGetEditorContainerWidth,
115
+ editorAnalyticsAPI: editorAnalyticsAPI,
116
+ stickyHeaders: stickyHeader,
117
+ pluginConfig: pluginConfig,
118
+ isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
119
+ getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags,
120
+ ariaNotifyPlugin: ariaNotifyPlugin,
121
+ api: api,
122
+ isCommentEditor: options === null || options === void 0 ? void 0 : options.isCommentEditor
123
+ }), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
124
+ editorView: editorView,
125
+ selection: editorView.state.selection,
126
+ tableRef: tableRef,
127
+ mountPoint: popupsMountPoint,
128
+ boundariesElement: popupsBoundariesElement,
129
+ scrollableElement: popupsScrollableElement,
130
+ stickyHeaders: stickyHeader,
131
+ isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
132
+ editorAnalyticsAPI: editorAnalyticsAPI,
133
+ api: api
134
+ }), ((options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) || (options === null || options === void 0 ? void 0 : options.tableOptions.allowTableResizing) && options.isCommentEditor) && isTableResizing && widthToWidest && resizingTableLocalId && resizingTableRef && widthToWidest[resizingTableLocalId] && /*#__PURE__*/React.createElement(FloatingToolbarLabel, {
135
+ target: resizingTableRef,
136
+ content: /*#__PURE__*/React.createElement(FullWidthDisplay, null),
137
+ alignX: 'center',
138
+ alignY: 'bottom',
139
+ stick: true,
140
+ forcePlacement: true,
141
+ zIndex: akEditorFloatingPanelZIndex,
142
+ offset: [0, 10]
143
+ }));
144
+ };
145
+ export const ContentComponent = ({
146
+ api,
147
+ editorView,
148
+ dispatchAnalyticsEvent,
149
+ options,
150
+ popupsMountPoint,
151
+ popupsBoundariesElement,
152
+ popupsScrollableElement,
153
+ defaultGetEditorContainerWidth,
154
+ defaultGetEditorFeatureFlags
155
+ }) => {
156
+ var _api$featureFlags;
157
+ return /*#__PURE__*/React.createElement(ErrorBoundary, {
158
+ component: ACTION_SUBJECT.TABLES_PLUGIN,
159
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
160
+ fallbackComponent: null
161
+ }, /*#__PURE__*/React.createElement(GlobalStylesWrapper, {
162
+ featureFlags: api === null || api === void 0 ? void 0 : (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState(),
163
+ isDragAndDropEnabledOption: options === null || options === void 0 ? void 0 : options.dragAndDropEnabled,
164
+ api: api
165
+ }), /*#__PURE__*/React.createElement(ContentComponentInternal, {
166
+ api: api,
167
+ editorView: editorView,
168
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
169
+ options: options,
170
+ popupsMountPoint: popupsMountPoint,
171
+ popupsBoundariesElement: popupsBoundariesElement,
172
+ popupsScrollableElement: popupsScrollableElement,
173
+ defaultGetEditorContainerWidth: defaultGetEditorContainerWidth,
174
+ defaultGetEditorFeatureFlags: defaultGetEditorFeatureFlags
175
+ }));
176
+ };
@@ -463,6 +463,7 @@ export const getToolbarConfig = (getEditorContainerWidth, api, editorAnalyticsAP
463
463
  onFocus: hoverTable(isInDanger, isSelected),
464
464
  onBlur: clearHoverSelection()
465
465
  });
466
+ const shouldGroupWithoutSeparators = editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_6');
466
467
  return {
467
468
  title: toolbarTitle,
468
469
  getDomRef,
@@ -473,12 +474,15 @@ export const getToolbarConfig = (getEditorContainerWidth, api, editorAnalyticsAP
473
474
  },
474
475
  zIndex: akEditorFloatingPanelZIndex + 1,
475
476
  // Place the context menu slightly above the others
476
- items: [menu, separator(menu.hidden), ...alignmentMenu, separator(alignmentMenu.length === 0), ...cellItems, ...columnSettingsItems, ...colorPicker, ...(editorExperiment('platform_editor_controls', 'control') ? [{
477
+ items: [menu, ...(!shouldGroupWithoutSeparators ? [separator(menu.hidden)] : []), ...alignmentMenu, ...(!shouldGroupWithoutSeparators ? [separator(alignmentMenu.length === 0)] : []), ...cellItems, ...columnSettingsItems, ...colorPicker, ...(editorExperiment('platform_editor_controls', 'control') ? [{
477
478
  type: 'extensions-placeholder',
478
479
  separator: 'end'
479
480
  }, copyButton, {
480
481
  type: 'separator'
481
- }, deleteButton] : [{
482
+ }, deleteButton] : [shouldGroupWithoutSeparators && {
483
+ type: 'separator',
484
+ fullHeight: true
485
+ }, {
482
486
  type: 'overflow-dropdown',
483
487
  dropdownWidth: 220,
484
488
  options: [{
@@ -594,7 +598,7 @@ const getColumnSettingItems = (editorState, editorView, {
594
598
  disabled: !wouldChange
595
599
  });
596
600
  }
597
- if (items.length !== 0) {
601
+ if (items.length !== 0 && (!editorExperiment('platform_editor_controls', 'variant1') || !fg('platform_editor_controls_patch_6'))) {
598
602
  items.push({
599
603
  type: 'separator'
600
604
  });
@@ -136,12 +136,10 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
136
136
  var _this2 = this;
137
137
  var oldIgnoreMutation;
138
138
  var selectionBookmark;
139
- var parentOffset = 0;
140
139
  var mutationsIgnored = false;
141
140
 
142
141
  // Only proceed if we have both a node and table, and the table isn't already inside the node
143
142
  if (node && this.table && !node.contains(this.table)) {
144
- var _this$view$state$sele;
145
143
  // Store the current ignoreMutation handler so we can restore it later
146
144
  oldIgnoreMutation = this.ignoreMutation;
147
145
 
@@ -149,7 +147,7 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
149
147
  // - Ignores all DOM mutations except selection changes
150
148
  // - Tracks when mutations have been ignored via mutationsIgnored flag
151
149
  this.ignoreMutation = function (m) {
152
- var isSelectionMutation = m.target instanceof Selection;
150
+ var isSelectionMutation = m.type === 'selection';
153
151
  if (!isSelectionMutation) {
154
152
  mutationsIgnored = true;
155
153
  }
@@ -162,15 +160,8 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
162
160
  selectionBookmark = this.view.state.selection.getBookmark();
163
161
  }
164
162
 
165
- // Store the current cursor position within the parent node
166
- // Used to determine if we need to restore selection later
167
- if (((_this$view$state$sele = this.view.state.selection) === null || _this$view$state$sele === void 0 ? void 0 : _this$view$state$sele.ranges.length) > 0) {
168
- var _this$view$state$sele2, _this$view$state$sele3;
169
- parentOffset = (_this$view$state$sele2 = (_this$view$state$sele3 = this.view.state.selection) === null || _this$view$state$sele3 === void 0 || (_this$view$state$sele3 = _this$view$state$sele3.ranges[0].$from) === null || _this$view$state$sele3 === void 0 ? void 0 : _this$view$state$sele3.parentOffset) !== null && _this$view$state$sele2 !== void 0 ? _this$view$state$sele2 : 0;
170
- }
171
-
172
163
  // Remove the ProseMirror table DOM structure to avoid duplication, as it's replaced with the React table node.
173
- if (this.renderedDOM) {
164
+ if (this.dom && this.renderedDOM) {
174
165
  this.dom.removeChild(this.renderedDOM);
175
166
  }
176
167
  // Move the table from the ProseMirror table structure into the React rendered table node.
@@ -184,9 +175,13 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
184
175
  // Restore the selection only if:
185
176
  // - We have a selection bookmark
186
177
  // - Mutations were ignored during the table move
187
- // - The cursor wasn't at the start of the node
188
- if (selectionBookmark && mutationsIgnored && parentOffset > 0) {
189
- _this2.view.dispatch(_this2.view.state.tr.setSelection(selectionBookmark.resolve(_this2.view.state.tr.doc)));
178
+ // - The bookmarked selection is different from the current selection.
179
+ if (selectionBookmark && mutationsIgnored) {
180
+ var resolvedSelection = selectionBookmark.resolve(_this2.view.state.tr.doc);
181
+ // Don't set the selection if it's the same as the current selection.
182
+ if (!resolvedSelection.eq(_this2.view.state.selection)) {
183
+ _this2.view.dispatch(_this2.view.state.tr.setSelection(resolvedSelection));
184
+ }
190
185
  }
191
186
  });
192
187
  }
@@ -31,7 +31,6 @@ import { createPlugin as createDragAndDropPlugin } from './pm-plugins/drag-and-d
31
31
  import { pluginKey as dragAndDropPluginKey } from './pm-plugins/drag-and-drop/plugin-key';
32
32
  import { keymapPlugin } from './pm-plugins/keymap';
33
33
  import { createPlugin } from './pm-plugins/main';
34
- import { getPluginState } from './pm-plugins/plugin-factory';
35
34
  import { pluginKey } from './pm-plugins/plugin-key';
36
35
  import { createPlugin as createTableSafariDeleteCompositionTextIssueWorkaroundPlugin } from './pm-plugins/safari-delete-composition-text-issue-workaround';
37
36
  import { createPlugin as createStickyHeadersPlugin } from './pm-plugins/sticky-headers/plugin';
@@ -48,6 +47,7 @@ import { createPlugin as createTableWidthPlugin, pluginKey as tableWidthPluginKe
48
47
  import { createPlugin as createTableWidthInCommentFixPlugin } from './pm-plugins/table-width-in-comment-fix';
49
48
  import { createTableWithWidth } from './pm-plugins/utils/create';
50
49
  import { createPlugin as createViewModeSortPlugin } from './pm-plugins/view-mode-sort';
50
+ import { ContentComponent } from './ui/ContentComponent';
51
51
  import FloatingContextualButton from './ui/FloatingContextualButton';
52
52
  import FloatingContextualMenu from './ui/FloatingContextualMenu';
53
53
  import FloatingDeleteButton from './ui/FloatingDeleteButton';
@@ -94,13 +94,19 @@ var tablePlugin = function tablePlugin(_ref) {
94
94
  // Use getSharedState to store fullWidthEnabled and wasFullWidthModeEnabled to guarantee access
95
95
  // to most up to date values - passing to createPluginState will not re-initialise the state
96
96
  getSharedState: function getSharedState(editorState) {
97
+ var _tablePluginState$tab, _tableWidthResizingPl;
97
98
  if (!editorState) {
98
99
  return undefined;
99
100
  }
100
- var tablePluginState = getPluginState(editorState);
101
+
102
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
103
+ var tablePluginState = pluginKey.getState(editorState);
101
104
  var tableResizingPluginState = getFlexiResizingPlugin(editorState);
102
105
  var tableWidthResizingPluginState = tableWidthPluginKey.getState(editorState);
103
- return {
106
+ var stickyHeadersState = stickyHeadersPluginKey.getState(editorState);
107
+ var stickyHeader = stickyHeadersState ? findStickyHeaderForTable(stickyHeadersState, tablePluginState === null || tablePluginState === void 0 ? void 0 : tablePluginState.tablePos) : undefined;
108
+ var dragAndDropState = dragAndDropPluginKey.getState(editorState);
109
+ var sharedStateInternal = {
104
110
  isFullWidthModeEnabled: !!(options !== null && options !== void 0 && options.fullWidthEnabled),
105
111
  wasFullWidthModeEnabled: !!(options !== null && options !== void 0 && options.wasFullWidthEnabled),
106
112
  isHeaderRowEnabled: tablePluginState.isHeaderRowEnabled,
@@ -117,8 +123,25 @@ var tablePlugin = function tablePlugin(_ref) {
117
123
  // IMPORTANT: Need to continue to pass tableNode to control re-renders
118
124
  // TableComponent listens for node attribute changes to update colgroups
119
125
  tableNode: tablePluginState.tableNode,
120
- widthToWidest: tablePluginState.widthToWidest
126
+ widthToWidest: tablePluginState.widthToWidest,
127
+ resizingTableLocalId: tableWidthResizingPluginState === null || tableWidthResizingPluginState === void 0 ? void 0 : tableWidthResizingPluginState.tableLocalId,
128
+ tableRef: (_tablePluginState$tab = tablePluginState === null || tablePluginState === void 0 ? void 0 : tablePluginState.tableRef) !== null && _tablePluginState$tab !== void 0 ? _tablePluginState$tab : undefined,
129
+ resizingTableRef: (_tableWidthResizingPl = tableWidthResizingPluginState === null || tableWidthResizingPluginState === void 0 ? void 0 : tableWidthResizingPluginState.tableRef) !== null && _tableWidthResizingPl !== void 0 ? _tableWidthResizingPl : undefined,
130
+ tablePos: tablePluginState.tablePos,
131
+ targetCellPosition: tablePluginState.targetCellPosition,
132
+ isContextualMenuOpen: tablePluginState.isContextualMenuOpen,
133
+ pluginConfig: tablePluginState.pluginConfig,
134
+ insertColumnButtonIndex: tablePluginState.insertColumnButtonIndex,
135
+ insertRowButtonIndex: tablePluginState.insertRowButtonIndex,
136
+ isDragAndDropEnabled: tablePluginState.isDragAndDropEnabled,
137
+ tableWrapperTarget: tablePluginState.tableWrapperTarget,
138
+ isCellMenuOpenByKeyboard: tablePluginState.isCellMenuOpenByKeyboard,
139
+ stickyHeader: stickyHeader,
140
+ dragMenuDirection: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuDirection,
141
+ dragMenuIndex: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuIndex,
142
+ isDragMenuOpen: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.isDragMenuOpen
121
143
  };
144
+ return sharedStateInternal;
122
145
  },
123
146
  actions: {
124
147
  insertTable: function insertTable(analyticsPayload) {
@@ -419,6 +442,19 @@ var tablePlugin = function tablePlugin(_ref) {
419
442
  popupsBoundariesElement = _ref20.popupsBoundariesElement,
420
443
  popupsScrollableElement = _ref20.popupsScrollableElement,
421
444
  dispatchAnalyticsEvent = _ref20.dispatchAnalyticsEvent;
445
+ if (editorExperiment('platform_editor_usesharedpluginstateselector', true)) {
446
+ return /*#__PURE__*/React.createElement(ContentComponent, {
447
+ api: api,
448
+ editorView: editorView,
449
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
450
+ options: options,
451
+ popupsMountPoint: popupsMountPoint,
452
+ popupsBoundariesElement: popupsBoundariesElement,
453
+ popupsScrollableElement: popupsScrollableElement,
454
+ defaultGetEditorContainerWidth: defaultGetEditorContainerWidth,
455
+ defaultGetEditorFeatureFlags: defaultGetEditorFeatureFlags
456
+ });
457
+ }
422
458
  return /*#__PURE__*/React.createElement(ErrorBoundary, {
423
459
  component: ACTION_SUBJECT.TABLES_PLUGIN,
424
460
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
@@ -0,0 +1,172 @@
1
+ import React from 'react';
2
+ import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
3
+ import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
4
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
5
+ import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
6
+ import FloatingContextualButton from './FloatingContextualButton';
7
+ import FloatingContextualMenu from './FloatingContextualMenu';
8
+ import FloatingDeleteButton from './FloatingDeleteButton';
9
+ import FloatingDragMenu from './FloatingDragMenu';
10
+ // Ignored via go/ees005
11
+ // eslint-disable-next-line import/no-named-as-default
12
+ import FloatingInsertButton from './FloatingInsertButton';
13
+ import { FloatingToolbarLabel } from './FloatingToolbarLabel/FloatingToolbarLabel';
14
+ import { GlobalStylesWrapper } from './global-styles';
15
+ import { FullWidthDisplay } from './TableFullWidthLabel';
16
+ var useSharedTablePluginStateSelector = function useSharedTablePluginStateSelector(api, key) {
17
+ var value = useSharedPluginStateSelector(api, "table.".concat(key));
18
+ return value;
19
+ };
20
+ var ContentComponentInternal = function ContentComponentInternal(_ref) {
21
+ var _api$analytics, _api$accessibilityUti;
22
+ var api = _ref.api,
23
+ editorView = _ref.editorView,
24
+ dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
25
+ options = _ref.options,
26
+ popupsMountPoint = _ref.popupsMountPoint,
27
+ popupsBoundariesElement = _ref.popupsBoundariesElement,
28
+ popupsScrollableElement = _ref.popupsScrollableElement,
29
+ defaultGetEditorContainerWidth = _ref.defaultGetEditorContainerWidth,
30
+ defaultGetEditorFeatureFlags = _ref.defaultGetEditorFeatureFlags;
31
+ var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
32
+ var ariaNotifyPlugin = api === null || api === void 0 || (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 ? void 0 : _api$accessibilityUti.actions.ariaNotify;
33
+ var resizingTableLocalId = useSharedTablePluginStateSelector(api, 'resizingTableLocalId');
34
+ var resizingTableRef = useSharedTablePluginStateSelector(api, 'resizingTableRef');
35
+ var isTableResizing = useSharedTablePluginStateSelector(api, 'isTableResizing');
36
+ var isResizing = useSharedTablePluginStateSelector(api, 'isResizing');
37
+ var widthToWidest = useSharedTablePluginStateSelector(api, 'widthToWidest');
38
+ var tableNode = useSharedTablePluginStateSelector(api, 'tableNode');
39
+ var targetCellPosition = useSharedTablePluginStateSelector(api, 'targetCellPosition');
40
+ var isContextualMenuOpen = useSharedTablePluginStateSelector(api, 'isContextualMenuOpen');
41
+ var tableRef = useSharedTablePluginStateSelector(api, 'tableRef');
42
+ var pluginConfig = useSharedTablePluginStateSelector(api, 'pluginConfig');
43
+ var insertColumnButtonIndex = useSharedTablePluginStateSelector(api, 'insertColumnButtonIndex');
44
+ var insertRowButtonIndex = useSharedTablePluginStateSelector(api, 'insertRowButtonIndex');
45
+ var isHeaderColumnEnabled = useSharedTablePluginStateSelector(api, 'isHeaderColumnEnabled');
46
+ var isHeaderRowEnabled = useSharedTablePluginStateSelector(api, 'isHeaderRowEnabled');
47
+ var isDragAndDropEnabled = useSharedTablePluginStateSelector(api, 'isDragAndDropEnabled');
48
+ var tableWrapperTarget = useSharedTablePluginStateSelector(api, 'tableWrapperTarget');
49
+ var isCellMenuOpenByKeyboard = useSharedTablePluginStateSelector(api, 'isCellMenuOpenByKeyboard');
50
+ var allowControls = pluginConfig.allowControls;
51
+ var stickyHeader = useSharedTablePluginStateSelector(api, 'stickyHeader');
52
+ var dragMenuDirection = useSharedTablePluginStateSelector(api, 'dragMenuDirection');
53
+ var dragMenuIndex = useSharedTablePluginStateSelector(api, 'dragMenuIndex');
54
+ var isDragMenuOpen = useSharedTablePluginStateSelector(api, 'isDragMenuOpen');
55
+ return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && (tableRef || isCellMenuOpenByKeyboard) && !isResizing && options && options.allowContextualMenu && /*#__PURE__*/React.createElement(FloatingContextualButton, {
56
+ isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
57
+ editorView: editorView,
58
+ tableNode: tableNode,
59
+ mountPoint: popupsMountPoint,
60
+ targetCellPosition: targetCellPosition,
61
+ scrollableElement: popupsScrollableElement,
62
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
63
+ isContextualMenuOpen: isContextualMenuOpen,
64
+ stickyHeader: stickyHeader,
65
+ tableWrapper: tableWrapperTarget,
66
+ isCellMenuOpenByKeyboard: isCellMenuOpenByKeyboard
67
+ }), allowControls && /*#__PURE__*/React.createElement(FloatingInsertButton, {
68
+ tableNode: tableNode,
69
+ tableRef: tableRef,
70
+ insertColumnButtonIndex: insertColumnButtonIndex,
71
+ insertRowButtonIndex: insertRowButtonIndex,
72
+ isHeaderColumnEnabled: isHeaderColumnEnabled,
73
+ isHeaderRowEnabled: isHeaderRowEnabled,
74
+ isDragAndDropEnabled: isDragAndDropEnabled,
75
+ isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
76
+ editorView: editorView,
77
+ mountPoint: popupsMountPoint,
78
+ boundariesElement: popupsBoundariesElement,
79
+ scrollableElement: popupsScrollableElement,
80
+ hasStickyHeaders: stickyHeader && stickyHeader.sticky,
81
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
82
+ editorAnalyticsAPI: editorAnalyticsAPI,
83
+ getEditorContainerWidth: defaultGetEditorContainerWidth,
84
+ getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags,
85
+ isChromelessEditor: options === null || options === void 0 ? void 0 : options.isChromelessEditor,
86
+ api: api,
87
+ isCommentEditor: options === null || options === void 0 ? void 0 : options.isCommentEditor
88
+ }), (options === null || options === void 0 ? void 0 : options.allowContextualMenu) && /*#__PURE__*/React.createElement(FloatingContextualMenu, {
89
+ editorView: editorView,
90
+ mountPoint: popupsMountPoint,
91
+ boundariesElement: popupsBoundariesElement,
92
+ targetCellPosition: targetCellPosition,
93
+ isOpen: Boolean(isContextualMenuOpen) && !isResizing,
94
+ pluginConfig: pluginConfig,
95
+ editorAnalyticsAPI: editorAnalyticsAPI,
96
+ getEditorContainerWidth: defaultGetEditorContainerWidth,
97
+ getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags,
98
+ isCellMenuOpenByKeyboard: isCellMenuOpenByKeyboard,
99
+ isCommentEditor: options === null || options === void 0 ? void 0 : options.isCommentEditor,
100
+ api: api
101
+ }), isDragAndDropEnabled && /*#__PURE__*/React.createElement(FloatingDragMenu, {
102
+ editorView: editorView,
103
+ mountPoint: popupsMountPoint,
104
+ boundariesElement: popupsBoundariesElement,
105
+ tableRef: tableRef,
106
+ tableNode: tableNode,
107
+ targetCellPosition: targetCellPosition,
108
+ direction: dragMenuDirection,
109
+ index: dragMenuIndex,
110
+ isOpen: !!isDragMenuOpen && !isResizing,
111
+ getEditorContainerWidth: defaultGetEditorContainerWidth,
112
+ editorAnalyticsAPI: editorAnalyticsAPI,
113
+ stickyHeaders: stickyHeader,
114
+ pluginConfig: pluginConfig,
115
+ isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
116
+ getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags,
117
+ ariaNotifyPlugin: ariaNotifyPlugin,
118
+ api: api,
119
+ isCommentEditor: options === null || options === void 0 ? void 0 : options.isCommentEditor
120
+ }), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
121
+ editorView: editorView,
122
+ selection: editorView.state.selection,
123
+ tableRef: tableRef,
124
+ mountPoint: popupsMountPoint,
125
+ boundariesElement: popupsBoundariesElement,
126
+ scrollableElement: popupsScrollableElement,
127
+ stickyHeaders: stickyHeader,
128
+ isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
129
+ editorAnalyticsAPI: editorAnalyticsAPI,
130
+ api: api
131
+ }), ((options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) || (options === null || options === void 0 ? void 0 : options.tableOptions.allowTableResizing) && options.isCommentEditor) && isTableResizing && widthToWidest && resizingTableLocalId && resizingTableRef && widthToWidest[resizingTableLocalId] && /*#__PURE__*/React.createElement(FloatingToolbarLabel, {
132
+ target: resizingTableRef,
133
+ content: /*#__PURE__*/React.createElement(FullWidthDisplay, null),
134
+ alignX: 'center',
135
+ alignY: 'bottom',
136
+ stick: true,
137
+ forcePlacement: true,
138
+ zIndex: akEditorFloatingPanelZIndex,
139
+ offset: [0, 10]
140
+ }));
141
+ };
142
+ export var ContentComponent = function ContentComponent(_ref2) {
143
+ var _api$featureFlags;
144
+ var api = _ref2.api,
145
+ editorView = _ref2.editorView,
146
+ dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent,
147
+ options = _ref2.options,
148
+ popupsMountPoint = _ref2.popupsMountPoint,
149
+ popupsBoundariesElement = _ref2.popupsBoundariesElement,
150
+ popupsScrollableElement = _ref2.popupsScrollableElement,
151
+ defaultGetEditorContainerWidth = _ref2.defaultGetEditorContainerWidth,
152
+ defaultGetEditorFeatureFlags = _ref2.defaultGetEditorFeatureFlags;
153
+ return /*#__PURE__*/React.createElement(ErrorBoundary, {
154
+ component: ACTION_SUBJECT.TABLES_PLUGIN,
155
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
156
+ fallbackComponent: null
157
+ }, /*#__PURE__*/React.createElement(GlobalStylesWrapper, {
158
+ featureFlags: api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState(),
159
+ isDragAndDropEnabledOption: options === null || options === void 0 ? void 0 : options.dragAndDropEnabled,
160
+ api: api
161
+ }), /*#__PURE__*/React.createElement(ContentComponentInternal, {
162
+ api: api,
163
+ editorView: editorView,
164
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
165
+ options: options,
166
+ popupsMountPoint: popupsMountPoint,
167
+ popupsBoundariesElement: popupsBoundariesElement,
168
+ popupsScrollableElement: popupsScrollableElement,
169
+ defaultGetEditorContainerWidth: defaultGetEditorContainerWidth,
170
+ defaultGetEditorFeatureFlags: defaultGetEditorFeatureFlags
171
+ }));
172
+ };
@@ -486,6 +486,7 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
486
486
  onBlur: clearHoverSelection()
487
487
  };
488
488
  };
489
+ var shouldGroupWithoutSeparators = editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_6');
489
490
  return {
490
491
  title: toolbarTitle,
491
492
  getDomRef: getDomRef,
@@ -496,12 +497,15 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
496
497
  },
497
498
  zIndex: akEditorFloatingPanelZIndex + 1,
498
499
  // Place the context menu slightly above the others
499
- items: [menu, separator(menu.hidden)].concat(_toConsumableArray(alignmentMenu), [separator(alignmentMenu.length === 0)], _toConsumableArray(cellItems), _toConsumableArray(columnSettingsItems), _toConsumableArray(colorPicker), _toConsumableArray(editorExperiment('platform_editor_controls', 'control') ? [{
500
+ items: [menu].concat(_toConsumableArray(!shouldGroupWithoutSeparators ? [separator(menu.hidden)] : []), _toConsumableArray(alignmentMenu), _toConsumableArray(!shouldGroupWithoutSeparators ? [separator(alignmentMenu.length === 0)] : []), _toConsumableArray(cellItems), _toConsumableArray(columnSettingsItems), _toConsumableArray(colorPicker), _toConsumableArray(editorExperiment('platform_editor_controls', 'control') ? [{
500
501
  type: 'extensions-placeholder',
501
502
  separator: 'end'
502
503
  }, copyButton, {
503
504
  type: 'separator'
504
- }, deleteButton] : [{
505
+ }, deleteButton] : [shouldGroupWithoutSeparators && {
506
+ type: 'separator',
507
+ fullHeight: true
508
+ }, {
505
509
  type: 'overflow-dropdown',
506
510
  dropdownWidth: 220,
507
511
  options: [{
@@ -631,7 +635,7 @@ var getColumnSettingItems = function getColumnSettingItems(editorState, editorVi
631
635
  disabled: !wouldChange
632
636
  });
633
637
  }
634
- if (items.length !== 0) {
638
+ if (items.length !== 0 && (!editorExperiment('platform_editor_controls', 'variant1') || !fg('platform_editor_controls_patch_6'))) {
635
639
  items.push({
636
640
  type: 'separator'
637
641
  });
@@ -8,6 +8,7 @@ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
8
8
  import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
9
9
  import type { Rect } from '@atlaskit/editor-tables/table-map';
10
10
  import type { Edge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
11
+ import { RowStickyState } from '../pm-plugins/sticky-headers/types';
11
12
  import type { TablePlugin } from '../tablePluginType';
12
13
  export declare const RESIZE_HANDLE_AREA_DECORATION_GAP = 30;
13
14
  export type RowInsertPosition = 'TOP' | 'BOTTOM';
@@ -33,10 +34,16 @@ export type PluginInjectionAPIWithA11y = ExtractInjectionAPI<TablePlugin> & {
33
34
  };
34
35
  };
35
36
  };
36
- export type TableSharedStateInternal = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled' | 'isHeaderRowEnabled' | 'isHeaderColumnEnabled' | 'ordering' | 'isInDanger' | 'hoveredRows' | 'hoveredColumns' | 'hoveredCell' | 'isTableHovered' | 'tableNode' | 'widthToWidest'> & {
37
+ export type TableSharedStateInternal = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled' | 'isHeaderRowEnabled' | 'isHeaderColumnEnabled' | 'ordering' | 'isInDanger' | 'hoveredRows' | 'hoveredColumns' | 'hoveredCell' | 'isTableHovered' | 'tableNode' | 'widthToWidest' | 'tableRef' | 'tablePos' | 'targetCellPosition' | 'isContextualMenuOpen' | 'pluginConfig' | 'insertColumnButtonIndex' | 'insertRowButtonIndex' | 'isDragAndDropEnabled' | 'tableWrapperTarget' | 'isCellMenuOpenByKeyboard'> & {
37
38
  isResizing: boolean;
38
39
  isTableResizing?: boolean;
39
40
  isWholeTableInDanger?: boolean;
41
+ resizingTableRef?: HTMLTableElement;
42
+ resizingTableLocalId?: string;
43
+ stickyHeader?: RowStickyState;
44
+ dragMenuDirection?: TableDirection;
45
+ dragMenuIndex?: number;
46
+ isDragMenuOpen?: boolean;
40
47
  };
41
48
  export type TableSharedState = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled'>;
42
49
  export type AlignmentOptions = 'center' | 'align-start';
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
3
+ import { ExtractInjectionAPI, GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
4
+ import { EditorView } from '@atlaskit/editor-prosemirror/view';
5
+ import { TablePlugin, TablePluginOptions } from '../tablePluginType';
6
+ export type ContentComponentProps = {
7
+ api: ExtractInjectionAPI<TablePlugin> | undefined;
8
+ editorView: EditorView;
9
+ dispatchAnalyticsEvent: DispatchAnalyticsEvent | undefined;
10
+ options?: TablePluginOptions;
11
+ popupsMountPoint?: HTMLElement;
12
+ popupsBoundariesElement?: HTMLElement;
13
+ popupsScrollableElement?: HTMLElement;
14
+ defaultGetEditorContainerWidth: GetEditorContainerWidth;
15
+ defaultGetEditorFeatureFlags: GetEditorFeatureFlags;
16
+ };
17
+ export declare const ContentComponent: ({ api, editorView, dispatchAnalyticsEvent, options, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, defaultGetEditorContainerWidth, defaultGetEditorFeatureFlags, }: ContentComponentProps) => React.JSX.Element;
@@ -8,6 +8,7 @@ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
8
8
  import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
9
9
  import type { Rect } from '@atlaskit/editor-tables/table-map';
10
10
  import type { Edge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
11
+ import { RowStickyState } from '../pm-plugins/sticky-headers/types';
11
12
  import type { TablePlugin } from '../tablePluginType';
12
13
  export declare const RESIZE_HANDLE_AREA_DECORATION_GAP = 30;
13
14
  export type RowInsertPosition = 'TOP' | 'BOTTOM';
@@ -33,10 +34,16 @@ export type PluginInjectionAPIWithA11y = ExtractInjectionAPI<TablePlugin> & {
33
34
  };
34
35
  };
35
36
  };
36
- export type TableSharedStateInternal = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled' | 'isHeaderRowEnabled' | 'isHeaderColumnEnabled' | 'ordering' | 'isInDanger' | 'hoveredRows' | 'hoveredColumns' | 'hoveredCell' | 'isTableHovered' | 'tableNode' | 'widthToWidest'> & {
37
+ export type TableSharedStateInternal = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled' | 'isHeaderRowEnabled' | 'isHeaderColumnEnabled' | 'ordering' | 'isInDanger' | 'hoveredRows' | 'hoveredColumns' | 'hoveredCell' | 'isTableHovered' | 'tableNode' | 'widthToWidest' | 'tableRef' | 'tablePos' | 'targetCellPosition' | 'isContextualMenuOpen' | 'pluginConfig' | 'insertColumnButtonIndex' | 'insertRowButtonIndex' | 'isDragAndDropEnabled' | 'tableWrapperTarget' | 'isCellMenuOpenByKeyboard'> & {
37
38
  isResizing: boolean;
38
39
  isTableResizing?: boolean;
39
40
  isWholeTableInDanger?: boolean;
41
+ resizingTableRef?: HTMLTableElement;
42
+ resizingTableLocalId?: string;
43
+ stickyHeader?: RowStickyState;
44
+ dragMenuDirection?: TableDirection;
45
+ dragMenuIndex?: number;
46
+ isDragMenuOpen?: boolean;
40
47
  };
41
48
  export type TableSharedState = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled'>;
42
49
  export type AlignmentOptions = 'center' | 'align-start';