diff --git a/blocksuite/affine/model/src/consts/note.ts b/blocksuite/affine/model/src/consts/note.ts index f3f6ddea03..49c378a254 100644 --- a/blocksuite/affine/model/src/consts/note.ts +++ b/blocksuite/affine/model/src/consts/note.ts @@ -8,6 +8,9 @@ export const NOTE_MIN_HEIGHT = 92; export const DEFAULT_NOTE_WIDTH = 450 + 24 * 2; export const DEFAULT_NOTE_HEIGHT = NOTE_MIN_HEIGHT; +export const DEFAULT_PAGE_BLOCK_WIDTH = 800; +export const DEFAULT_PAGE_BLOCK_HEIGHT = DEFAULT_NOTE_HEIGHT; + export enum NoteShadow { Box = '--affine-note-shadow-box', Film = '--affine-note-shadow-film', diff --git a/blocksuite/affine/shared/src/utils/model/doc.ts b/blocksuite/affine/shared/src/utils/model/doc.ts index 4e1111a9b2..d974cf7c1f 100644 --- a/blocksuite/affine/shared/src/utils/model/doc.ts +++ b/blocksuite/affine/shared/src/utils/model/doc.ts @@ -1,3 +1,7 @@ +import { + DEFAULT_PAGE_BLOCK_HEIGHT, + DEFAULT_PAGE_BLOCK_WIDTH, +} from '@blocksuite/affine-model'; import type { Workspace } from '@blocksuite/store'; import { Text } from '@blocksuite/store'; @@ -17,7 +21,13 @@ export function createDefaultDoc( }); doc.addBlock('affine:surface', {}, rootId); - const noteId = doc.addBlock('affine:note', {}, rootId); + const noteId = doc.addBlock( + 'affine:note', + { + xywh: `[0, 0, ${DEFAULT_PAGE_BLOCK_WIDTH}, ${DEFAULT_PAGE_BLOCK_HEIGHT}]`, + }, + rootId + ); doc.addBlock('affine:paragraph', {}, noteId); // To make sure the content of new doc would not be clear // By undo operation for the first time diff --git a/packages/frontend/core/src/blocksuite/block-suite-page-list/utils.tsx b/packages/frontend/core/src/blocksuite/block-suite-page-list/utils.tsx index d13a7c82a0..056cab611a 100644 --- a/packages/frontend/core/src/blocksuite/block-suite-page-list/utils.tsx +++ b/packages/frontend/core/src/blocksuite/block-suite-page-list/utils.tsx @@ -5,7 +5,11 @@ import { DocsService } from '@affine/core/modules/doc'; import { EditorSettingService } from '@affine/core/modules/editor-setting'; import { WorkbenchService } from '@affine/core/modules/workbench'; import { getAFFiNEWorkspaceSchema } from '@affine/core/modules/workspace'; -import { type DocMode } from '@blocksuite/affine/model'; +import { + DEFAULT_PAGE_BLOCK_HEIGHT, + DEFAULT_PAGE_BLOCK_WIDTH, + type DocMode, +} from '@blocksuite/affine/model'; import type { Workspace } from '@blocksuite/affine/store'; import { useServices } from '@toeverything/infra'; import { useCallback, useMemo } from 'react'; @@ -39,7 +43,10 @@ export const usePageHelper = (docCollection: Workspace) => { ) => { appSidebar.setHovering(false); const docProps: DocProps = { - note: editorSettingService.editorSetting.get('affine:note'), + note: { + ...editorSettingService.editorSetting.get('affine:note'), + xywh: `[0, 0, ${DEFAULT_PAGE_BLOCK_WIDTH}, ${DEFAULT_PAGE_BLOCK_HEIGHT}]`, + }, }; const page = docsService.createDoc({ docProps });