diff --git a/packages/frontend/hooks/package.json b/packages/frontend/hooks/package.json index 4bad2538da..e0867e1f35 100644 --- a/packages/frontend/hooks/package.json +++ b/packages/frontend/hooks/package.json @@ -10,7 +10,8 @@ "jotai": "^2.4.3", "lodash.debounce": "^4.0.8", "react": "18.2.0", - "swr": "2.2.4" + "swr": "2.2.4", + "uuid": "^9.0.1" }, "devDependencies": { "@affine/env": "workspace:*", diff --git a/packages/frontend/hooks/src/use-block-suite-workspace-helper.ts b/packages/frontend/hooks/src/use-block-suite-workspace-helper.ts index 3695884435..cbcd7a9a4e 100644 --- a/packages/frontend/hooks/src/use-block-suite-workspace-helper.ts +++ b/packages/frontend/hooks/src/use-block-suite-workspace-helper.ts @@ -1,10 +1,14 @@ import type { Page, Workspace } from '@blocksuite/store'; import { useMemo } from 'react'; +import { v4 as uuid } from 'uuid'; export function useBlockSuiteWorkspaceHelper(blockSuiteWorkspace: Workspace) { return useMemo( () => ({ createPage: (pageId?: string): Page => { + if (!pageId) { + pageId = uuid(); + } return blockSuiteWorkspace.createPage({ id: pageId }); }, }), diff --git a/yarn.lock b/yarn.lock index 5dbeb14718..6f7510663c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12706,6 +12706,7 @@ __metadata: lodash.debounce: ^4.0.8 react: 18.2.0 swr: 2.2.4 + uuid: ^9.0.1 vitest: 0.34.6 y-provider: "workspace:*" peerDependencies: