@atlaskit/editor-plugin-block-controls 2.18.0 → 2.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 2.18.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#100915](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/100915)
|
|
8
|
+
[`8c10232e0f242`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8c10232e0f242) -
|
|
9
|
+
ED-24615 Fixed expand not remembering expand state when a node is moved into it
|
|
10
|
+
|
|
3
11
|
## 2.18.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.moveNodeViaShortcut = exports.moveNode = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
|
+
var _expand = require("@atlaskit/editor-common/expand");
|
|
10
11
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
11
12
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
12
13
|
var _transforms = require("@atlaskit/editor-common/transforms");
|
|
@@ -171,13 +172,16 @@ var moveNode = exports.moveNode = function moveNode(api) {
|
|
|
171
172
|
if (!node) {
|
|
172
173
|
return tr;
|
|
173
174
|
}
|
|
175
|
+
var _tr$doc$type$schema$n = tr.doc.type.schema.nodes,
|
|
176
|
+
expand = _tr$doc$type$schema$n.expand,
|
|
177
|
+
nestedExpand = _tr$doc$type$schema$n.nestedExpand;
|
|
174
178
|
var size = (_node$nodeSize = node === null || node === void 0 ? void 0 : node.nodeSize) !== null && _node$nodeSize !== void 0 ? _node$nodeSize : 1;
|
|
175
179
|
var end = start + size;
|
|
176
180
|
var $from = tr.doc.resolve(start);
|
|
181
|
+
var $to = tr.doc.resolve(to);
|
|
177
182
|
var mappedTo;
|
|
178
183
|
if ((0, _experiments.editorExperiment)('nested-dnd', true)) {
|
|
179
184
|
var nodeCopy = tr.doc.slice(start, end, false); // cut the content
|
|
180
|
-
var $to = tr.doc.resolve(to);
|
|
181
185
|
var destType = $to.node().type;
|
|
182
186
|
var destParent = $to.node($to.depth);
|
|
183
187
|
var sourceNode = $from.nodeAfter;
|
|
@@ -221,6 +225,14 @@ var moveNode = exports.moveNode = function moveNode(api) {
|
|
|
221
225
|
});
|
|
222
226
|
api === null || api === void 0 || api.core.actions.focus();
|
|
223
227
|
var $mappedTo = tr.doc.resolve(mappedTo);
|
|
228
|
+
var expandAncestor = (0, _utils2.findParentNodeOfTypeClosestToPos)($to, [expand, nestedExpand]);
|
|
229
|
+
if (expandAncestor && (0, _experiments.editorExperiment)('nested-dnd', true) && (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_6')) {
|
|
230
|
+
var wasExpandExpanded = _expand.expandedState.get(expandAncestor.node);
|
|
231
|
+
var updatedExpandAncestor = (0, _utils2.findParentNodeOfTypeClosestToPos)($mappedTo, [expand, nestedExpand]);
|
|
232
|
+
if (wasExpandExpanded !== undefined && updatedExpandAncestor) {
|
|
233
|
+
_expand.expandedState.set(updatedExpandAncestor.node, wasExpandExpanded);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
224
236
|
if ((0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
225
237
|
(0, _fireAnalytics.attachMoveNodeAnalytics)(tr, inputMethod, resolvedNode.depth, node.type.name, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name, $from.sameParent($mappedTo), api);
|
|
226
238
|
} else {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { expandedState } from '@atlaskit/editor-common/expand';
|
|
2
3
|
import { blockControlsMessages } from '@atlaskit/editor-common/messages';
|
|
3
4
|
import { GapCursorSelection } from '@atlaskit/editor-common/selection';
|
|
4
5
|
import { transformSliceNestedExpandToExpand } from '@atlaskit/editor-common/transforms';
|
|
5
6
|
import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
6
7
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
7
8
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
-
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
9
|
+
import { findParentNodeOfType, findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
9
10
|
import { findTable, isInTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
10
11
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
12
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
@@ -165,13 +166,17 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
|
|
|
165
166
|
if (!node) {
|
|
166
167
|
return tr;
|
|
167
168
|
}
|
|
169
|
+
const {
|
|
170
|
+
expand,
|
|
171
|
+
nestedExpand
|
|
172
|
+
} = tr.doc.type.schema.nodes;
|
|
168
173
|
const size = (_node$nodeSize = node === null || node === void 0 ? void 0 : node.nodeSize) !== null && _node$nodeSize !== void 0 ? _node$nodeSize : 1;
|
|
169
174
|
const end = start + size;
|
|
170
175
|
const $from = tr.doc.resolve(start);
|
|
176
|
+
const $to = tr.doc.resolve(to);
|
|
171
177
|
let mappedTo;
|
|
172
178
|
if (editorExperiment('nested-dnd', true)) {
|
|
173
179
|
const nodeCopy = tr.doc.slice(start, end, false); // cut the content
|
|
174
|
-
const $to = tr.doc.resolve(to);
|
|
175
180
|
const destType = $to.node().type;
|
|
176
181
|
const destParent = $to.node($to.depth);
|
|
177
182
|
const sourceNode = $from.nodeAfter;
|
|
@@ -215,6 +220,14 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
|
|
|
215
220
|
});
|
|
216
221
|
api === null || api === void 0 ? void 0 : api.core.actions.focus();
|
|
217
222
|
const $mappedTo = tr.doc.resolve(mappedTo);
|
|
223
|
+
const expandAncestor = findParentNodeOfTypeClosestToPos($to, [expand, nestedExpand]);
|
|
224
|
+
if (expandAncestor && editorExperiment('nested-dnd', true) && fg('platform_editor_element_dnd_nested_fix_patch_6')) {
|
|
225
|
+
const wasExpandExpanded = expandedState.get(expandAncestor.node);
|
|
226
|
+
const updatedExpandAncestor = findParentNodeOfTypeClosestToPos($mappedTo, [expand, nestedExpand]);
|
|
227
|
+
if (wasExpandExpanded !== undefined && updatedExpandAncestor) {
|
|
228
|
+
expandedState.set(updatedExpandAncestor.node, wasExpandExpanded);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
218
231
|
if (editorExperiment('advanced_layouts', true)) {
|
|
219
232
|
attachMoveNodeAnalytics(tr, inputMethod, resolvedNode.depth, node.type.name, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name, $from.sameParent($mappedTo), api);
|
|
220
233
|
} else {
|
|
@@ -2,13 +2,14 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
|
+
import { expandedState } from '@atlaskit/editor-common/expand';
|
|
5
6
|
import { blockControlsMessages } from '@atlaskit/editor-common/messages';
|
|
6
7
|
import { GapCursorSelection } from '@atlaskit/editor-common/selection';
|
|
7
8
|
import { transformSliceNestedExpandToExpand } from '@atlaskit/editor-common/transforms';
|
|
8
9
|
import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
9
10
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
10
11
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
11
|
-
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
12
|
+
import { findParentNodeOfType, findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
12
13
|
import { findTable, isInTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
13
14
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
14
15
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
@@ -165,13 +166,16 @@ export var moveNode = function moveNode(api) {
|
|
|
165
166
|
if (!node) {
|
|
166
167
|
return tr;
|
|
167
168
|
}
|
|
169
|
+
var _tr$doc$type$schema$n = tr.doc.type.schema.nodes,
|
|
170
|
+
expand = _tr$doc$type$schema$n.expand,
|
|
171
|
+
nestedExpand = _tr$doc$type$schema$n.nestedExpand;
|
|
168
172
|
var size = (_node$nodeSize = node === null || node === void 0 ? void 0 : node.nodeSize) !== null && _node$nodeSize !== void 0 ? _node$nodeSize : 1;
|
|
169
173
|
var end = start + size;
|
|
170
174
|
var $from = tr.doc.resolve(start);
|
|
175
|
+
var $to = tr.doc.resolve(to);
|
|
171
176
|
var mappedTo;
|
|
172
177
|
if (editorExperiment('nested-dnd', true)) {
|
|
173
178
|
var nodeCopy = tr.doc.slice(start, end, false); // cut the content
|
|
174
|
-
var $to = tr.doc.resolve(to);
|
|
175
179
|
var destType = $to.node().type;
|
|
176
180
|
var destParent = $to.node($to.depth);
|
|
177
181
|
var sourceNode = $from.nodeAfter;
|
|
@@ -215,6 +219,14 @@ export var moveNode = function moveNode(api) {
|
|
|
215
219
|
});
|
|
216
220
|
api === null || api === void 0 || api.core.actions.focus();
|
|
217
221
|
var $mappedTo = tr.doc.resolve(mappedTo);
|
|
222
|
+
var expandAncestor = findParentNodeOfTypeClosestToPos($to, [expand, nestedExpand]);
|
|
223
|
+
if (expandAncestor && editorExperiment('nested-dnd', true) && fg('platform_editor_element_dnd_nested_fix_patch_6')) {
|
|
224
|
+
var wasExpandExpanded = expandedState.get(expandAncestor.node);
|
|
225
|
+
var updatedExpandAncestor = findParentNodeOfTypeClosestToPos($mappedTo, [expand, nestedExpand]);
|
|
226
|
+
if (wasExpandExpanded !== undefined && updatedExpandAncestor) {
|
|
227
|
+
expandedState.set(updatedExpandAncestor.node, wasExpandExpanded);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
218
230
|
if (editorExperiment('advanced_layouts', true)) {
|
|
219
231
|
attachMoveNodeAnalytics(tr, inputMethod, resolvedNode.depth, node.type.name, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name, $from.sameParent($mappedTo), api);
|
|
220
232
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "2.18.
|
|
3
|
+
"version": "2.18.1",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -124,6 +124,9 @@
|
|
|
124
124
|
"platform_editor_element_dnd_nested_fix_patch_3": {
|
|
125
125
|
"type": "boolean"
|
|
126
126
|
},
|
|
127
|
+
"platform_editor_element_dnd_nested_fix_patch_6": {
|
|
128
|
+
"type": "boolean"
|
|
129
|
+
},
|
|
127
130
|
"platform_editor_element_dnd_nested_a11y": {
|
|
128
131
|
"type": "boolean"
|
|
129
132
|
},
|