mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-23 13:29:02 +08:00
refactor(editor): refactor page note empty checker (#9570)
Close [BS-2320](https://linear.app/affine-design/issue/BS-2320/内容为空的状态判断)
This commit is contained in:
@@ -22,6 +22,22 @@ export class RootBlockModel extends BlockModel<RootBlockProps> {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* A page is empty if it only contains one empty note and the canvas is empty
|
||||
*/
|
||||
override isEmpty() {
|
||||
let numNotes = 0;
|
||||
let empty = true;
|
||||
for (const child of this.children) {
|
||||
empty = empty && child.isEmpty();
|
||||
|
||||
if (child.flavour === 'affine:note') numNotes++;
|
||||
if (numNotes > 1) return false;
|
||||
}
|
||||
|
||||
return empty;
|
||||
}
|
||||
}
|
||||
|
||||
export const RootBlockSchema = defineBlockSchema({
|
||||
|
||||
Reference in New Issue
Block a user