mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-15 09:06:19 +08:00
Merge pull request #326 from toeverything/feature-toc-mitsuha-dev
Feature toc mitsuha dev
This commit is contained in:
@@ -346,6 +346,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
|
||||
@@ -490,6 +496,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 {
|
||||
|
||||
@@ -9,7 +9,10 @@
|
||||
* 6. Dependencies between plugins are not supported for the time being
|
||||
*/
|
||||
import type { PatchNode } from '@toeverything/components/ui';
|
||||
import type { BlockFlavors } from '@toeverything/datasource/db-service';
|
||||
import type {
|
||||
BlockFlavors,
|
||||
ReturnEditorBlock,
|
||||
} from '@toeverything/datasource/db-service';
|
||||
import type { IdList, SelectionInfo, SelectionManager } from './selection';
|
||||
|
||||
import { Point } from '@toeverything/utils';
|
||||
@@ -67,6 +70,8 @@ export interface Virgo {
|
||||
) => Promise<AsyncBlock>;
|
||||
getRootBlockId: () => string;
|
||||
getBlockById(blockId: string): Promise<AsyncBlock | null>;
|
||||
getBlockByIds(blockId: string[]): Promise<(AsyncBlock | null)[]>;
|
||||
queryByPageId(pageId: string): Promise<(ReturnEditorBlock | null)[]>;
|
||||
setHotKeysScope(scope?: string): void;
|
||||
getBlockList: () => Promise<AsyncBlock[]>;
|
||||
getBlockListByLevelOrder: () => Promise<AsyncBlock[]>;
|
||||
|
||||
Reference in New Issue
Block a user