Revert "fix: Make sure editor is available on first render (#2282), fix #2040, fix #2182"

This reverts commit 2436e2c8fe.
This commit is contained in:
Philipp Kühn
2021-12-17 09:42:22 +01:00
parent 07cabe65f4
commit 629f4d2a76

View File

@@ -9,18 +9,13 @@ function useForceUpdate() {
} }
export const useEditor = (options: Partial<EditorOptions> = {}, deps: DependencyList = []) => { export const useEditor = (options: Partial<EditorOptions> = {}, deps: DependencyList = []) => {
const [editor, setEditor] = useState<Editor>(() => new Editor(options)) const [editor, setEditor] = useState<Editor | null>(null)
const forceUpdate = useForceUpdate() const forceUpdate = useForceUpdate()
useEffect(() => { useEffect(() => {
let instance: Editor const instance = new Editor(options)
if (editor.isDestroyed) { setEditor(instance)
instance = new Editor(options)
setEditor(instance)
} else {
instance = editor
}
instance.on('transaction', () => { instance.on('transaction', () => {
requestAnimationFrame(() => { requestAnimationFrame(() => {