@atlaskit/editor-plugin-block-menu 6.0.2 → 6.0.4
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-actions/isTransformToTargetDisabled.js +3 -3
- package/dist/cjs/editor-commands/transform-node-utils/tranformContent.js +3 -2
- package/dist/cjs/editor-commands/transform-node-utils/transform.js +5 -2
- package/dist/cjs/editor-commands/transform-node-utils/utils.js +4 -1
- package/dist/cjs/editor-commands/transformNode.js +3 -4
- package/dist/es2019/editor-actions/isTransformToTargetDisabled.js +3 -3
- package/dist/es2019/editor-commands/transform-node-utils/tranformContent.js +3 -2
- package/dist/es2019/editor-commands/transform-node-utils/transform.js +5 -2
- package/dist/es2019/editor-commands/transform-node-utils/utils.js +4 -1
- package/dist/es2019/editor-commands/transformNode.js +3 -4
- package/dist/esm/editor-actions/isTransformToTargetDisabled.js +3 -3
- package/dist/esm/editor-commands/transform-node-utils/tranformContent.js +3 -2
- package/dist/esm/editor-commands/transform-node-utils/transform.js +5 -2
- package/dist/esm/editor-commands/transform-node-utils/utils.js +4 -1
- package/dist/esm/editor-commands/transformNode.js +3 -4
- package/dist/types/editor-commands/transform-node-utils/tranformContent.d.ts +2 -2
- package/dist/types/editor-commands/transform-node-utils/transform.d.ts +2 -1
- package/dist/types/editor-commands/transform-node-utils/utils.d.ts +1 -1
- package/dist/types-ts4.5/editor-commands/transform-node-utils/tranformContent.d.ts +2 -2
- package/dist/types-ts4.5/editor-commands/transform-node-utils/transform.d.ts +2 -1
- package/dist/types-ts4.5/editor-commands/transform-node-utils/utils.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-menu
|
|
2
2
|
|
|
3
|
+
## 6.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`9d63742a083b1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9d63742a083b1) -
|
|
8
|
+
Fixes analytics and updates getTargeNodeTypeNameInContext to be used for transforms and contextual
|
|
9
|
+
options.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 6.0.3
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [`c94a46ce70f89`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c94a46ce70f89) -
|
|
17
|
+
[ux] File can't be transformed to bullet or ordered list. Disable those options in the 'Turn into'
|
|
18
|
+
menu.
|
|
19
|
+
|
|
3
20
|
## 6.0.2
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -10,7 +10,7 @@ var _transform = require("../editor-commands/transform-node-utils/transform");
|
|
|
10
10
|
var _types = require("../editor-commands/transform-node-utils/types");
|
|
11
11
|
var _utils = require("../editor-commands/transform-node-utils/utils");
|
|
12
12
|
var canParentContainNodeType = exports.canParentContainNodeType = function canParentContainNodeType(schema, selectedNodeTypeName, parentNode, nodeTypeName, nodeTypeAttrs) {
|
|
13
|
-
var adjustedNodeTypeName =
|
|
13
|
+
var adjustedNodeTypeName = (0, _utils.getTargetNodeTypeNameInContext)(nodeTypeName, true, parentNode);
|
|
14
14
|
if (!adjustedNodeTypeName) {
|
|
15
15
|
return false;
|
|
16
16
|
}
|
|
@@ -18,8 +18,8 @@ var canParentContainNodeType = exports.canParentContainNodeType = function canPa
|
|
|
18
18
|
var content = null;
|
|
19
19
|
var nodesThatCantBeNestedInNestedExpand = ['blockCard', 'embedCard', 'table'];
|
|
20
20
|
if (nodesThatCantBeNestedInNestedExpand.includes(selectedNodeTypeName) && (adjustedNodeTypeName === 'expand' || adjustedNodeTypeName === 'nestedExpand')) {
|
|
21
|
-
var
|
|
22
|
-
content =
|
|
21
|
+
var node = schema.nodes[selectedNodeTypeName];
|
|
22
|
+
content = node.createAndFill();
|
|
23
23
|
}
|
|
24
24
|
return parentNode.type.validContent(_model.Fragment.from(nodeType.createAndFill(nodeTypeAttrs, content)));
|
|
25
25
|
};
|
|
@@ -6,13 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.tranformContent = void 0;
|
|
7
7
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
8
8
|
var _transform = require("./transform");
|
|
9
|
-
var tranformContent = exports.tranformContent = function tranformContent(content, targetNodeType, schema, isNested, targetAttrs) {
|
|
9
|
+
var tranformContent = exports.tranformContent = function tranformContent(content, targetNodeType, schema, isNested, targetAttrs, parent) {
|
|
10
10
|
var outputNodes = (0, _transform.getOutputNodes)({
|
|
11
11
|
sourceNodes: Array.from(content.content),
|
|
12
12
|
targetNodeType: targetNodeType,
|
|
13
13
|
schema: schema,
|
|
14
14
|
isNested: isNested,
|
|
15
|
-
targetAttrs: targetAttrs
|
|
15
|
+
targetAttrs: targetAttrs,
|
|
16
|
+
parentNode: parent
|
|
16
17
|
});
|
|
17
18
|
return outputNodes ? _model.Fragment.fromArray(outputNodes) : content;
|
|
18
19
|
};
|
|
@@ -172,6 +172,8 @@ var TRANSFORM_STEPS_OVERRIDE = {
|
|
|
172
172
|
layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep],
|
|
173
173
|
codeBlock: null,
|
|
174
174
|
decisionList: null,
|
|
175
|
+
bulletList: null,
|
|
176
|
+
orderedList: null,
|
|
175
177
|
taskList: null
|
|
176
178
|
},
|
|
177
179
|
decisionList: {
|
|
@@ -240,14 +242,15 @@ var getOutputNodes = exports.getOutputNodes = function getOutputNodes(_ref) {
|
|
|
240
242
|
targetNodeType = _ref.targetNodeType,
|
|
241
243
|
schema = _ref.schema,
|
|
242
244
|
isNested = _ref.isNested,
|
|
243
|
-
targetAttrs = _ref.targetAttrs
|
|
245
|
+
targetAttrs = _ref.targetAttrs,
|
|
246
|
+
parentNode = _ref.parentNode;
|
|
244
247
|
var sourceNode = sourceNodes.at(0);
|
|
245
248
|
if (!sourceNode) {
|
|
246
249
|
return;
|
|
247
250
|
}
|
|
248
251
|
var selectedNodeTypeName = (0, _types.toNodeTypeValue)((0, _types.getNodeName)(sourceNodes));
|
|
249
252
|
var initialTargetNodeTypeName = (0, _types.toNodeTypeValue)(targetNodeType.name);
|
|
250
|
-
var targetNodeTypeName = (0, _utils.getTargetNodeTypeNameInContext)(initialTargetNodeTypeName, isNested);
|
|
253
|
+
var targetNodeTypeName = (0, _utils.getTargetNodeTypeNameInContext)(initialTargetNodeTypeName, isNested, parentNode);
|
|
251
254
|
if (!selectedNodeTypeName || !targetNodeTypeName) {
|
|
252
255
|
// We may decide to return an empty array or undefined here
|
|
253
256
|
return;
|
|
@@ -49,7 +49,10 @@ var getSelectedNode = exports.getSelectedNode = function getSelectedNode(selecti
|
|
|
49
49
|
}
|
|
50
50
|
return undefined;
|
|
51
51
|
};
|
|
52
|
-
var getTargetNodeTypeNameInContext = exports.getTargetNodeTypeNameInContext = function getTargetNodeTypeNameInContext(nodeTypeName, isNested) {
|
|
52
|
+
var getTargetNodeTypeNameInContext = exports.getTargetNodeTypeNameInContext = function getTargetNodeTypeNameInContext(nodeTypeName, isNested, parentNode) {
|
|
53
|
+
if (parentNode && isNested && (parentNode.type.name === 'layoutColumn' || parentNode.type.name === 'bodiedSyncBlock')) {
|
|
54
|
+
return nodeTypeName;
|
|
55
|
+
}
|
|
53
56
|
if (nodeTypeName === 'expand' && isNested) {
|
|
54
57
|
return 'nestedExpand';
|
|
55
58
|
}
|
|
@@ -32,8 +32,7 @@ var transformNode = exports.transformNode = function transformNode(api) {
|
|
|
32
32
|
$from = _expandSelectionToBlo.$from,
|
|
33
33
|
$to = _expandSelectionToBlo.$to;
|
|
34
34
|
var selectedParent = $from.parent;
|
|
35
|
-
var
|
|
36
|
-
var isNestedExceptLayout = (0, _isNestedNode.isNestedNode)(preservedSelection, '') && !isParentLayout;
|
|
35
|
+
var isNested = (0, _isNestedNode.isNestedNode)(preservedSelection, '');
|
|
37
36
|
var isList = (0, _utils.isListNode)(selectedParent);
|
|
38
37
|
var slice = tr.doc.slice(isList ? $from.pos - 1 : $from.pos, isList ? $to.pos + 1 : $to.pos);
|
|
39
38
|
|
|
@@ -45,7 +44,7 @@ var transformNode = exports.transformNode = function transformNode(api) {
|
|
|
45
44
|
var nodeTypeName = node.type.name;
|
|
46
45
|
sourceNodeTypes[nodeTypeName] = (sourceNodeTypes[nodeTypeName] || 0) + 1;
|
|
47
46
|
});
|
|
48
|
-
var transformedNodes = (0, _tranformContent.tranformContent)(slice.content, targetType, schema,
|
|
47
|
+
var transformedNodes = (0, _tranformContent.tranformContent)(slice.content, targetType, schema, isNested, metadata === null || metadata === void 0 ? void 0 : metadata.targetAttrs, selectedParent);
|
|
49
48
|
var nodesToDeleteAndInsert = [nodes.mediaSingle];
|
|
50
49
|
if (preservedSelection instanceof _state.NodeSelection && nodesToDeleteAndInsert.includes(preservedSelection.node.type)) {
|
|
51
50
|
// when node is media single, use tr.replaceWith freeze editor, if modify position, tr.replaceWith creates duplicats
|
|
@@ -65,7 +64,7 @@ var transformNode = exports.transformNode = function transformNode(api) {
|
|
|
65
64
|
attributes: {
|
|
66
65
|
duration: duration,
|
|
67
66
|
isList: isList,
|
|
68
|
-
isNested:
|
|
67
|
+
isNested: isNested,
|
|
69
68
|
nodeCount: nodeCount,
|
|
70
69
|
sourceNodeTypes: sourceNodeTypes,
|
|
71
70
|
startTime: startTime,
|
|
@@ -4,7 +4,7 @@ import { isTransformDisabledBasedOnStepsConfig } from '../editor-commands/transf
|
|
|
4
4
|
import { toNodeTypeValue } from '../editor-commands/transform-node-utils/types';
|
|
5
5
|
import { getBlockNodesInRange, getTargetNodeTypeNameInContext } from '../editor-commands/transform-node-utils/utils';
|
|
6
6
|
export const canParentContainNodeType = (schema, selectedNodeTypeName, parentNode, nodeTypeName, nodeTypeAttrs) => {
|
|
7
|
-
const adjustedNodeTypeName =
|
|
7
|
+
const adjustedNodeTypeName = getTargetNodeTypeNameInContext(nodeTypeName, true, parentNode);
|
|
8
8
|
if (!adjustedNodeTypeName) {
|
|
9
9
|
return false;
|
|
10
10
|
}
|
|
@@ -12,8 +12,8 @@ export const canParentContainNodeType = (schema, selectedNodeTypeName, parentNod
|
|
|
12
12
|
let content = null;
|
|
13
13
|
const nodesThatCantBeNestedInNestedExpand = ['blockCard', 'embedCard', 'table'];
|
|
14
14
|
if (nodesThatCantBeNestedInNestedExpand.includes(selectedNodeTypeName) && (adjustedNodeTypeName === 'expand' || adjustedNodeTypeName === 'nestedExpand')) {
|
|
15
|
-
const
|
|
16
|
-
content =
|
|
15
|
+
const node = schema.nodes[selectedNodeTypeName];
|
|
16
|
+
content = node.createAndFill();
|
|
17
17
|
}
|
|
18
18
|
return parentNode.type.validContent(Fragment.from(nodeType.createAndFill(nodeTypeAttrs, content)));
|
|
19
19
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import { getOutputNodes } from './transform';
|
|
3
|
-
export const tranformContent = (content, targetNodeType, schema, isNested, targetAttrs) => {
|
|
3
|
+
export const tranformContent = (content, targetNodeType, schema, isNested, targetAttrs, parent) => {
|
|
4
4
|
const outputNodes = getOutputNodes({
|
|
5
5
|
sourceNodes: Array.from(content.content),
|
|
6
6
|
targetNodeType,
|
|
7
7
|
schema,
|
|
8
8
|
isNested,
|
|
9
|
-
targetAttrs
|
|
9
|
+
targetAttrs,
|
|
10
|
+
parentNode: parent
|
|
10
11
|
});
|
|
11
12
|
return outputNodes ? Fragment.fromArray(outputNodes) : content;
|
|
12
13
|
};
|
|
@@ -167,6 +167,8 @@ const TRANSFORM_STEPS_OVERRIDE = {
|
|
|
167
167
|
layoutSection: [wrapIntoLayoutStep],
|
|
168
168
|
codeBlock: null,
|
|
169
169
|
decisionList: null,
|
|
170
|
+
bulletList: null,
|
|
171
|
+
orderedList: null,
|
|
170
172
|
taskList: null
|
|
171
173
|
},
|
|
172
174
|
decisionList: {
|
|
@@ -235,7 +237,8 @@ export const getOutputNodes = ({
|
|
|
235
237
|
targetNodeType,
|
|
236
238
|
schema,
|
|
237
239
|
isNested,
|
|
238
|
-
targetAttrs
|
|
240
|
+
targetAttrs,
|
|
241
|
+
parentNode
|
|
239
242
|
}) => {
|
|
240
243
|
const sourceNode = sourceNodes.at(0);
|
|
241
244
|
if (!sourceNode) {
|
|
@@ -243,7 +246,7 @@ export const getOutputNodes = ({
|
|
|
243
246
|
}
|
|
244
247
|
const selectedNodeTypeName = toNodeTypeValue(getNodeName(sourceNodes));
|
|
245
248
|
const initialTargetNodeTypeName = toNodeTypeValue(targetNodeType.name);
|
|
246
|
-
const targetNodeTypeName = getTargetNodeTypeNameInContext(initialTargetNodeTypeName, isNested);
|
|
249
|
+
const targetNodeTypeName = getTargetNodeTypeNameInContext(initialTargetNodeTypeName, isNested, parentNode);
|
|
247
250
|
if (!selectedNodeTypeName || !targetNodeTypeName) {
|
|
248
251
|
// We may decide to return an empty array or undefined here
|
|
249
252
|
return;
|
|
@@ -44,7 +44,10 @@ export const getSelectedNode = selection => {
|
|
|
44
44
|
}
|
|
45
45
|
return undefined;
|
|
46
46
|
};
|
|
47
|
-
export const getTargetNodeTypeNameInContext = (nodeTypeName, isNested) => {
|
|
47
|
+
export const getTargetNodeTypeNameInContext = (nodeTypeName, isNested, parentNode) => {
|
|
48
|
+
if (parentNode && isNested && (parentNode.type.name === 'layoutColumn' || parentNode.type.name === 'bodiedSyncBlock')) {
|
|
49
|
+
return nodeTypeName;
|
|
50
|
+
}
|
|
48
51
|
if (nodeTypeName === 'expand' && isNested) {
|
|
49
52
|
return 'nestedExpand';
|
|
50
53
|
}
|
|
@@ -29,8 +29,7 @@ export const transformNode = api =>
|
|
|
29
29
|
$to
|
|
30
30
|
} = expandSelectionToBlockRange(preservedSelection);
|
|
31
31
|
const selectedParent = $from.parent;
|
|
32
|
-
const
|
|
33
|
-
const isNestedExceptLayout = isNestedNode(preservedSelection, '') && !isParentLayout;
|
|
32
|
+
const isNested = isNestedNode(preservedSelection, '');
|
|
34
33
|
const isList = isListNode(selectedParent);
|
|
35
34
|
const slice = tr.doc.slice(isList ? $from.pos - 1 : $from.pos, isList ? $to.pos + 1 : $to.pos);
|
|
36
35
|
|
|
@@ -42,7 +41,7 @@ export const transformNode = api =>
|
|
|
42
41
|
const nodeTypeName = node.type.name;
|
|
43
42
|
sourceNodeTypes[nodeTypeName] = (sourceNodeTypes[nodeTypeName] || 0) + 1;
|
|
44
43
|
});
|
|
45
|
-
const transformedNodes = tranformContent(slice.content, targetType, schema,
|
|
44
|
+
const transformedNodes = tranformContent(slice.content, targetType, schema, isNested, metadata === null || metadata === void 0 ? void 0 : metadata.targetAttrs, selectedParent);
|
|
46
45
|
const nodesToDeleteAndInsert = [nodes.mediaSingle];
|
|
47
46
|
if (preservedSelection instanceof NodeSelection && nodesToDeleteAndInsert.includes(preservedSelection.node.type)) {
|
|
48
47
|
// when node is media single, use tr.replaceWith freeze editor, if modify position, tr.replaceWith creates duplicats
|
|
@@ -62,7 +61,7 @@ export const transformNode = api =>
|
|
|
62
61
|
attributes: {
|
|
63
62
|
duration,
|
|
64
63
|
isList,
|
|
65
|
-
isNested
|
|
64
|
+
isNested,
|
|
66
65
|
nodeCount,
|
|
67
66
|
sourceNodeTypes,
|
|
68
67
|
startTime,
|
|
@@ -4,7 +4,7 @@ import { isTransformDisabledBasedOnStepsConfig } from '../editor-commands/transf
|
|
|
4
4
|
import { toNodeTypeValue } from '../editor-commands/transform-node-utils/types';
|
|
5
5
|
import { getBlockNodesInRange, getTargetNodeTypeNameInContext } from '../editor-commands/transform-node-utils/utils';
|
|
6
6
|
export var canParentContainNodeType = function canParentContainNodeType(schema, selectedNodeTypeName, parentNode, nodeTypeName, nodeTypeAttrs) {
|
|
7
|
-
var adjustedNodeTypeName =
|
|
7
|
+
var adjustedNodeTypeName = getTargetNodeTypeNameInContext(nodeTypeName, true, parentNode);
|
|
8
8
|
if (!adjustedNodeTypeName) {
|
|
9
9
|
return false;
|
|
10
10
|
}
|
|
@@ -12,8 +12,8 @@ export var canParentContainNodeType = function canParentContainNodeType(schema,
|
|
|
12
12
|
var content = null;
|
|
13
13
|
var nodesThatCantBeNestedInNestedExpand = ['blockCard', 'embedCard', 'table'];
|
|
14
14
|
if (nodesThatCantBeNestedInNestedExpand.includes(selectedNodeTypeName) && (adjustedNodeTypeName === 'expand' || adjustedNodeTypeName === 'nestedExpand')) {
|
|
15
|
-
var
|
|
16
|
-
content =
|
|
15
|
+
var node = schema.nodes[selectedNodeTypeName];
|
|
16
|
+
content = node.createAndFill();
|
|
17
17
|
}
|
|
18
18
|
return parentNode.type.validContent(Fragment.from(nodeType.createAndFill(nodeTypeAttrs, content)));
|
|
19
19
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import { getOutputNodes } from './transform';
|
|
3
|
-
export var tranformContent = function tranformContent(content, targetNodeType, schema, isNested, targetAttrs) {
|
|
3
|
+
export var tranformContent = function tranformContent(content, targetNodeType, schema, isNested, targetAttrs, parent) {
|
|
4
4
|
var outputNodes = getOutputNodes({
|
|
5
5
|
sourceNodes: Array.from(content.content),
|
|
6
6
|
targetNodeType: targetNodeType,
|
|
7
7
|
schema: schema,
|
|
8
8
|
isNested: isNested,
|
|
9
|
-
targetAttrs: targetAttrs
|
|
9
|
+
targetAttrs: targetAttrs,
|
|
10
|
+
parentNode: parent
|
|
10
11
|
});
|
|
11
12
|
return outputNodes ? Fragment.fromArray(outputNodes) : content;
|
|
12
13
|
};
|
|
@@ -167,6 +167,8 @@ var TRANSFORM_STEPS_OVERRIDE = {
|
|
|
167
167
|
layoutSection: [wrapIntoLayoutStep],
|
|
168
168
|
codeBlock: null,
|
|
169
169
|
decisionList: null,
|
|
170
|
+
bulletList: null,
|
|
171
|
+
orderedList: null,
|
|
170
172
|
taskList: null
|
|
171
173
|
},
|
|
172
174
|
decisionList: {
|
|
@@ -235,14 +237,15 @@ export var getOutputNodes = function getOutputNodes(_ref) {
|
|
|
235
237
|
targetNodeType = _ref.targetNodeType,
|
|
236
238
|
schema = _ref.schema,
|
|
237
239
|
isNested = _ref.isNested,
|
|
238
|
-
targetAttrs = _ref.targetAttrs
|
|
240
|
+
targetAttrs = _ref.targetAttrs,
|
|
241
|
+
parentNode = _ref.parentNode;
|
|
239
242
|
var sourceNode = sourceNodes.at(0);
|
|
240
243
|
if (!sourceNode) {
|
|
241
244
|
return;
|
|
242
245
|
}
|
|
243
246
|
var selectedNodeTypeName = toNodeTypeValue(getNodeName(sourceNodes));
|
|
244
247
|
var initialTargetNodeTypeName = toNodeTypeValue(targetNodeType.name);
|
|
245
|
-
var targetNodeTypeName = getTargetNodeTypeNameInContext(initialTargetNodeTypeName, isNested);
|
|
248
|
+
var targetNodeTypeName = getTargetNodeTypeNameInContext(initialTargetNodeTypeName, isNested, parentNode);
|
|
246
249
|
if (!selectedNodeTypeName || !targetNodeTypeName) {
|
|
247
250
|
// We may decide to return an empty array or undefined here
|
|
248
251
|
return;
|
|
@@ -43,7 +43,10 @@ export var getSelectedNode = function getSelectedNode(selection) {
|
|
|
43
43
|
}
|
|
44
44
|
return undefined;
|
|
45
45
|
};
|
|
46
|
-
export var getTargetNodeTypeNameInContext = function getTargetNodeTypeNameInContext(nodeTypeName, isNested) {
|
|
46
|
+
export var getTargetNodeTypeNameInContext = function getTargetNodeTypeNameInContext(nodeTypeName, isNested, parentNode) {
|
|
47
|
+
if (parentNode && isNested && (parentNode.type.name === 'layoutColumn' || parentNode.type.name === 'bodiedSyncBlock')) {
|
|
48
|
+
return nodeTypeName;
|
|
49
|
+
}
|
|
47
50
|
if (nodeTypeName === 'expand' && isNested) {
|
|
48
51
|
return 'nestedExpand';
|
|
49
52
|
}
|
|
@@ -26,8 +26,7 @@ export var transformNode = function transformNode(api) {
|
|
|
26
26
|
$from = _expandSelectionToBlo.$from,
|
|
27
27
|
$to = _expandSelectionToBlo.$to;
|
|
28
28
|
var selectedParent = $from.parent;
|
|
29
|
-
var
|
|
30
|
-
var isNestedExceptLayout = isNestedNode(preservedSelection, '') && !isParentLayout;
|
|
29
|
+
var isNested = isNestedNode(preservedSelection, '');
|
|
31
30
|
var isList = isListNode(selectedParent);
|
|
32
31
|
var slice = tr.doc.slice(isList ? $from.pos - 1 : $from.pos, isList ? $to.pos + 1 : $to.pos);
|
|
33
32
|
|
|
@@ -39,7 +38,7 @@ export var transformNode = function transformNode(api) {
|
|
|
39
38
|
var nodeTypeName = node.type.name;
|
|
40
39
|
sourceNodeTypes[nodeTypeName] = (sourceNodeTypes[nodeTypeName] || 0) + 1;
|
|
41
40
|
});
|
|
42
|
-
var transformedNodes = tranformContent(slice.content, targetType, schema,
|
|
41
|
+
var transformedNodes = tranformContent(slice.content, targetType, schema, isNested, metadata === null || metadata === void 0 ? void 0 : metadata.targetAttrs, selectedParent);
|
|
43
42
|
var nodesToDeleteAndInsert = [nodes.mediaSingle];
|
|
44
43
|
if (preservedSelection instanceof NodeSelection && nodesToDeleteAndInsert.includes(preservedSelection.node.type)) {
|
|
45
44
|
// when node is media single, use tr.replaceWith freeze editor, if modify position, tr.replaceWith creates duplicats
|
|
@@ -59,7 +58,7 @@ export var transformNode = function transformNode(api) {
|
|
|
59
58
|
attributes: {
|
|
60
59
|
duration: duration,
|
|
61
60
|
isList: isList,
|
|
62
|
-
isNested:
|
|
61
|
+
isNested: isNested,
|
|
63
62
|
nodeCount: nodeCount,
|
|
64
63
|
sourceNodeTypes: sourceNodeTypes,
|
|
65
64
|
startTime: startTime,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { NodeType, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
1
|
+
import type { NodeType, Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
export declare const tranformContent: (content: Fragment, targetNodeType: NodeType, schema: Schema, isNested: boolean, targetAttrs?: Record<string, unknown
|
|
3
|
+
export declare const tranformContent: (content: Fragment, targetNodeType: NodeType, schema: Schema, isNested: boolean, targetAttrs?: Record<string, unknown>, parent?: PMNode) => Fragment;
|
|
@@ -2,11 +2,12 @@ import { type Node as PMNode, type NodeType, type Schema } from '@atlaskit/edito
|
|
|
2
2
|
import type { NodeTypeName } from './types';
|
|
3
3
|
interface GetOutputNodesArgs {
|
|
4
4
|
isNested: boolean;
|
|
5
|
+
parentNode?: PMNode;
|
|
5
6
|
schema: Schema;
|
|
6
7
|
sourceNodes: PMNode[];
|
|
7
8
|
targetAttrs?: Record<string, unknown>;
|
|
8
9
|
targetNodeType: NodeType;
|
|
9
10
|
}
|
|
10
|
-
export declare const getOutputNodes: ({ sourceNodes, targetNodeType, schema, isNested, targetAttrs, }: GetOutputNodesArgs) => PMNode[] | undefined;
|
|
11
|
+
export declare const getOutputNodes: ({ sourceNodes, targetNodeType, schema, isNested, targetAttrs, parentNode, }: GetOutputNodesArgs) => PMNode[] | undefined;
|
|
11
12
|
export declare const isTransformDisabledBasedOnStepsConfig: (selectedNodeType: NodeTypeName, targetNodeType: NodeTypeName) => boolean;
|
|
12
13
|
export {};
|
|
@@ -3,7 +3,7 @@ import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
|
3
3
|
import { type ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
|
|
4
4
|
import type { NodeTypeName } from './types';
|
|
5
5
|
export declare const getSelectedNode: (selection: Selection) => ContentNodeWithPos | undefined;
|
|
6
|
-
export declare const getTargetNodeTypeNameInContext: (nodeTypeName: NodeTypeName | null, isNested?: boolean) => NodeTypeName | null;
|
|
6
|
+
export declare const getTargetNodeTypeNameInContext: (nodeTypeName: NodeTypeName | null, isNested?: boolean, parentNode?: PMNode) => NodeTypeName | null;
|
|
7
7
|
/**
|
|
8
8
|
* Converts a nestedExpand to a regular expand node.
|
|
9
9
|
* NestedExpands can only exist inside expands, so when breaking out or placing
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { NodeType, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
1
|
+
import type { NodeType, Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
export declare const tranformContent: (content: Fragment, targetNodeType: NodeType, schema: Schema, isNested: boolean, targetAttrs?: Record<string, unknown
|
|
3
|
+
export declare const tranformContent: (content: Fragment, targetNodeType: NodeType, schema: Schema, isNested: boolean, targetAttrs?: Record<string, unknown>, parent?: PMNode) => Fragment;
|
|
@@ -2,11 +2,12 @@ import { type Node as PMNode, type NodeType, type Schema } from '@atlaskit/edito
|
|
|
2
2
|
import type { NodeTypeName } from './types';
|
|
3
3
|
interface GetOutputNodesArgs {
|
|
4
4
|
isNested: boolean;
|
|
5
|
+
parentNode?: PMNode;
|
|
5
6
|
schema: Schema;
|
|
6
7
|
sourceNodes: PMNode[];
|
|
7
8
|
targetAttrs?: Record<string, unknown>;
|
|
8
9
|
targetNodeType: NodeType;
|
|
9
10
|
}
|
|
10
|
-
export declare const getOutputNodes: ({ sourceNodes, targetNodeType, schema, isNested, targetAttrs, }: GetOutputNodesArgs) => PMNode[] | undefined;
|
|
11
|
+
export declare const getOutputNodes: ({ sourceNodes, targetNodeType, schema, isNested, targetAttrs, parentNode, }: GetOutputNodesArgs) => PMNode[] | undefined;
|
|
11
12
|
export declare const isTransformDisabledBasedOnStepsConfig: (selectedNodeType: NodeTypeName, targetNodeType: NodeTypeName) => boolean;
|
|
12
13
|
export {};
|
|
@@ -3,7 +3,7 @@ import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
|
3
3
|
import { type ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
|
|
4
4
|
import type { NodeTypeName } from './types';
|
|
5
5
|
export declare const getSelectedNode: (selection: Selection) => ContentNodeWithPos | undefined;
|
|
6
|
-
export declare const getTargetNodeTypeNameInContext: (nodeTypeName: NodeTypeName | null, isNested?: boolean) => NodeTypeName | null;
|
|
6
|
+
export declare const getTargetNodeTypeNameInContext: (nodeTypeName: NodeTypeName | null, isNested?: boolean, parentNode?: PMNode) => NodeTypeName | null;
|
|
7
7
|
/**
|
|
8
8
|
* Converts a nestedExpand to a regular expand node.
|
|
9
9
|
* NestedExpands can only exist inside expands, so when breaking out or placing
|