valaxy-theme-press 0.24.4 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,10 +1,51 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { useAddonAlgolia } from 'valaxy-addon-algolia'
|
|
3
|
+
import { onMounted, onUnmounted } from 'vue'
|
|
3
4
|
import { useI18n } from 'vue-i18n'
|
|
4
5
|
|
|
5
6
|
const { t } = useI18n()
|
|
6
7
|
|
|
7
|
-
const { loaded, load } = useAddonAlgolia()
|
|
8
|
+
const { loaded, load, dispatchEvent } = useAddonAlgolia()
|
|
9
|
+
|
|
10
|
+
defineExpose({
|
|
11
|
+
loaded,
|
|
12
|
+
load,
|
|
13
|
+
dispatchEvent,
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
function isEditingContent(event: KeyboardEvent): boolean {
|
|
17
|
+
const element = event.target as HTMLElement
|
|
18
|
+
const tagName = element.tagName
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
element.isContentEditable
|
|
22
|
+
|| tagName === 'INPUT'
|
|
23
|
+
|| tagName === 'SELECT'
|
|
24
|
+
|| tagName === 'TEXTAREA'
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
onMounted(() => {
|
|
29
|
+
const handleSearchHotKey = (event: KeyboardEvent) => {
|
|
30
|
+
if (
|
|
31
|
+
(event.key?.toLowerCase() === 'k' && (event.metaKey || event.ctrlKey))
|
|
32
|
+
|| (!isEditingContent(event) && event.key === '/')
|
|
33
|
+
) {
|
|
34
|
+
event.preventDefault()
|
|
35
|
+
load()
|
|
36
|
+
// eslint-disable-next-line ts/no-use-before-define
|
|
37
|
+
remove()
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const remove = () => {
|
|
42
|
+
window.removeEventListener('keydown', handleSearchHotKey)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
window.addEventListener('keydown', handleSearchHotKey)
|
|
46
|
+
|
|
47
|
+
onUnmounted(remove)
|
|
48
|
+
})
|
|
8
49
|
</script>
|
|
9
50
|
|
|
10
51
|
<template>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "valaxy-theme-press",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"description": "Docs Theme for Valaxy",
|
|
5
5
|
"author": {
|
|
6
6
|
"email": "me@yunyoujun.cn",
|
|
@@ -26,6 +26,6 @@
|
|
|
26
26
|
"@docsearch/js": "^3.9.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"valaxy": "0.
|
|
29
|
+
"valaxy": "0.25.0"
|
|
30
30
|
}
|
|
31
31
|
}
|