diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..884a2323e --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +**/dist/** diff --git a/.eslintrc.js b/.eslintrc.js index b0b56cb7f..de47e9861 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -14,9 +14,6 @@ module.exports = { './**/*.js', './**/*.vue', ], - excludedFiles: [ - 'dist/**', - ], plugins: [ 'html', 'cypress', diff --git a/packages/core/src/Editor.ts b/packages/core/src/Editor.ts index b474ac8b5..2be9f5170 100644 --- a/packages/core/src/Editor.ts +++ b/packages/core/src/Editor.ts @@ -159,7 +159,7 @@ export class Editor extends EventEmitter { public setOptions(options: Partial = {}) { this.options = { ...this.options, ...options } - if (this.view && this.state) { + if (this.view && this.state && !this.isDestroyed) { this.view.updateState(this.state) } } @@ -399,4 +399,12 @@ export class Editor extends EventEmitter { removeElement(this.css) } + /** + * Check if the editor is already destroyed. + */ + private get isDestroyed() { + // @ts-ignore + return !this.view?.docView + } + } diff --git a/packages/vue/src/components/EditorContent.ts b/packages/vue/src/components/EditorContent.ts index ae7642cb9..35c873bd6 100644 --- a/packages/vue/src/components/EditorContent.ts +++ b/packages/vue/src/components/EditorContent.ts @@ -27,6 +27,8 @@ export default Vue.extend({ }, beforeDestroy() { - this.editor.options.element = this.$el + this.editor.setOptions({ + element: this.$el, + }) }, })