mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-07 01:12:56 +08:00
This commit is contained in:
parent
8ed485ba53
commit
2436e2c8fe
@ -9,13 +9,18 @@ function useForceUpdate() {
|
||||
}
|
||||
|
||||
export const useEditor = (options: Partial<EditorOptions> = {}, deps: DependencyList = []) => {
|
||||
const [editor, setEditor] = useState<Editor | null>(null)
|
||||
const [editor, setEditor] = useState<Editor>(() => new Editor(options))
|
||||
const forceUpdate = useForceUpdate()
|
||||
|
||||
useEffect(() => {
|
||||
const instance = new Editor(options)
|
||||
let instance: Editor
|
||||
|
||||
setEditor(instance)
|
||||
if (editor.isDestroyed) {
|
||||
instance = new Editor(options)
|
||||
setEditor(instance)
|
||||
} else {
|
||||
instance = editor
|
||||
}
|
||||
|
||||
instance.on('transaction', () => {
|
||||
requestAnimationFrame(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user