refactor(editor): query methods in edgeless api (#9407)

This commit is contained in:
Saul-Mirone
2024-12-28 07:48:41 +00:00
parent dc92d78895
commit 1e4b1807be
35 changed files with 296 additions and 275 deletions
@@ -137,4 +137,26 @@ export class EdgelessCRUDExtension extends Extension {
this.std.doc.updateBlock(block, props);
}
};
getElementById(id: string): BlockSuite.EdgelessModel | null {
const surface = this._surface;
if (!surface) {
return null;
}
const el =
surface.getElementById(id) ??
(this.std.doc.getBlockById(
id
) as BlockSuite.EdgelessBlockModelType | null);
return el;
}
getElementsByType<K extends keyof BlockSuite.SurfaceElementModelMap>(
type: K
): BlockSuite.SurfaceElementModelMap[K][] {
if (!this._surface) {
return [];
}
return this._surface.getElementsByType(type);
}
}