Improve the way we handle SelectAll events (from the Menu shortcuts) when a text input (and not the editor) has focus

This commit is contained in:
Jonatan Heyman 2025-04-10 19:34:26 +02:00
parent 813522cc0e
commit ae4d86b9f3
3 changed files with 6 additions and 14 deletions

View File

@ -133,12 +133,6 @@
return
}
// support Ctrl/Cmd+A to select all
if (event.key === "a" && event[window.heynote.platform.isMac ? "metaKey" : "ctrlKey"]) {
event.preventDefault()
event.srcElement.select()
}
if (this.filteredItems.length === 0) {
return
}

View File

@ -65,9 +65,13 @@
window.heynote.mainProcess.on(DELETE_BLOCK_EVENT, this.onDeleteBlock)
this.onSelectAll = () => {
if (this.editor) {
const activeEl = document.activeElement
if (activeEl && activeEl.tagName === "INPUT") {
// if the active element is an input, select all text in it
activeEl.select()
} else if (this.editor) {
// make sure the editor is focused
if (this.$refs.editor.contains(document.activeElement)) {
if (this.$refs.editor.contains(activeEl)) {
toRaw(this.editor).selectAll()
}
}

View File

@ -50,12 +50,6 @@
methods: {
onKeydown(event) {
// support Ctrl/Cmd+A to select all
if (event.key === "a" && event[window.heynote.platform.isMac ? "metaKey" : "ctrlKey"]) {
event.preventDefault()
event.srcElement.select()
}
if (event.key === "ArrowDown") {
this.selected = Math.min(this.selected + 1, this.filteredItems.length - 1)
event.preventDefault()