Skip to content

Commit

Permalink
Key control: confirm with <Enter> or <Tab>, abort with <Esc>
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas Meurer <jonas@freesources.org>
  • Loading branch information
mejo- committed Nov 24, 2021
1 parent 014c22b commit 9e3acdd
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/components/EditorWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,7 @@ export default {
},
// Is called when an emoji suggestion is canceled
onExit: () => {
// Reset all saved values
this.emojiQuery = null
this.filteredEmojis = []
this.emojiRange = null
this.navigatedEmojiIndex = 0
this.emojiRect = null
this.resetEmoji()
},
// Is called on every keyDown event while an emoji suggestion is active
onKeyDown: ({ event }) => {
Expand All @@ -418,11 +413,14 @@ export default {
this.navigatedEmojiIndex = (this.navigatedEmojiIndex + 1) % this.filteredEmojis.length
return true
}
if (event.key === 'Enter') {
if (event.key === 'Enter' || event.key === 'Tab') {
const emojiObject = this.filteredEmojis[this.navigatedEmojiIndex]
this.selectEmoji(emojiObject)
return true
}
if (event.key === 'Escape') {
this.resetEmoji()
}
return false
},
}),
Expand Down Expand Up @@ -595,6 +593,15 @@ export default {
})
this.tiptap.focus()
},
resetEmoji() {
// Reset all saved values
this.emojiQuery = null
this.filteredEmojis = []
this.emojiRange = null
this.navigatedEmojiIndex = 0
this.emojiRect = null
},
},
}
</script>
Expand Down

0 comments on commit 9e3acdd

Please sign in to comment.