mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
fix: create page with title (#1449)
Co-authored-by: Himself65 <himself65@outlook.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { useTranslation } from '@affine/i18n';
|
||||
import type { PageBlockModel } from '@blocksuite/blocks';
|
||||
import { PlusIcon } from '@blocksuite/icons';
|
||||
import { assertEquals, nanoid } from '@blocksuite/store';
|
||||
import { Command } from 'cmdk';
|
||||
@@ -26,7 +27,6 @@ export const Footer: React.FC<FooterProps> = ({
|
||||
const { createPage } = useBlockSuiteWorkspaceHelper(blockSuiteWorkspace);
|
||||
const { t } = useTranslation();
|
||||
const { jumpToPage } = useRouterHelper(router);
|
||||
|
||||
return (
|
||||
<Command.Item
|
||||
data-testid="quick-search-add-new-page"
|
||||
@@ -35,7 +35,17 @@ export const Footer: React.FC<FooterProps> = ({
|
||||
const id = nanoid();
|
||||
const pageId = await createPage(id, query);
|
||||
assertEquals(pageId, id);
|
||||
jumpToPage(blockSuiteWorkspace.id, pageId);
|
||||
await jumpToPage(blockSuiteWorkspace.id, pageId);
|
||||
if (!query) {
|
||||
return;
|
||||
}
|
||||
const newPage = blockSuiteWorkspace.getPage(pageId);
|
||||
if (newPage) {
|
||||
const block = newPage.getBlockByFlavour(
|
||||
'affine:page'
|
||||
)[0] as PageBlockModel;
|
||||
block.title.insert(query, 0);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<StyledModalFooterContent>
|
||||
|
||||
Reference in New Issue
Block a user