@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.
- package/CHANGELOG.md +35 -0
- package/dist/cjs/nodeviews/table.js +9 -14
- package/dist/cjs/tablePlugin.js +42 -6
- package/dist/cjs/ui/ContentComponent.js +180 -0
- package/dist/cjs/ui/toolbar.js +7 -3
- package/dist/es2019/nodeviews/table.js +9 -14
- package/dist/es2019/tablePlugin.js +40 -4
- package/dist/es2019/ui/ContentComponent.js +176 -0
- package/dist/es2019/ui/toolbar.js +7 -3
- package/dist/esm/nodeviews/table.js +9 -14
- package/dist/esm/tablePlugin.js +40 -4
- package/dist/esm/ui/ContentComponent.js +172 -0
- package/dist/esm/ui/toolbar.js +7 -3
- package/dist/types/types/index.d.ts +8 -1
- package/dist/types/ui/ContentComponent.d.ts +17 -0
- package/dist/types-ts4.5/types/index.d.ts +8 -1
- package/dist/types-ts4.5/ui/ContentComponent.d.ts +17 -0
- package/package.json +7 -4
- package/src/nodeviews/table.tsx +15 -16
- package/src/tablePlugin.tsx +46 -4
- package/src/types/index.ts +17 -0
- package/src/ui/ContentComponent.tsx +249 -0
- package/src/ui/toolbar.tsx +12 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 10.9.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#144209](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/144209)
|
|
8
|
+
[`7110eac24db43`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7110eac24db43) -
|
|
9
|
+
ED-26373: Remove parentOffset logic from \_handleTableRef. This was preventing the users cursor
|
|
10
|
+
selection from being the first cell in the table upon table creation.
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 10.9.1
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#145186](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/145186)
|
|
18
|
+
[`6a555b119bc46`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6a555b119bc46) -
|
|
19
|
+
ED-27719: Add checks to \_handleTableRef so this.dom is not used if it is undefined. This was
|
|
20
|
+
causing sentry errors.
|
|
21
|
+
- [#144194](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/144194)
|
|
22
|
+
[`542b82e03416e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/542b82e03416e) -
|
|
23
|
+
[ux] Remove separators within group in Editor floating toolbar
|
|
24
|
+
- Updated dependencies
|
|
25
|
+
|
|
26
|
+
## 10.9.0
|
|
27
|
+
|
|
28
|
+
### Minor Changes
|
|
29
|
+
|
|
30
|
+
- [#142156](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/142156)
|
|
31
|
+
[`9e2d56551d2cc`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9e2d56551d2cc) -
|
|
32
|
+
Remove WithPluginState from Table via platform_editor_usesharedpluginstateselector
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- Updated dependencies
|
|
37
|
+
|
|
3
38
|
## 10.8.3
|
|
4
39
|
|
|
5
40
|
### Patch Changes
|
|
@@ -143,12 +143,10 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
143
143
|
var _this2 = this;
|
|
144
144
|
var oldIgnoreMutation;
|
|
145
145
|
var selectionBookmark;
|
|
146
|
-
var parentOffset = 0;
|
|
147
146
|
var mutationsIgnored = false;
|
|
148
147
|
|
|
149
148
|
// Only proceed if we have both a node and table, and the table isn't already inside the node
|
|
150
149
|
if (node && this.table && !node.contains(this.table)) {
|
|
151
|
-
var _this$view$state$sele;
|
|
152
150
|
// Store the current ignoreMutation handler so we can restore it later
|
|
153
151
|
oldIgnoreMutation = this.ignoreMutation;
|
|
154
152
|
|
|
@@ -156,7 +154,7 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
156
154
|
// - Ignores all DOM mutations except selection changes
|
|
157
155
|
// - Tracks when mutations have been ignored via mutationsIgnored flag
|
|
158
156
|
this.ignoreMutation = function (m) {
|
|
159
|
-
var isSelectionMutation = m.
|
|
157
|
+
var isSelectionMutation = m.type === 'selection';
|
|
160
158
|
if (!isSelectionMutation) {
|
|
161
159
|
mutationsIgnored = true;
|
|
162
160
|
}
|
|
@@ -169,15 +167,8 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
169
167
|
selectionBookmark = this.view.state.selection.getBookmark();
|
|
170
168
|
}
|
|
171
169
|
|
|
172
|
-
// Store the current cursor position within the parent node
|
|
173
|
-
// Used to determine if we need to restore selection later
|
|
174
|
-
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) {
|
|
175
|
-
var _this$view$state$sele2, _this$view$state$sele3;
|
|
176
|
-
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;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
170
|
// Remove the ProseMirror table DOM structure to avoid duplication, as it's replaced with the React table node.
|
|
180
|
-
if (this.renderedDOM) {
|
|
171
|
+
if (this.dom && this.renderedDOM) {
|
|
181
172
|
this.dom.removeChild(this.renderedDOM);
|
|
182
173
|
}
|
|
183
174
|
// Move the table from the ProseMirror table structure into the React rendered table node.
|
|
@@ -191,9 +182,13 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
191
182
|
// Restore the selection only if:
|
|
192
183
|
// - We have a selection bookmark
|
|
193
184
|
// - Mutations were ignored during the table move
|
|
194
|
-
// - The
|
|
195
|
-
if (selectionBookmark && mutationsIgnored
|
|
196
|
-
|
|
185
|
+
// - The bookmarked selection is different from the current selection.
|
|
186
|
+
if (selectionBookmark && mutationsIgnored) {
|
|
187
|
+
var resolvedSelection = selectionBookmark.resolve(_this2.view.state.tr.doc);
|
|
188
|
+
// Don't set the selection if it's the same as the current selection.
|
|
189
|
+
if (!resolvedSelection.eq(_this2.view.state.selection)) {
|
|
190
|
+
_this2.view.dispatch(_this2.view.state.tr.setSelection(resolvedSelection));
|
|
191
|
+
}
|
|
197
192
|
}
|
|
198
193
|
});
|
|
199
194
|
}
|
package/dist/cjs/tablePlugin.js
CHANGED
|
@@ -37,7 +37,6 @@ var _plugin3 = require("./pm-plugins/drag-and-drop/plugin");
|
|
|
37
37
|
var _pluginKey2 = require("./pm-plugins/drag-and-drop/plugin-key");
|
|
38
38
|
var _keymap = require("./pm-plugins/keymap");
|
|
39
39
|
var _main = require("./pm-plugins/main");
|
|
40
|
-
var _pluginFactory = require("./pm-plugins/plugin-factory");
|
|
41
40
|
var _pluginKey3 = require("./pm-plugins/plugin-key");
|
|
42
41
|
var _safariDeleteCompositionTextIssueWorkaround = require("./pm-plugins/safari-delete-composition-text-issue-workaround");
|
|
43
42
|
var _plugin4 = require("./pm-plugins/sticky-headers/plugin");
|
|
@@ -46,7 +45,7 @@ var _util = require("./pm-plugins/sticky-headers/util");
|
|
|
46
45
|
var _tableAnalytics = require("./pm-plugins/table-analytics");
|
|
47
46
|
var _tableLocalId = require("./pm-plugins/table-local-id");
|
|
48
47
|
var _plugin5 = require("./pm-plugins/table-resizing/plugin");
|
|
49
|
-
var
|
|
48
|
+
var _pluginFactory = require("./pm-plugins/table-resizing/plugin-factory");
|
|
50
49
|
var _pluginKey5 = require("./pm-plugins/table-resizing/plugin-key");
|
|
51
50
|
var _tableSelectionKeymap = require("./pm-plugins/table-selection-keymap");
|
|
52
51
|
var _tableSizeSelector = require("./pm-plugins/table-size-selector");
|
|
@@ -54,6 +53,7 @@ var _tableWidth = require("./pm-plugins/table-width");
|
|
|
54
53
|
var _tableWidthInCommentFix = require("./pm-plugins/table-width-in-comment-fix");
|
|
55
54
|
var _create = require("./pm-plugins/utils/create");
|
|
56
55
|
var _viewModeSort = require("./pm-plugins/view-mode-sort");
|
|
56
|
+
var _ContentComponent = require("./ui/ContentComponent");
|
|
57
57
|
var _FloatingContextualButton = _interopRequireDefault(require("./ui/FloatingContextualButton"));
|
|
58
58
|
var _FloatingContextualMenu = _interopRequireDefault(require("./ui/FloatingContextualMenu"));
|
|
59
59
|
var _FloatingDeleteButton = _interopRequireDefault(require("./ui/FloatingDeleteButton"));
|
|
@@ -103,13 +103,19 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
103
103
|
// Use getSharedState to store fullWidthEnabled and wasFullWidthModeEnabled to guarantee access
|
|
104
104
|
// to most up to date values - passing to createPluginState will not re-initialise the state
|
|
105
105
|
getSharedState: function getSharedState(editorState) {
|
|
106
|
+
var _tablePluginState$tab, _tableWidthResizingPl;
|
|
106
107
|
if (!editorState) {
|
|
107
108
|
return undefined;
|
|
108
109
|
}
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
|
|
111
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
112
|
+
var tablePluginState = _pluginKey3.pluginKey.getState(editorState);
|
|
113
|
+
var tableResizingPluginState = (0, _pluginFactory.getPluginState)(editorState);
|
|
111
114
|
var tableWidthResizingPluginState = _tableWidth.pluginKey.getState(editorState);
|
|
112
|
-
|
|
115
|
+
var stickyHeadersState = _pluginKey4.pluginKey.getState(editorState);
|
|
116
|
+
var stickyHeader = stickyHeadersState ? (0, _util.findStickyHeaderForTable)(stickyHeadersState, tablePluginState === null || tablePluginState === void 0 ? void 0 : tablePluginState.tablePos) : undefined;
|
|
117
|
+
var dragAndDropState = _pluginKey2.pluginKey.getState(editorState);
|
|
118
|
+
var sharedStateInternal = {
|
|
113
119
|
isFullWidthModeEnabled: !!(options !== null && options !== void 0 && options.fullWidthEnabled),
|
|
114
120
|
wasFullWidthModeEnabled: !!(options !== null && options !== void 0 && options.wasFullWidthEnabled),
|
|
115
121
|
isHeaderRowEnabled: tablePluginState.isHeaderRowEnabled,
|
|
@@ -126,8 +132,25 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
126
132
|
// IMPORTANT: Need to continue to pass tableNode to control re-renders
|
|
127
133
|
// TableComponent listens for node attribute changes to update colgroups
|
|
128
134
|
tableNode: tablePluginState.tableNode,
|
|
129
|
-
widthToWidest: tablePluginState.widthToWidest
|
|
135
|
+
widthToWidest: tablePluginState.widthToWidest,
|
|
136
|
+
resizingTableLocalId: tableWidthResizingPluginState === null || tableWidthResizingPluginState === void 0 ? void 0 : tableWidthResizingPluginState.tableLocalId,
|
|
137
|
+
tableRef: (_tablePluginState$tab = tablePluginState === null || tablePluginState === void 0 ? void 0 : tablePluginState.tableRef) !== null && _tablePluginState$tab !== void 0 ? _tablePluginState$tab : undefined,
|
|
138
|
+
resizingTableRef: (_tableWidthResizingPl = tableWidthResizingPluginState === null || tableWidthResizingPluginState === void 0 ? void 0 : tableWidthResizingPluginState.tableRef) !== null && _tableWidthResizingPl !== void 0 ? _tableWidthResizingPl : undefined,
|
|
139
|
+
tablePos: tablePluginState.tablePos,
|
|
140
|
+
targetCellPosition: tablePluginState.targetCellPosition,
|
|
141
|
+
isContextualMenuOpen: tablePluginState.isContextualMenuOpen,
|
|
142
|
+
pluginConfig: tablePluginState.pluginConfig,
|
|
143
|
+
insertColumnButtonIndex: tablePluginState.insertColumnButtonIndex,
|
|
144
|
+
insertRowButtonIndex: tablePluginState.insertRowButtonIndex,
|
|
145
|
+
isDragAndDropEnabled: tablePluginState.isDragAndDropEnabled,
|
|
146
|
+
tableWrapperTarget: tablePluginState.tableWrapperTarget,
|
|
147
|
+
isCellMenuOpenByKeyboard: tablePluginState.isCellMenuOpenByKeyboard,
|
|
148
|
+
stickyHeader: stickyHeader,
|
|
149
|
+
dragMenuDirection: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuDirection,
|
|
150
|
+
dragMenuIndex: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuIndex,
|
|
151
|
+
isDragMenuOpen: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.isDragMenuOpen
|
|
130
152
|
};
|
|
153
|
+
return sharedStateInternal;
|
|
131
154
|
},
|
|
132
155
|
actions: {
|
|
133
156
|
insertTable: function insertTable(analyticsPayload) {
|
|
@@ -428,6 +451,19 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
428
451
|
popupsBoundariesElement = _ref20.popupsBoundariesElement,
|
|
429
452
|
popupsScrollableElement = _ref20.popupsScrollableElement,
|
|
430
453
|
dispatchAnalyticsEvent = _ref20.dispatchAnalyticsEvent;
|
|
454
|
+
if ((0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)) {
|
|
455
|
+
return /*#__PURE__*/_react.default.createElement(_ContentComponent.ContentComponent, {
|
|
456
|
+
api: api,
|
|
457
|
+
editorView: editorView,
|
|
458
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
459
|
+
options: options,
|
|
460
|
+
popupsMountPoint: popupsMountPoint,
|
|
461
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
462
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
463
|
+
defaultGetEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
464
|
+
defaultGetEditorFeatureFlags: defaultGetEditorFeatureFlags
|
|
465
|
+
});
|
|
466
|
+
}
|
|
431
467
|
return /*#__PURE__*/_react.default.createElement(_errorBoundary.ErrorBoundary, {
|
|
432
468
|
component: _analytics.ACTION_SUBJECT.TABLES_PLUGIN,
|
|
433
469
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ContentComponent = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
|
+
var _errorBoundary = require("@atlaskit/editor-common/error-boundary");
|
|
11
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
12
|
+
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
13
|
+
var _FloatingContextualButton = _interopRequireDefault(require("./FloatingContextualButton"));
|
|
14
|
+
var _FloatingContextualMenu = _interopRequireDefault(require("./FloatingContextualMenu"));
|
|
15
|
+
var _FloatingDeleteButton = _interopRequireDefault(require("./FloatingDeleteButton"));
|
|
16
|
+
var _FloatingDragMenu = _interopRequireDefault(require("./FloatingDragMenu"));
|
|
17
|
+
var _FloatingInsertButton = _interopRequireDefault(require("./FloatingInsertButton"));
|
|
18
|
+
var _FloatingToolbarLabel = require("./FloatingToolbarLabel/FloatingToolbarLabel");
|
|
19
|
+
var _globalStyles = require("./global-styles");
|
|
20
|
+
var _TableFullWidthLabel = require("./TableFullWidthLabel");
|
|
21
|
+
// Ignored via go/ees005
|
|
22
|
+
// eslint-disable-next-line import/no-named-as-default
|
|
23
|
+
|
|
24
|
+
var useSharedTablePluginStateSelector = function useSharedTablePluginStateSelector(api, key) {
|
|
25
|
+
var value = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, "table.".concat(key));
|
|
26
|
+
return value;
|
|
27
|
+
};
|
|
28
|
+
var ContentComponentInternal = function ContentComponentInternal(_ref) {
|
|
29
|
+
var _api$analytics, _api$accessibilityUti;
|
|
30
|
+
var api = _ref.api,
|
|
31
|
+
editorView = _ref.editorView,
|
|
32
|
+
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
|
|
33
|
+
options = _ref.options,
|
|
34
|
+
popupsMountPoint = _ref.popupsMountPoint,
|
|
35
|
+
popupsBoundariesElement = _ref.popupsBoundariesElement,
|
|
36
|
+
popupsScrollableElement = _ref.popupsScrollableElement,
|
|
37
|
+
defaultGetEditorContainerWidth = _ref.defaultGetEditorContainerWidth,
|
|
38
|
+
defaultGetEditorFeatureFlags = _ref.defaultGetEditorFeatureFlags;
|
|
39
|
+
var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
40
|
+
var ariaNotifyPlugin = api === null || api === void 0 || (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 ? void 0 : _api$accessibilityUti.actions.ariaNotify;
|
|
41
|
+
var resizingTableLocalId = useSharedTablePluginStateSelector(api, 'resizingTableLocalId');
|
|
42
|
+
var resizingTableRef = useSharedTablePluginStateSelector(api, 'resizingTableRef');
|
|
43
|
+
var isTableResizing = useSharedTablePluginStateSelector(api, 'isTableResizing');
|
|
44
|
+
var isResizing = useSharedTablePluginStateSelector(api, 'isResizing');
|
|
45
|
+
var widthToWidest = useSharedTablePluginStateSelector(api, 'widthToWidest');
|
|
46
|
+
var tableNode = useSharedTablePluginStateSelector(api, 'tableNode');
|
|
47
|
+
var targetCellPosition = useSharedTablePluginStateSelector(api, 'targetCellPosition');
|
|
48
|
+
var isContextualMenuOpen = useSharedTablePluginStateSelector(api, 'isContextualMenuOpen');
|
|
49
|
+
var tableRef = useSharedTablePluginStateSelector(api, 'tableRef');
|
|
50
|
+
var pluginConfig = useSharedTablePluginStateSelector(api, 'pluginConfig');
|
|
51
|
+
var insertColumnButtonIndex = useSharedTablePluginStateSelector(api, 'insertColumnButtonIndex');
|
|
52
|
+
var insertRowButtonIndex = useSharedTablePluginStateSelector(api, 'insertRowButtonIndex');
|
|
53
|
+
var isHeaderColumnEnabled = useSharedTablePluginStateSelector(api, 'isHeaderColumnEnabled');
|
|
54
|
+
var isHeaderRowEnabled = useSharedTablePluginStateSelector(api, 'isHeaderRowEnabled');
|
|
55
|
+
var isDragAndDropEnabled = useSharedTablePluginStateSelector(api, 'isDragAndDropEnabled');
|
|
56
|
+
var tableWrapperTarget = useSharedTablePluginStateSelector(api, 'tableWrapperTarget');
|
|
57
|
+
var isCellMenuOpenByKeyboard = useSharedTablePluginStateSelector(api, 'isCellMenuOpenByKeyboard');
|
|
58
|
+
var allowControls = pluginConfig.allowControls;
|
|
59
|
+
var stickyHeader = useSharedTablePluginStateSelector(api, 'stickyHeader');
|
|
60
|
+
var dragMenuDirection = useSharedTablePluginStateSelector(api, 'dragMenuDirection');
|
|
61
|
+
var dragMenuIndex = useSharedTablePluginStateSelector(api, 'dragMenuIndex');
|
|
62
|
+
var isDragMenuOpen = useSharedTablePluginStateSelector(api, 'isDragMenuOpen');
|
|
63
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, targetCellPosition && (tableRef || isCellMenuOpenByKeyboard) && !isResizing && options && options.allowContextualMenu && /*#__PURE__*/_react.default.createElement(_FloatingContextualButton.default, {
|
|
64
|
+
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
65
|
+
editorView: editorView,
|
|
66
|
+
tableNode: tableNode,
|
|
67
|
+
mountPoint: popupsMountPoint,
|
|
68
|
+
targetCellPosition: targetCellPosition,
|
|
69
|
+
scrollableElement: popupsScrollableElement,
|
|
70
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
71
|
+
isContextualMenuOpen: isContextualMenuOpen,
|
|
72
|
+
stickyHeader: stickyHeader,
|
|
73
|
+
tableWrapper: tableWrapperTarget,
|
|
74
|
+
isCellMenuOpenByKeyboard: isCellMenuOpenByKeyboard
|
|
75
|
+
}), allowControls && /*#__PURE__*/_react.default.createElement(_FloatingInsertButton.default, {
|
|
76
|
+
tableNode: tableNode,
|
|
77
|
+
tableRef: tableRef,
|
|
78
|
+
insertColumnButtonIndex: insertColumnButtonIndex,
|
|
79
|
+
insertRowButtonIndex: insertRowButtonIndex,
|
|
80
|
+
isHeaderColumnEnabled: isHeaderColumnEnabled,
|
|
81
|
+
isHeaderRowEnabled: isHeaderRowEnabled,
|
|
82
|
+
isDragAndDropEnabled: isDragAndDropEnabled,
|
|
83
|
+
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
|
|
84
|
+
editorView: editorView,
|
|
85
|
+
mountPoint: popupsMountPoint,
|
|
86
|
+
boundariesElement: popupsBoundariesElement,
|
|
87
|
+
scrollableElement: popupsScrollableElement,
|
|
88
|
+
hasStickyHeaders: stickyHeader && stickyHeader.sticky,
|
|
89
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
90
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
91
|
+
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
92
|
+
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags,
|
|
93
|
+
isChromelessEditor: options === null || options === void 0 ? void 0 : options.isChromelessEditor,
|
|
94
|
+
api: api,
|
|
95
|
+
isCommentEditor: options === null || options === void 0 ? void 0 : options.isCommentEditor
|
|
96
|
+
}), (options === null || options === void 0 ? void 0 : options.allowContextualMenu) && /*#__PURE__*/_react.default.createElement(_FloatingContextualMenu.default, {
|
|
97
|
+
editorView: editorView,
|
|
98
|
+
mountPoint: popupsMountPoint,
|
|
99
|
+
boundariesElement: popupsBoundariesElement,
|
|
100
|
+
targetCellPosition: targetCellPosition,
|
|
101
|
+
isOpen: Boolean(isContextualMenuOpen) && !isResizing,
|
|
102
|
+
pluginConfig: pluginConfig,
|
|
103
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
104
|
+
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
105
|
+
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags,
|
|
106
|
+
isCellMenuOpenByKeyboard: isCellMenuOpenByKeyboard,
|
|
107
|
+
isCommentEditor: options === null || options === void 0 ? void 0 : options.isCommentEditor,
|
|
108
|
+
api: api
|
|
109
|
+
}), isDragAndDropEnabled && /*#__PURE__*/_react.default.createElement(_FloatingDragMenu.default, {
|
|
110
|
+
editorView: editorView,
|
|
111
|
+
mountPoint: popupsMountPoint,
|
|
112
|
+
boundariesElement: popupsBoundariesElement,
|
|
113
|
+
tableRef: tableRef,
|
|
114
|
+
tableNode: tableNode,
|
|
115
|
+
targetCellPosition: targetCellPosition,
|
|
116
|
+
direction: dragMenuDirection,
|
|
117
|
+
index: dragMenuIndex,
|
|
118
|
+
isOpen: !!isDragMenuOpen && !isResizing,
|
|
119
|
+
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
120
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
121
|
+
stickyHeaders: stickyHeader,
|
|
122
|
+
pluginConfig: pluginConfig,
|
|
123
|
+
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
|
|
124
|
+
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags,
|
|
125
|
+
ariaNotifyPlugin: ariaNotifyPlugin,
|
|
126
|
+
api: api,
|
|
127
|
+
isCommentEditor: options === null || options === void 0 ? void 0 : options.isCommentEditor
|
|
128
|
+
}), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/_react.default.createElement(_FloatingDeleteButton.default, {
|
|
129
|
+
editorView: editorView,
|
|
130
|
+
selection: editorView.state.selection,
|
|
131
|
+
tableRef: tableRef,
|
|
132
|
+
mountPoint: popupsMountPoint,
|
|
133
|
+
boundariesElement: popupsBoundariesElement,
|
|
134
|
+
scrollableElement: popupsScrollableElement,
|
|
135
|
+
stickyHeaders: stickyHeader,
|
|
136
|
+
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
137
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
138
|
+
api: api
|
|
139
|
+
}), ((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.default.createElement(_FloatingToolbarLabel.FloatingToolbarLabel, {
|
|
140
|
+
target: resizingTableRef,
|
|
141
|
+
content: /*#__PURE__*/_react.default.createElement(_TableFullWidthLabel.FullWidthDisplay, null),
|
|
142
|
+
alignX: 'center',
|
|
143
|
+
alignY: 'bottom',
|
|
144
|
+
stick: true,
|
|
145
|
+
forcePlacement: true,
|
|
146
|
+
zIndex: _editorSharedStyles.akEditorFloatingPanelZIndex,
|
|
147
|
+
offset: [0, 10]
|
|
148
|
+
}));
|
|
149
|
+
};
|
|
150
|
+
var ContentComponent = exports.ContentComponent = function ContentComponent(_ref2) {
|
|
151
|
+
var _api$featureFlags;
|
|
152
|
+
var api = _ref2.api,
|
|
153
|
+
editorView = _ref2.editorView,
|
|
154
|
+
dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent,
|
|
155
|
+
options = _ref2.options,
|
|
156
|
+
popupsMountPoint = _ref2.popupsMountPoint,
|
|
157
|
+
popupsBoundariesElement = _ref2.popupsBoundariesElement,
|
|
158
|
+
popupsScrollableElement = _ref2.popupsScrollableElement,
|
|
159
|
+
defaultGetEditorContainerWidth = _ref2.defaultGetEditorContainerWidth,
|
|
160
|
+
defaultGetEditorFeatureFlags = _ref2.defaultGetEditorFeatureFlags;
|
|
161
|
+
return /*#__PURE__*/_react.default.createElement(_errorBoundary.ErrorBoundary, {
|
|
162
|
+
component: _analytics.ACTION_SUBJECT.TABLES_PLUGIN,
|
|
163
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
164
|
+
fallbackComponent: null
|
|
165
|
+
}, /*#__PURE__*/_react.default.createElement(_globalStyles.GlobalStylesWrapper, {
|
|
166
|
+
featureFlags: api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState(),
|
|
167
|
+
isDragAndDropEnabledOption: options === null || options === void 0 ? void 0 : options.dragAndDropEnabled,
|
|
168
|
+
api: api
|
|
169
|
+
}), /*#__PURE__*/_react.default.createElement(ContentComponentInternal, {
|
|
170
|
+
api: api,
|
|
171
|
+
editorView: editorView,
|
|
172
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
173
|
+
options: options,
|
|
174
|
+
popupsMountPoint: popupsMountPoint,
|
|
175
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
176
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
177
|
+
defaultGetEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
178
|
+
defaultGetEditorFeatureFlags: defaultGetEditorFeatureFlags
|
|
179
|
+
}));
|
|
180
|
+
};
|
package/dist/cjs/ui/toolbar.js
CHANGED
|
@@ -494,6 +494,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
494
494
|
onBlur: (0, _commands.clearHoverSelection)()
|
|
495
495
|
};
|
|
496
496
|
};
|
|
497
|
+
var shouldGroupWithoutSeparators = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_6');
|
|
497
498
|
return {
|
|
498
499
|
title: toolbarTitle,
|
|
499
500
|
getDomRef: getDomRef,
|
|
@@ -504,12 +505,15 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
504
505
|
},
|
|
505
506
|
zIndex: _editorSharedStyles.akEditorFloatingPanelZIndex + 1,
|
|
506
507
|
// Place the context menu slightly above the others
|
|
507
|
-
items: [menu, separator(menu.hidden)]
|
|
508
|
+
items: [menu].concat((0, _toConsumableArray2.default)(!shouldGroupWithoutSeparators ? [separator(menu.hidden)] : []), (0, _toConsumableArray2.default)(alignmentMenu), (0, _toConsumableArray2.default)(!shouldGroupWithoutSeparators ? [separator(alignmentMenu.length === 0)] : []), (0, _toConsumableArray2.default)(cellItems), (0, _toConsumableArray2.default)(columnSettingsItems), (0, _toConsumableArray2.default)(colorPicker), (0, _toConsumableArray2.default)((0, _experiments.editorExperiment)('platform_editor_controls', 'control') ? [{
|
|
508
509
|
type: 'extensions-placeholder',
|
|
509
510
|
separator: 'end'
|
|
510
511
|
}, copyButton, {
|
|
511
512
|
type: 'separator'
|
|
512
|
-
}, deleteButton] : [{
|
|
513
|
+
}, deleteButton] : [shouldGroupWithoutSeparators && {
|
|
514
|
+
type: 'separator',
|
|
515
|
+
fullHeight: true
|
|
516
|
+
}, {
|
|
513
517
|
type: 'overflow-dropdown',
|
|
514
518
|
dropdownWidth: 220,
|
|
515
519
|
options: [{
|
|
@@ -639,7 +643,7 @@ var getColumnSettingItems = function getColumnSettingItems(editorState, editorVi
|
|
|
639
643
|
disabled: !wouldChange
|
|
640
644
|
});
|
|
641
645
|
}
|
|
642
|
-
if (items.length !== 0) {
|
|
646
|
+
if (items.length !== 0 && (!(0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') || !(0, _platformFeatureFlags.fg)('platform_editor_controls_patch_6'))) {
|
|
643
647
|
items.push({
|
|
644
648
|
type: 'separator'
|
|
645
649
|
});
|
|
@@ -114,12 +114,10 @@ export default class TableView extends ReactNodeView {
|
|
|
114
114
|
_handleTableRef(node) {
|
|
115
115
|
let oldIgnoreMutation;
|
|
116
116
|
let selectionBookmark;
|
|
117
|
-
let parentOffset = 0;
|
|
118
117
|
let mutationsIgnored = false;
|
|
119
118
|
|
|
120
119
|
// Only proceed if we have both a node and table, and the table isn't already inside the node
|
|
121
120
|
if (node && this.table && !node.contains(this.table)) {
|
|
122
|
-
var _this$view$state$sele;
|
|
123
121
|
// Store the current ignoreMutation handler so we can restore it later
|
|
124
122
|
oldIgnoreMutation = this.ignoreMutation;
|
|
125
123
|
|
|
@@ -127,7 +125,7 @@ export default class TableView extends ReactNodeView {
|
|
|
127
125
|
// - Ignores all DOM mutations except selection changes
|
|
128
126
|
// - Tracks when mutations have been ignored via mutationsIgnored flag
|
|
129
127
|
this.ignoreMutation = m => {
|
|
130
|
-
const isSelectionMutation = m.
|
|
128
|
+
const isSelectionMutation = m.type === 'selection';
|
|
131
129
|
if (!isSelectionMutation) {
|
|
132
130
|
mutationsIgnored = true;
|
|
133
131
|
}
|
|
@@ -140,15 +138,8 @@ export default class TableView extends ReactNodeView {
|
|
|
140
138
|
selectionBookmark = this.view.state.selection.getBookmark();
|
|
141
139
|
}
|
|
142
140
|
|
|
143
|
-
// Store the current cursor position within the parent node
|
|
144
|
-
// Used to determine if we need to restore selection later
|
|
145
|
-
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) {
|
|
146
|
-
var _this$view$state$sele2, _this$view$state$sele3, _this$view$state$sele4;
|
|
147
|
-
parentOffset = (_this$view$state$sele2 = (_this$view$state$sele3 = this.view.state.selection) === null || _this$view$state$sele3 === void 0 ? void 0 : (_this$view$state$sele4 = _this$view$state$sele3.ranges[0].$from) === null || _this$view$state$sele4 === void 0 ? void 0 : _this$view$state$sele4.parentOffset) !== null && _this$view$state$sele2 !== void 0 ? _this$view$state$sele2 : 0;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
141
|
// Remove the ProseMirror table DOM structure to avoid duplication, as it's replaced with the React table node.
|
|
151
|
-
if (this.renderedDOM) {
|
|
142
|
+
if (this.dom && this.renderedDOM) {
|
|
152
143
|
this.dom.removeChild(this.renderedDOM);
|
|
153
144
|
}
|
|
154
145
|
// Move the table from the ProseMirror table structure into the React rendered table node.
|
|
@@ -162,9 +153,13 @@ export default class TableView extends ReactNodeView {
|
|
|
162
153
|
// Restore the selection only if:
|
|
163
154
|
// - We have a selection bookmark
|
|
164
155
|
// - Mutations were ignored during the table move
|
|
165
|
-
// - The
|
|
166
|
-
if (selectionBookmark && mutationsIgnored
|
|
167
|
-
|
|
156
|
+
// - The bookmarked selection is different from the current selection.
|
|
157
|
+
if (selectionBookmark && mutationsIgnored) {
|
|
158
|
+
const resolvedSelection = selectionBookmark.resolve(this.view.state.tr.doc);
|
|
159
|
+
// Don't set the selection if it's the same as the current selection.
|
|
160
|
+
if (!resolvedSelection.eq(this.view.state.selection)) {
|
|
161
|
+
this.view.dispatch(this.view.state.tr.setSelection(resolvedSelection));
|
|
162
|
+
}
|
|
168
163
|
}
|
|
169
164
|
});
|
|
170
165
|
}
|
|
@@ -28,7 +28,6 @@ import { createPlugin as createDragAndDropPlugin } from './pm-plugins/drag-and-d
|
|
|
28
28
|
import { pluginKey as dragAndDropPluginKey } from './pm-plugins/drag-and-drop/plugin-key';
|
|
29
29
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
30
30
|
import { createPlugin } from './pm-plugins/main';
|
|
31
|
-
import { getPluginState } from './pm-plugins/plugin-factory';
|
|
32
31
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
33
32
|
import { createPlugin as createTableSafariDeleteCompositionTextIssueWorkaroundPlugin } from './pm-plugins/safari-delete-composition-text-issue-workaround';
|
|
34
33
|
import { createPlugin as createStickyHeadersPlugin } from './pm-plugins/sticky-headers/plugin';
|
|
@@ -45,6 +44,7 @@ import { createPlugin as createTableWidthPlugin, pluginKey as tableWidthPluginKe
|
|
|
45
44
|
import { createPlugin as createTableWidthInCommentFixPlugin } from './pm-plugins/table-width-in-comment-fix';
|
|
46
45
|
import { createTableWithWidth } from './pm-plugins/utils/create';
|
|
47
46
|
import { createPlugin as createViewModeSortPlugin } from './pm-plugins/view-mode-sort';
|
|
47
|
+
import { ContentComponent } from './ui/ContentComponent';
|
|
48
48
|
import FloatingContextualButton from './ui/FloatingContextualButton';
|
|
49
49
|
import FloatingContextualMenu from './ui/FloatingContextualMenu';
|
|
50
50
|
import FloatingDeleteButton from './ui/FloatingDeleteButton';
|
|
@@ -90,13 +90,19 @@ const tablePlugin = ({
|
|
|
90
90
|
// Use getSharedState to store fullWidthEnabled and wasFullWidthModeEnabled to guarantee access
|
|
91
91
|
// to most up to date values - passing to createPluginState will not re-initialise the state
|
|
92
92
|
getSharedState: editorState => {
|
|
93
|
+
var _tablePluginState$tab, _tableWidthResizingPl;
|
|
93
94
|
if (!editorState) {
|
|
94
95
|
return undefined;
|
|
95
96
|
}
|
|
96
|
-
|
|
97
|
+
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
99
|
+
const tablePluginState = pluginKey.getState(editorState);
|
|
97
100
|
const tableResizingPluginState = getFlexiResizingPlugin(editorState);
|
|
98
101
|
const tableWidthResizingPluginState = tableWidthPluginKey.getState(editorState);
|
|
99
|
-
|
|
102
|
+
const stickyHeadersState = stickyHeadersPluginKey.getState(editorState);
|
|
103
|
+
const stickyHeader = stickyHeadersState ? findStickyHeaderForTable(stickyHeadersState, tablePluginState === null || tablePluginState === void 0 ? void 0 : tablePluginState.tablePos) : undefined;
|
|
104
|
+
const dragAndDropState = dragAndDropPluginKey.getState(editorState);
|
|
105
|
+
const sharedStateInternal = {
|
|
100
106
|
isFullWidthModeEnabled: !!(options !== null && options !== void 0 && options.fullWidthEnabled),
|
|
101
107
|
wasFullWidthModeEnabled: !!(options !== null && options !== void 0 && options.wasFullWidthEnabled),
|
|
102
108
|
isHeaderRowEnabled: tablePluginState.isHeaderRowEnabled,
|
|
@@ -113,8 +119,25 @@ const tablePlugin = ({
|
|
|
113
119
|
// IMPORTANT: Need to continue to pass tableNode to control re-renders
|
|
114
120
|
// TableComponent listens for node attribute changes to update colgroups
|
|
115
121
|
tableNode: tablePluginState.tableNode,
|
|
116
|
-
widthToWidest: tablePluginState.widthToWidest
|
|
122
|
+
widthToWidest: tablePluginState.widthToWidest,
|
|
123
|
+
resizingTableLocalId: tableWidthResizingPluginState === null || tableWidthResizingPluginState === void 0 ? void 0 : tableWidthResizingPluginState.tableLocalId,
|
|
124
|
+
tableRef: (_tablePluginState$tab = tablePluginState === null || tablePluginState === void 0 ? void 0 : tablePluginState.tableRef) !== null && _tablePluginState$tab !== void 0 ? _tablePluginState$tab : undefined,
|
|
125
|
+
resizingTableRef: (_tableWidthResizingPl = tableWidthResizingPluginState === null || tableWidthResizingPluginState === void 0 ? void 0 : tableWidthResizingPluginState.tableRef) !== null && _tableWidthResizingPl !== void 0 ? _tableWidthResizingPl : undefined,
|
|
126
|
+
tablePos: tablePluginState.tablePos,
|
|
127
|
+
targetCellPosition: tablePluginState.targetCellPosition,
|
|
128
|
+
isContextualMenuOpen: tablePluginState.isContextualMenuOpen,
|
|
129
|
+
pluginConfig: tablePluginState.pluginConfig,
|
|
130
|
+
insertColumnButtonIndex: tablePluginState.insertColumnButtonIndex,
|
|
131
|
+
insertRowButtonIndex: tablePluginState.insertRowButtonIndex,
|
|
132
|
+
isDragAndDropEnabled: tablePluginState.isDragAndDropEnabled,
|
|
133
|
+
tableWrapperTarget: tablePluginState.tableWrapperTarget,
|
|
134
|
+
isCellMenuOpenByKeyboard: tablePluginState.isCellMenuOpenByKeyboard,
|
|
135
|
+
stickyHeader,
|
|
136
|
+
dragMenuDirection: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuDirection,
|
|
137
|
+
dragMenuIndex: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuIndex,
|
|
138
|
+
isDragMenuOpen: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.isDragMenuOpen
|
|
117
139
|
};
|
|
140
|
+
return sharedStateInternal;
|
|
118
141
|
},
|
|
119
142
|
actions: {
|
|
120
143
|
insertTable: analyticsPayload => (state, dispatch) => {
|
|
@@ -416,6 +439,19 @@ const tablePlugin = ({
|
|
|
416
439
|
dispatchAnalyticsEvent
|
|
417
440
|
}) {
|
|
418
441
|
var _api$featureFlags;
|
|
442
|
+
if (editorExperiment('platform_editor_usesharedpluginstateselector', true)) {
|
|
443
|
+
return /*#__PURE__*/React.createElement(ContentComponent, {
|
|
444
|
+
api: api,
|
|
445
|
+
editorView: editorView,
|
|
446
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
447
|
+
options: options,
|
|
448
|
+
popupsMountPoint: popupsMountPoint,
|
|
449
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
450
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
451
|
+
defaultGetEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
452
|
+
defaultGetEditorFeatureFlags: defaultGetEditorFeatureFlags
|
|
453
|
+
});
|
|
454
|
+
}
|
|
419
455
|
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
420
456
|
component: ACTION_SUBJECT.TABLES_PLUGIN,
|
|
421
457
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|