mirror of
https://github.com/heyman/heynote.git
synced 2025-06-28 05:21:48 +02:00
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:
parent
813522cc0e
commit
ae4d86b9f3
@ -133,12 +133,6 @@
|
|||||||
return
|
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) {
|
if (this.filteredItems.length === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -65,9 +65,13 @@
|
|||||||
window.heynote.mainProcess.on(DELETE_BLOCK_EVENT, this.onDeleteBlock)
|
window.heynote.mainProcess.on(DELETE_BLOCK_EVENT, this.onDeleteBlock)
|
||||||
|
|
||||||
this.onSelectAll = () => {
|
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
|
// make sure the editor is focused
|
||||||
if (this.$refs.editor.contains(document.activeElement)) {
|
if (this.$refs.editor.contains(activeEl)) {
|
||||||
toRaw(this.editor).selectAll()
|
toRaw(this.editor).selectAll()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,12 +50,6 @@
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onKeydown(event) {
|
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") {
|
if (event.key === "ArrowDown") {
|
||||||
this.selected = Math.min(this.selected + 1, this.filteredItems.length - 1)
|
this.selected = Math.min(this.selected + 1, this.filteredItems.length - 1)
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user