@atlaskit/editor-plugin-block-menu 6.0.41 → 6.0.43
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 +17 -0
- package/dist/cjs/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +18 -2
- package/dist/cjs/editor-commands/transform-node-utils/utils.js +24 -4
- package/dist/cjs/editor-commands/transform-node-utils/wrapStep.js +13 -1
- package/dist/cjs/editor-commands/transformNode.js +40 -0
- package/dist/es2019/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +18 -2
- package/dist/es2019/editor-commands/transform-node-utils/utils.js +20 -2
- package/dist/es2019/editor-commands/transform-node-utils/wrapStep.js +13 -1
- package/dist/es2019/editor-commands/transformNode.js +42 -0
- package/dist/esm/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +18 -2
- package/dist/esm/editor-commands/transform-node-utils/utils.js +23 -4
- package/dist/esm/editor-commands/transform-node-utils/wrapStep.js +13 -1
- package/dist/esm/editor-commands/transformNode.js +40 -0
- package/package.json +10 -4
- package/tsconfig.json +1 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-menu
|
|
2
2
|
|
|
3
|
+
## 6.0.43
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`61ffb7d51ff40`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/61ffb7d51ff40) -
|
|
8
|
+
[ux] Ensure that when a transform to an expand happens, its localId is present so that it remains
|
|
9
|
+
'expanded'
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 6.0.42
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [`f0de8d658199d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f0de8d658199d) -
|
|
17
|
+
[ux] Ensure if table transform occurs, the result remains selected
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 6.0.41
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.wrapMixedContentStep = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
10
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
11
|
var _marks = require("../marks");
|
|
11
12
|
var _types = require("../types");
|
|
12
13
|
var _utils = require("../utils");
|
|
@@ -35,7 +36,15 @@ var createTextContentContainer = function createTextContentContainer(textContent
|
|
|
35
36
|
* Creates a regular container with node content.
|
|
36
37
|
*/
|
|
37
38
|
var createNodeContentContainer = function createNodeContentContainer(nodeContent, targetNodeType) {
|
|
38
|
-
|
|
39
|
+
// [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
|
|
40
|
+
// Pre-assigns a localId so the localId plugin's appendTransaction does not replace the node
|
|
41
|
+
// object, preserving the expandedState WeakMap entry set in transformNode.ts.
|
|
42
|
+
// To clean up: remove the if-else, always use the flag-on branch.
|
|
43
|
+
var isExpandType = targetNodeType.name === 'expand' || targetNodeType.name === 'nestedExpand';
|
|
44
|
+
var nodeAttrs = isExpandType && (0, _platformFeatureFlags.fg)('platform_editor_block_menu_expand_localid_fix') ? {
|
|
45
|
+
localId: crypto.randomUUID()
|
|
46
|
+
} : {};
|
|
47
|
+
return targetNodeType.createAndFill(nodeAttrs, nodeContent);
|
|
39
48
|
};
|
|
40
49
|
|
|
41
50
|
/**
|
|
@@ -70,7 +79,14 @@ var handleEmptyContainerEdgeCase = function handleEmptyContainerEdgeCase(result,
|
|
|
70
79
|
return emptyCodeBlock ? [emptyCodeBlock].concat((0, _toConsumableArray2.default)(result)) : result;
|
|
71
80
|
}
|
|
72
81
|
var emptyParagraph = schema.nodes.paragraph.create();
|
|
73
|
-
|
|
82
|
+
// [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
|
|
83
|
+
// Same localId pre-assignment rationale as createNodeContentContainer above.
|
|
84
|
+
// To clean up: remove the if-else, always use the flag-on branch.
|
|
85
|
+
var isExpandType = targetNodeTypeName === 'expand' || targetNodeTypeName === 'nestedExpand';
|
|
86
|
+
var emptyContainerAttrs = isExpandType && (0, _platformFeatureFlags.fg)('platform_editor_block_menu_expand_localid_fix') ? {
|
|
87
|
+
localId: crypto.randomUUID()
|
|
88
|
+
} : {};
|
|
89
|
+
var emptyContainer = targetNodeType.create(emptyContainerAttrs, emptyParagraph);
|
|
74
90
|
return [emptyContainer].concat((0, _toConsumableArray2.default)(result));
|
|
75
91
|
};
|
|
76
92
|
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.isTextNode = exports.getTargetNodeTypeNameInContext = exports.getSelectedNode = exports.getBlockNodesInRange = exports.createTextContent = exports.convertTextNodeToParagraph = exports.convertNestedExpandToExpand = exports.convertExpandToNestedExpand = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
7
9
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
10
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
9
11
|
var _editorTables = require("@atlaskit/editor-tables");
|
|
12
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
13
|
var _types = require("./types");
|
|
14
|
+
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; }
|
|
15
|
+
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) { (0, _defineProperty2.default)(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; }
|
|
11
16
|
/**
|
|
12
17
|
* Determines if a node is a text node (heading or paragraph).
|
|
13
18
|
* Text nodes can have their content converted to paragraphs when they can't be wrapped directly.
|
|
@@ -79,9 +84,17 @@ var convertNestedExpandToExpand = exports.convertNestedExpandToExpand = function
|
|
|
79
84
|
if (!expandType) {
|
|
80
85
|
return null;
|
|
81
86
|
}
|
|
82
|
-
|
|
87
|
+
|
|
88
|
+
// [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
|
|
89
|
+
// Pre-assigns a localId so the localId plugin's appendTransaction does not replace the node
|
|
90
|
+
// object, preserving the expandedState WeakMap entry set in transformNode.ts.
|
|
91
|
+
// To clean up: remove the if-else, always include localId in attrs.
|
|
92
|
+
var localIdAttr = (0, _platformFeatureFlags.fg)('platform_editor_block_menu_expand_localid_fix') ? {
|
|
93
|
+
localId: crypto.randomUUID()
|
|
94
|
+
} : {};
|
|
95
|
+
return expandType.createAndFill(_objectSpread({
|
|
83
96
|
title: ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.title) || ''
|
|
84
|
-
}, node.content);
|
|
97
|
+
}, localIdAttr), node.content);
|
|
85
98
|
};
|
|
86
99
|
|
|
87
100
|
/**
|
|
@@ -95,9 +108,16 @@ var convertExpandToNestedExpand = exports.convertExpandToNestedExpand = function
|
|
|
95
108
|
if (!nestedExpandType) {
|
|
96
109
|
return null;
|
|
97
110
|
}
|
|
98
|
-
|
|
111
|
+
|
|
112
|
+
// [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
|
|
113
|
+
// Same localId pre-assignment rationale as convertNestedExpandToExpand above.
|
|
114
|
+
// To clean up: remove the if-else, always include localId in attrs.
|
|
115
|
+
var localIdAttr = (0, _platformFeatureFlags.fg)('platform_editor_block_menu_expand_localid_fix') ? {
|
|
116
|
+
localId: crypto.randomUUID()
|
|
117
|
+
} : {};
|
|
118
|
+
return nestedExpandType.createAndFill(_objectSpread({
|
|
99
119
|
title: ((_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.title) || ''
|
|
100
|
-
}, node.content);
|
|
120
|
+
}, localIdAttr), node.content);
|
|
101
121
|
};
|
|
102
122
|
|
|
103
123
|
/**
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.wrapStep = void 0;
|
|
7
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
7
8
|
var _marks = require("./marks");
|
|
8
9
|
var _utils = require("./utils");
|
|
9
10
|
/**
|
|
@@ -27,6 +28,17 @@ var wrapStep = exports.wrapStep = function wrapStep(nodes, context) {
|
|
|
27
28
|
return node;
|
|
28
29
|
});
|
|
29
30
|
}
|
|
30
|
-
var
|
|
31
|
+
var targetNodeType = schema.nodes[targetNodeTypeName];
|
|
32
|
+
|
|
33
|
+
// [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
|
|
34
|
+
// Pre-assigns a localId so the localId plugin's appendTransaction does not replace the node
|
|
35
|
+
// object (via setNodeAttribute), which would invalidate the expandedState WeakMap entry set
|
|
36
|
+
// in transformNode.ts and cause the expand to render as collapsed.
|
|
37
|
+
// To clean up: remove the if-else, always use the flag-on branch (isExpandType with uuid).
|
|
38
|
+
var isExpandType = targetNodeTypeName === 'expand' || targetNodeTypeName === 'nestedExpand';
|
|
39
|
+
var nodeAttrs = isExpandType && (0, _platformFeatureFlags.fg)('platform_editor_block_menu_expand_localid_fix') ? {
|
|
40
|
+
localId: crypto.randomUUID()
|
|
41
|
+
} : {};
|
|
42
|
+
var outputNode = targetNodeType.createAndFill(nodeAttrs, (0, _marks.removeDisallowedMarks)(processedNodes, schema.nodes[targetNodeTypeName]));
|
|
31
43
|
return outputNode ? [outputNode] : nodes;
|
|
32
44
|
};
|
|
@@ -5,10 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.transformNode = void 0;
|
|
7
7
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
|
+
var _expand = require("@atlaskit/editor-common/expand");
|
|
8
9
|
var _performanceMeasures = require("@atlaskit/editor-common/performance-measures");
|
|
9
10
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
10
11
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
12
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
13
|
+
var _editorTables = require("@atlaskit/editor-tables");
|
|
14
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
15
|
var _isNestedNode = require("../ui/utils/isNestedNode");
|
|
13
16
|
var _transform2 = require("./transform-node-utils/transform");
|
|
14
17
|
var _utils = require("./transforms/utils");
|
|
@@ -50,6 +53,23 @@ var transformNode = exports.transformNode = function transformNode(api) {
|
|
|
50
53
|
});
|
|
51
54
|
var content = resultNodes.length > 0 ? resultNodes : sourceNodes;
|
|
52
55
|
var sliceStart = isList ? $from.pos - 1 : $from.pos;
|
|
56
|
+
|
|
57
|
+
// [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
|
|
58
|
+
// Pre-populates the expandedState WeakMap so ExpandNodeView initializes newly created
|
|
59
|
+
// expand/nestedExpand nodes as expanded rather than collapsed. Works in conjunction with
|
|
60
|
+
// the localId pre-assignment in the transform steps — without a pre-assigned localId the
|
|
61
|
+
// localId plugin's appendTransaction replaces the node object (via setNodeAttribute),
|
|
62
|
+
// invalidating this WeakMap entry. The else branch preserves the previous behaviour.
|
|
63
|
+
// To clean up: remove the if-else block and keep only the flag-on body.
|
|
64
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_block_menu_expand_localid_fix')) {
|
|
65
|
+
var expand = nodes.expand,
|
|
66
|
+
nestedExpand = nodes.nestedExpand;
|
|
67
|
+
content.forEach(function (node) {
|
|
68
|
+
if (node.type === expand || node.type === nestedExpand) {
|
|
69
|
+
_expand.expandedState.set(node, true);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
53
73
|
if (preservedSelection instanceof _state.NodeSelection && preservedSelection.node.type === nodes.mediaSingle) {
|
|
54
74
|
var _api$blockControls2;
|
|
55
75
|
// when node is media single, use tr.replaceWith freeze editor, if modify position, tr.replaceWith creates duplicats
|
|
@@ -76,6 +96,26 @@ var transformNode = exports.transformNode = function transformNode(api) {
|
|
|
76
96
|
} else {
|
|
77
97
|
tr.replaceWith(sliceStart, $to.pos, content);
|
|
78
98
|
}
|
|
99
|
+
|
|
100
|
+
// [FEATURE FLAG: platform_editor_table_transform_selection_fix]
|
|
101
|
+
// Fixes table cell selection not being preserved after transform to expand/layout.
|
|
102
|
+
// When a table with CellSelection is transformed, we need to re-select the wrapper node.
|
|
103
|
+
// To clean up: remove the if-else block and keep only the flag-on behavior.
|
|
104
|
+
if (preservedSelection instanceof _editorTables.CellSelection && (0, _platformFeatureFlags.fg)('platform_editor_table_transform_selection_fix')) {
|
|
105
|
+
var insertedNode = tr.doc.nodeAt($from.pos);
|
|
106
|
+
var isSelectable = insertedNode && _state.NodeSelection.isSelectable(insertedNode);
|
|
107
|
+
if (isSelectable) {
|
|
108
|
+
var _api$blockControls3;
|
|
109
|
+
var nodeSelection = _state.NodeSelection.create(tr.doc, $from.pos);
|
|
110
|
+
tr.setSelection(nodeSelection);
|
|
111
|
+
|
|
112
|
+
// Update preserved selection to match the new NodeSelection
|
|
113
|
+
// This prevents appendTransaction from restoring the old table selection positions
|
|
114
|
+
api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 || _api$blockControls3.commands.startPreservingSelection()({
|
|
115
|
+
tr: tr
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
79
119
|
(0, _performanceMeasures.stopMeasure)(measureId, function (duration, startTime) {
|
|
80
120
|
var _api$analytics;
|
|
81
121
|
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || _api$analytics.attachAnalyticsEvent({
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { removeDisallowedMarks } from '../marks';
|
|
3
4
|
import { NODE_CATEGORY_BY_TYPE } from '../types';
|
|
4
5
|
import { convertTextNodeToParagraph, createTextContent, isTextNode } from '../utils';
|
|
@@ -28,7 +29,15 @@ const createTextContentContainer = (textContentArray, targetNodeType, schema) =>
|
|
|
28
29
|
* Creates a regular container with node content.
|
|
29
30
|
*/
|
|
30
31
|
const createNodeContentContainer = (nodeContent, targetNodeType) => {
|
|
31
|
-
|
|
32
|
+
// [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
|
|
33
|
+
// Pre-assigns a localId so the localId plugin's appendTransaction does not replace the node
|
|
34
|
+
// object, preserving the expandedState WeakMap entry set in transformNode.ts.
|
|
35
|
+
// To clean up: remove the if-else, always use the flag-on branch.
|
|
36
|
+
const isExpandType = targetNodeType.name === 'expand' || targetNodeType.name === 'nestedExpand';
|
|
37
|
+
const nodeAttrs = isExpandType && fg('platform_editor_block_menu_expand_localid_fix') ? {
|
|
38
|
+
localId: crypto.randomUUID()
|
|
39
|
+
} : {};
|
|
40
|
+
return targetNodeType.createAndFill(nodeAttrs, nodeContent);
|
|
32
41
|
};
|
|
33
42
|
|
|
34
43
|
/**
|
|
@@ -63,7 +72,14 @@ const handleEmptyContainerEdgeCase = (result, hasCreatedContainer, fromNode, tar
|
|
|
63
72
|
return emptyCodeBlock ? [emptyCodeBlock, ...result] : result;
|
|
64
73
|
}
|
|
65
74
|
const emptyParagraph = schema.nodes.paragraph.create();
|
|
66
|
-
|
|
75
|
+
// [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
|
|
76
|
+
// Same localId pre-assignment rationale as createNodeContentContainer above.
|
|
77
|
+
// To clean up: remove the if-else, always use the flag-on branch.
|
|
78
|
+
const isExpandType = targetNodeTypeName === 'expand' || targetNodeTypeName === 'nestedExpand';
|
|
79
|
+
const emptyContainerAttrs = isExpandType && fg('platform_editor_block_menu_expand_localid_fix') ? {
|
|
80
|
+
localId: crypto.randomUUID()
|
|
81
|
+
} : {};
|
|
82
|
+
const emptyContainer = targetNodeType.create(emptyContainerAttrs, emptyParagraph);
|
|
67
83
|
return [emptyContainer, ...result];
|
|
68
84
|
};
|
|
69
85
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
3
3
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { NODE_CATEGORY_BY_TYPE } from './types';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -75,8 +76,17 @@ export const convertNestedExpandToExpand = (node, schema) => {
|
|
|
75
76
|
if (!expandType) {
|
|
76
77
|
return null;
|
|
77
78
|
}
|
|
79
|
+
|
|
80
|
+
// [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
|
|
81
|
+
// Pre-assigns a localId so the localId plugin's appendTransaction does not replace the node
|
|
82
|
+
// object, preserving the expandedState WeakMap entry set in transformNode.ts.
|
|
83
|
+
// To clean up: remove the if-else, always include localId in attrs.
|
|
84
|
+
const localIdAttr = fg('platform_editor_block_menu_expand_localid_fix') ? {
|
|
85
|
+
localId: crypto.randomUUID()
|
|
86
|
+
} : {};
|
|
78
87
|
return expandType.createAndFill({
|
|
79
|
-
title: ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.title) || ''
|
|
88
|
+
title: ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.title) || '',
|
|
89
|
+
...localIdAttr
|
|
80
90
|
}, node.content);
|
|
81
91
|
};
|
|
82
92
|
|
|
@@ -91,8 +101,16 @@ export const convertExpandToNestedExpand = (node, schema) => {
|
|
|
91
101
|
if (!nestedExpandType) {
|
|
92
102
|
return null;
|
|
93
103
|
}
|
|
104
|
+
|
|
105
|
+
// [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
|
|
106
|
+
// Same localId pre-assignment rationale as convertNestedExpandToExpand above.
|
|
107
|
+
// To clean up: remove the if-else, always include localId in attrs.
|
|
108
|
+
const localIdAttr = fg('platform_editor_block_menu_expand_localid_fix') ? {
|
|
109
|
+
localId: crypto.randomUUID()
|
|
110
|
+
} : {};
|
|
94
111
|
return nestedExpandType.createAndFill({
|
|
95
|
-
title: ((_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.title) || ''
|
|
112
|
+
title: ((_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.title) || '',
|
|
113
|
+
...localIdAttr
|
|
96
114
|
}, node.content);
|
|
97
115
|
};
|
|
98
116
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
1
2
|
import { removeDisallowedMarks } from './marks';
|
|
2
3
|
import { convertExpandToNestedExpand } from './utils';
|
|
3
4
|
|
|
@@ -24,6 +25,17 @@ export const wrapStep = (nodes, context) => {
|
|
|
24
25
|
return node;
|
|
25
26
|
});
|
|
26
27
|
}
|
|
27
|
-
const
|
|
28
|
+
const targetNodeType = schema.nodes[targetNodeTypeName];
|
|
29
|
+
|
|
30
|
+
// [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
|
|
31
|
+
// Pre-assigns a localId so the localId plugin's appendTransaction does not replace the node
|
|
32
|
+
// object (via setNodeAttribute), which would invalidate the expandedState WeakMap entry set
|
|
33
|
+
// in transformNode.ts and cause the expand to render as collapsed.
|
|
34
|
+
// To clean up: remove the if-else, always use the flag-on branch (isExpandType with uuid).
|
|
35
|
+
const isExpandType = targetNodeTypeName === 'expand' || targetNodeTypeName === 'nestedExpand';
|
|
36
|
+
const nodeAttrs = isExpandType && fg('platform_editor_block_menu_expand_localid_fix') ? {
|
|
37
|
+
localId: crypto.randomUUID()
|
|
38
|
+
} : {};
|
|
39
|
+
const outputNode = targetNodeType.createAndFill(nodeAttrs, removeDisallowedMarks(processedNodes, schema.nodes[targetNodeTypeName]));
|
|
28
40
|
return outputNode ? [outputNode] : nodes;
|
|
29
41
|
};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { expandedState } from '@atlaskit/editor-common/expand';
|
|
2
3
|
import { startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
|
|
3
4
|
import { expandSelectionToBlockRange, getSourceNodesFromSelectionRange } from '@atlaskit/editor-common/selection';
|
|
4
5
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
6
|
import { Mapping, StepMap } from '@atlaskit/editor-prosemirror/transform';
|
|
7
|
+
import { CellSelection } from '@atlaskit/editor-tables';
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
9
|
import { isNestedNode } from '../ui/utils/isNestedNode';
|
|
7
10
|
import { convertNodesToTargetType } from './transform-node-utils/transform';
|
|
8
11
|
import { isListNode } from './transforms/utils';
|
|
@@ -46,6 +49,25 @@ export const transformNode = api => (targetType, metadata) => ({
|
|
|
46
49
|
});
|
|
47
50
|
const content = resultNodes.length > 0 ? resultNodes : sourceNodes;
|
|
48
51
|
const sliceStart = isList ? $from.pos - 1 : $from.pos;
|
|
52
|
+
|
|
53
|
+
// [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
|
|
54
|
+
// Pre-populates the expandedState WeakMap so ExpandNodeView initializes newly created
|
|
55
|
+
// expand/nestedExpand nodes as expanded rather than collapsed. Works in conjunction with
|
|
56
|
+
// the localId pre-assignment in the transform steps — without a pre-assigned localId the
|
|
57
|
+
// localId plugin's appendTransaction replaces the node object (via setNodeAttribute),
|
|
58
|
+
// invalidating this WeakMap entry. The else branch preserves the previous behaviour.
|
|
59
|
+
// To clean up: remove the if-else block and keep only the flag-on body.
|
|
60
|
+
if (fg('platform_editor_block_menu_expand_localid_fix')) {
|
|
61
|
+
const {
|
|
62
|
+
expand,
|
|
63
|
+
nestedExpand
|
|
64
|
+
} = nodes;
|
|
65
|
+
content.forEach(node => {
|
|
66
|
+
if (node.type === expand || node.type === nestedExpand) {
|
|
67
|
+
expandedState.set(node, true);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
49
71
|
if (preservedSelection instanceof NodeSelection && preservedSelection.node.type === nodes.mediaSingle) {
|
|
50
72
|
var _api$blockControls2;
|
|
51
73
|
// when node is media single, use tr.replaceWith freeze editor, if modify position, tr.replaceWith creates duplicats
|
|
@@ -68,6 +90,26 @@ export const transformNode = api => (targetType, metadata) => ({
|
|
|
68
90
|
} else {
|
|
69
91
|
tr.replaceWith(sliceStart, $to.pos, content);
|
|
70
92
|
}
|
|
93
|
+
|
|
94
|
+
// [FEATURE FLAG: platform_editor_table_transform_selection_fix]
|
|
95
|
+
// Fixes table cell selection not being preserved after transform to expand/layout.
|
|
96
|
+
// When a table with CellSelection is transformed, we need to re-select the wrapper node.
|
|
97
|
+
// To clean up: remove the if-else block and keep only the flag-on behavior.
|
|
98
|
+
if (preservedSelection instanceof CellSelection && fg('platform_editor_table_transform_selection_fix')) {
|
|
99
|
+
const insertedNode = tr.doc.nodeAt($from.pos);
|
|
100
|
+
const isSelectable = insertedNode && NodeSelection.isSelectable(insertedNode);
|
|
101
|
+
if (isSelectable) {
|
|
102
|
+
var _api$blockControls3;
|
|
103
|
+
const nodeSelection = NodeSelection.create(tr.doc, $from.pos);
|
|
104
|
+
tr.setSelection(nodeSelection);
|
|
105
|
+
|
|
106
|
+
// Update preserved selection to match the new NodeSelection
|
|
107
|
+
// This prevents appendTransaction from restoring the old table selection positions
|
|
108
|
+
api === null || api === void 0 ? void 0 : (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.startPreservingSelection()({
|
|
109
|
+
tr
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
71
113
|
stopMeasure(measureId, (duration, startTime) => {
|
|
72
114
|
var _api$analytics, _api$analytics$action;
|
|
73
115
|
api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : (_api$analytics$action = _api$analytics.actions) === null || _api$analytics$action === void 0 ? void 0 : _api$analytics$action.attachAnalyticsEvent({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
import { removeDisallowedMarks } from '../marks';
|
|
4
5
|
import { NODE_CATEGORY_BY_TYPE } from '../types';
|
|
5
6
|
import { convertTextNodeToParagraph, createTextContent, isTextNode } from '../utils';
|
|
@@ -29,7 +30,15 @@ var createTextContentContainer = function createTextContentContainer(textContent
|
|
|
29
30
|
* Creates a regular container with node content.
|
|
30
31
|
*/
|
|
31
32
|
var createNodeContentContainer = function createNodeContentContainer(nodeContent, targetNodeType) {
|
|
32
|
-
|
|
33
|
+
// [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
|
|
34
|
+
// Pre-assigns a localId so the localId plugin's appendTransaction does not replace the node
|
|
35
|
+
// object, preserving the expandedState WeakMap entry set in transformNode.ts.
|
|
36
|
+
// To clean up: remove the if-else, always use the flag-on branch.
|
|
37
|
+
var isExpandType = targetNodeType.name === 'expand' || targetNodeType.name === 'nestedExpand';
|
|
38
|
+
var nodeAttrs = isExpandType && fg('platform_editor_block_menu_expand_localid_fix') ? {
|
|
39
|
+
localId: crypto.randomUUID()
|
|
40
|
+
} : {};
|
|
41
|
+
return targetNodeType.createAndFill(nodeAttrs, nodeContent);
|
|
33
42
|
};
|
|
34
43
|
|
|
35
44
|
/**
|
|
@@ -64,7 +73,14 @@ var handleEmptyContainerEdgeCase = function handleEmptyContainerEdgeCase(result,
|
|
|
64
73
|
return emptyCodeBlock ? [emptyCodeBlock].concat(_toConsumableArray(result)) : result;
|
|
65
74
|
}
|
|
66
75
|
var emptyParagraph = schema.nodes.paragraph.create();
|
|
67
|
-
|
|
76
|
+
// [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
|
|
77
|
+
// Same localId pre-assignment rationale as createNodeContentContainer above.
|
|
78
|
+
// To clean up: remove the if-else, always use the flag-on branch.
|
|
79
|
+
var isExpandType = targetNodeTypeName === 'expand' || targetNodeTypeName === 'nestedExpand';
|
|
80
|
+
var emptyContainerAttrs = isExpandType && fg('platform_editor_block_menu_expand_localid_fix') ? {
|
|
81
|
+
localId: crypto.randomUUID()
|
|
82
|
+
} : {};
|
|
83
|
+
var emptyContainer = targetNodeType.create(emptyContainerAttrs, emptyParagraph);
|
|
68
84
|
return [emptyContainer].concat(_toConsumableArray(result));
|
|
69
85
|
};
|
|
70
86
|
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
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
|
+
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; }
|
|
1
4
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
5
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
3
6
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
8
|
import { NODE_CATEGORY_BY_TYPE } from './types';
|
|
5
9
|
|
|
6
10
|
/**
|
|
@@ -74,9 +78,17 @@ export var convertNestedExpandToExpand = function convertNestedExpandToExpand(no
|
|
|
74
78
|
if (!expandType) {
|
|
75
79
|
return null;
|
|
76
80
|
}
|
|
77
|
-
|
|
81
|
+
|
|
82
|
+
// [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
|
|
83
|
+
// Pre-assigns a localId so the localId plugin's appendTransaction does not replace the node
|
|
84
|
+
// object, preserving the expandedState WeakMap entry set in transformNode.ts.
|
|
85
|
+
// To clean up: remove the if-else, always include localId in attrs.
|
|
86
|
+
var localIdAttr = fg('platform_editor_block_menu_expand_localid_fix') ? {
|
|
87
|
+
localId: crypto.randomUUID()
|
|
88
|
+
} : {};
|
|
89
|
+
return expandType.createAndFill(_objectSpread({
|
|
78
90
|
title: ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.title) || ''
|
|
79
|
-
}, node.content);
|
|
91
|
+
}, localIdAttr), node.content);
|
|
80
92
|
};
|
|
81
93
|
|
|
82
94
|
/**
|
|
@@ -90,9 +102,16 @@ export var convertExpandToNestedExpand = function convertExpandToNestedExpand(no
|
|
|
90
102
|
if (!nestedExpandType) {
|
|
91
103
|
return null;
|
|
92
104
|
}
|
|
93
|
-
|
|
105
|
+
|
|
106
|
+
// [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
|
|
107
|
+
// Same localId pre-assignment rationale as convertNestedExpandToExpand above.
|
|
108
|
+
// To clean up: remove the if-else, always include localId in attrs.
|
|
109
|
+
var localIdAttr = fg('platform_editor_block_menu_expand_localid_fix') ? {
|
|
110
|
+
localId: crypto.randomUUID()
|
|
111
|
+
} : {};
|
|
112
|
+
return nestedExpandType.createAndFill(_objectSpread({
|
|
94
113
|
title: ((_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.title) || ''
|
|
95
|
-
}, node.content);
|
|
114
|
+
}, localIdAttr), node.content);
|
|
96
115
|
};
|
|
97
116
|
|
|
98
117
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
1
2
|
import { removeDisallowedMarks } from './marks';
|
|
2
3
|
import { convertExpandToNestedExpand } from './utils';
|
|
3
4
|
|
|
@@ -22,6 +23,17 @@ export var wrapStep = function wrapStep(nodes, context) {
|
|
|
22
23
|
return node;
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
|
-
var
|
|
26
|
+
var targetNodeType = schema.nodes[targetNodeTypeName];
|
|
27
|
+
|
|
28
|
+
// [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
|
|
29
|
+
// Pre-assigns a localId so the localId plugin's appendTransaction does not replace the node
|
|
30
|
+
// object (via setNodeAttribute), which would invalidate the expandedState WeakMap entry set
|
|
31
|
+
// in transformNode.ts and cause the expand to render as collapsed.
|
|
32
|
+
// To clean up: remove the if-else, always use the flag-on branch (isExpandType with uuid).
|
|
33
|
+
var isExpandType = targetNodeTypeName === 'expand' || targetNodeTypeName === 'nestedExpand';
|
|
34
|
+
var nodeAttrs = isExpandType && fg('platform_editor_block_menu_expand_localid_fix') ? {
|
|
35
|
+
localId: crypto.randomUUID()
|
|
36
|
+
} : {};
|
|
37
|
+
var outputNode = targetNodeType.createAndFill(nodeAttrs, removeDisallowedMarks(processedNodes, schema.nodes[targetNodeTypeName]));
|
|
26
38
|
return outputNode ? [outputNode] : nodes;
|
|
27
39
|
};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { expandedState } from '@atlaskit/editor-common/expand';
|
|
2
3
|
import { startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
|
|
3
4
|
import { expandSelectionToBlockRange, getSourceNodesFromSelectionRange } from '@atlaskit/editor-common/selection';
|
|
4
5
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
6
|
import { Mapping, StepMap } from '@atlaskit/editor-prosemirror/transform';
|
|
7
|
+
import { CellSelection } from '@atlaskit/editor-tables';
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
9
|
import { isNestedNode } from '../ui/utils/isNestedNode';
|
|
7
10
|
import { convertNodesToTargetType } from './transform-node-utils/transform';
|
|
8
11
|
import { isListNode } from './transforms/utils';
|
|
@@ -44,6 +47,23 @@ export var transformNode = function transformNode(api) {
|
|
|
44
47
|
});
|
|
45
48
|
var content = resultNodes.length > 0 ? resultNodes : sourceNodes;
|
|
46
49
|
var sliceStart = isList ? $from.pos - 1 : $from.pos;
|
|
50
|
+
|
|
51
|
+
// [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
|
|
52
|
+
// Pre-populates the expandedState WeakMap so ExpandNodeView initializes newly created
|
|
53
|
+
// expand/nestedExpand nodes as expanded rather than collapsed. Works in conjunction with
|
|
54
|
+
// the localId pre-assignment in the transform steps — without a pre-assigned localId the
|
|
55
|
+
// localId plugin's appendTransaction replaces the node object (via setNodeAttribute),
|
|
56
|
+
// invalidating this WeakMap entry. The else branch preserves the previous behaviour.
|
|
57
|
+
// To clean up: remove the if-else block and keep only the flag-on body.
|
|
58
|
+
if (fg('platform_editor_block_menu_expand_localid_fix')) {
|
|
59
|
+
var expand = nodes.expand,
|
|
60
|
+
nestedExpand = nodes.nestedExpand;
|
|
61
|
+
content.forEach(function (node) {
|
|
62
|
+
if (node.type === expand || node.type === nestedExpand) {
|
|
63
|
+
expandedState.set(node, true);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
47
67
|
if (preservedSelection instanceof NodeSelection && preservedSelection.node.type === nodes.mediaSingle) {
|
|
48
68
|
var _api$blockControls2;
|
|
49
69
|
// when node is media single, use tr.replaceWith freeze editor, if modify position, tr.replaceWith creates duplicats
|
|
@@ -70,6 +90,26 @@ export var transformNode = function transformNode(api) {
|
|
|
70
90
|
} else {
|
|
71
91
|
tr.replaceWith(sliceStart, $to.pos, content);
|
|
72
92
|
}
|
|
93
|
+
|
|
94
|
+
// [FEATURE FLAG: platform_editor_table_transform_selection_fix]
|
|
95
|
+
// Fixes table cell selection not being preserved after transform to expand/layout.
|
|
96
|
+
// When a table with CellSelection is transformed, we need to re-select the wrapper node.
|
|
97
|
+
// To clean up: remove the if-else block and keep only the flag-on behavior.
|
|
98
|
+
if (preservedSelection instanceof CellSelection && fg('platform_editor_table_transform_selection_fix')) {
|
|
99
|
+
var insertedNode = tr.doc.nodeAt($from.pos);
|
|
100
|
+
var isSelectable = insertedNode && NodeSelection.isSelectable(insertedNode);
|
|
101
|
+
if (isSelectable) {
|
|
102
|
+
var _api$blockControls3;
|
|
103
|
+
var nodeSelection = NodeSelection.create(tr.doc, $from.pos);
|
|
104
|
+
tr.setSelection(nodeSelection);
|
|
105
|
+
|
|
106
|
+
// Update preserved selection to match the new NodeSelection
|
|
107
|
+
// This prevents appendTransaction from restoring the old table selection positions
|
|
108
|
+
api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 || _api$blockControls3.commands.startPreservingSelection()({
|
|
109
|
+
tr: tr
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
73
113
|
stopMeasure(measureId, function (duration, startTime) {
|
|
74
114
|
var _api$analytics;
|
|
75
115
|
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || _api$analytics.attachAnalyticsEvent({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-menu",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.43",
|
|
4
4
|
"description": "BlockMenu plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@atlaskit/css": "^0.19.0",
|
|
33
33
|
"@atlaskit/dropdown-menu": "^16.4.0",
|
|
34
34
|
"@atlaskit/editor-plugin-analytics": "^7.0.0",
|
|
35
|
-
"@atlaskit/editor-plugin-block-controls": "^8.
|
|
35
|
+
"@atlaskit/editor-plugin-block-controls": "^8.4.0",
|
|
36
36
|
"@atlaskit/editor-plugin-decorations": "^7.0.0",
|
|
37
37
|
"@atlaskit/editor-plugin-selection": "^7.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-user-intent": "^5.0.0",
|
|
@@ -46,13 +46,13 @@
|
|
|
46
46
|
"@atlaskit/platform-feature-flags-react": "^0.4.0",
|
|
47
47
|
"@atlaskit/primitives": "^18.0.0",
|
|
48
48
|
"@atlaskit/prosemirror-history": "^0.2.0",
|
|
49
|
-
"@atlaskit/tmp-editor-statsig": "^25.
|
|
49
|
+
"@atlaskit/tmp-editor-statsig": "^25.6.0",
|
|
50
50
|
"@atlaskit/tokens": "^11.0.0",
|
|
51
51
|
"@babel/runtime": "^7.0.0",
|
|
52
52
|
"bind-event-listener": "^3.0.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@atlaskit/editor-common": "^111.
|
|
55
|
+
"@atlaskit/editor-common": "^111.15.0",
|
|
56
56
|
"react": "^18.2.0",
|
|
57
57
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
58
58
|
},
|
|
@@ -96,8 +96,14 @@
|
|
|
96
96
|
"platform_editor_adf_with_localid": {
|
|
97
97
|
"type": "boolean"
|
|
98
98
|
},
|
|
99
|
+
"platform_editor_block_menu_expand_localid_fix": {
|
|
100
|
+
"type": "boolean"
|
|
101
|
+
},
|
|
99
102
|
"platform_editor_block_menu_v2_patch_2": {
|
|
100
103
|
"type": "boolean"
|
|
104
|
+
},
|
|
105
|
+
"platform_editor_table_transform_selection_fix": {
|
|
106
|
+
"type": "boolean"
|
|
101
107
|
}
|
|
102
108
|
}
|
|
103
109
|
}
|
package/tsconfig.json
CHANGED