update:过滤粘贴过程中 disableMark 中的mark节点

This commit is contained in:
yanmao 2022-01-20 21:49:38 +08:00
parent 69ef914587
commit aaa0332049
1 changed files with 16 additions and 0 deletions

View File

@ -43,6 +43,7 @@ export default class Paste {
const { inline } = this.engine;
const nodeApi = this.engine.node;
const markApi = this.engine.mark;
const blockApi = this.engine.block;
$(fragment).traverse((node) => {
let parent = node.parent();
@ -408,6 +409,21 @@ export default class Paste {
node = nodeClone;
nodeParent = node.parent();
}
if (node.length > 0 && nodeApi.isMark(node, this.schema)) {
const block = blockApi.closest(node);
if (!block.equal(node)) {
const markPlugin = markApi.findPlugin(node);
const blockPlugin = blockApi.findPlugin(block);
if (
markPlugin &&
blockPlugin?.disableMark?.includes(markPlugin.name)
) {
nodeApi.unwrap(node);
return;
}
}
}
// mark 相同的嵌套
nodeParent = parent;
while (