@atlaskit/editor-plugin-table 10.9.21 → 10.9.22
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 +12 -0
- package/dist/cjs/pm-plugins/main.js +4 -12
- package/dist/cjs/tablePlugin.js +8 -2
- package/dist/cjs/ui/ContentComponent.js +20 -2
- package/dist/es2019/pm-plugins/main.js +4 -12
- package/dist/es2019/tablePlugin.js +8 -2
- package/dist/es2019/ui/ContentComponent.js +21 -3
- package/dist/esm/pm-plugins/main.js +4 -12
- package/dist/esm/tablePlugin.js +8 -2
- package/dist/esm/ui/ContentComponent.js +21 -3
- package/dist/types/types/index.d.ts +2 -0
- package/dist/types/ui/ContentComponent.d.ts +2 -1
- package/dist/types/ui/hooks/useInternalTablePluginStateSelector.d.ts +1 -1
- package/dist/types-ts4.5/types/index.d.ts +2 -0
- package/dist/types-ts4.5/ui/ContentComponent.d.ts +2 -1
- package/dist/types-ts4.5/ui/hooks/useInternalTablePluginStateSelector.d.ts +1 -1
- package/package.json +1 -4
- package/src/pm-plugins/main.ts +5 -13
- package/src/tablePlugin.tsx +6 -0
- package/src/types/index.ts +2 -0
- package/src/ui/ContentComponent.tsx +41 -2
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 10.9.22
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#154546](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/154546)
|
|
8
|
+
[`11d9e46f3caaa`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/11d9e46f3caaa) -
|
|
9
|
+
Fix tables insertion when platform_editor_usesharedpluginstateselector experiment is enabled
|
|
10
|
+
- [#154340](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/154340)
|
|
11
|
+
[`982623fd6523f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/982623fd6523f) -
|
|
12
|
+
[ux] [EDITOR-325] Clean up nested tables feature gate
|
|
13
|
+
`platform_editor_nested_tables_bodied_extension_fix`
|
|
14
|
+
|
|
3
15
|
## 10.9.21
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -218,19 +218,11 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
218
218
|
|
|
219
219
|
// transformSliceToRemoveOpenTable() transforms based on the depth of the root node, assuming that the tables will be at the root
|
|
220
220
|
// Bodied extensions will contribute to the depth of the table selection so we need to remove them first
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
slice = (0, _transforms.transformSliceToRemoveOpenBodiedExtension)(slice, schema);
|
|
221
|
+
/** If a partial paste of bodied extension, paste only text */
|
|
222
|
+
slice = (0, _transforms.transformSliceToRemoveOpenBodiedExtension)(slice, schema);
|
|
224
223
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
} else {
|
|
228
|
-
/** If a partial paste of table, paste only table's content */
|
|
229
|
-
slice = (0, _paste.transformSliceToRemoveOpenTable)(slice, schema);
|
|
230
|
-
|
|
231
|
-
/** If a partial paste of bodied extension, paste only text */
|
|
232
|
-
slice = (0, _transforms.transformSliceToRemoveOpenBodiedExtension)(slice, schema);
|
|
233
|
-
}
|
|
224
|
+
/** If a partial paste of table, paste only table's content */
|
|
225
|
+
slice = (0, _paste.transformSliceToRemoveOpenTable)(slice, schema);
|
|
234
226
|
|
|
235
227
|
/** If a partial paste of multi bodied extension, paste only children */
|
|
236
228
|
slice = (0, _transforms.transformSliceToRemoveOpenMultiBodiedExtension)(slice, schema);
|
package/dist/cjs/tablePlugin.js
CHANGED
|
@@ -128,6 +128,7 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
128
128
|
var stickyHeadersState = _pluginKey4.pluginKey.getState(editorState);
|
|
129
129
|
var stickyHeader = stickyHeadersState ? (0, _util.findStickyHeaderForTable)(stickyHeadersState, tablePluginState === null || tablePluginState === void 0 ? void 0 : tablePluginState.tablePos) : undefined;
|
|
130
130
|
var dragAndDropState = _pluginKey2.pluginKey.getState(editorState);
|
|
131
|
+
var sizeSelectorPluginState = _tableSizeSelector.pluginKey.getState(editorState);
|
|
131
132
|
var sharedStateInternal = {
|
|
132
133
|
isFullWidthModeEnabled: !!(options !== null && options !== void 0 && options.fullWidthEnabled),
|
|
133
134
|
wasFullWidthModeEnabled: !!(options !== null && options !== void 0 && options.wasFullWidthEnabled),
|
|
@@ -161,7 +162,9 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
161
162
|
stickyHeader: stickyHeader,
|
|
162
163
|
dragMenuDirection: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuDirection,
|
|
163
164
|
dragMenuIndex: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuIndex,
|
|
164
|
-
isDragMenuOpen: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.isDragMenuOpen
|
|
165
|
+
isDragMenuOpen: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.isDragMenuOpen,
|
|
166
|
+
isSizeSelectorOpen: sizeSelectorPluginState === null || sizeSelectorPluginState === void 0 ? void 0 : sizeSelectorPluginState.isSelectorOpen,
|
|
167
|
+
sizeSelectorTargetRef: sizeSelectorPluginState === null || sizeSelectorPluginState === void 0 ? void 0 : sizeSelectorPluginState.targetRef
|
|
165
168
|
};
|
|
166
169
|
return sharedStateInternal;
|
|
167
170
|
},
|
|
@@ -474,7 +477,8 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
474
477
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
475
478
|
popupsScrollableElement: popupsScrollableElement,
|
|
476
479
|
defaultGetEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
477
|
-
defaultGetEditorFeatureFlags: defaultGetEditorFeatureFlags
|
|
480
|
+
defaultGetEditorFeatureFlags: defaultGetEditorFeatureFlags,
|
|
481
|
+
isTableSelectorEnabled: isTableSelectorEnabled
|
|
478
482
|
});
|
|
479
483
|
}
|
|
480
484
|
return /*#__PURE__*/_react.default.createElement(_errorBoundary.ErrorBoundary, {
|
|
@@ -503,6 +507,8 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
503
507
|
tableWidthPluginState = _ref21.tableWidthPluginState,
|
|
504
508
|
dragAndDropState = _ref21.dragAndDropState,
|
|
505
509
|
sizeSelectorPluginState = _ref21.sizeSelectorPluginState;
|
|
510
|
+
// Any changes made inside `<WithPluginState>` need to be reflected in the
|
|
511
|
+
// `<ContentComponent>` as well.
|
|
506
512
|
var isColumnResizing = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
|
|
507
513
|
var isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
|
|
508
514
|
var resizingTableLocalId = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.tableLocalId;
|
|
@@ -8,7 +8,10 @@ exports.ContentComponent = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
10
|
var _errorBoundary = require("@atlaskit/editor-common/error-boundary");
|
|
11
|
+
var _getDomRefFromSelection = require("@atlaskit/editor-common/get-dom-ref-from-selection");
|
|
12
|
+
var _resizer = require("@atlaskit/editor-common/resizer");
|
|
11
13
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
14
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
12
15
|
var _FloatingContextualButton = _interopRequireDefault(require("./FloatingContextualButton"));
|
|
13
16
|
var _FloatingContextualMenu = _interopRequireDefault(require("./FloatingContextualMenu"));
|
|
14
17
|
var _FloatingDeleteButton = _interopRequireDefault(require("./FloatingDeleteButton"));
|
|
@@ -17,12 +20,13 @@ var _FloatingInsertButton = _interopRequireDefault(require("./FloatingInsertButt
|
|
|
17
20
|
var _FloatingToolbarLabel = require("./FloatingToolbarLabel/FloatingToolbarLabel");
|
|
18
21
|
var _globalStyles = require("./global-styles");
|
|
19
22
|
var _useInternalTablePluginStateSelector = require("./hooks/useInternalTablePluginStateSelector");
|
|
23
|
+
var _SizeSelector = require("./SizeSelector");
|
|
20
24
|
var _TableFullWidthLabel = require("./TableFullWidthLabel");
|
|
21
25
|
// Ignored via go/ees005
|
|
22
26
|
// eslint-disable-next-line import/no-named-as-default
|
|
23
27
|
|
|
24
28
|
var ContentComponentInternal = function ContentComponentInternal(_ref) {
|
|
25
|
-
var _api$analytics, _api$accessibilityUti;
|
|
29
|
+
var _api$analytics, _api$accessibilityUti, _api$analytics2;
|
|
26
30
|
var api = _ref.api,
|
|
27
31
|
editorView = _ref.editorView,
|
|
28
32
|
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
|
|
@@ -30,6 +34,7 @@ var ContentComponentInternal = function ContentComponentInternal(_ref) {
|
|
|
30
34
|
popupsMountPoint = _ref.popupsMountPoint,
|
|
31
35
|
popupsBoundariesElement = _ref.popupsBoundariesElement,
|
|
32
36
|
popupsScrollableElement = _ref.popupsScrollableElement,
|
|
37
|
+
isTableSelectorEnabled = _ref.isTableSelectorEnabled,
|
|
33
38
|
defaultGetEditorContainerWidth = _ref.defaultGetEditorContainerWidth,
|
|
34
39
|
defaultGetEditorFeatureFlags = _ref.defaultGetEditorFeatureFlags;
|
|
35
40
|
var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
@@ -57,6 +62,8 @@ var ContentComponentInternal = function ContentComponentInternal(_ref) {
|
|
|
57
62
|
var dragMenuDirection = (0, _useInternalTablePluginStateSelector.useInternalTablePluginStateSelector)(api, 'dragMenuDirection');
|
|
58
63
|
var dragMenuIndex = (0, _useInternalTablePluginStateSelector.useInternalTablePluginStateSelector)(api, 'dragMenuIndex');
|
|
59
64
|
var isDragMenuOpen = (0, _useInternalTablePluginStateSelector.useInternalTablePluginStateSelector)(api, 'isDragMenuOpen');
|
|
65
|
+
var isSizeSelectorOpen = (0, _useInternalTablePluginStateSelector.useInternalTablePluginStateSelector)(api, 'isSizeSelectorOpen');
|
|
66
|
+
var sizeSelectorTargetRef = (0, _useInternalTablePluginStateSelector.useInternalTablePluginStateSelector)(api, 'sizeSelectorTargetRef');
|
|
60
67
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, targetCellPosition && (tableRef || isCellMenuOpenByKeyboard) && !isResizing && options && options.allowContextualMenu && /*#__PURE__*/_react.default.createElement(_FloatingContextualButton.default, {
|
|
61
68
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
62
69
|
editorView: editorView,
|
|
@@ -135,13 +142,22 @@ var ContentComponentInternal = function ContentComponentInternal(_ref) {
|
|
|
135
142
|
api: api
|
|
136
143
|
}), ((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, {
|
|
137
144
|
target: resizingTableRef,
|
|
138
|
-
content: /*#__PURE__*/_react.default.createElement(
|
|
145
|
+
content: (0, _experiments.editorExperiment)('single_column_layouts', true) ? /*#__PURE__*/_react.default.createElement(_resizer.ResizerBreakoutModeLabel, {
|
|
146
|
+
layout: "full-width"
|
|
147
|
+
}) : /*#__PURE__*/_react.default.createElement(_TableFullWidthLabel.FullWidthDisplay, null),
|
|
139
148
|
alignX: 'center',
|
|
140
149
|
alignY: 'bottom',
|
|
141
150
|
stick: true,
|
|
142
151
|
forcePlacement: true,
|
|
143
152
|
zIndex: _editorSharedStyles.akEditorFloatingPanelZIndex,
|
|
144
153
|
offset: [0, 10]
|
|
154
|
+
}), isTableSelectorEnabled && isSizeSelectorOpen && /*#__PURE__*/_react.default.createElement(_SizeSelector.SizeSelector, {
|
|
155
|
+
api: api,
|
|
156
|
+
isOpenedByKeyboard: false,
|
|
157
|
+
popupsMountPoint: popupsMountPoint,
|
|
158
|
+
target: sizeSelectorTargetRef !== null && sizeSelectorTargetRef !== void 0 ? sizeSelectorTargetRef : (0, _getDomRefFromSelection.getDomRefFromSelection)(editorView, _analytics.ACTION_SUBJECT_ID.PICKER_TABLE_SIZE, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions),
|
|
159
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
160
|
+
popupsScrollableElement: popupsScrollableElement
|
|
145
161
|
}));
|
|
146
162
|
};
|
|
147
163
|
var ContentComponent = exports.ContentComponent = function ContentComponent(_ref3) {
|
|
@@ -153,6 +169,7 @@ var ContentComponent = exports.ContentComponent = function ContentComponent(_ref
|
|
|
153
169
|
popupsMountPoint = _ref3.popupsMountPoint,
|
|
154
170
|
popupsBoundariesElement = _ref3.popupsBoundariesElement,
|
|
155
171
|
popupsScrollableElement = _ref3.popupsScrollableElement,
|
|
172
|
+
isTableSelectorEnabled = _ref3.isTableSelectorEnabled,
|
|
156
173
|
defaultGetEditorContainerWidth = _ref3.defaultGetEditorContainerWidth,
|
|
157
174
|
defaultGetEditorFeatureFlags = _ref3.defaultGetEditorFeatureFlags;
|
|
158
175
|
return /*#__PURE__*/_react.default.createElement(_errorBoundary.ErrorBoundary, {
|
|
@@ -171,6 +188,7 @@ var ContentComponent = exports.ContentComponent = function ContentComponent(_ref
|
|
|
171
188
|
popupsMountPoint: popupsMountPoint,
|
|
172
189
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
173
190
|
popupsScrollableElement: popupsScrollableElement,
|
|
191
|
+
isTableSelectorEnabled: isTableSelectorEnabled,
|
|
174
192
|
defaultGetEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
175
193
|
defaultGetEditorFeatureFlags: defaultGetEditorFeatureFlags
|
|
176
194
|
}));
|
|
@@ -210,19 +210,11 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
210
210
|
|
|
211
211
|
// transformSliceToRemoveOpenTable() transforms based on the depth of the root node, assuming that the tables will be at the root
|
|
212
212
|
// Bodied extensions will contribute to the depth of the table selection so we need to remove them first
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
slice = transformSliceToRemoveOpenBodiedExtension(slice, schema);
|
|
213
|
+
/** If a partial paste of bodied extension, paste only text */
|
|
214
|
+
slice = transformSliceToRemoveOpenBodiedExtension(slice, schema);
|
|
216
215
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
} else {
|
|
220
|
-
/** If a partial paste of table, paste only table's content */
|
|
221
|
-
slice = transformSliceToRemoveOpenTable(slice, schema);
|
|
222
|
-
|
|
223
|
-
/** If a partial paste of bodied extension, paste only text */
|
|
224
|
-
slice = transformSliceToRemoveOpenBodiedExtension(slice, schema);
|
|
225
|
-
}
|
|
216
|
+
/** If a partial paste of table, paste only table's content */
|
|
217
|
+
slice = transformSliceToRemoveOpenTable(slice, schema);
|
|
226
218
|
|
|
227
219
|
/** If a partial paste of multi bodied extension, paste only children */
|
|
228
220
|
slice = transformSliceToRemoveOpenMultiBodiedExtension(slice, schema);
|
|
@@ -116,6 +116,7 @@ const tablePlugin = ({
|
|
|
116
116
|
const stickyHeadersState = stickyHeadersPluginKey.getState(editorState);
|
|
117
117
|
const stickyHeader = stickyHeadersState ? findStickyHeaderForTable(stickyHeadersState, tablePluginState === null || tablePluginState === void 0 ? void 0 : tablePluginState.tablePos) : undefined;
|
|
118
118
|
const dragAndDropState = dragAndDropPluginKey.getState(editorState);
|
|
119
|
+
const sizeSelectorPluginState = sizeSelectorPluginKey.getState(editorState);
|
|
119
120
|
const sharedStateInternal = {
|
|
120
121
|
isFullWidthModeEnabled: !!(options !== null && options !== void 0 && options.fullWidthEnabled),
|
|
121
122
|
wasFullWidthModeEnabled: !!(options !== null && options !== void 0 && options.wasFullWidthEnabled),
|
|
@@ -149,7 +150,9 @@ const tablePlugin = ({
|
|
|
149
150
|
stickyHeader,
|
|
150
151
|
dragMenuDirection: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuDirection,
|
|
151
152
|
dragMenuIndex: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuIndex,
|
|
152
|
-
isDragMenuOpen: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.isDragMenuOpen
|
|
153
|
+
isDragMenuOpen: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.isDragMenuOpen,
|
|
154
|
+
isSizeSelectorOpen: sizeSelectorPluginState === null || sizeSelectorPluginState === void 0 ? void 0 : sizeSelectorPluginState.isSelectorOpen,
|
|
155
|
+
sizeSelectorTargetRef: sizeSelectorPluginState === null || sizeSelectorPluginState === void 0 ? void 0 : sizeSelectorPluginState.targetRef
|
|
153
156
|
};
|
|
154
157
|
return sharedStateInternal;
|
|
155
158
|
},
|
|
@@ -463,7 +466,8 @@ const tablePlugin = ({
|
|
|
463
466
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
464
467
|
popupsScrollableElement: popupsScrollableElement,
|
|
465
468
|
defaultGetEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
466
|
-
defaultGetEditorFeatureFlags: defaultGetEditorFeatureFlags
|
|
469
|
+
defaultGetEditorFeatureFlags: defaultGetEditorFeatureFlags,
|
|
470
|
+
isTableSelectorEnabled: isTableSelectorEnabled
|
|
467
471
|
});
|
|
468
472
|
}
|
|
469
473
|
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
@@ -493,6 +497,8 @@ const tablePlugin = ({
|
|
|
493
497
|
sizeSelectorPluginState
|
|
494
498
|
}) => {
|
|
495
499
|
var _sizeSelectorPluginSt, _api$analytics3;
|
|
500
|
+
// Any changes made inside `<WithPluginState>` need to be reflected in the
|
|
501
|
+
// `<ContentComponent>` as well.
|
|
496
502
|
const isColumnResizing = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
|
|
497
503
|
const isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
|
|
498
504
|
const resizingTableLocalId = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.tableLocalId;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { ACTION_SUBJECT, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
4
|
+
import { getDomRefFromSelection } from '@atlaskit/editor-common/get-dom-ref-from-selection';
|
|
5
|
+
import { ResizerBreakoutModeLabel } from '@atlaskit/editor-common/resizer';
|
|
4
6
|
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
7
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
8
|
import FloatingContextualButton from './FloatingContextualButton';
|
|
6
9
|
import FloatingContextualMenu from './FloatingContextualMenu';
|
|
7
10
|
import FloatingDeleteButton from './FloatingDeleteButton';
|
|
@@ -12,6 +15,7 @@ import FloatingInsertButton from './FloatingInsertButton';
|
|
|
12
15
|
import { FloatingToolbarLabel } from './FloatingToolbarLabel/FloatingToolbarLabel';
|
|
13
16
|
import { GlobalStylesWrapper } from './global-styles';
|
|
14
17
|
import { useInternalTablePluginStateSelector } from './hooks/useInternalTablePluginStateSelector';
|
|
18
|
+
import { SizeSelector } from './SizeSelector';
|
|
15
19
|
import { FullWidthDisplay } from './TableFullWidthLabel';
|
|
16
20
|
const ContentComponentInternal = ({
|
|
17
21
|
api,
|
|
@@ -21,10 +25,11 @@ const ContentComponentInternal = ({
|
|
|
21
25
|
popupsMountPoint,
|
|
22
26
|
popupsBoundariesElement,
|
|
23
27
|
popupsScrollableElement,
|
|
28
|
+
isTableSelectorEnabled,
|
|
24
29
|
defaultGetEditorContainerWidth,
|
|
25
30
|
defaultGetEditorFeatureFlags
|
|
26
31
|
}) => {
|
|
27
|
-
var _api$analytics, _api$accessibilityUti;
|
|
32
|
+
var _api$analytics, _api$accessibilityUti, _api$analytics2;
|
|
28
33
|
const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
29
34
|
const ariaNotifyPlugin = api === null || api === void 0 ? void 0 : (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 ? void 0 : _api$accessibilityUti.actions.ariaNotify;
|
|
30
35
|
const resizingTableLocalId = useInternalTablePluginStateSelector(api, 'resizingTableLocalId');
|
|
@@ -51,6 +56,8 @@ const ContentComponentInternal = ({
|
|
|
51
56
|
const dragMenuDirection = useInternalTablePluginStateSelector(api, 'dragMenuDirection');
|
|
52
57
|
const dragMenuIndex = useInternalTablePluginStateSelector(api, 'dragMenuIndex');
|
|
53
58
|
const isDragMenuOpen = useInternalTablePluginStateSelector(api, 'isDragMenuOpen');
|
|
59
|
+
const isSizeSelectorOpen = useInternalTablePluginStateSelector(api, 'isSizeSelectorOpen');
|
|
60
|
+
const sizeSelectorTargetRef = useInternalTablePluginStateSelector(api, 'sizeSelectorTargetRef');
|
|
54
61
|
return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && (tableRef || isCellMenuOpenByKeyboard) && !isResizing && options && options.allowContextualMenu && /*#__PURE__*/React.createElement(FloatingContextualButton, {
|
|
55
62
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
56
63
|
editorView: editorView,
|
|
@@ -129,13 +136,22 @@ const ContentComponentInternal = ({
|
|
|
129
136
|
api: api
|
|
130
137
|
}), ((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, {
|
|
131
138
|
target: resizingTableRef,
|
|
132
|
-
content: /*#__PURE__*/React.createElement(
|
|
139
|
+
content: editorExperiment('single_column_layouts', true) ? /*#__PURE__*/React.createElement(ResizerBreakoutModeLabel, {
|
|
140
|
+
layout: "full-width"
|
|
141
|
+
}) : /*#__PURE__*/React.createElement(FullWidthDisplay, null),
|
|
133
142
|
alignX: 'center',
|
|
134
143
|
alignY: 'bottom',
|
|
135
144
|
stick: true,
|
|
136
145
|
forcePlacement: true,
|
|
137
146
|
zIndex: akEditorFloatingPanelZIndex,
|
|
138
147
|
offset: [0, 10]
|
|
148
|
+
}), isTableSelectorEnabled && isSizeSelectorOpen && /*#__PURE__*/React.createElement(SizeSelector, {
|
|
149
|
+
api: api,
|
|
150
|
+
isOpenedByKeyboard: false,
|
|
151
|
+
popupsMountPoint: popupsMountPoint,
|
|
152
|
+
target: sizeSelectorTargetRef !== null && sizeSelectorTargetRef !== void 0 ? sizeSelectorTargetRef : getDomRefFromSelection(editorView, ACTION_SUBJECT_ID.PICKER_TABLE_SIZE, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions),
|
|
153
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
154
|
+
popupsScrollableElement: popupsScrollableElement
|
|
139
155
|
}));
|
|
140
156
|
};
|
|
141
157
|
export const ContentComponent = ({
|
|
@@ -146,6 +162,7 @@ export const ContentComponent = ({
|
|
|
146
162
|
popupsMountPoint,
|
|
147
163
|
popupsBoundariesElement,
|
|
148
164
|
popupsScrollableElement,
|
|
165
|
+
isTableSelectorEnabled,
|
|
149
166
|
defaultGetEditorContainerWidth,
|
|
150
167
|
defaultGetEditorFeatureFlags
|
|
151
168
|
}) => {
|
|
@@ -166,6 +183,7 @@ export const ContentComponent = ({
|
|
|
166
183
|
popupsMountPoint: popupsMountPoint,
|
|
167
184
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
168
185
|
popupsScrollableElement: popupsScrollableElement,
|
|
186
|
+
isTableSelectorEnabled: isTableSelectorEnabled,
|
|
169
187
|
defaultGetEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
170
188
|
defaultGetEditorFeatureFlags: defaultGetEditorFeatureFlags
|
|
171
189
|
}));
|
|
@@ -211,19 +211,11 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
|
|
|
211
211
|
|
|
212
212
|
// transformSliceToRemoveOpenTable() transforms based on the depth of the root node, assuming that the tables will be at the root
|
|
213
213
|
// Bodied extensions will contribute to the depth of the table selection so we need to remove them first
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
slice = transformSliceToRemoveOpenBodiedExtension(slice, schema);
|
|
214
|
+
/** If a partial paste of bodied extension, paste only text */
|
|
215
|
+
slice = transformSliceToRemoveOpenBodiedExtension(slice, schema);
|
|
217
216
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
} else {
|
|
221
|
-
/** If a partial paste of table, paste only table's content */
|
|
222
|
-
slice = transformSliceToRemoveOpenTable(slice, schema);
|
|
223
|
-
|
|
224
|
-
/** If a partial paste of bodied extension, paste only text */
|
|
225
|
-
slice = transformSliceToRemoveOpenBodiedExtension(slice, schema);
|
|
226
|
-
}
|
|
217
|
+
/** If a partial paste of table, paste only table's content */
|
|
218
|
+
slice = transformSliceToRemoveOpenTable(slice, schema);
|
|
227
219
|
|
|
228
220
|
/** If a partial paste of multi bodied extension, paste only children */
|
|
229
221
|
slice = transformSliceToRemoveOpenMultiBodiedExtension(slice, schema);
|
package/dist/esm/tablePlugin.js
CHANGED
|
@@ -119,6 +119,7 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
119
119
|
var stickyHeadersState = stickyHeadersPluginKey.getState(editorState);
|
|
120
120
|
var stickyHeader = stickyHeadersState ? findStickyHeaderForTable(stickyHeadersState, tablePluginState === null || tablePluginState === void 0 ? void 0 : tablePluginState.tablePos) : undefined;
|
|
121
121
|
var dragAndDropState = dragAndDropPluginKey.getState(editorState);
|
|
122
|
+
var sizeSelectorPluginState = sizeSelectorPluginKey.getState(editorState);
|
|
122
123
|
var sharedStateInternal = {
|
|
123
124
|
isFullWidthModeEnabled: !!(options !== null && options !== void 0 && options.fullWidthEnabled),
|
|
124
125
|
wasFullWidthModeEnabled: !!(options !== null && options !== void 0 && options.wasFullWidthEnabled),
|
|
@@ -152,7 +153,9 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
152
153
|
stickyHeader: stickyHeader,
|
|
153
154
|
dragMenuDirection: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuDirection,
|
|
154
155
|
dragMenuIndex: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuIndex,
|
|
155
|
-
isDragMenuOpen: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.isDragMenuOpen
|
|
156
|
+
isDragMenuOpen: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.isDragMenuOpen,
|
|
157
|
+
isSizeSelectorOpen: sizeSelectorPluginState === null || sizeSelectorPluginState === void 0 ? void 0 : sizeSelectorPluginState.isSelectorOpen,
|
|
158
|
+
sizeSelectorTargetRef: sizeSelectorPluginState === null || sizeSelectorPluginState === void 0 ? void 0 : sizeSelectorPluginState.targetRef
|
|
156
159
|
};
|
|
157
160
|
return sharedStateInternal;
|
|
158
161
|
},
|
|
@@ -465,7 +468,8 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
465
468
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
466
469
|
popupsScrollableElement: popupsScrollableElement,
|
|
467
470
|
defaultGetEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
468
|
-
defaultGetEditorFeatureFlags: defaultGetEditorFeatureFlags
|
|
471
|
+
defaultGetEditorFeatureFlags: defaultGetEditorFeatureFlags,
|
|
472
|
+
isTableSelectorEnabled: isTableSelectorEnabled
|
|
469
473
|
});
|
|
470
474
|
}
|
|
471
475
|
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
@@ -494,6 +498,8 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
494
498
|
tableWidthPluginState = _ref21.tableWidthPluginState,
|
|
495
499
|
dragAndDropState = _ref21.dragAndDropState,
|
|
496
500
|
sizeSelectorPluginState = _ref21.sizeSelectorPluginState;
|
|
501
|
+
// Any changes made inside `<WithPluginState>` need to be reflected in the
|
|
502
|
+
// `<ContentComponent>` as well.
|
|
497
503
|
var isColumnResizing = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
|
|
498
504
|
var isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
|
|
499
505
|
var resizingTableLocalId = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.tableLocalId;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { ACTION_SUBJECT, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
4
|
+
import { getDomRefFromSelection } from '@atlaskit/editor-common/get-dom-ref-from-selection';
|
|
5
|
+
import { ResizerBreakoutModeLabel } from '@atlaskit/editor-common/resizer';
|
|
4
6
|
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
7
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
8
|
import FloatingContextualButton from './FloatingContextualButton';
|
|
6
9
|
import FloatingContextualMenu from './FloatingContextualMenu';
|
|
7
10
|
import FloatingDeleteButton from './FloatingDeleteButton';
|
|
@@ -12,9 +15,10 @@ import FloatingInsertButton from './FloatingInsertButton';
|
|
|
12
15
|
import { FloatingToolbarLabel } from './FloatingToolbarLabel/FloatingToolbarLabel';
|
|
13
16
|
import { GlobalStylesWrapper } from './global-styles';
|
|
14
17
|
import { useInternalTablePluginStateSelector } from './hooks/useInternalTablePluginStateSelector';
|
|
18
|
+
import { SizeSelector } from './SizeSelector';
|
|
15
19
|
import { FullWidthDisplay } from './TableFullWidthLabel';
|
|
16
20
|
var ContentComponentInternal = function ContentComponentInternal(_ref) {
|
|
17
|
-
var _api$analytics, _api$accessibilityUti;
|
|
21
|
+
var _api$analytics, _api$accessibilityUti, _api$analytics2;
|
|
18
22
|
var api = _ref.api,
|
|
19
23
|
editorView = _ref.editorView,
|
|
20
24
|
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
|
|
@@ -22,6 +26,7 @@ var ContentComponentInternal = function ContentComponentInternal(_ref) {
|
|
|
22
26
|
popupsMountPoint = _ref.popupsMountPoint,
|
|
23
27
|
popupsBoundariesElement = _ref.popupsBoundariesElement,
|
|
24
28
|
popupsScrollableElement = _ref.popupsScrollableElement,
|
|
29
|
+
isTableSelectorEnabled = _ref.isTableSelectorEnabled,
|
|
25
30
|
defaultGetEditorContainerWidth = _ref.defaultGetEditorContainerWidth,
|
|
26
31
|
defaultGetEditorFeatureFlags = _ref.defaultGetEditorFeatureFlags;
|
|
27
32
|
var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
@@ -49,6 +54,8 @@ var ContentComponentInternal = function ContentComponentInternal(_ref) {
|
|
|
49
54
|
var dragMenuDirection = useInternalTablePluginStateSelector(api, 'dragMenuDirection');
|
|
50
55
|
var dragMenuIndex = useInternalTablePluginStateSelector(api, 'dragMenuIndex');
|
|
51
56
|
var isDragMenuOpen = useInternalTablePluginStateSelector(api, 'isDragMenuOpen');
|
|
57
|
+
var isSizeSelectorOpen = useInternalTablePluginStateSelector(api, 'isSizeSelectorOpen');
|
|
58
|
+
var sizeSelectorTargetRef = useInternalTablePluginStateSelector(api, 'sizeSelectorTargetRef');
|
|
52
59
|
return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && (tableRef || isCellMenuOpenByKeyboard) && !isResizing && options && options.allowContextualMenu && /*#__PURE__*/React.createElement(FloatingContextualButton, {
|
|
53
60
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
54
61
|
editorView: editorView,
|
|
@@ -127,13 +134,22 @@ var ContentComponentInternal = function ContentComponentInternal(_ref) {
|
|
|
127
134
|
api: api
|
|
128
135
|
}), ((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, {
|
|
129
136
|
target: resizingTableRef,
|
|
130
|
-
content: /*#__PURE__*/React.createElement(
|
|
137
|
+
content: editorExperiment('single_column_layouts', true) ? /*#__PURE__*/React.createElement(ResizerBreakoutModeLabel, {
|
|
138
|
+
layout: "full-width"
|
|
139
|
+
}) : /*#__PURE__*/React.createElement(FullWidthDisplay, null),
|
|
131
140
|
alignX: 'center',
|
|
132
141
|
alignY: 'bottom',
|
|
133
142
|
stick: true,
|
|
134
143
|
forcePlacement: true,
|
|
135
144
|
zIndex: akEditorFloatingPanelZIndex,
|
|
136
145
|
offset: [0, 10]
|
|
146
|
+
}), isTableSelectorEnabled && isSizeSelectorOpen && /*#__PURE__*/React.createElement(SizeSelector, {
|
|
147
|
+
api: api,
|
|
148
|
+
isOpenedByKeyboard: false,
|
|
149
|
+
popupsMountPoint: popupsMountPoint,
|
|
150
|
+
target: sizeSelectorTargetRef !== null && sizeSelectorTargetRef !== void 0 ? sizeSelectorTargetRef : getDomRefFromSelection(editorView, ACTION_SUBJECT_ID.PICKER_TABLE_SIZE, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions),
|
|
151
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
152
|
+
popupsScrollableElement: popupsScrollableElement
|
|
137
153
|
}));
|
|
138
154
|
};
|
|
139
155
|
export var ContentComponent = function ContentComponent(_ref3) {
|
|
@@ -145,6 +161,7 @@ export var ContentComponent = function ContentComponent(_ref3) {
|
|
|
145
161
|
popupsMountPoint = _ref3.popupsMountPoint,
|
|
146
162
|
popupsBoundariesElement = _ref3.popupsBoundariesElement,
|
|
147
163
|
popupsScrollableElement = _ref3.popupsScrollableElement,
|
|
164
|
+
isTableSelectorEnabled = _ref3.isTableSelectorEnabled,
|
|
148
165
|
defaultGetEditorContainerWidth = _ref3.defaultGetEditorContainerWidth,
|
|
149
166
|
defaultGetEditorFeatureFlags = _ref3.defaultGetEditorFeatureFlags;
|
|
150
167
|
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
@@ -163,6 +180,7 @@ export var ContentComponent = function ContentComponent(_ref3) {
|
|
|
163
180
|
popupsMountPoint: popupsMountPoint,
|
|
164
181
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
165
182
|
popupsScrollableElement: popupsScrollableElement,
|
|
183
|
+
isTableSelectorEnabled: isTableSelectorEnabled,
|
|
166
184
|
defaultGetEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
167
185
|
defaultGetEditorFeatureFlags: defaultGetEditorFeatureFlags
|
|
168
186
|
}));
|
|
@@ -44,6 +44,8 @@ export type TableSharedStateInternal = Pick<TablePluginState, 'isFullWidthModeEn
|
|
|
44
44
|
dragMenuDirection?: TableDirection;
|
|
45
45
|
dragMenuIndex?: number;
|
|
46
46
|
isDragMenuOpen?: boolean;
|
|
47
|
+
isSizeSelectorOpen?: boolean;
|
|
48
|
+
sizeSelectorTargetRef?: HTMLElement;
|
|
47
49
|
};
|
|
48
50
|
export type TableSharedState = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled'>;
|
|
49
51
|
export type AlignmentOptions = 'center' | 'align-start';
|
|
@@ -11,7 +11,8 @@ export type ContentComponentProps = {
|
|
|
11
11
|
popupsMountPoint?: HTMLElement;
|
|
12
12
|
popupsBoundariesElement?: HTMLElement;
|
|
13
13
|
popupsScrollableElement?: HTMLElement;
|
|
14
|
+
isTableSelectorEnabled: boolean | undefined;
|
|
14
15
|
defaultGetEditorContainerWidth: GetEditorContainerWidth;
|
|
15
16
|
defaultGetEditorFeatureFlags: GetEditorFeatureFlags;
|
|
16
17
|
};
|
|
17
|
-
export declare const ContentComponent: ({ api, editorView, dispatchAnalyticsEvent, options, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, defaultGetEditorContainerWidth, defaultGetEditorFeatureFlags, }: ContentComponentProps) => React.JSX.Element;
|
|
18
|
+
export declare const ContentComponent: ({ api, editorView, dispatchAnalyticsEvent, options, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, isTableSelectorEnabled, defaultGetEditorContainerWidth, defaultGetEditorFeatureFlags, }: ContentComponentProps) => React.JSX.Element;
|
|
@@ -16,5 +16,5 @@ type Options = {
|
|
|
16
16
|
* @param key Key of TableSharedStateInternal to select
|
|
17
17
|
* @returns
|
|
18
18
|
*/
|
|
19
|
-
export declare const useInternalTablePluginStateSelector: <K extends "isFullWidthModeEnabled" | "wasFullWidthModeEnabled" | "isHeaderRowEnabled" | "isHeaderColumnEnabled" | "ordering" | "isInDanger" | "hoveredRows" | "hoveredColumns" | "hoveredCell" | "isTableHovered" | "tableNode" | "widthToWidest" | "tableRef" | "tablePos" | "targetCellPosition" | "isContextualMenuOpen" | "pluginConfig" | "insertColumnButtonIndex" | "insertRowButtonIndex" | "isDragAndDropEnabled" | "tableWrapperTarget" | "isCellMenuOpenByKeyboard" | "isWholeTableInDanger" | "isDragMenuOpen" | "dragMenuDirection" | "dragMenuIndex" | "isResizing" | "isTableResizing" | "resizingTableRef" | "resizingTableLocalId" | "stickyHeader">(api: ExtractInjectionAPI<TablePlugin> | undefined, key: K, options?: Options) => TableSharedStateInternal[K] | undefined;
|
|
19
|
+
export declare const useInternalTablePluginStateSelector: <K extends "isFullWidthModeEnabled" | "wasFullWidthModeEnabled" | "isHeaderRowEnabled" | "isHeaderColumnEnabled" | "ordering" | "isInDanger" | "hoveredRows" | "hoveredColumns" | "hoveredCell" | "isTableHovered" | "tableNode" | "widthToWidest" | "tableRef" | "tablePos" | "targetCellPosition" | "isContextualMenuOpen" | "pluginConfig" | "insertColumnButtonIndex" | "insertRowButtonIndex" | "isDragAndDropEnabled" | "tableWrapperTarget" | "isCellMenuOpenByKeyboard" | "isWholeTableInDanger" | "isDragMenuOpen" | "dragMenuDirection" | "dragMenuIndex" | "isResizing" | "isTableResizing" | "resizingTableRef" | "resizingTableLocalId" | "stickyHeader" | "isSizeSelectorOpen" | "sizeSelectorTargetRef">(api: ExtractInjectionAPI<TablePlugin> | undefined, key: K, options?: Options) => TableSharedStateInternal[K] | undefined;
|
|
20
20
|
export {};
|
|
@@ -44,6 +44,8 @@ export type TableSharedStateInternal = Pick<TablePluginState, 'isFullWidthModeEn
|
|
|
44
44
|
dragMenuDirection?: TableDirection;
|
|
45
45
|
dragMenuIndex?: number;
|
|
46
46
|
isDragMenuOpen?: boolean;
|
|
47
|
+
isSizeSelectorOpen?: boolean;
|
|
48
|
+
sizeSelectorTargetRef?: HTMLElement;
|
|
47
49
|
};
|
|
48
50
|
export type TableSharedState = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled'>;
|
|
49
51
|
export type AlignmentOptions = 'center' | 'align-start';
|
|
@@ -11,7 +11,8 @@ export type ContentComponentProps = {
|
|
|
11
11
|
popupsMountPoint?: HTMLElement;
|
|
12
12
|
popupsBoundariesElement?: HTMLElement;
|
|
13
13
|
popupsScrollableElement?: HTMLElement;
|
|
14
|
+
isTableSelectorEnabled: boolean | undefined;
|
|
14
15
|
defaultGetEditorContainerWidth: GetEditorContainerWidth;
|
|
15
16
|
defaultGetEditorFeatureFlags: GetEditorFeatureFlags;
|
|
16
17
|
};
|
|
17
|
-
export declare const ContentComponent: ({ api, editorView, dispatchAnalyticsEvent, options, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, defaultGetEditorContainerWidth, defaultGetEditorFeatureFlags, }: ContentComponentProps) => React.JSX.Element;
|
|
18
|
+
export declare const ContentComponent: ({ api, editorView, dispatchAnalyticsEvent, options, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, isTableSelectorEnabled, defaultGetEditorContainerWidth, defaultGetEditorFeatureFlags, }: ContentComponentProps) => React.JSX.Element;
|
|
@@ -16,5 +16,5 @@ type Options = {
|
|
|
16
16
|
* @param key Key of TableSharedStateInternal to select
|
|
17
17
|
* @returns
|
|
18
18
|
*/
|
|
19
|
-
export declare const useInternalTablePluginStateSelector: <K extends "isFullWidthModeEnabled" | "wasFullWidthModeEnabled" | "isHeaderRowEnabled" | "isHeaderColumnEnabled" | "ordering" | "isInDanger" | "hoveredRows" | "hoveredColumns" | "hoveredCell" | "isTableHovered" | "tableNode" | "widthToWidest" | "tableRef" | "tablePos" | "targetCellPosition" | "isContextualMenuOpen" | "pluginConfig" | "insertColumnButtonIndex" | "insertRowButtonIndex" | "isDragAndDropEnabled" | "tableWrapperTarget" | "isCellMenuOpenByKeyboard" | "isWholeTableInDanger" | "isDragMenuOpen" | "dragMenuDirection" | "dragMenuIndex" | "isResizing" | "isTableResizing" | "resizingTableRef" | "resizingTableLocalId" | "stickyHeader">(api: ExtractInjectionAPI<TablePlugin> | undefined, key: K, options?: Options) => TableSharedStateInternal[K] | undefined;
|
|
19
|
+
export declare const useInternalTablePluginStateSelector: <K extends "isFullWidthModeEnabled" | "wasFullWidthModeEnabled" | "isHeaderRowEnabled" | "isHeaderColumnEnabled" | "ordering" | "isInDanger" | "hoveredRows" | "hoveredColumns" | "hoveredCell" | "isTableHovered" | "tableNode" | "widthToWidest" | "tableRef" | "tablePos" | "targetCellPosition" | "isContextualMenuOpen" | "pluginConfig" | "insertColumnButtonIndex" | "insertRowButtonIndex" | "isDragAndDropEnabled" | "tableWrapperTarget" | "isCellMenuOpenByKeyboard" | "isWholeTableInDanger" | "isDragMenuOpen" | "dragMenuDirection" | "dragMenuIndex" | "isResizing" | "isTableResizing" | "resizingTableRef" | "resizingTableLocalId" | "stickyHeader" | "isSizeSelectorOpen" | "sizeSelectorTargetRef">(api: ExtractInjectionAPI<TablePlugin> | undefined, key: K, options?: Options) => TableSharedStateInternal[K] | undefined;
|
|
20
20
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "10.9.
|
|
3
|
+
"version": "10.9.22",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -144,9 +144,6 @@
|
|
|
144
144
|
"platform_editor_nested_tables_view_mode_sort": {
|
|
145
145
|
"type": "boolean"
|
|
146
146
|
},
|
|
147
|
-
"platform_editor_nested_tables_bodied_extension_fix": {
|
|
148
|
-
"type": "boolean"
|
|
149
|
-
},
|
|
150
147
|
"platform_editor_nested_table_drag_controls": {
|
|
151
148
|
"type": "boolean"
|
|
152
149
|
},
|
package/src/pm-plugins/main.ts
CHANGED
|
@@ -308,19 +308,11 @@ export const createPlugin = (
|
|
|
308
308
|
|
|
309
309
|
// transformSliceToRemoveOpenTable() transforms based on the depth of the root node, assuming that the tables will be at the root
|
|
310
310
|
// Bodied extensions will contribute to the depth of the table selection so we need to remove them first
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
slice = transformSliceToRemoveOpenTable(slice, schema);
|
|
317
|
-
} else {
|
|
318
|
-
/** If a partial paste of table, paste only table's content */
|
|
319
|
-
slice = transformSliceToRemoveOpenTable(slice, schema);
|
|
320
|
-
|
|
321
|
-
/** If a partial paste of bodied extension, paste only text */
|
|
322
|
-
slice = transformSliceToRemoveOpenBodiedExtension(slice, schema);
|
|
323
|
-
}
|
|
311
|
+
/** If a partial paste of bodied extension, paste only text */
|
|
312
|
+
slice = transformSliceToRemoveOpenBodiedExtension(slice, schema);
|
|
313
|
+
|
|
314
|
+
/** If a partial paste of table, paste only table's content */
|
|
315
|
+
slice = transformSliceToRemoveOpenTable(slice, schema);
|
|
324
316
|
|
|
325
317
|
/** If a partial paste of multi bodied extension, paste only children */
|
|
326
318
|
slice = transformSliceToRemoveOpenMultiBodiedExtension(slice, schema);
|
package/src/tablePlugin.tsx
CHANGED
|
@@ -166,6 +166,7 @@ const tablePlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
166
166
|
: undefined;
|
|
167
167
|
|
|
168
168
|
const dragAndDropState = dragAndDropPluginKey.getState(editorState);
|
|
169
|
+
const sizeSelectorPluginState = sizeSelectorPluginKey.getState(editorState);
|
|
169
170
|
|
|
170
171
|
const sharedStateInternal: TableSharedStateInternal = {
|
|
171
172
|
isFullWidthModeEnabled: !!options?.fullWidthEnabled,
|
|
@@ -203,6 +204,8 @@ const tablePlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
203
204
|
dragMenuDirection: dragAndDropState?.dragMenuDirection,
|
|
204
205
|
dragMenuIndex: dragAndDropState?.dragMenuIndex,
|
|
205
206
|
isDragMenuOpen: dragAndDropState?.isDragMenuOpen,
|
|
207
|
+
isSizeSelectorOpen: sizeSelectorPluginState?.isSelectorOpen,
|
|
208
|
+
sizeSelectorTargetRef: sizeSelectorPluginState?.targetRef,
|
|
206
209
|
};
|
|
207
210
|
|
|
208
211
|
return sharedStateInternal;
|
|
@@ -589,6 +592,7 @@ const tablePlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
589
592
|
popupsScrollableElement={popupsScrollableElement}
|
|
590
593
|
defaultGetEditorContainerWidth={defaultGetEditorContainerWidth}
|
|
591
594
|
defaultGetEditorFeatureFlags={defaultGetEditorFeatureFlags}
|
|
595
|
+
isTableSelectorEnabled={isTableSelectorEnabled}
|
|
592
596
|
/>
|
|
593
597
|
);
|
|
594
598
|
}
|
|
@@ -622,6 +626,8 @@ const tablePlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
622
626
|
dragAndDropState,
|
|
623
627
|
sizeSelectorPluginState,
|
|
624
628
|
}) => {
|
|
629
|
+
// Any changes made inside `<WithPluginState>` need to be reflected in the
|
|
630
|
+
// `<ContentComponent>` as well.
|
|
625
631
|
const isColumnResizing = resizingPluginState?.dragging;
|
|
626
632
|
const isTableResizing = tableWidthPluginState?.resizing;
|
|
627
633
|
const resizingTableLocalId = tableWidthPluginState?.tableLocalId;
|
package/src/types/index.ts
CHANGED
|
@@ -79,6 +79,8 @@ export type TableSharedStateInternal = Pick<
|
|
|
79
79
|
dragMenuDirection?: TableDirection;
|
|
80
80
|
dragMenuIndex?: number;
|
|
81
81
|
isDragMenuOpen?: boolean;
|
|
82
|
+
isSizeSelectorOpen?: boolean;
|
|
83
|
+
sizeSelectorTargetRef?: HTMLElement;
|
|
82
84
|
};
|
|
83
85
|
|
|
84
86
|
export type TableSharedState = Pick<
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
ACTION_SUBJECT,
|
|
5
|
+
ACTION_SUBJECT_ID,
|
|
6
|
+
DispatchAnalyticsEvent,
|
|
7
|
+
} from '@atlaskit/editor-common/analytics';
|
|
4
8
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
9
|
+
import { getDomRefFromSelection } from '@atlaskit/editor-common/get-dom-ref-from-selection';
|
|
10
|
+
import { ResizerBreakoutModeLabel } from '@atlaskit/editor-common/resizer';
|
|
5
11
|
import {
|
|
6
12
|
ExtractInjectionAPI,
|
|
7
13
|
GetEditorContainerWidth,
|
|
@@ -9,6 +15,7 @@ import {
|
|
|
9
15
|
} from '@atlaskit/editor-common/types';
|
|
10
16
|
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
11
17
|
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
18
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
12
19
|
|
|
13
20
|
import { TablePlugin, TablePluginOptions } from '../tablePluginType';
|
|
14
21
|
|
|
@@ -22,6 +29,7 @@ import FloatingInsertButton from './FloatingInsertButton';
|
|
|
22
29
|
import { FloatingToolbarLabel } from './FloatingToolbarLabel/FloatingToolbarLabel';
|
|
23
30
|
import { GlobalStylesWrapper } from './global-styles';
|
|
24
31
|
import { useInternalTablePluginStateSelector } from './hooks/useInternalTablePluginStateSelector';
|
|
32
|
+
import { SizeSelector } from './SizeSelector';
|
|
25
33
|
import { FullWidthDisplay } from './TableFullWidthLabel';
|
|
26
34
|
|
|
27
35
|
export type ContentComponentProps = {
|
|
@@ -32,6 +40,7 @@ export type ContentComponentProps = {
|
|
|
32
40
|
popupsMountPoint?: HTMLElement;
|
|
33
41
|
popupsBoundariesElement?: HTMLElement;
|
|
34
42
|
popupsScrollableElement?: HTMLElement;
|
|
43
|
+
isTableSelectorEnabled: boolean | undefined;
|
|
35
44
|
defaultGetEditorContainerWidth: GetEditorContainerWidth;
|
|
36
45
|
defaultGetEditorFeatureFlags: GetEditorFeatureFlags;
|
|
37
46
|
};
|
|
@@ -44,6 +53,7 @@ const ContentComponentInternal = ({
|
|
|
44
53
|
popupsMountPoint,
|
|
45
54
|
popupsBoundariesElement,
|
|
46
55
|
popupsScrollableElement,
|
|
56
|
+
isTableSelectorEnabled,
|
|
47
57
|
defaultGetEditorContainerWidth,
|
|
48
58
|
defaultGetEditorFeatureFlags,
|
|
49
59
|
}: ContentComponentProps) => {
|
|
@@ -83,6 +93,9 @@ const ContentComponentInternal = ({
|
|
|
83
93
|
const dragMenuIndex = useInternalTablePluginStateSelector(api, 'dragMenuIndex');
|
|
84
94
|
const isDragMenuOpen = useInternalTablePluginStateSelector(api, 'isDragMenuOpen');
|
|
85
95
|
|
|
96
|
+
const isSizeSelectorOpen = useInternalTablePluginStateSelector(api, 'isSizeSelectorOpen');
|
|
97
|
+
const sizeSelectorTargetRef = useInternalTablePluginStateSelector(api, 'sizeSelectorTargetRef');
|
|
98
|
+
|
|
86
99
|
return (
|
|
87
100
|
<>
|
|
88
101
|
{targetCellPosition &&
|
|
@@ -189,7 +202,13 @@ const ContentComponentInternal = ({
|
|
|
189
202
|
widthToWidest[resizingTableLocalId] && (
|
|
190
203
|
<FloatingToolbarLabel
|
|
191
204
|
target={resizingTableRef}
|
|
192
|
-
content={
|
|
205
|
+
content={
|
|
206
|
+
editorExperiment('single_column_layouts', true) ? (
|
|
207
|
+
<ResizerBreakoutModeLabel layout="full-width" />
|
|
208
|
+
) : (
|
|
209
|
+
<FullWidthDisplay />
|
|
210
|
+
)
|
|
211
|
+
}
|
|
193
212
|
alignX={'center'}
|
|
194
213
|
alignY={'bottom'}
|
|
195
214
|
stick={true}
|
|
@@ -198,6 +217,24 @@ const ContentComponentInternal = ({
|
|
|
198
217
|
offset={[0, 10]}
|
|
199
218
|
/>
|
|
200
219
|
)}
|
|
220
|
+
|
|
221
|
+
{isTableSelectorEnabled && isSizeSelectorOpen && (
|
|
222
|
+
<SizeSelector
|
|
223
|
+
api={api}
|
|
224
|
+
isOpenedByKeyboard={false}
|
|
225
|
+
popupsMountPoint={popupsMountPoint}
|
|
226
|
+
target={
|
|
227
|
+
sizeSelectorTargetRef ??
|
|
228
|
+
getDomRefFromSelection(
|
|
229
|
+
editorView,
|
|
230
|
+
ACTION_SUBJECT_ID.PICKER_TABLE_SIZE,
|
|
231
|
+
api?.analytics?.actions,
|
|
232
|
+
)
|
|
233
|
+
}
|
|
234
|
+
popupsBoundariesElement={popupsBoundariesElement}
|
|
235
|
+
popupsScrollableElement={popupsScrollableElement}
|
|
236
|
+
/>
|
|
237
|
+
)}
|
|
201
238
|
</>
|
|
202
239
|
);
|
|
203
240
|
};
|
|
@@ -210,6 +247,7 @@ export const ContentComponent = ({
|
|
|
210
247
|
popupsMountPoint,
|
|
211
248
|
popupsBoundariesElement,
|
|
212
249
|
popupsScrollableElement,
|
|
250
|
+
isTableSelectorEnabled,
|
|
213
251
|
defaultGetEditorContainerWidth,
|
|
214
252
|
defaultGetEditorFeatureFlags,
|
|
215
253
|
}: ContentComponentProps) => {
|
|
@@ -232,6 +270,7 @@ export const ContentComponent = ({
|
|
|
232
270
|
popupsMountPoint={popupsMountPoint}
|
|
233
271
|
popupsBoundariesElement={popupsBoundariesElement}
|
|
234
272
|
popupsScrollableElement={popupsScrollableElement}
|
|
273
|
+
isTableSelectorEnabled={isTableSelectorEnabled}
|
|
235
274
|
defaultGetEditorContainerWidth={defaultGetEditorContainerWidth}
|
|
236
275
|
defaultGetEditorFeatureFlags={defaultGetEditorFeatureFlags}
|
|
237
276
|
/>
|
|
@@ -114,7 +114,7 @@ export const ColumnControls = ({
|
|
|
114
114
|
const hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
|
|
115
115
|
|
|
116
116
|
const rowControlStickyTop = 45;
|
|
117
|
-
const marginTop = hasHeaderRow && stickyTop !== undefined ?
|
|
117
|
+
const marginTop = hasHeaderRow && stickyTop !== undefined ? rowControlStickyTop ?? 0 : 0;
|
|
118
118
|
|
|
119
119
|
const handleClick = useCallback(
|
|
120
120
|
(event: MouseEvent) => {
|