feat: support subpage (#1663)

This commit is contained in:
Qi
2023-03-23 13:47:07 +08:00
committed by GitHub
parent 2551785451
commit 6a7b5601aa
26 changed files with 824 additions and 82 deletions

View File

@@ -9,9 +9,9 @@ export function useBlockSuiteWorkspaceHelper(
) {
return useMemo(
() => ({
createPage: (pageId: string, title?: string): Page => {
createPage: (pageId: string, parentId?: string): Page => {
assertExists(blockSuiteWorkspace);
return blockSuiteWorkspace.createPage(pageId);
return blockSuiteWorkspace.createPage(pageId, parentId);
},
}),
[blockSuiteWorkspace]

View File

@@ -22,7 +22,6 @@ declare global {
callback: Set<() => void>;
};
}
if (!globalThis.featureFlag) {
globalThis.featureFlag = featureFlag;
}

View File

@@ -6,6 +6,7 @@ import type { BlockSuiteWorkspace } from '../shared';
declare module '@blocksuite/store' {
interface PageMeta {
favorite?: boolean;
subpageIds: string[];
trash?: boolean;
trashDate?: number;
// whether to create the page with the default template
@@ -45,6 +46,12 @@ export function usePageMetaHelper(blockSuiteWorkspace: BlockSuiteWorkspace) {
setPageMeta: (pageId: string, pageMeta: Partial<PageMeta>) => {
blockSuiteWorkspace.meta.setPageMeta(pageId, pageMeta);
},
getPageMeta: (pageId: string) => {
return blockSuiteWorkspace.meta.getPageMeta(pageId);
},
shiftPageMeta: (pageId: string, index: number) => {
return blockSuiteWorkspace.meta.shiftPageMeta(pageId, index);
},
}),
[blockSuiteWorkspace]
);