feat: update blocksuit & adpat it
This commit is contained in:
@@ -90,11 +90,11 @@ export const Header = () => {
|
||||
useEffect(() => {
|
||||
setTimeout(() => {
|
||||
const editor = window.editor;
|
||||
setTitle(editor.model.title);
|
||||
setTitle(editor.model.title || '');
|
||||
editor.model.propsUpdated.on(() => {
|
||||
setTitle(editor.model.title);
|
||||
});
|
||||
}, 1000);
|
||||
}, 500);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { Suspense, useEffect, useRef } from 'react';
|
||||
import type { EditorContainer } from '@blocksuite/editor';
|
||||
import { Text } from '@blocksuite/store';
|
||||
import '@blocksuite/blocks';
|
||||
import '@blocksuite/editor';
|
||||
import '@blocksuite/blocks/style';
|
||||
@@ -8,9 +10,29 @@ declare global {
|
||||
editor: EditorContainer;
|
||||
}
|
||||
}
|
||||
|
||||
export const Editor = () => {
|
||||
return <editor-container />;
|
||||
const editorRef = useRef<EditorContainer>();
|
||||
|
||||
useEffect(() => {
|
||||
const { store } = editorRef.current as EditorContainer;
|
||||
|
||||
const pageId = store.addBlock({
|
||||
flavour: 'page',
|
||||
title: 'Blocksuite live demo',
|
||||
});
|
||||
const groupId = store.addBlock({ flavour: 'group' }, pageId);
|
||||
|
||||
const text = new Text('Legend from here ...');
|
||||
store.addBlock({ flavour: 'paragraph', text }, groupId);
|
||||
|
||||
// store._history.clear();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Suspense fallback={<div>Error!</div>}>
|
||||
<editor-container ref={editorRef} />
|
||||
</Suspense>
|
||||
);
|
||||
};
|
||||
|
||||
declare global {
|
||||
|
||||
Reference in New Issue
Block a user