|
|
|
@ -9,6 +9,7 @@ import {
|
|
|
|
|
useScrollLock,
|
|
|
|
|
useSessionStorage
|
|
|
|
|
} from '@vueuse/core'
|
|
|
|
|
import { useFocusTrap } from '@vueuse/integrations/useFocusTrap'
|
|
|
|
|
import Mark from 'mark.js/src/vanilla.js'
|
|
|
|
|
import MiniSearch, { type SearchResult } from 'minisearch'
|
|
|
|
|
import { useRouter } from 'vitepress'
|
|
|
|
@ -26,11 +27,11 @@ import {
|
|
|
|
|
type Ref
|
|
|
|
|
} from 'vue'
|
|
|
|
|
import type { ModalTranslations } from '../../../../types/local-search'
|
|
|
|
|
import { dataSymbol } from '../../app/data'
|
|
|
|
|
import { pathToFile } from '../../app/utils'
|
|
|
|
|
import { slash } from '../../shared'
|
|
|
|
|
import { useData } from '../composables/data'
|
|
|
|
|
import { createTranslate } from '../support/translation'
|
|
|
|
|
import { dataSymbol } from '../../app/data'
|
|
|
|
|
|
|
|
|
|
defineProps<{
|
|
|
|
|
placeholder: string
|
|
|
|
@ -64,6 +65,12 @@ interface Result {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const vitePressData = useData()
|
|
|
|
|
const { activate } = useFocusTrap(el, {
|
|
|
|
|
immediate: true,
|
|
|
|
|
allowOutsideClick: true,
|
|
|
|
|
clickOutsideDeactivates: true,
|
|
|
|
|
escapeDeactivates: true
|
|
|
|
|
})
|
|
|
|
|
const { localeIndex, theme } = vitePressData
|
|
|
|
|
const searchIndex = computedAsync(async () =>
|
|
|
|
|
markRaw(
|
|
|
|
@ -84,14 +91,14 @@ const searchIndex = computedAsync(async () =>
|
|
|
|
|
|
|
|
|
|
const disableQueryPersistence = computed(() => {
|
|
|
|
|
return (
|
|
|
|
|
theme.value.search?.provider === 'local' &&
|
|
|
|
|
theme.value.search.options?.disableQueryPersistence === true
|
|
|
|
|
theme.value.search?.provider === 'local' &&
|
|
|
|
|
theme.value.search.options?.disableQueryPersistence === true
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const filterText = disableQueryPersistence.value
|
|
|
|
|
? ref('')
|
|
|
|
|
: useSessionStorage('vitepress:local-search-filter', '')
|
|
|
|
|
? ref('')
|
|
|
|
|
: useSessionStorage('vitepress:local-search-filter', '')
|
|
|
|
|
|
|
|
|
|
const showDetailedList = useLocalStorage(
|
|
|
|
|
'vitepress:local-search-detailed-list',
|
|
|
|
@ -334,6 +341,7 @@ onMounted(() => {
|
|
|
|
|
body.value = document.body
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
isLocked.value = true
|
|
|
|
|
nextTick().then(() => activate())
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
@ -474,6 +482,7 @@ function formMarkRegex(terms: Set<string>) {
|
|
|
|
|
}"
|
|
|
|
|
:aria-label="[...p.titles, p.title].join(' > ')"
|
|
|
|
|
@mouseenter="!disableMouseOver && (selectedIndex = index)"
|
|
|
|
|
@focusin="selectedIndex = index"
|
|
|
|
|
@click="$emit('close')"
|
|
|
|
|
>
|
|
|
|
|
<div>
|
|
|
|
@ -498,7 +507,7 @@ function formMarkRegex(terms: Set<string>) {
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div v-if="showDetailedList" class="excerpt-wrapper">
|
|
|
|
|
<div v-if="p.text" class="excerpt">
|
|
|
|
|
<div v-if="p.text" class="excerpt" inert>
|
|
|
|
|
<div class="vp-doc" v-html="p.text" />
|
|
|
|
|
</div>
|
|
|
|
|
<div class="excerpt-gradient-bottom" />
|
|
|
|
@ -727,6 +736,7 @@ function formMarkRegex(terms: Set<string>) {
|
|
|
|
|
transition: none;
|
|
|
|
|
line-height: 1rem;
|
|
|
|
|
border: solid 2px var(--vp-local-search-result-border);
|
|
|
|
|
outline: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.result > div {
|
|
|
|
|