@atlaskit/editor-plugin-block-menu 6.0.0 → 6.0.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 +7 -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/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/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/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,12 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-menu
|
|
2
2
|
|
|
3
|
+
## 6.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`3ae29083b2189`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3ae29083b2189) -
|
|
8
|
+
Remove block marks when wrapping nodes (fixes multi-select codeblock)
|
|
9
|
+
|
|
3
10
|
## 6.0.0
|
|
4
11
|
|
|
5
12
|
### 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
|
};
|
|
@@ -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,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,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[];
|