mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-07 17:43:49 +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 = []) => {
|
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()
|
const forceUpdate = useForceUpdate()
|
||||||
|
|
||||||
useEffect(() => {
|
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', () => {
|
instance.on('transaction', () => {
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user