feat: isEmpty

This commit is contained in:
yanmao 2021-11-25 22:39:40 +08:00
parent 7f290e70c8
commit 7d3164aac5
1 changed files with 7 additions and 3 deletions

View File

@ -286,10 +286,14 @@ class ChangeModel implements ChangeInterface {
isEmpty() {
const { container, node, schema } = this.engine;
const tags = schema.getAllowInTags();
const children = container.children();
return (
container.children().length === 1 &&
node.isEmpty(container) &&
!container.allChildren().some((child) => tags.includes(child.name))
children.length === 0 ||
(children.length === 1 &&
node.isEmpty(container) &&
!container
.allChildren()
.some((child) => tags.includes(child.name)))
);
}