|
|
|
@ -61,9 +61,12 @@ onMounted(() => {
|
|
|
|
|
|
|
|
|
|
preconnect()
|
|
|
|
|
|
|
|
|
|
const handleSearchHotKey = (e: KeyboardEvent) => {
|
|
|
|
|
if (e.key === 'k' && (e.ctrlKey || e.metaKey)) {
|
|
|
|
|
e.preventDefault()
|
|
|
|
|
const handleSearchHotKey = (event: KeyboardEvent) => {
|
|
|
|
|
if (
|
|
|
|
|
(event.key.toLowerCase() === 'k' && (event.metaKey || event.ctrlKey)) ||
|
|
|
|
|
(!isEditingContent(event) && event.key === '/')
|
|
|
|
|
) {
|
|
|
|
|
event.preventDefault()
|
|
|
|
|
load()
|
|
|
|
|
remove()
|
|
|
|
|
}
|
|
|
|
@ -101,6 +104,18 @@ function poll() {
|
|
|
|
|
}, 16)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function isEditingContent(event: KeyboardEvent): boolean {
|
|
|
|
|
const element = event.target as HTMLElement
|
|
|
|
|
const tagName = element.tagName
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
element.isContentEditable ||
|
|
|
|
|
tagName === 'INPUT' ||
|
|
|
|
|
tagName === 'SELECT' ||
|
|
|
|
|
tagName === 'TEXTAREA'
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Local search
|
|
|
|
|
|
|
|
|
|
const showSearch = ref(false)
|
|
|
|
@ -112,6 +127,13 @@ if (__VP_LOCAL_SEARCH__) {
|
|
|
|
|
showSearch.value = true
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
onKeyStroke('/', (event) => {
|
|
|
|
|
if (!isEditingContent(event)) {
|
|
|
|
|
event.preventDefault()
|
|
|
|
|
showSearch.value = true
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const metaKey = ref(`'Meta'`)
|
|
|
|
|