diff --git a/apps/web/src/hooks/use-pinboard-handler.ts b/apps/web/src/hooks/use-pinboard-handler.ts index 36b5bee098..88b0fe619f 100644 --- a/apps/web/src/hooks/use-pinboard-handler.ts +++ b/apps/web/src/hooks/use-pinboard-handler.ts @@ -1,6 +1,5 @@ import type { TreeViewProps } from '@affine/component'; import { DebugLogger } from '@affine/debug'; -import { initPage } from '@affine/env/blocksuite'; import type { PageMeta } from '@blocksuite/store'; import { nanoid } from '@blocksuite/store'; import { usePageMetaHelper } from '@toeverything/hooks/use-block-suite-page-meta'; @@ -65,16 +64,7 @@ export function usePinboardHandler({ const addPin = useCallback( (parentId: string) => { const id = nanoid(); - const page = createPage(id); - initPage(page); - page.addBlock('affine:paragraph', { - text: page.Text.fromDelta([ - { - insert: ' ', - attributes: { reference: { type: 'LinkedPage', pageId: page.id } }, - }, - ]), - }); + createPage(id, parentId); onAdd?.(id, parentId); addReferenceLink(parentId, id); }, diff --git a/packages/hooks/src/use-block-suite-workspace-helper.ts b/packages/hooks/src/use-block-suite-workspace-helper.ts index 096dbee579..6c69d9800a 100644 --- a/packages/hooks/src/use-block-suite-workspace-helper.ts +++ b/packages/hooks/src/use-block-suite-workspace-helper.ts @@ -10,9 +10,9 @@ import { useMemo } from 'react'; export function useBlockSuiteWorkspaceHelper(blockSuiteWorkspace: Workspace) { return useMemo( () => ({ - createPage: (pageId: string): Page => { + createPage: (pageId: string, parentId?: string): Page => { assertExists(blockSuiteWorkspace); - return blockSuiteWorkspace.createPage(pageId); + return blockSuiteWorkspace.createPage(pageId, parentId); }, markMilestone: async (name: string) => { assertExists(blockSuiteWorkspace);