fix: prevent bug when editor is destroyed very fast

This commit is contained in:
Philipp Kühn 2021-05-28 12:14:12 +02:00
parent 5858871ca8
commit 939fc3d93a
3 changed files with 12 additions and 1 deletions

View File

@ -87,10 +87,13 @@ export class Editor extends EventEmitter {
this.on('destroy', this.options.onDestroy)
window.setTimeout(() => {
if (this.isDestroyed) {
return
}
this.commands.focus(this.options.autofocus)
this.emit('create', { editor: this })
}, 0)
}
/**

View File

@ -48,6 +48,10 @@ export const EditorContent: Component = {
beforeDestroy(this: EditorContentInterface) {
const { editor } = this
if (!editor) {
return
}
if (!editor.isDestroyed) {
editor.view.setProps({
nodeViews: {},

View File

@ -56,6 +56,10 @@ export const EditorContent = defineComponent({
onBeforeUnmount(() => {
const editor = props.editor
if (!editor) {
return
}
// destroy nodeviews before vue removes dom element
if (!editor.isDestroyed) {
editor.view.setProps({