CTRL/CMD + ENTER to Save Changes on Card Description - fixes nextcloud/deck#3268

Signed-off-by: ben <ben@ro.tt>
This commit is contained in:
ben
2022-04-30 23:17:49 +02:00
committed by Julius Härtl
parent d93b431554
commit f01a4433ed

View File

@@ -115,6 +115,7 @@ export default {
}, },
data() { data() {
return { return {
keyExitState: 0,
description: '', description: '',
markdownIt: null, markdownIt: null,
descriptionEditing: false, descriptionEditing: false,
@@ -180,8 +181,33 @@ export default {
} }
this.descriptionEditing = true this.descriptionEditing = true
this.description = this.card.description 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() { hideEditor() {
this.$refs.markdownEditor.easymde.codemirror.off('keydown', undefined)
this.$refs.markdownEditor.easymde.codemirror.off('keyup', undefined)
this.descriptionEditing = false this.descriptionEditing = false
}, },
showAttachmentModal() { showAttachmentModal() {