fix: prevent bug when editor is destroyed very fast
This commit is contained in:
@@ -87,10 +87,13 @@ export class Editor extends EventEmitter {
|
|||||||
this.on('destroy', this.options.onDestroy)
|
this.on('destroy', this.options.onDestroy)
|
||||||
|
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
|
if (this.isDestroyed) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
this.commands.focus(this.options.autofocus)
|
this.commands.focus(this.options.autofocus)
|
||||||
this.emit('create', { editor: this })
|
this.emit('create', { editor: this })
|
||||||
}, 0)
|
}, 0)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -48,6 +48,10 @@ export const EditorContent: Component = {
|
|||||||
beforeDestroy(this: EditorContentInterface) {
|
beforeDestroy(this: EditorContentInterface) {
|
||||||
const { editor } = this
|
const { editor } = this
|
||||||
|
|
||||||
|
if (!editor) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (!editor.isDestroyed) {
|
if (!editor.isDestroyed) {
|
||||||
editor.view.setProps({
|
editor.view.setProps({
|
||||||
nodeViews: {},
|
nodeViews: {},
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ export const EditorContent = defineComponent({
|
|||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
const editor = props.editor
|
const editor = props.editor
|
||||||
|
|
||||||
|
if (!editor) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// destroy nodeviews before vue removes dom element
|
// destroy nodeviews before vue removes dom element
|
||||||
if (!editor.isDestroyed) {
|
if (!editor.isDestroyed) {
|
||||||
editor.view.setProps({
|
editor.view.setProps({
|
||||||
|
|||||||
Reference in New Issue
Block a user