From 93a29c613c0e831aa979b9627b7c9d574a39b7d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Wed, 30 Sep 2020 22:43:58 +0200 Subject: [PATCH] fix lint error --- .eslintignore | 1 + .eslintrc.js | 3 --- packages/core/src/Editor.ts | 10 +++++++++- packages/vue/src/components/EditorContent.ts | 4 +++- 4 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 .eslintignore 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, + }) }, })