chore(editor): move helper to playground (#9498)
This commit is contained in:
21
blocksuite/playground/apps/_common/helper.ts
Normal file
21
blocksuite/playground/apps/_common/helper.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { AffineSchemas } from '@blocksuite/blocks';
|
||||
import { DocCollection, Schema } from '@blocksuite/store';
|
||||
|
||||
export function createEmptyDoc() {
|
||||
const schema = new Schema().register(AffineSchemas);
|
||||
const collection = new DocCollection({ schema });
|
||||
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;
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
import '../../../style.css';
|
||||
|
||||
import { createEmptyDoc, EdgelessEditor } from '@blocksuite/presets';
|
||||
import { EdgelessEditor } from '@blocksuite/presets';
|
||||
|
||||
import { createEmptyDoc } from '../../../apps/_common/helper';
|
||||
|
||||
const doc = createEmptyDoc().init();
|
||||
const editor = new EdgelessEditor();
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import '../../../style.css';
|
||||
|
||||
import { createEmptyDoc, PageEditor } from '@blocksuite/presets';
|
||||
import { PageEditor } from '@blocksuite/presets';
|
||||
import { Text } from '@blocksuite/store';
|
||||
|
||||
import { createEmptyDoc } from '../../../apps/_common/helper';
|
||||
|
||||
const doc = createEmptyDoc().init();
|
||||
const editor = new PageEditor();
|
||||
editor.doc = doc;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import '../../../style.css';
|
||||
|
||||
import { createEmptyDoc, EdgelessEditor } from '@blocksuite/presets';
|
||||
import { EdgelessEditor } from '@blocksuite/presets';
|
||||
|
||||
import { createEmptyDoc } from '../../../apps/_common/helper';
|
||||
|
||||
const container = document.createElement('div');
|
||||
container.style.display = 'flex';
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import '../../../style.css';
|
||||
|
||||
import {
|
||||
createEmptyDoc,
|
||||
EdgelessEditor,
|
||||
PageEditor,
|
||||
} from '@blocksuite/presets';
|
||||
import { EdgelessEditor, PageEditor } from '@blocksuite/presets';
|
||||
|
||||
import { createEmptyDoc } from '../../../apps/_common/helper';
|
||||
|
||||
const container = document.createElement('div');
|
||||
container.style.display = 'flex';
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import '../../../style.css';
|
||||
|
||||
import { createEmptyDoc, PageEditor } from '@blocksuite/presets';
|
||||
import { PageEditor } from '@blocksuite/presets';
|
||||
|
||||
import { createEmptyDoc } from '../../../apps/_common/helper';
|
||||
|
||||
const container = document.createElement('div');
|
||||
container.style.display = 'flex';
|
||||
|
||||
Reference in New Issue
Block a user