feat: 1. add toc;

This commit is contained in:
mitsuha
2022-08-23 15:37:44 +08:00
parent 7b4999225a
commit ab070daa7e
9 changed files with 350 additions and 38 deletions
@@ -333,6 +333,12 @@ export class Editor implements Virgo {
return await this.getBlock({ workspace: this.workspace, id: blockId });
}
async getBlockByIds(ids: string[]): Promise<Awaited<AsyncBlock | null>[]> {
return await Promise.all(
ids.map(id => this.getBlock({ workspace: this.workspace, id }))
);
}
/**
* TODO: to be optimized
* get block`s dom by block`s id
@@ -477,6 +483,13 @@ export class Editor implements Virgo {
return await services.api.editorBlock.query(this.workspace, query);
}
async queryByPageId(pageId: string) {
return await services.api.editorBlock.get({
workspace: this.workspace,
ids: [pageId],
});
}
/** Hooks */
public getHooks(): HooksRunner & PluginHooks {