fix(hooks): use uuid as pageId (#4658)

This commit is contained in:
Alex Yang 2023-10-18 22:14:41 -05:00 committed by GitHub
parent 97d8660a54
commit 9958baa843
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View File

@ -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:*",

View File

@ -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 });
},
}),

View File

@ -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: