diff options
author | Julius Härtl <jus@bitgrid.net> | 2022-10-19 22:49:40 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-19 22:49:40 +0300 |
commit | 60ee9f77caa1711c88f3e7b349d7881a098d518f (patch) | |
tree | f3b184b306a5caa56c73eaa439384838c2b09f08 | |
parent | 3eaba6fe1a60d8f144f3ca0385746b0090419c67 (diff) | |
parent | 3af54d7186a74550debb05792115dc28a687c733 (diff) |
Merge pull request #3774 from Ben-Ro/CTRL/CMD_+_ENTER_to_Save_Changes_on_Card_Description
feat: #3268 CTRL/CMD + ENTER to Save Changes on Card Description
-rw-r--r-- | src/components/card/Description.vue | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/components/card/Description.vue b/src/components/card/Description.vue index 3d05db44..a4089559 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" /> @@ -115,6 +116,7 @@ export default { }, data() { return { + keyExitState: 0, description: '', markdownIt: null, descriptionEditing: false, @@ -174,14 +176,37 @@ 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 } this.descriptionEditing = true this.description = this.card.description + }, hideEditor() { + this.$refs.markdownEditor.easymde.codemirror.off('keydown', undefined) + this.$refs.markdownEditor.easymde.codemirror.off('keyup', undefined) this.descriptionEditing = false }, showAttachmentModal() { |