mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-16 17:46:18 +08:00
feat: support create page with title
This commit is contained in:
@@ -15,9 +15,9 @@ export const useEditorHandler = ({
|
||||
const router = useRouter();
|
||||
|
||||
return {
|
||||
createPage: async (pageId = generateDefaultPageId()) => {
|
||||
createPage: async ({ pageId = generateDefaultPageId(), title } = {}) => {
|
||||
const page = await createPage(workspace!, pageId);
|
||||
initialPage(page);
|
||||
initialPage(page, title);
|
||||
return page;
|
||||
},
|
||||
getPageMeta(pageId: string) {
|
||||
|
||||
@@ -26,7 +26,7 @@ export type PageMeta = {
|
||||
} & OriginalPageMeta;
|
||||
|
||||
export type EditorHandlers = {
|
||||
createPage: (pageId?: string) => Promise<Page>;
|
||||
createPage: (params?: { pageId?: string; title?: string }) => Promise<Page>;
|
||||
openPage: (
|
||||
pageId: string,
|
||||
query?: { [key: string]: string }
|
||||
|
||||
@@ -26,8 +26,8 @@ export const createPage = (
|
||||
});
|
||||
};
|
||||
|
||||
export const initialPage = (page: Page) => {
|
||||
const pageBlockId = page.addBlock({ flavour: 'affine:page' });
|
||||
export const initialPage = (page: Page, title?: string) => {
|
||||
const pageBlockId = page.addBlock({ flavour: 'affine:page', title });
|
||||
const groupId = page.addBlock({ flavour: 'affine:group' }, pageBlockId);
|
||||
page.addBlock({ flavour: 'affine:paragraph' }, groupId);
|
||||
return page;
|
||||
|
||||
Reference in New Issue
Block a user