@atlaskit/editor-plugin-table 10.9.0 → 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 +23 -0
- package/dist/cjs/nodeviews/table.js +9 -14
- package/dist/cjs/ui/toolbar.js +7 -3
- package/dist/es2019/nodeviews/table.js +9 -14
- package/dist/es2019/ui/toolbar.js +7 -3
- package/dist/esm/nodeviews/table.js +9 -14
- package/dist/esm/ui/toolbar.js +7 -3
- package/package.json +6 -3
- package/src/nodeviews/table.tsx +15 -16
- package/src/ui/toolbar.tsx +12 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
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
|
+
|
|
3
26
|
## 10.9.0
|
|
4
27
|
|
|
5
28
|
### Minor 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/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
|
}
|
|
@@ -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.
|
|
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
|
|
188
|
-
if (selectionBookmark && mutationsIgnored
|
|
189
|
-
|
|
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
|
}
|
package/dist/esm/ui/toolbar.js
CHANGED
|
@@ -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
|
|
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
|
});
|
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.2",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"@atlaskit/adf-schema": "^47.6.0",
|
|
33
33
|
"@atlaskit/button": "^23.0.0",
|
|
34
34
|
"@atlaskit/custom-steps": "^0.11.0",
|
|
35
|
-
"@atlaskit/editor-common": "^103.
|
|
35
|
+
"@atlaskit/editor-common": "^103.15.0",
|
|
36
36
|
"@atlaskit/editor-palette": "^2.1.0",
|
|
37
37
|
"@atlaskit/editor-plugin-accessibility-utils": "^2.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-analytics": "^2.2.0",
|
|
39
39
|
"@atlaskit/editor-plugin-batch-attribute-updates": "^2.1.0",
|
|
40
40
|
"@atlaskit/editor-plugin-content-insertion": "^2.1.0",
|
|
41
41
|
"@atlaskit/editor-plugin-editor-viewmode": "^3.1.0",
|
|
42
|
-
"@atlaskit/editor-plugin-extension": "5.2.
|
|
42
|
+
"@atlaskit/editor-plugin-extension": "5.2.6",
|
|
43
43
|
"@atlaskit/editor-plugin-guideline": "^2.0.0",
|
|
44
44
|
"@atlaskit/editor-plugin-selection": "^2.1.0",
|
|
45
45
|
"@atlaskit/editor-plugin-width": "^3.0.0",
|
|
@@ -203,6 +203,9 @@
|
|
|
203
203
|
},
|
|
204
204
|
"platform_editor_controls_table_picker": {
|
|
205
205
|
"type": "boolean"
|
|
206
|
+
},
|
|
207
|
+
"platform_editor_controls_patch_6": {
|
|
208
|
+
"type": "boolean"
|
|
206
209
|
}
|
|
207
210
|
}
|
|
208
211
|
}
|
package/src/nodeviews/table.tsx
CHANGED
|
@@ -15,7 +15,11 @@ import type {
|
|
|
15
15
|
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
16
16
|
import type { DOMOutputSpec, Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
17
17
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
18
|
-
import
|
|
18
|
+
import {
|
|
19
|
+
type EditorState,
|
|
20
|
+
type PluginKey,
|
|
21
|
+
type SelectionBookmark,
|
|
22
|
+
} from '@atlaskit/editor-prosemirror/state';
|
|
19
23
|
import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
20
24
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
21
25
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
@@ -177,7 +181,6 @@ export default class TableView extends ReactNodeView<Props> {
|
|
|
177
181
|
let oldIgnoreMutation: (mutation: MutationRecord) => boolean;
|
|
178
182
|
|
|
179
183
|
let selectionBookmark: SelectionBookmark;
|
|
180
|
-
let parentOffset = 0;
|
|
181
184
|
let mutationsIgnored = false;
|
|
182
185
|
|
|
183
186
|
// Only proceed if we have both a node and table, and the table isn't already inside the node
|
|
@@ -188,8 +191,8 @@ export default class TableView extends ReactNodeView<Props> {
|
|
|
188
191
|
// Set up a temporary mutation handler that:
|
|
189
192
|
// - Ignores all DOM mutations except selection changes
|
|
190
193
|
// - Tracks when mutations have been ignored via mutationsIgnored flag
|
|
191
|
-
this.ignoreMutation = (m: MutationRecord) => {
|
|
192
|
-
const isSelectionMutation = m.
|
|
194
|
+
this.ignoreMutation = (m: MutationRecord | { type: string; target: Node }) => {
|
|
195
|
+
const isSelectionMutation = m.type === 'selection';
|
|
193
196
|
if (!isSelectionMutation) {
|
|
194
197
|
mutationsIgnored = true;
|
|
195
198
|
}
|
|
@@ -202,14 +205,8 @@ export default class TableView extends ReactNodeView<Props> {
|
|
|
202
205
|
selectionBookmark = this.view.state.selection.getBookmark();
|
|
203
206
|
}
|
|
204
207
|
|
|
205
|
-
// Store the current cursor position within the parent node
|
|
206
|
-
// Used to determine if we need to restore selection later
|
|
207
|
-
if (this.view.state.selection?.ranges.length > 0) {
|
|
208
|
-
parentOffset = this.view.state.selection?.ranges[0].$from?.parentOffset ?? 0;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
208
|
// Remove the ProseMirror table DOM structure to avoid duplication, as it's replaced with the React table node.
|
|
212
|
-
if (this.renderedDOM) {
|
|
209
|
+
if (this.dom && this.renderedDOM) {
|
|
213
210
|
this.dom.removeChild(this.renderedDOM);
|
|
214
211
|
}
|
|
215
212
|
// Move the table from the ProseMirror table structure into the React rendered table node.
|
|
@@ -223,11 +220,13 @@ export default class TableView extends ReactNodeView<Props> {
|
|
|
223
220
|
// Restore the selection only if:
|
|
224
221
|
// - We have a selection bookmark
|
|
225
222
|
// - Mutations were ignored during the table move
|
|
226
|
-
// - The
|
|
227
|
-
if (selectionBookmark && mutationsIgnored
|
|
228
|
-
this.view.
|
|
229
|
-
|
|
230
|
-
)
|
|
223
|
+
// - The bookmarked selection is different from the current selection.
|
|
224
|
+
if (selectionBookmark && mutationsIgnored) {
|
|
225
|
+
const resolvedSelection = selectionBookmark.resolve(this.view.state.tr.doc);
|
|
226
|
+
// Don't set the selection if it's the same as the current selection.
|
|
227
|
+
if (!resolvedSelection.eq(this.view.state.selection)) {
|
|
228
|
+
this.view.dispatch(this.view.state.tr.setSelection(resolvedSelection));
|
|
229
|
+
}
|
|
231
230
|
}
|
|
232
231
|
});
|
|
233
232
|
}
|
package/src/ui/toolbar.tsx
CHANGED
|
@@ -672,6 +672,10 @@ export const getToolbarConfig =
|
|
|
672
672
|
onBlur: clearHoverSelection(),
|
|
673
673
|
});
|
|
674
674
|
|
|
675
|
+
const shouldGroupWithoutSeparators =
|
|
676
|
+
editorExperiment('platform_editor_controls', 'variant1') &&
|
|
677
|
+
fg('platform_editor_controls_patch_6');
|
|
678
|
+
|
|
675
679
|
return {
|
|
676
680
|
title: toolbarTitle,
|
|
677
681
|
getDomRef,
|
|
@@ -681,9 +685,9 @@ export const getToolbarConfig =
|
|
|
681
685
|
zIndex: akEditorFloatingPanelZIndex + 1, // Place the context menu slightly above the others
|
|
682
686
|
items: [
|
|
683
687
|
menu,
|
|
684
|
-
separator(menu.hidden),
|
|
688
|
+
...(!shouldGroupWithoutSeparators ? [separator(menu.hidden)] : []),
|
|
685
689
|
...alignmentMenu,
|
|
686
|
-
separator(alignmentMenu.length === 0),
|
|
690
|
+
...(!shouldGroupWithoutSeparators ? [separator(alignmentMenu.length === 0)] : []),
|
|
687
691
|
...cellItems,
|
|
688
692
|
...columnSettingsItems,
|
|
689
693
|
...colorPicker,
|
|
@@ -698,6 +702,7 @@ export const getToolbarConfig =
|
|
|
698
702
|
deleteButton,
|
|
699
703
|
] as Array<FloatingToolbarItem<Command>>)
|
|
700
704
|
: [
|
|
705
|
+
shouldGroupWithoutSeparators && { type: 'separator', fullHeight: true },
|
|
701
706
|
{
|
|
702
707
|
type: 'overflow-dropdown',
|
|
703
708
|
dropdownWidth: 220,
|
|
@@ -900,7 +905,11 @@ const getColumnSettingItems = (
|
|
|
900
905
|
});
|
|
901
906
|
}
|
|
902
907
|
|
|
903
|
-
if (
|
|
908
|
+
if (
|
|
909
|
+
items.length !== 0 &&
|
|
910
|
+
(!editorExperiment('platform_editor_controls', 'variant1') ||
|
|
911
|
+
!fg('platform_editor_controls_patch_6'))
|
|
912
|
+
) {
|
|
904
913
|
items.push({
|
|
905
914
|
type: 'separator',
|
|
906
915
|
});
|