mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
25 lines
767 B
TypeScript
25 lines
767 B
TypeScript
import { AffineSchemas, SpecProvider } from '@blocksuite/blocks';
|
|
import { Schema } from '@blocksuite/store';
|
|
import { TestWorkspace } from '@blocksuite/store/test';
|
|
|
|
export function createEmptyDoc() {
|
|
const schema = new Schema().register(AffineSchemas);
|
|
const collection = new TestWorkspace({ schema });
|
|
collection.storeExtensions =
|
|
SpecProvider.getInstance().getSpec('store').value;
|
|
collection.meta.initialize();
|
|
const doc = collection.createDoc();
|
|
|
|
return {
|
|
doc,
|
|
init() {
|
|
doc.load();
|
|
const rootId = doc.addBlock('affine:page', {});
|
|
doc.addBlock('affine:surface', {}, rootId);
|
|
const noteId = doc.addBlock('affine:note', {}, rootId);
|
|
doc.addBlock('affine:paragraph', {}, noteId);
|
|
return doc;
|
|
},
|
|
};
|
|
}
|