mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-03 02:20:19 +08:00
refactor(editor): query methods in edgeless api (#9407)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user