@atlaskit/editor-plugin-block-menu 6.0.0 → 6.0.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 +16 -0
- package/dist/cjs/editor-commands/transform-node-utils/marks.js +12 -12
- package/dist/cjs/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +6 -3
- package/dist/cjs/editor-commands/transform-node-utils/wrapIntoLayoutStep.js +1 -1
- package/dist/cjs/editor-commands/transform-node-utils/wrapStep.js +1 -1
- package/dist/cjs/editor-commands/transformNode.js +35 -0
- package/dist/es2019/editor-commands/transform-node-utils/marks.js +9 -7
- package/dist/es2019/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +5 -3
- package/dist/es2019/editor-commands/transform-node-utils/wrapIntoLayoutStep.js +2 -2
- package/dist/es2019/editor-commands/transform-node-utils/wrapStep.js +2 -2
- package/dist/es2019/editor-commands/transformNode.js +35 -0
- package/dist/esm/editor-commands/transform-node-utils/marks.js +11 -11
- package/dist/esm/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +6 -3
- package/dist/esm/editor-commands/transform-node-utils/wrapIntoLayoutStep.js +2 -2
- package/dist/esm/editor-commands/transform-node-utils/wrapStep.js +2 -2
- package/dist/esm/editor-commands/transformNode.js +35 -0
- package/dist/types/editor-commands/transform-node-utils/marks.d.ts +9 -2
- package/dist/types-ts4.5/editor-commands/transform-node-utils/marks.d.ts +9 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-menu
|
|
2
2
|
|
|
3
|
+
## 6.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`7b54da3c92435`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7b54da3c92435) -
|
|
8
|
+
EDITOR-3993 Add analytics measure timings for transformNode function with operational events
|
|
9
|
+
tracking duration, node count, and source/target node types
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 6.0.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [`3ae29083b2189`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3ae29083b2189) -
|
|
17
|
+
Remove block marks when wrapping nodes (fixes multi-select codeblock)
|
|
18
|
+
|
|
3
19
|
## 6.0.0
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
exports.removeDisallowedMarks = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Removes all disallowed marks from a node based on the target node type.
|
|
9
|
+
*
|
|
10
|
+
* @param node - The node to remove marks from.
|
|
11
|
+
* @param targetNode - The target node type to check against.
|
|
12
|
+
* @returns The nodes with the marks removed.
|
|
13
|
+
*/
|
|
14
|
+
var removeDisallowedMarks = exports.removeDisallowedMarks = function removeDisallowedMarks(nodes, targetNode) {
|
|
15
|
+
return nodes.map(function (node) {
|
|
16
|
+
return node.mark(targetNode.allowedMarks(node.marks));
|
|
17
|
+
});
|
|
18
18
|
};
|
|
@@ -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 _marks = require("../marks");
|
|
10
11
|
var _types = require("../types");
|
|
11
12
|
var _utils = require("../utils");
|
|
12
13
|
/**
|
|
@@ -19,7 +20,7 @@ var isTextNode = function isTextNode(node) {
|
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
|
-
* Determines if a node can be wrapped in the target container type.
|
|
23
|
+
* Determines if a node can be wrapped in the target container type, removes block marks from the node during check.
|
|
23
24
|
* Uses the schema's validContent to check if the target container can hold this node.
|
|
24
25
|
*
|
|
25
26
|
* Note: What can be wrapped depends on the target container type - for example:
|
|
@@ -33,7 +34,7 @@ var canWrapInTarget = function canWrapInTarget(node, targetNodeType, targetNodeT
|
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
// Use the schema to determine if this node can be contained in the target
|
|
36
|
-
return targetNodeType.validContent(_model.Fragment.from(node));
|
|
37
|
+
return targetNodeType.validContent(_model.Fragment.from((0, _marks.removeDisallowedMarks)([node], targetNodeType)));
|
|
37
38
|
};
|
|
38
39
|
|
|
39
40
|
/**
|
|
@@ -110,8 +111,10 @@ var wrapMixedContentStep = exports.wrapMixedContentStep = function wrapMixedCont
|
|
|
110
111
|
};
|
|
111
112
|
nodes.forEach(function (node) {
|
|
112
113
|
if (canWrapInTarget(node, targetNodeType, targetNodeTypeName)) {
|
|
114
|
+
var _currentContainerCont;
|
|
113
115
|
// Node can be wrapped - add to current container content
|
|
114
|
-
|
|
116
|
+
// remove marks from node as nested nodes don't usually support block marks
|
|
117
|
+
(_currentContainerCont = currentContainerContent).push.apply(_currentContainerCont, (0, _toConsumableArray2.default)((0, _marks.removeDisallowedMarks)([node], targetNodeType)));
|
|
115
118
|
} else if (node.type.name === targetNodeTypeName) {
|
|
116
119
|
// Same-type container - breaks out as a separate container (preserved as-is)
|
|
117
120
|
// This handles: "If there's a panel in the expand, it breaks out into a separate panel"
|
|
@@ -10,7 +10,7 @@ var wrapIntoLayoutStep = exports.wrapIntoLayoutStep = function wrapIntoLayoutSte
|
|
|
10
10
|
var _ref = schema.nodes || {},
|
|
11
11
|
layoutSection = _ref.layoutSection,
|
|
12
12
|
layoutColumn = _ref.layoutColumn;
|
|
13
|
-
var columnOne = layoutColumn.createAndFill({}, (0, _marks.
|
|
13
|
+
var columnOne = layoutColumn.createAndFill({}, (0, _marks.removeDisallowedMarks)(nodes, layoutColumn));
|
|
14
14
|
var columnTwo = layoutColumn.createAndFill();
|
|
15
15
|
if (!columnOne || !columnTwo) {
|
|
16
16
|
return nodes;
|
|
@@ -27,6 +27,6 @@ var wrapStep = exports.wrapStep = function wrapStep(nodes, context) {
|
|
|
27
27
|
return node;
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
var outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, (0, _marks.
|
|
30
|
+
var outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, (0, _marks.removeDisallowedMarks)(processedNodes, schema.nodes[targetNodeTypeName]));
|
|
31
31
|
return outputNode ? [outputNode] : nodes;
|
|
32
32
|
};
|
|
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.transformNode = void 0;
|
|
7
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
|
+
var _performanceMeasures = require("@atlaskit/editor-common/performance-measures");
|
|
7
9
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
8
10
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
11
|
var _isNestedNode = require("../ui/utils/isNestedNode");
|
|
@@ -20,6 +22,10 @@ var transformNode = exports.transformNode = function transformNode(api) {
|
|
|
20
22
|
if (!preservedSelection) {
|
|
21
23
|
return tr;
|
|
22
24
|
}
|
|
25
|
+
|
|
26
|
+
// Start performance measurement
|
|
27
|
+
var measureId = "transformNode_".concat(targetType.name, "_").concat(Date.now());
|
|
28
|
+
(0, _performanceMeasures.startMeasure)(measureId);
|
|
23
29
|
var schema = tr.doc.type.schema;
|
|
24
30
|
var nodes = schema.nodes;
|
|
25
31
|
var _expandSelectionToBlo = (0, _selection.expandSelectionToBlockRange)(preservedSelection),
|
|
@@ -30,6 +36,15 @@ var transformNode = exports.transformNode = function transformNode(api) {
|
|
|
30
36
|
var isNestedExceptLayout = (0, _isNestedNode.isNestedNode)(preservedSelection, '') && !isParentLayout;
|
|
31
37
|
var isList = (0, _utils.isListNode)(selectedParent);
|
|
32
38
|
var slice = tr.doc.slice(isList ? $from.pos - 1 : $from.pos, isList ? $to.pos + 1 : $to.pos);
|
|
39
|
+
|
|
40
|
+
// Collect source node information for analytics before transformation
|
|
41
|
+
var nodeCount = 0;
|
|
42
|
+
var sourceNodeTypes = {};
|
|
43
|
+
slice.content.forEach(function (node) {
|
|
44
|
+
nodeCount++;
|
|
45
|
+
var nodeTypeName = node.type.name;
|
|
46
|
+
sourceNodeTypes[nodeTypeName] = (sourceNodeTypes[nodeTypeName] || 0) + 1;
|
|
47
|
+
});
|
|
33
48
|
var transformedNodes = (0, _tranformContent.tranformContent)(slice.content, targetType, schema, isNestedExceptLayout, metadata === null || metadata === void 0 ? void 0 : metadata.targetAttrs);
|
|
34
49
|
var nodesToDeleteAndInsert = [nodes.mediaSingle];
|
|
35
50
|
if (preservedSelection instanceof _state.NodeSelection && nodesToDeleteAndInsert.includes(preservedSelection.node.type)) {
|
|
@@ -39,6 +54,26 @@ var transformNode = exports.transformNode = function transformNode(api) {
|
|
|
39
54
|
} else {
|
|
40
55
|
tr.replaceWith(isList ? $from.pos - 1 : $from.pos, $to.pos, transformedNodes);
|
|
41
56
|
}
|
|
57
|
+
|
|
58
|
+
// Stop performance measurement and fire analytics
|
|
59
|
+
(0, _performanceMeasures.stopMeasure)(measureId, function (duration, startTime) {
|
|
60
|
+
var _api$analytics;
|
|
61
|
+
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.fireAnalyticsEvent({
|
|
62
|
+
action: _analytics.ACTION.TRANSFORMED,
|
|
63
|
+
actionSubject: _analytics.ACTION_SUBJECT.ELEMENT,
|
|
64
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.TRANSFORM,
|
|
65
|
+
attributes: {
|
|
66
|
+
duration: duration,
|
|
67
|
+
isList: isList,
|
|
68
|
+
isNested: isNestedExceptLayout,
|
|
69
|
+
nodeCount: nodeCount,
|
|
70
|
+
sourceNodeTypes: sourceNodeTypes,
|
|
71
|
+
startTime: startTime,
|
|
72
|
+
targetNodeType: targetType.name
|
|
73
|
+
},
|
|
74
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
75
|
+
});
|
|
76
|
+
});
|
|
42
77
|
return tr;
|
|
43
78
|
};
|
|
44
79
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Removes all disallowed marks from a node based on the target node type.
|
|
3
|
+
*
|
|
4
|
+
* @param node - The node to remove marks from.
|
|
5
|
+
* @param targetNode - The target node type to check against.
|
|
6
|
+
* @returns The nodes with the marks removed.
|
|
7
|
+
*/
|
|
8
|
+
export const removeDisallowedMarks = (nodes, targetNode) => {
|
|
9
|
+
return nodes.map(node => node.mark(targetNode.allowedMarks(node.marks)));
|
|
8
10
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import { removeDisallowedMarks } from '../marks';
|
|
2
3
|
import { NODE_CATEGORY_BY_TYPE } from '../types';
|
|
3
4
|
import { convertTextNodeToParagraph } from '../utils';
|
|
4
5
|
|
|
@@ -12,7 +13,7 @@ const isTextNode = node => {
|
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
|
-
* Determines if a node can be wrapped in the target container type.
|
|
16
|
+
* Determines if a node can be wrapped in the target container type, removes block marks from the node during check.
|
|
16
17
|
* Uses the schema's validContent to check if the target container can hold this node.
|
|
17
18
|
*
|
|
18
19
|
* Note: What can be wrapped depends on the target container type - for example:
|
|
@@ -26,7 +27,7 @@ const canWrapInTarget = (node, targetNodeType, targetNodeTypeName) => {
|
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
// Use the schema to determine if this node can be contained in the target
|
|
29
|
-
return targetNodeType.validContent(Fragment.from(node));
|
|
30
|
+
return targetNodeType.validContent(Fragment.from(removeDisallowedMarks([node], targetNodeType)));
|
|
30
31
|
};
|
|
31
32
|
|
|
32
33
|
/**
|
|
@@ -106,7 +107,8 @@ export const wrapMixedContentStep = (nodes, context) => {
|
|
|
106
107
|
nodes.forEach(node => {
|
|
107
108
|
if (canWrapInTarget(node, targetNodeType, targetNodeTypeName)) {
|
|
108
109
|
// Node can be wrapped - add to current container content
|
|
109
|
-
|
|
110
|
+
// remove marks from node as nested nodes don't usually support block marks
|
|
111
|
+
currentContainerContent.push(...removeDisallowedMarks([node], targetNodeType));
|
|
110
112
|
} else if (node.type.name === targetNodeTypeName) {
|
|
111
113
|
// Same-type container - breaks out as a separate container (preserved as-is)
|
|
112
114
|
// This handles: "If there's a panel in the expand, it breaks out into a separate panel"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { removeDisallowedMarks } from './marks';
|
|
2
2
|
export const wrapIntoLayoutStep = (nodes, context) => {
|
|
3
3
|
const {
|
|
4
4
|
schema
|
|
@@ -7,7 +7,7 @@ export const wrapIntoLayoutStep = (nodes, context) => {
|
|
|
7
7
|
layoutSection,
|
|
8
8
|
layoutColumn
|
|
9
9
|
} = schema.nodes || {};
|
|
10
|
-
const columnOne = layoutColumn.createAndFill({},
|
|
10
|
+
const columnOne = layoutColumn.createAndFill({}, removeDisallowedMarks(nodes, layoutColumn));
|
|
11
11
|
const columnTwo = layoutColumn.createAndFill();
|
|
12
12
|
if (!columnOne || !columnTwo) {
|
|
13
13
|
return nodes;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { removeDisallowedMarks } from './marks';
|
|
2
2
|
import { convertExpandToNestedExpand } from './utils';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -24,6 +24,6 @@ export const wrapStep = (nodes, context) => {
|
|
|
24
24
|
return node;
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
const outputNode = schema.nodes[targetNodeTypeName].createAndFill({},
|
|
27
|
+
const outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, removeDisallowedMarks(processedNodes, schema.nodes[targetNodeTypeName]));
|
|
28
28
|
return outputNode ? [outputNode] : nodes;
|
|
29
29
|
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
|
|
1
3
|
import { expandSelectionToBlockRange } from '@atlaskit/editor-common/selection';
|
|
2
4
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
5
|
import { isNestedNode } from '../ui/utils/isNestedNode';
|
|
@@ -14,6 +16,10 @@ export const transformNode = api =>
|
|
|
14
16
|
if (!preservedSelection) {
|
|
15
17
|
return tr;
|
|
16
18
|
}
|
|
19
|
+
|
|
20
|
+
// Start performance measurement
|
|
21
|
+
const measureId = `transformNode_${targetType.name}_${Date.now()}`;
|
|
22
|
+
startMeasure(measureId);
|
|
17
23
|
const schema = tr.doc.type.schema;
|
|
18
24
|
const {
|
|
19
25
|
nodes
|
|
@@ -27,6 +33,15 @@ export const transformNode = api =>
|
|
|
27
33
|
const isNestedExceptLayout = isNestedNode(preservedSelection, '') && !isParentLayout;
|
|
28
34
|
const isList = isListNode(selectedParent);
|
|
29
35
|
const slice = tr.doc.slice(isList ? $from.pos - 1 : $from.pos, isList ? $to.pos + 1 : $to.pos);
|
|
36
|
+
|
|
37
|
+
// Collect source node information for analytics before transformation
|
|
38
|
+
let nodeCount = 0;
|
|
39
|
+
const sourceNodeTypes = {};
|
|
40
|
+
slice.content.forEach(node => {
|
|
41
|
+
nodeCount++;
|
|
42
|
+
const nodeTypeName = node.type.name;
|
|
43
|
+
sourceNodeTypes[nodeTypeName] = (sourceNodeTypes[nodeTypeName] || 0) + 1;
|
|
44
|
+
});
|
|
30
45
|
const transformedNodes = tranformContent(slice.content, targetType, schema, isNestedExceptLayout, metadata === null || metadata === void 0 ? void 0 : metadata.targetAttrs);
|
|
31
46
|
const nodesToDeleteAndInsert = [nodes.mediaSingle];
|
|
32
47
|
if (preservedSelection instanceof NodeSelection && nodesToDeleteAndInsert.includes(preservedSelection.node.type)) {
|
|
@@ -36,6 +51,26 @@ export const transformNode = api =>
|
|
|
36
51
|
} else {
|
|
37
52
|
tr.replaceWith(isList ? $from.pos - 1 : $from.pos, $to.pos, transformedNodes);
|
|
38
53
|
}
|
|
54
|
+
|
|
55
|
+
// Stop performance measurement and fire analytics
|
|
56
|
+
stopMeasure(measureId, (duration, startTime) => {
|
|
57
|
+
var _api$analytics, _api$analytics$action;
|
|
58
|
+
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.fireAnalyticsEvent({
|
|
59
|
+
action: ACTION.TRANSFORMED,
|
|
60
|
+
actionSubject: ACTION_SUBJECT.ELEMENT,
|
|
61
|
+
actionSubjectId: ACTION_SUBJECT_ID.TRANSFORM,
|
|
62
|
+
attributes: {
|
|
63
|
+
duration,
|
|
64
|
+
isList,
|
|
65
|
+
isNested: isNestedExceptLayout,
|
|
66
|
+
nodeCount,
|
|
67
|
+
sourceNodeTypes,
|
|
68
|
+
startTime,
|
|
69
|
+
targetNodeType: targetType.name
|
|
70
|
+
},
|
|
71
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
72
|
+
});
|
|
73
|
+
});
|
|
39
74
|
return tr;
|
|
40
75
|
};
|
|
41
76
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Removes all disallowed marks from a node based on the target node type.
|
|
3
|
+
*
|
|
4
|
+
* @param node - The node to remove marks from.
|
|
5
|
+
* @param targetNode - The target node type to check against.
|
|
6
|
+
* @returns The nodes with the marks removed.
|
|
7
|
+
*/
|
|
8
|
+
export var removeDisallowedMarks = function removeDisallowedMarks(nodes, targetNode) {
|
|
9
|
+
return nodes.map(function (node) {
|
|
10
|
+
return node.mark(targetNode.allowedMarks(node.marks));
|
|
11
|
+
});
|
|
12
12
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
import { removeDisallowedMarks } from '../marks';
|
|
3
4
|
import { NODE_CATEGORY_BY_TYPE } from '../types';
|
|
4
5
|
import { convertTextNodeToParagraph } from '../utils';
|
|
5
6
|
|
|
@@ -13,7 +14,7 @@ var isTextNode = function isTextNode(node) {
|
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
|
-
* Determines if a node can be wrapped in the target container type.
|
|
17
|
+
* Determines if a node can be wrapped in the target container type, removes block marks from the node during check.
|
|
17
18
|
* Uses the schema's validContent to check if the target container can hold this node.
|
|
18
19
|
*
|
|
19
20
|
* Note: What can be wrapped depends on the target container type - for example:
|
|
@@ -27,7 +28,7 @@ var canWrapInTarget = function canWrapInTarget(node, targetNodeType, targetNodeT
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
// Use the schema to determine if this node can be contained in the target
|
|
30
|
-
return targetNodeType.validContent(Fragment.from(node));
|
|
31
|
+
return targetNodeType.validContent(Fragment.from(removeDisallowedMarks([node], targetNodeType)));
|
|
31
32
|
};
|
|
32
33
|
|
|
33
34
|
/**
|
|
@@ -104,8 +105,10 @@ export var wrapMixedContentStep = function wrapMixedContentStep(nodes, context)
|
|
|
104
105
|
};
|
|
105
106
|
nodes.forEach(function (node) {
|
|
106
107
|
if (canWrapInTarget(node, targetNodeType, targetNodeTypeName)) {
|
|
108
|
+
var _currentContainerCont;
|
|
107
109
|
// Node can be wrapped - add to current container content
|
|
108
|
-
|
|
110
|
+
// remove marks from node as nested nodes don't usually support block marks
|
|
111
|
+
(_currentContainerCont = currentContainerContent).push.apply(_currentContainerCont, _toConsumableArray(removeDisallowedMarks([node], targetNodeType)));
|
|
109
112
|
} else if (node.type.name === targetNodeTypeName) {
|
|
110
113
|
// Same-type container - breaks out as a separate container (preserved as-is)
|
|
111
114
|
// This handles: "If there's a panel in the expand, it breaks out into a separate panel"
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { removeDisallowedMarks } from './marks';
|
|
2
2
|
export var wrapIntoLayoutStep = function wrapIntoLayoutStep(nodes, context) {
|
|
3
3
|
var schema = context.schema;
|
|
4
4
|
var _ref = schema.nodes || {},
|
|
5
5
|
layoutSection = _ref.layoutSection,
|
|
6
6
|
layoutColumn = _ref.layoutColumn;
|
|
7
|
-
var columnOne = layoutColumn.createAndFill({},
|
|
7
|
+
var columnOne = layoutColumn.createAndFill({}, removeDisallowedMarks(nodes, layoutColumn));
|
|
8
8
|
var columnTwo = layoutColumn.createAndFill();
|
|
9
9
|
if (!columnOne || !columnTwo) {
|
|
10
10
|
return nodes;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { removeDisallowedMarks } from './marks';
|
|
2
2
|
import { convertExpandToNestedExpand } from './utils';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -22,6 +22,6 @@ export var wrapStep = function wrapStep(nodes, context) {
|
|
|
22
22
|
return node;
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
var outputNode = schema.nodes[targetNodeTypeName].createAndFill({},
|
|
25
|
+
var outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, removeDisallowedMarks(processedNodes, schema.nodes[targetNodeTypeName]));
|
|
26
26
|
return outputNode ? [outputNode] : nodes;
|
|
27
27
|
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
|
|
1
3
|
import { expandSelectionToBlockRange } from '@atlaskit/editor-common/selection';
|
|
2
4
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
5
|
import { isNestedNode } from '../ui/utils/isNestedNode';
|
|
@@ -14,6 +16,10 @@ export var transformNode = function transformNode(api) {
|
|
|
14
16
|
if (!preservedSelection) {
|
|
15
17
|
return tr;
|
|
16
18
|
}
|
|
19
|
+
|
|
20
|
+
// Start performance measurement
|
|
21
|
+
var measureId = "transformNode_".concat(targetType.name, "_").concat(Date.now());
|
|
22
|
+
startMeasure(measureId);
|
|
17
23
|
var schema = tr.doc.type.schema;
|
|
18
24
|
var nodes = schema.nodes;
|
|
19
25
|
var _expandSelectionToBlo = expandSelectionToBlockRange(preservedSelection),
|
|
@@ -24,6 +30,15 @@ export var transformNode = function transformNode(api) {
|
|
|
24
30
|
var isNestedExceptLayout = isNestedNode(preservedSelection, '') && !isParentLayout;
|
|
25
31
|
var isList = isListNode(selectedParent);
|
|
26
32
|
var slice = tr.doc.slice(isList ? $from.pos - 1 : $from.pos, isList ? $to.pos + 1 : $to.pos);
|
|
33
|
+
|
|
34
|
+
// Collect source node information for analytics before transformation
|
|
35
|
+
var nodeCount = 0;
|
|
36
|
+
var sourceNodeTypes = {};
|
|
37
|
+
slice.content.forEach(function (node) {
|
|
38
|
+
nodeCount++;
|
|
39
|
+
var nodeTypeName = node.type.name;
|
|
40
|
+
sourceNodeTypes[nodeTypeName] = (sourceNodeTypes[nodeTypeName] || 0) + 1;
|
|
41
|
+
});
|
|
27
42
|
var transformedNodes = tranformContent(slice.content, targetType, schema, isNestedExceptLayout, metadata === null || metadata === void 0 ? void 0 : metadata.targetAttrs);
|
|
28
43
|
var nodesToDeleteAndInsert = [nodes.mediaSingle];
|
|
29
44
|
if (preservedSelection instanceof NodeSelection && nodesToDeleteAndInsert.includes(preservedSelection.node.type)) {
|
|
@@ -33,6 +48,26 @@ export var transformNode = function transformNode(api) {
|
|
|
33
48
|
} else {
|
|
34
49
|
tr.replaceWith(isList ? $from.pos - 1 : $from.pos, $to.pos, transformedNodes);
|
|
35
50
|
}
|
|
51
|
+
|
|
52
|
+
// Stop performance measurement and fire analytics
|
|
53
|
+
stopMeasure(measureId, function (duration, startTime) {
|
|
54
|
+
var _api$analytics;
|
|
55
|
+
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.fireAnalyticsEvent({
|
|
56
|
+
action: ACTION.TRANSFORMED,
|
|
57
|
+
actionSubject: ACTION_SUBJECT.ELEMENT,
|
|
58
|
+
actionSubjectId: ACTION_SUBJECT_ID.TRANSFORM,
|
|
59
|
+
attributes: {
|
|
60
|
+
duration: duration,
|
|
61
|
+
isList: isList,
|
|
62
|
+
isNested: isNestedExceptLayout,
|
|
63
|
+
nodeCount: nodeCount,
|
|
64
|
+
sourceNodeTypes: sourceNodeTypes,
|
|
65
|
+
startTime: startTime,
|
|
66
|
+
targetNodeType: targetType.name
|
|
67
|
+
},
|
|
68
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
69
|
+
});
|
|
70
|
+
});
|
|
36
71
|
return tr;
|
|
37
72
|
};
|
|
38
73
|
}
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
import type { Node as PMNode
|
|
2
|
-
|
|
1
|
+
import type { NodeType, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
/**
|
|
3
|
+
* Removes all disallowed marks from a node based on the target node type.
|
|
4
|
+
*
|
|
5
|
+
* @param node - The node to remove marks from.
|
|
6
|
+
* @param targetNode - The target node type to check against.
|
|
7
|
+
* @returns The nodes with the marks removed.
|
|
8
|
+
*/
|
|
9
|
+
export declare const removeDisallowedMarks: (nodes: PMNode[], targetNode: NodeType) => PMNode[];
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
import type { Node as PMNode
|
|
2
|
-
|
|
1
|
+
import type { NodeType, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
/**
|
|
3
|
+
* Removes all disallowed marks from a node based on the target node type.
|
|
4
|
+
*
|
|
5
|
+
* @param node - The node to remove marks from.
|
|
6
|
+
* @param targetNode - The target node type to check against.
|
|
7
|
+
* @returns The nodes with the marks removed.
|
|
8
|
+
*/
|
|
9
|
+
export declare const removeDisallowedMarks: (nodes: PMNode[], targetNode: NodeType) => PMNode[];
|