mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-23 13:29:02 +08:00
18 lines
457 B
TypeScript
18 lines
457 B
TypeScript
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 });
|
|
},
|
|
}),
|
|
[blockSuiteWorkspace]
|
|
);
|
|
}
|