mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00: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:
@@ -103,6 +103,10 @@ export class SurfaceBlockModel extends BlockModel<SurfaceBlockProps> {
|
||||
return Object.keys(this._elementCtorMap);
|
||||
}
|
||||
|
||||
override isEmpty(): boolean {
|
||||
return this._elementModels.size === 0 && this.children.length === 0;
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.created.once(() => this._init());
|
||||
|
||||
@@ -70,9 +70,9 @@ export class BlockModel<
|
||||
|
||||
id!: string;
|
||||
|
||||
isEmpty = computed(() => {
|
||||
return this._children.value.length === 0;
|
||||
});
|
||||
isEmpty() {
|
||||
return this.children.length === 0;
|
||||
}
|
||||
|
||||
keys!: string[];
|
||||
|
||||
|
||||
@@ -192,7 +192,7 @@ export class Blocks {
|
||||
}
|
||||
|
||||
get isEmpty() {
|
||||
return Object.values(this._blocks.peek()).length === 0;
|
||||
return this.root?.isEmpty() ?? true;
|
||||
}
|
||||
|
||||
get loaded() {
|
||||
|
||||
Reference in New Issue
Block a user