diff --git a/apps/web/src/hooks/use-pinboard-handler.ts b/apps/web/src/hooks/use-pinboard-handler.ts index 88b0fe619f..36b5bee098 100644 --- a/apps/web/src/hooks/use-pinboard-handler.ts +++ b/apps/web/src/hooks/use-pinboard-handler.ts @@ -1,5 +1,6 @@ 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'; @@ -64,7 +65,16 @@ export function usePinboardHandler({ const addPin = useCallback( (parentId: string) => { const id = nanoid(); - createPage(id, parentId); + const page = createPage(id); + initPage(page); + page.addBlock('affine:paragraph', { + text: page.Text.fromDelta([ + { + insert: ' ', + attributes: { reference: { type: 'LinkedPage', pageId: page.id } }, + }, + ]), + }); 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 6c69d9800a..096dbee579 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, parentId?: string): Page => { + createPage: (pageId: string): Page => { assertExists(blockSuiteWorkspace); - return blockSuiteWorkspace.createPage(pageId, parentId); + return blockSuiteWorkspace.createPage(pageId); }, markMilestone: async (name: string) => { assertExists(blockSuiteWorkspace);