diff --git a/src/components/card/Description.vue b/src/components/card/Description.vue index 951327623..a40895595 100644 --- a/src/components/card/Description.vue +++ b/src/components/card/Description.vue @@ -60,6 +60,7 @@ ref="markdownEditor" v-model="description" :configs="mdeConfig" + @initialized="addKeyListeners" @update:modelValue="updateDescription" @blur="saveDescription" /> @@ -175,6 +176,26 @@ export default { }, }, methods: { + addKeyListeners() { + this.$refs.markdownEditor.easymde.codemirror.on('keydown', (a, b) => { + + if (this.keyExitState === 0 && (b.key === 'Meta' || b.key === 'Alt')) { + this.keyExitState = 1 + } + if (this.keyExitState === 1 && b.key === 'Enter') { + this.keyExitState = 0 + this.$refs.markdownEditor.easymde.codemirror.off('keydown', undefined) + this.$refs.markdownEditor.easymde.codemirror.off('keyup', undefined) + this.hideEditor() + } + }) + this.$refs.markdownEditor.easymde.codemirror.on('keyup', (a, b) => { + if (b.key === 'Meta' || b.key === 'Control') { + this.keyExitState = 0 + } + + }) + }, showEditor() { if (!this.canEdit) { return @@ -182,28 +203,6 @@ export default { this.descriptionEditing = true this.description = this.card.description - // Has to start after the Editor is fully loaded. This shouldn't take longer than 1/4 second - setTimeout(() => { - this.$refs.markdownEditor.easymde.codemirror.on('keydown', (a, b) => { - - if (this.keyExitState === 0 && (b.key === 'Meta' || b.key === 'Alt')) { - this.keyExitState = 1 - } - if (this.keyExitState === 1 && b.key === 'Enter') { - this.keyExitState = 0 - this.$refs.markdownEditor.easymde.codemirror.off('keydown', undefined) - this.$refs.markdownEditor.easymde.codemirror.off('keyup', undefined) - this.hideEditor() - } - }) - this.$refs.markdownEditor.easymde.codemirror.on('keyup', (a, b) => { - if (b.key === 'Meta' || b.key === 'Control') { - this.keyExitState = 0 - } - - }) - }, 250) - }, hideEditor() { this.$refs.markdownEditor.easymde.codemirror.off('keydown', undefined)