This reverts commit 2436e2c8fe.
This commit is contained in:
@@ -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(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user