diff options
author | Vinicius Reis <vinicius.reis@nextcloud.com> | 2022-07-13 01:14:35 +0300 |
---|---|---|
committer | nextcloud-command <nextcloud-command@users.noreply.github.com> | 2022-07-13 15:39:18 +0300 |
commit | 4fb9dbdefdd6f87f7f0b3ab6a30769be003b45fe (patch) | |
tree | 37deee3f257726782255965a7a5ce75ea39e36d5 /src | |
parent | f2615c7ac988f8d5de4ed074be5c7d9f8213e09e (diff) |
⚡️ (#2387): remove events from $editor before destroy it
Signed-off-by: Vinicius Reis <vinicius.reis@nextcloud.com>
Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/components/EditorWrapper.vue | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/src/components/EditorWrapper.vue b/src/components/EditorWrapper.vue index c8f8085c3..831e59d1e 100644 --- a/src/components/EditorWrapper.vue +++ b/src/components/EditorWrapper.vue @@ -401,6 +401,15 @@ export default { this.forceRecreate = false }, + listenEditorEvents() { + this.$editor.on('focus', this.onFocus) + this.$editor.on('blur', this.onBlur) + }, + unlistenEditorEvents() { + this.$editor.off('focus', this.onFocus) + this.$editor.off('blur', this.onBlur) + }, + listenSyncServiceEvents() { this.$syncService .on('opened', this.onOpened) @@ -441,6 +450,7 @@ export default { const connect = () => { this.unlistenSyncServiceEvents() + this.unlistenEditorEvents() this.$syncService = null this.$editor.destroy() this.initSession() @@ -574,12 +584,9 @@ export default { ], enableRichEditing: this.isRichEditor, }) - this.$editor.on('focus', () => { - this.$emit('focus') - }) - this.$editor.on('blur', () => { - this.$emit('blur') - }) + + this.listenEditorEvents() + this.$syncService.state = this.$editor.state }) @@ -677,6 +684,12 @@ export default { this.$emit('sync-service:save') }) }, + onFocus() { + this.$emit('focus') + }, + onBlur() { + this.$emit('blur') + }, async close() { clearInterval(this.saveStatusPolling) @@ -690,6 +703,15 @@ export default { // Ignore issues closing the session since those might happen due to network issues } } + if (this.$editor) { + try { + this.unlistenEditorEvents() + this.$editor.destroy() + this.$editor = null + } catch (err) { + console.warn(err) + } + } return true }, }, |