feat: add default content

This commit is contained in:
QiShaoXuan
2022-10-24 16:03:01 +08:00
parent f30657f9e1
commit ca0a216795
2 changed files with 72 additions and 7 deletions
+10 -7
View File
@@ -6,26 +6,29 @@ import '@blocksuite/editor';
import '@blocksuite/blocks/style';
import { useEditor } from '@/components/editor-provider';
import pkg from '../../package.json';
import exampleMarkdown from './example-markdown';
export const Editor = () => {
const editorRef = useRef<EditorContainer>();
const { setEditor } = useEditor();
useEffect(() => {
setEditor(editorRef.current!);
const { store } = editorRef.current as EditorContainer;
const version = pkg.dependencies['@blocksuite/editor'].substring(1);
const pageId = store.addBlock({
flavour: 'page',
title: `BlockSuite live demo ${version}`,
title: 'Welcome to the AFFiNE Alpha',
});
const groupId = store.addBlock({ flavour: 'group' }, pageId);
const text = new Text(store, 'Legend from here...');
store.addBlock({ flavour: 'paragraph', text }, groupId);
// const text = new Text(store, 'Legend from here...');
// store.addBlock({ flavour: 'paragraph', text }, groupId);
editorRef.current!.clipboard.importMarkdown(exampleMarkdown, `${groupId}`);
store.resetHistory();
}, [setEditor]);
useEffect(() => {
const version = pkg.dependencies['@blocksuite/editor'].substring(1);
console.log(`BlockSuite live demo ${version}`);
}, []);
return (
<Suspense fallback={<div>Error!</div>}>
<editor-container ref={editorRef} />