mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-17 10:06:17 +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,8 +1,8 @@
|
||||
import { Unreachable } from '@affine/env/constant';
|
||||
import type { DocMode } from '@blocksuite/blocks';
|
||||
import { type DocMode } from '@blocksuite/blocks';
|
||||
|
||||
import { Service } from '../../../framework';
|
||||
import { initEmptyPage } from '../../../initialization';
|
||||
import { type DocProps, initDocFromProps } from '../../../initialization';
|
||||
import { ObjectPool } from '../../../utils';
|
||||
import type { Doc } from '../entities/doc';
|
||||
import { DocRecordList } from '../entities/record-list';
|
||||
@@ -54,11 +54,11 @@ export class DocsService extends Service {
|
||||
createDoc(
|
||||
options: {
|
||||
primaryMode?: DocMode;
|
||||
title?: string;
|
||||
docProps?: DocProps;
|
||||
} = {}
|
||||
) {
|
||||
const doc = this.store.createBlockSuiteDoc();
|
||||
initEmptyPage(doc, options.title);
|
||||
initDocFromProps(doc, options.docProps);
|
||||
this.store.markDocSyncStateAsReady(doc.id);
|
||||
const docRecord = this.list.doc$(doc.id).value;
|
||||
if (!docRecord) {
|
||||
|
||||
Reference in New Issue
Block a user