close #240 fix block class to handle text node changes

This commit is contained in:
Yanzhen Yu
2026-04-01 12:00:00 +08:00
parent c8cc397418
commit 6c87b03e0d
2 changed files with 8 additions and 1 deletions

View File

@@ -216,7 +216,10 @@ export default class MutationBuffer {
m.removedNodes.forEach((n) => {
const nodeId = mirror.getId(n as INode);
const parentId = mirror.getId(m.target as INode);
if (isBlocked(n, this.blockClass)) {
if (
isBlocked(n, this.blockClass) ||
isBlocked(m.target, this.blockClass)
) {
return;
}
// removed node has not been serialized yet, just remove it from the Set

View File

@@ -189,6 +189,10 @@ export function isBlocked(node: Node | null, blockClass: blockClass): boolean {
}
return needBlock || isBlocked(node.parentNode, blockClass);
}
if (node.nodeType === node.TEXT_NODE) {
// check parent node since text node do not have class name
return isBlocked(node.parentNode, blockClass);
}
return isBlocked(node.parentNode, blockClass);
}