mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-15 09:06:19 +08:00
fix: default style of new document does not follow AFFiNE settings (#8291)
Close issue [BS-1377](https://linear.app/affine-design/issue/BS-1377). ### What changed? - Add `initDocFromProps` function to initialize the document with specific props. - Extract `docProps` from editor settings and pass it to `docsService.createDoc` function. <div class='graphite__hidden'> <div>🎥 Video uploaded on Graphite:</div> <a href="https://app.graphite.dev/media/video/sJGviKxfE3Ap685cl5bj/8082a8bd-ab3d-432c-9d3e-2f1d1a8398eb.mov"> <img src="https://app.graphite.dev/api/v1/graphite/video/thumbnail/sJGviKxfE3Ap685cl5bj/8082a8bd-ab3d-432c-9d3e-2f1d1a8398eb.mov"> </a> </div> <video src="https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/sJGviKxfE3Ap685cl5bj/8082a8bd-ab3d-432c-9d3e-2f1d1a8398eb.mov">录屏2024-09-18 16.13.43.mov</video>
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { track } from '@affine/track';
|
||||
import type { DocsService } from '@toeverything/infra';
|
||||
import { Text } from '@blocksuite/store';
|
||||
import type { DocProps, DocsService } from '@toeverything/infra';
|
||||
import { Service } from '@toeverything/infra';
|
||||
|
||||
import { EditorSettingService } from '../../editor-settting';
|
||||
import type { WorkbenchService } from '../../workbench';
|
||||
import { CollectionsQuickSearchSession } from '../impls/collections';
|
||||
import { CommandsQuickSearchSession } from '../impls/commands';
|
||||
@@ -92,16 +94,22 @@ export class CMDKQuickSearchService extends Service {
|
||||
}
|
||||
|
||||
if (result.source === 'creation') {
|
||||
const editorSettingService =
|
||||
this.framework.get(EditorSettingService);
|
||||
const docProps: DocProps = {
|
||||
page: { title: new Text(result.payload.title) },
|
||||
note: editorSettingService.editorSetting.get('affine:note'),
|
||||
};
|
||||
if (result.id === 'creation:create-page') {
|
||||
const newDoc = this.docsService.createDoc({
|
||||
primaryMode: 'page',
|
||||
title: result.payload.title,
|
||||
docProps,
|
||||
});
|
||||
this.workbenchService.workbench.openDoc(newDoc.id);
|
||||
} else if (result.id === 'creation:create-edgeless') {
|
||||
const newDoc = this.docsService.createDoc({
|
||||
primaryMode: 'edgeless',
|
||||
title: result.payload.title,
|
||||
docProps,
|
||||
});
|
||||
this.workbenchService.workbench.openDoc(newDoc.id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user