Commit 1f2dfae5f9

1f2dfae5f968c0e733bcc87e35741e3033cf18a0

parent: a2544f1719

Unsigned

Duck <57977673+woducku@users.noreply.github.com> · 2026-06-03 15:21 UTC

ash again

https://youtu.be/twUFbqyul_M

Layout: unified · split

docs/.vitepress/configs/index.ts +2 −1
@@ -17,7 +17,7 @@ import { hostname, sidebar, siteConfig } from './constants'
17import { generateImages, generateMeta } from './hooks' 17import { generateImages, generateMeta } from './hooks'
18import { configureMarkdown } from './markdown' 18import { configureMarkdown } from './markdown'
19import { aliases, defs, movePlugin } from './markdown/emoji' 19import { aliases, defs, movePlugin } from './markdown/emoji'
20import { collectPageLinks, writeUrlSearchIndex } from '../plugins/urlSearchPlugin' 20import { collectPageLinks, urlSearchDevPlugin, writeUrlSearchIndex } from '../plugins/urlSearchPlugin'
21 21
22const GIT_COMMIT = process.env.NODE_ENV === 'development' 22const GIT_COMMIT = process.env.NODE_ENV === 'development'
23 ? 'dev' 23 ? 'dev'
@@ -107,6 +107,7 @@ export const shared: UserConfig<DefaultTheme.Config> = {
107 ] 107 ]
108 }, 108 },
109 plugins: [ 109 plugins: [
110 urlSearchDevPlugin(),
110 Devtools(), 111 Devtools(),
111 PageProperties(), 112 PageProperties(),
112 PagePropertiesMarkdownSection(), 113 PagePropertiesMarkdownSection(),
docs/.vitepress/plugins/urlSearchPlugin.ts +19
@@ -94,4 +94,23 @@ export function writeUrlSearchIndex(outDir: string) {
94 const outPath = join(outDir, 'url-search-index.json') 94 const outPath = join(outDir, 'url-search-index.json')
95 writeFileSync(outPath, JSON.stringify(deduped), 'utf-8') 95 writeFileSync(outPath, JSON.stringify(deduped), 'utf-8')
96 console.log(`[url-search] wrote ${deduped.length} links → ${outPath}`) 96 console.log(`[url-search] wrote ${deduped.length} links → ${outPath}`)
97}
98
99export function urlSearchDevPlugin() {
100 return {
101 name: 'url-search-dev',
102 configureServer(server: any) {
103 server.middlewares.use('/url-search-index.json', (_req: any, res: any) => {
104 const seen = new Set<string>()
105 const deduped = collected.filter((l) => {
106 const key = l.href + '\x00' + l.pageId + '\x00' + l.anchor
107 if (seen.has(key)) return false
108 seen.add(key)
109 return true
110 })
111 res.setHeader('Content-Type', 'application/json')
112 res.end(JSON.stringify(deduped))
113 })
114 }
115 }
97}\ No newline at end of file 116}\ No newline at end of file
docs/.vitepress/theme/components/Search.vue +640 −335
@@ -22,7 +22,6 @@ import { escapeRegExp } from 'vitepress/dist/client/shared'
22import { 22import {
23 computedAsync, 23 computedAsync,
24 onKeyStroke, 24 onKeyStroke,
25 refDebounced,
26 useEventListener, 25 useEventListener,
27 useLocalStorage, 26 useLocalStorage,
28 useScrollLock, 27 useScrollLock,
@@ -140,7 +139,19 @@ const filterText = disableQueryPersistence.value
140 ? ref('') 139 ? ref('')
141 : useSessionStorage('vitepress:local-search-filter', '') 140 : useSessionStorage('vitepress:local-search-filter', '')
142 141
143const debouncedFilterText = refDebounced(filterText, 300) 142const urlFilterDebounced = ref(filterText.value)
143let urlDebounceTimer: ReturnType<typeof setTimeout> | undefined
144watch(filterText, (v) => {
145 clearTimeout(urlDebounceTimer)
146 if (!v) {
147 urlFilterDebounced.value = '' // instant clear, no trailing-edge delay
148 return
149 }
150 urlDebounceTimer = setTimeout(() => {
151 urlFilterDebounced.value = v
152 }, 60)
153})
154onBeforeUnmount(() => clearTimeout(urlDebounceTimer))
144 155
145const showDetailedList = useLocalStorage( 156const showDetailedList = useLocalStorage(
146 'vitepress:local-search-detailed-list', 157 'vitepress:local-search-detailed-list',
@@ -196,18 +207,22 @@ interface UrlResult {
196 highlighted: string 207 highlighted: string
197} 208}
198 209
199const urlResults = computed((): UrlResult[] => { 210const URL_PAGE_SIZE = 50
200 if (!urlSearchMode.value || !debouncedFilterText.value.trim()) return [] 211
201 const query = debouncedFilterText.value.trim().toLowerCase() 212// 1-indexed current page within the URL results.
202 const escaped = query.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') 213const urlPage = ref(1)
203 const regex = new RegExp(`(${escaped})`, 'gi') 214
204 // allLinks is pre-sorted by page order — no sort needed here 215// Full match set — cheap string filtering only (no regex, no object churn).
205 return allLinks.value 216// Used for accurate page-group counts in the ribbon and for pagination.
206 .filter(({ href }) => href.toLowerCase().includes(query)) 217const urlMatches = computed((): PageLink[] => {
207 .map(({ href, linkText, pageId, anchor, titles }) => ({ 218 if (!urlSearchMode.value || !filterText.value.trim()) return []
208 href, linkText, pageId, anchor, titles, 219 const query = urlFilterDebounced.value.trim().toLowerCase()
209 highlighted: href.replace(regex, '<mark class="url-highlight">$1</mark>') 220 if (!query) return []
210 })) 221 const out: PageLink[] = []
222 for (const link of allLinks.value) {
223 if (link.href.toLowerCase().includes(query)) out.push(link)
224 }
225 return out
211}) 226})
212 227
213// URL mode page ribbon — mirrors the normal pageGroups/filteredResults logic 228// URL mode page ribbon — mirrors the normal pageGroups/filteredResults logic
@@ -215,7 +230,7 @@ const urlActivePageFilter = ref<string | null>(null)
215 230
216const urlPageGroups = computed(() => { 231const urlPageGroups = computed(() => {
217 const map = new Map<string, { key: string; label: string; count: number }>() 232 const map = new Map<string, { key: string; label: string; count: number }>()
218 for (const r of urlResults.value) { 233 for (const r of urlMatches.value) {
219 const key = r.pageId 234 const key = r.pageId
220 const existing = map.get(key) 235 const existing = map.get(key)
221 if (existing) existing.count++ 236 if (existing) existing.count++
@@ -224,24 +239,93 @@ const urlPageGroups = computed(() => {
224 return [...map.values()].sort((a, b) => getPageOrder(a.key) - getPageOrder(b.key)) 239 return [...map.values()].sort((a, b) => getPageOrder(a.key) - getPageOrder(b.key))
225}) 240})
226 241
227const filteredUrlResults = computed(() => { 242// Full match set honoring the active ribbon page filter (uncapped).
228 if (!urlActivePageFilter.value) return urlResults.value 243const urlFilteredMatches = computed((): PageLink[] => {
229 return urlResults.value.filter((r) => r.pageId === urlActivePageFilter.value) 244 if (!urlActivePageFilter.value) return urlMatches.value
245 return urlMatches.value.filter((l) => l.pageId === urlActivePageFilter.value)
246})
247
248// Total number of result pages (Google-style paging through urlFilteredMatches).
249const urlTotalPages = computed(() =>
250 Math.max(1, Math.ceil(urlFilteredMatches.value.length / URL_PAGE_SIZE))
251)
252
253// Clamp the current page whenever the result set shrinks.
254const urlCurrentPage = computed(() =>
255 Math.min(urlPage.value, urlTotalPages.value)
256)
257
258// The rows actually rendered: the current page's slice of the filtered matches.
259const filteredUrlResults = computed((): UrlResult[] => {
260 const matches = urlFilteredMatches.value
261 const start = (urlCurrentPage.value - 1) * URL_PAGE_SIZE
262 const end = start + URL_PAGE_SIZE
263 const out: UrlResult[] = []
264 for (let i = start; i < end && i < matches.length; i++) {
265 const link = matches[i]
266 out.push({
267 href: link.href,
268 linkText: link.linkText,
269 pageId: link.pageId,
270 anchor: link.anchor,
271 titles: link.titles,
272 highlighted: link.href // not currently rendered; kept for type compat
273 })
274 }
275 return out
276})
277
278// Compact page-number list with ellipses, e.g. [1, '…', 4, 5, 6, '…', 12].
279const urlPageList = computed<(number | '…')[]>(() => {
280 const total = urlTotalPages.value
281 const current = urlCurrentPage.value
282 if (total <= 7) return Array.from({ length: total }, (_, i) => i + 1)
283 const pages: (number | '…')[] = [1]
284 const left = Math.max(2, current - 1)
285 const right = Math.min(total - 1, current + 1)
286 if (left > 2) pages.push('…')
287 for (let p = left; p <= right; p++) pages.push(p)
288 if (right < total - 1) pages.push('…')
289 pages.push(total)
290 return pages
291})
292
293function goToUrlPage(p: number) {
294 const target = Math.min(Math.max(1, p), urlTotalPages.value)
295 if (target === urlCurrentPage.value) return
296 urlPage.value = target
297 selectedIndex.value = filteredUrlResults.value.length ? 1 : -1
298 nextTick(() => {
299 if (resultsEl.value) resultsEl.value.scrollTop = 0
300 scrollToSelectedResult()
301 })
302}
303
304// Reset to page 1 whenever the query changes or the page filter changes.
305watch([urlFilterDebounced, urlActivePageFilter], () => {
306 urlPage.value = 1
230}) 307})
231 308
232// Reset URL filter when query changes or mode switches 309// Reset URL ribbon filter if the active page disappears from the groups.
233watch(urlResults, (r) => { 310watch(urlMatches, () => {
234 if (urlActivePageFilter.value && !urlPageGroups.value.some((g) => g.key === urlActivePageFilter.value)) { 311 if (
312 urlActivePageFilter.value &&
313 !urlPageGroups.value.some((g) => g.key === urlActivePageFilter.value)
314 ) {
235 urlActivePageFilter.value = null 315 urlActivePageFilter.value = null
236 } 316 }
237}) 317})
238 318
239watch(urlSearchMode, (active) => { 319watch(urlSearchMode, (active) => {
240 if (!active) urlActivePageFilter.value = null 320 if (!active) {
321 urlActivePageFilter.value = null
322 urlPage.value = 1
323 }
241}) 324})
242 325
243function setUrlPageFilter(key: string | null) { 326function setUrlPageFilter(key: string | null) {
244 urlActivePageFilter.value = urlActivePageFilter.value === key ? null : key 327 urlActivePageFilter.value = urlActivePageFilter.value === key ? null : key
328 urlPage.value = 1
245 selectedIndex.value = filteredUrlResults.value.length ? 1 : -1 329 selectedIndex.value = filteredUrlResults.value.length ? 1 : -1
246 nextTick(() => { 330 nextTick(() => {
247 if (resultsEl.value) resultsEl.value.scrollTop = 0 331 if (resultsEl.value) resultsEl.value.scrollTop = 0
@@ -364,6 +448,58 @@ const filteredResults = computed(() => {
364 ) 448 )
365}) 449})
366 450
451// --- Normal-mode (exact/fuzzy) pagination ---------------------------------
452// Mirrors the URL-mode pager. filteredResults stays the full filtered set;
453// pagedResults is the current page slice that actually renders.
454const NORMAL_PAGE_SIZE = URL_PAGE_SIZE
455
456const normalPage = ref(1)
457
458const normalTotalPages = computed(() =>
459 Math.max(1, Math.ceil(filteredResults.value.length / NORMAL_PAGE_SIZE))
460)
461
462const normalCurrentPage = computed(() =>
463 Math.min(normalPage.value, normalTotalPages.value)
464)
465
466const pagedResults = computed(() => {
467 const start = (normalCurrentPage.value - 1) * NORMAL_PAGE_SIZE
468 return filteredResults.value.slice(start, start + NORMAL_PAGE_SIZE)
469})
470
471const normalPageList = computed<(number | '…')[]>(() => {
472 const total = normalTotalPages.value
473 const current = normalCurrentPage.value
474 if (total <= 7) return Array.from({ length: total }, (_, i) => i + 1)
475 const pages: (number | '…')[] = [1]
476 const left = Math.max(2, current - 1)
477 const right = Math.min(total - 1, current + 1)
478 if (left > 2) pages.push('…')
479 for (let p = left; p <= right; p++) pages.push(p)
480 if (right < total - 1) pages.push('…')
481 pages.push(total)
482 return pages
483})
484
485function goToNormalPage(p: number) {
486 const target = Math.min(Math.max(1, p), normalTotalPages.value)
487 if (target === normalCurrentPage.value) return
488 normalPage.value = target
489 selectedIndex.value = pagedResults.value.length ? 1 : -1
490 nextTick(() => {
491 if (resultsEl.value) resultsEl.value.scrollTop = 0
492 scrollToSelectedResult()
493 reapplyHighlights()
494 })
495}
496
497// Reset to page 1 when the query changes (results replaced) or filter changes.
498watch([results, activePageFilter], () => {
499 normalPage.value = 1
500})
501// ---------------------------------------------------------------------------
502
367function setPageFilter(key: string | null) { 503function setPageFilter(key: string | null) {
368 activePageFilter.value = activePageFilter.value === key ? null : key 504 activePageFilter.value = activePageFilter.value === key ? null : key
369 selectedIndex.value = filteredResults.value.length ? 1 : -1 505 selectedIndex.value = filteredResults.value.length ? 1 : -1
@@ -842,12 +978,12 @@ function onSearchBarClick(event: PointerEvent) {
842const selectedIndex = ref(-1) 978const selectedIndex = ref(-1)
843const disableMouseOver = ref(true) 979const disableMouseOver = ref(true)
844 980
845// Active result list length (URL mode vs normal mode) 981// Active result list length (URL mode vs normal mode) — current page only
846const activeResultsLength = computed(() => 982const activeResultsLength = computed(() =>
847 urlSearchMode.value ? filteredUrlResults.value.length : filteredResults.value.length 983 urlSearchMode.value ? filteredUrlResults.value.length : pagedResults.value.length
848) 984)
849 985
850watch(filteredResults, (r) => { 986watch(pagedResults, (r) => {
851 if (!urlSearchMode.value) { 987 if (!urlSearchMode.value) {
852 selectedIndex.value = r.length ? 0 : -1 988 selectedIndex.value = r.length ? 0 : -1
853 scrollToSelectedResult() 989 scrollToSelectedResult()
@@ -918,7 +1054,7 @@ onKeyStroke('Enter', (e) => {
918 return 1054 return
919 } 1055 }
920 1056
921 const selectedPackage = filteredResults.value[index] 1057 const selectedPackage = pagedResults.value[index]
922 if (e.target instanceof HTMLInputElement && !selectedPackage) { 1058 if (e.target instanceof HTMLInputElement && !selectedPackage) {
923 e.preventDefault() 1059 e.preventDefault()
924 return 1060 return
@@ -1051,346 +1187,396 @@ function onMouseMove(e: MouseEvent) {
1051 v-if="showSearch" 1187 v-if="showSearch"
1052 class="shell" 1188 class="shell"
1053 > 1189 >
1054 <form 1190 <form
1055 class="search-bar" 1191 class="search-bar"
1056 @pointerup="onSearchBarClick($event)" 1192 @pointerup="onSearchBarClick($event)"
1057 @submit.prevent="" 1193 @submit.prevent=""
1194 >
1195 <label
1196 :title="buttonText"
1197 id="localsearch-label"
1198 for="localsearch-input"
1058 > 1199 >
1059 <label 1200 <span
1060 :title="buttonText" 1201 aria-hidden="true"
1061 id="localsearch-label" 1202 class="vpi-search search-icon local-search-icon"
1062 for="localsearch-input" 1203 />
1204 </label>
1205 <div class="search-actions before">
1206 <button
1207 class="back-button"
1208 :title="translate('modal.backButtonTitle')"
1209 @click="showSearch = false"
1063 > 1210 >
1064 <span 1211 <span class="vpi-arrow-left local-search-icon" />
1065 aria-hidden="true" 1212 </button>
1066 class="vpi-search search-icon local-search-icon" 1213 </div>
1067 /> 1214 <input
1068 </label> 1215 ref="searchInput"
1069 <div class="search-actions before"> 1216 v-model="filterText"
1217 :aria-activedescendant="selectedIndex > -1
1218 ? 'localsearch-item-' + selectedIndex
1219 : undefined"
1220 aria-autocomplete="both"
1221 :aria-controls="results?.length ? 'localsearch-list' : undefined"
1222 aria-labelledby="localsearch-label"
1223 autocapitalize="off"
1224 autocomplete="off"
1225 autocorrect="off"
1226 class="search-input"
1227 id="localsearch-input"
1228 enterkeyhint="go"
1229 maxlength="64"
1230 :placeholder="buttonText"
1231 spellcheck="false"
1232 type="search"
1233 />
1234 <div class="search-actions">
1235 <div v-if="!disableDetailedView && searchMode !== 'url'" class="view-group toolbar-group">
1236 <button
1237 type="button"
1238 class="mode-btn"
1239 :class="{ 'mode-active': showDetailedList }"
1240 title="Detail view (Consumes more RAM)"
1241 @click="showDetailedList ? showDetailedList = false : showDetailedList = true"
1242 >
1243 <LayoutList :size="18" stroke-width="1.25" />
1244 </button>
1070 <button 1245 <button
1071 class="back-button" 1246 type="button"
1072 :title="translate('modal.backButtonTitle')" 1247 class="mode-btn"
1073 @click="showSearch = false" 1248 :class="{ 'mode-active': !showDetailedList }"
1249 title="List view (Consumes less RAM)"
1250 @click="!showDetailedList ? showDetailedList = true : showDetailedList = false"
1074 > 1251 >
1075 <span class="vpi-arrow-left local-search-icon" /> 1252 <List :size="18" stroke-width="1.25" />
1076 </button> 1253 </button>
1077 </div> 1254 </div>
1078 <input 1255 <div class="search-mode-group toolbar-group">
1079 ref="searchInput"
1080 v-model="filterText"
1081 :aria-activedescendant="selectedIndex > -1
1082 ? 'localsearch-item-' + selectedIndex
1083 : undefined"
1084 aria-autocomplete="both"
1085 :aria-controls="results?.length ? 'localsearch-list' : undefined"
1086 aria-labelledby="localsearch-label"
1087 autocapitalize="off"
1088 autocomplete="off"
1089 autocorrect="off"
1090 class="search-input"
1091 id="localsearch-input"
1092 enterkeyhint="go"
1093 maxlength="64"
1094 :placeholder="buttonText"
1095 spellcheck="false"
1096 type="search"
1097 />
1098 <div class="search-actions">
1099 <div v-if="!disableDetailedView && searchMode !== 'url'" class="view-group toolbar-group">
1100 <button
1101 type="button"
1102 class="mode-btn"
1103 :class="{ 'mode-active': showDetailedList }"
1104 title="Detail view (Consumes more RAM)"
1105 @click="showDetailedList ? showDetailedList = false : showDetailedList = true"
1106 >
1107 <LayoutList :size="18" stroke-width="1.25" />
1108 </button>
1109 <button
1110 type="button"
1111 class="mode-btn"
1112 :class="{ 'mode-active': !showDetailedList }"
1113 title="List view (Consumes less RAM)"
1114 @click="!showDetailedList ? showDetailedList = true : showDetailedList = false"
1115 >
1116 <List :size="18" stroke-width="1.25" />
1117 </button>
1118 </div>
1119 <div class="search-mode-group toolbar-group">
1120 <button
1121 type="button"
1122 class="mode-btn"
1123 :class="{ 'mode-active': searchMode === 'exact' }"
1124 title="Exact search"
1125 @click="searchMode === 'exact' ? cycleSearchMode() : searchMode = 'exact'"
1126 >
1127 <Locate :size="18" stroke-width="1.25" />
1128 </button>
1129 <button
1130 type="button"
1131 class="mode-btn"
1132 :class="{ 'mode-active': searchMode === 'fuzzy' }"
1133 title="Fuzzy search"
1134 @click="searchMode === 'fuzzy' ? cycleSearchMode() : searchMode = 'fuzzy'"
1135 >
1136 <LocateOff :size="18" stroke-width="1.25" />
1137 </button>
1138 <button
1139 type="button"
1140 class="mode-btn"
1141 :class="{ 'mode-active': searchMode === 'url' }"
1142 title="URL search"
1143 @click="searchMode === 'url' ? cycleSearchMode() : searchMode = 'url'"
1144 >
1145 <Globe :size="18" stroke-width="1.25" />
1146 </button>
1147 </div>
1148 <button 1256 <button
1149 class="clear-button" 1257 type="button"
1150 type="reset" 1258 class="mode-btn"
1151 :disabled="disableReset" 1259 :class="{ 'mode-active': searchMode === 'exact' }"
1152 :title="translate('modal.resetButtonTitle')" 1260 title="Exact search"
1153 @click="resetSearch" 1261 @click="searchMode === 'exact' ? cycleSearchMode() : searchMode = 'exact'"
1262 >
1263 <Locate :size="18" stroke-width="1.25" />
1264 </button>
1265 <button
1266 type="button"
1267 class="mode-btn"
1268 :class="{ 'mode-active': searchMode === 'fuzzy' }"
1269 title="Fuzzy search"
1270 @click="searchMode === 'fuzzy' ? cycleSearchMode() : searchMode = 'fuzzy'"
1271 >
1272 <LocateOff :size="18" stroke-width="1.25" />
1273 </button>
1274 <button
1275 type="button"
1276 class="mode-btn"
1277 :class="{ 'mode-active': searchMode === 'url' }"
1278 title="URL search"
1279 @click="searchMode === 'url' ? cycleSearchMode() : searchMode = 'url'"
1154 > 1280 >
1155 <Delete :size="19" stroke-width="1.25" /> 1281 <Globe :size="18" stroke-width="1.25" />
1156 </button> 1282 </button>
1157 </div> 1283 </div>
1158 </form> 1284 <button
1159 1285 class="clear-button"
1286 type="reset"
1287 :disabled="disableReset"
1288 :title="translate('modal.resetButtonTitle')"
1289 @click="resetSearch"
1290 >
1291 <Delete :size="19" stroke-width="1.25" />
1292 </button>
1293 </div>
1294 </form>
1295
1296 <div
1297 v-if="urlSearchMode ? urlPageGroups.length > 1 : pageGroups.length > 1"
1298 class="page-ribbon"
1299 >
1300 <button
1301 v-if="ribbonCanScrollLeft"
1302 type="button"
1303 class="page-ribbon-arrow left"
1304 aria-label="Scroll filters left"
1305 @click="scrollRibbon(-1)"
1306 >
1307 <ChevronRight :size="18" stroke-width="1.75" />
1308 </button>
1160 <div 1309 <div
1161 v-if="urlSearchMode ? urlPageGroups.length > 1 : pageGroups.length > 1" 1310 ref="ribbonTrack"
1162 class="page-ribbon" 1311 class="page-ribbon-track"
1312 @scroll="updateRibbonOverflow"
1163 > 1313 >
1314 <!-- URL mode tabs -->
1315 <template v-if="urlSearchMode">
1164 <button 1316 <button
1165 v-if="ribbonCanScrollLeft"
1166 type="button" 1317 type="button"
1167 class="page-ribbon-arrow left" 1318 class="page-pill"
1168 aria-label="Scroll filters left" 1319 :class="{ active: urlActivePageFilter === null }"
1169 @click="scrollRibbon(-1)" 1320 @click="setUrlPageFilter(null)"
1170 > 1321 >
1171 <ChevronRight :size="18" stroke-width="1.75" /> 1322 All
1323 <span class="page-pill-count">{{ urlMatches.length }}</span>
1172 </button> 1324 </button>
1173 <div 1325 <button
1174 ref="ribbonTrack" 1326 v-for="group in urlPageGroups"
1175 class="page-ribbon-track" 1327 :key="group.key"
1176 @scroll="updateRibbonOverflow" 1328 type="button"
1329 class="page-pill"
1330 :class="{ active: urlActivePageFilter === group.key }"
1331 @click="setUrlPageFilter(group.key)"
1177 > 1332 >
1178 <!-- URL mode tabs --> 1333 <span class="page-pill-label">{{ group.label }}</span>
1179 <template v-if="urlSearchMode"> 1334 <span class="page-pill-count">{{ group.count }}</span>
1180 <button 1335 </button>
1181 type="button" 1336 </template>
1182 class="page-pill" 1337 <!-- Normal mode tabs -->
1183 :class="{ active: urlActivePageFilter === null }" 1338 <template v-else>
1184 @click="setUrlPageFilter(null)"
1185 >
1186 All
1187 <span class="page-pill-count">{{ urlResults.length }}</span>
1188 </button>
1189 <button
1190 v-for="group in urlPageGroups"
1191 :key="group.key"
1192 type="button"
1193 class="page-pill"
1194 :class="{ active: urlActivePageFilter === group.key }"
1195 @click="setUrlPageFilter(group.key)"
1196 >
1197 <span class="page-pill-label">{{ group.label }}</span>
1198 <span class="page-pill-count">{{ group.count }}</span>
1199 </button>
1200 </template>
1201 <!-- Normal mode tabs -->
1202 <template v-else>
1203 <button
1204 type="button"
1205 class="page-pill"
1206 :class="{ active: activePageFilter === null }"
1207 @click="setPageFilter(null)"
1208 >
1209 All
1210 <span class="page-pill-count">{{ results.length }}</span>
1211 </button>
1212 <button
1213 v-for="group in pageGroups"
1214 :key="group.key"
1215 type="button"
1216 class="page-pill"
1217 :class="{ active: activePageFilter === group.key }"
1218 @click="setPageFilter(group.key)"
1219 >
1220 <span class="page-pill-label">{{ group.label }}</span>
1221 <span class="page-pill-count">{{ group.count }}</span>
1222 </button>
1223 </template>
1224 </div>
1225 <button 1339 <button
1226 v-if="ribbonCanScrollRight"
1227 type="button" 1340 type="button"
1228 class="page-ribbon-arrow right" 1341 class="page-pill"
1229 aria-label="Scroll filters right" 1342 :class="{ active: activePageFilter === null }"
1230 @click="scrollRibbon(1)" 1343 @click="setPageFilter(null)"
1231 > 1344 >
1232 <ChevronRight :size="18" stroke-width="1.75" /> 1345 All
1346 <span class="page-pill-count">{{ results.length }}</span>
1233 </button> 1347 </button>
1234 </div> 1348 <button
1349 v-for="group in pageGroups"
1350 :key="group.key"
1351 type="button"
1352 class="page-pill"
1353 :class="{ active: activePageFilter === group.key }"
1354 @click="setPageFilter(group.key)"
1355 >
1356 <span class="page-pill-label">{{ group.label }}</span>
1357 <span class="page-pill-count">{{ group.count }}</span>
1358 </button>
1359 </template>
1360 </div>
1361 <button
1362 v-if="ribbonCanScrollRight"
1363 type="button"
1364 class="page-ribbon-arrow right"
1365 aria-label="Scroll filters right"
1366 @click="scrollRibbon(1)"
1367 >
1368 <ChevronRight :size="18" stroke-width="1.75" />
1369 </button>
1370 </div>
1235 1371
1236 <ul 1372 <ul
1237 ref="resultsEl" 1373 ref="resultsEl"
1238 :id="results?.length ? 'localsearch-list' : undefined" 1374 :id="results?.length ? 'localsearch-list' : undefined"
1239 :role="results?.length ? 'listbox' : undefined" 1375 :role="results?.length ? 'listbox' : undefined"
1240 :aria-labelledby="results?.length ? 'localsearch-label' : undefined" 1376 :aria-labelledby="results?.length ? 'localsearch-label' : undefined"
1241 class="results" 1377 class="results"
1242 @mousemove="onMouseMove" 1378 @mousemove="onMouseMove"
1379 >
1380 <!-- Empty state (shared) -->
1381 <div
1382 v-if="urlSearchMode
1383 ? (!filterText || !urlMatches.length)
1384 : (!filterText || !filteredResults.length)"
1385 class="flex flex-col justify-center items-center h-47.5 gap-2 font-medium text-sm text-gray-500 dark:text-gray-300 m-auto md:mt-10 md:mb-6 opacity-90"
1243 > 1386 >
1244 <!-- Empty state (shared) --> 1387 <img
1245 <div 1388 class="h-40 object-contain object-center -translate-x-2"
1246 v-if="urlSearchMode 1389 src="/asset/smolame.png"
1247 ? (!filterText || !urlResults.length) 1390 alt="Smol ame"
1248 : (!filterText || !filteredResults.length)" 1391 />
1249 class="flex flex-col justify-center items-center h-47.5 gap-2 font-medium text-sm text-gray-500 dark:text-gray-300 m-auto md:mt-10 md:mb-6 opacity-90" 1392 <h1 v-if="filterText">Couldn't find anything, try again?</h1>
1250 > 1393 <h1 v-else>Looking for something?</h1>
1251 <img 1394 </div>
1252 class="h-40 object-contain object-center -translate-x-2"
1253 src="/asset/smolame.png"
1254 alt="Smol ame"
1255 />
1256 <h1 v-if="filterText">Couldn't find anything, try again?</h1>
1257 <h1 v-else>Looking for something?</h1>
1258 </div>
1259 1395
1260 <!-- URL search results --> 1396 <!-- URL search results -->
1261 <template v-if="urlSearchMode"> 1397 <template v-if="urlSearchMode">
1262 <li 1398 <li
1263 v-for="(item, index) in filteredUrlResults" 1399 v-for="(item, index) in filteredUrlResults"
1264 :key="item.href + item.pageId" 1400 :key="'url-' + urlCurrentPage + '-' + item.pageId + '-' + item.anchor + '-' + index"
1265 class="result-layout" 1401 class="result-layout"
1266 :id="'localsearch-item-' + (index + 1)" 1402 :id="'localsearch-item-' + (index + 1)"
1267 :aria-selected="selectedIndex === index + 1 ? 'true' : 'false'" 1403 :aria-selected="selectedIndex === index + 1 ? 'true' : 'false'"
1268 role="option" 1404 role="option"
1405 >
1406 <a
1407 :href="item.anchor ? item.pageId + '#' + item.anchor : item.pageId"
1408 class="result"
1409 :class="{ selected: selectedIndex === index + 1 }"
1410 :aria-label="item.linkText || item.href"
1411 @mouseenter="!disableMouseOver && (selectedIndex = index + 1)"
1412 @focusin="selectedIndex = index + 1"
1413 @click="onResultClick"
1414 :data-index="index + 1"
1269 > 1415 >
1270 <a 1416 <div class="url-result-body">
1271 :href="item.anchor ? item.pageId + '#' + item.anchor : item.pageId" 1417 <div class="titles url-titles">
1272 class="result" 1418 <Hash v-if="item.titles.length > 0" stroke-width="1.25" :size="18" />
1273 :class="{ selected: selectedIndex === index + 1 }" 1419 <File v-else stroke-width="1.25" :size="18" />
1274 :aria-label="item.linkText || item.href" 1420 <span
1275 @mouseenter="!disableMouseOver && (selectedIndex = index + 1)" 1421 v-for="(t, ti) in item.titles"
1276 @focusin="selectedIndex = index + 1" 1422 :key="ti"
1277 @click="onResultClick" 1423 class="title"
1278 :data-index="index + 1" 1424 >
1279 > 1425 <span class="text" v-html="t" />
1280 <div> 1426 <ArrowRight stroke-width="1.25" :size="18" class="mx-0.5" />
1281 <div class="titles"> 1427 </span>
1282 <Hash v-if="item.titles.length > 0" stroke-width="1.25" :size="18" /> 1428 <span class="title main">
1283 <File v-else stroke-width="1.25" :size="18" /> 1429 <span class="text">{{ item.linkText || item.href }}</span>
1284 <span 1430 </span>
1285 v-for="(t, ti) in item.titles"
1286 :key="ti"
1287 class="title"
1288 >
1289 <span class="text" v-html="t" />
1290 <ArrowRight stroke-width="1.25" :size="18" class="mx-0.5" />
1291 </span>
1292 <span class="title main">
1293 <span class="text">{{ item.linkText || item.href }}</span>
1294 </span>
1295 <a
1296 :href="item.href"
1297 target="_blank"
1298 rel="noopener noreferrer"
1299 class="url-open-btn"
1300 :class="{ 'url-open-btn-selected': selectedIndex === index + 1 }"
1301 title="Open link"
1302 @click.stop
1303 >
1304 <ExternalLink :size="14" stroke-width="1.5" />
1305 </a>
1306 </div>
1307 </div> 1431 </div>
1308 </a> 1432 <a
1309 </li> 1433 :href="item.href"
1310 </template> 1434 target="_blank"
1311 1435 rel="noopener noreferrer"
1312 <!-- Normal search results --> 1436 class="url-open-btn"
1313 <template v-else> 1437 :class="{ 'url-open-btn-selected': selectedIndex === index + 1 }"
1314 <li 1438 title="Open link"
1315 v-for="(p, index) in filteredResults" 1439 @click.stop
1316 :key="p.id" 1440 >
1317 class="result-layout" 1441 <ExternalLink :size="14" stroke-width="1.5" />
1318 :id="'localsearch-item-' + (index + 1)" 1442 </a>
1319 :aria-selected="selectedIndex === index + 1 ? 'true' : 'false'" 1443 </div>
1320 role="option" 1444 </a>
1445 </li>
1446 </template>
1447
1448 <!-- Normal search results -->
1449 <template v-else>
1450 <li
1451 v-for="(p, index) in pagedResults"
1452 :key="'normal-' + normalCurrentPage + '-' + p.id"
1453 class="result-layout"
1454 :id="'localsearch-item-' + (index + 1)"
1455 :aria-selected="selectedIndex === index + 1 ? 'true' : 'false'"
1456 role="option"
1457 >
1458 <a
1459 :href="p.id"
1460 class="result"
1461 :class="{ selected: selectedIndex === index + 1 }"
1462 :aria-label="[...p.titles, p.title].join(' > ')"
1463 @mouseenter="!disableMouseOver && (selectedIndex = index + 1)"
1464 @focusin="selectedIndex = index + 1"
1465 @click="onResultClick"
1466 :data-index="index + 1"
1321 > 1467 >
1322 <a 1468 <div>
1323 :href="p.id" 1469 <div class="titles">
1324 class="result" 1470 <Hash v-if="p.titles.length > 0" stroke-width="1.25" :size="18" />
1325 :class="{ selected: selectedIndex === index + 1 }" 1471 <File v-else stroke-width="1.25" :size="18" />
1326 :aria-label="[...p.titles, p.title].join(' > ')" 1472 <span
1327 @mouseenter="!disableMouseOver && (selectedIndex = index + 1)" 1473 v-for="(t, index) in p.titles"
1328 @focusin="selectedIndex = index + 1" 1474 :key="index"
1329 @click="onResultClick" 1475 class="title"
1330 :data-index="index + 1" 1476 >
1331 > 1477 <span class="text" v-html="t" />
1332 <div> 1478 <ArrowRight stroke-width="1.25" :size="18" class="mx-0.5" />
1333 <div class="titles"> 1479 </span>
1334 <Hash v-if="p.titles.length > 0" stroke-width="1.25" :size="18" /> 1480 <span class="title main">
1335 <File v-else stroke-width="1.25" :size="18" /> 1481 <span class="text" v-html="p.title" />
1336 <span 1482 </span>
1337 v-for="(t, index) in p.titles" 1483 </div>
1338 :key="index"
1339 class="title"
1340 >
1341 <span class="text" v-html="t" />
1342 <ArrowRight stroke-width="1.25" :size="18" class="mx-0.5" />
1343 </span>
1344 <span class="title main">
1345 <span class="text" v-html="p.title" />
1346 </span>
1347 </div>
1348 1484
1349 <div v-if="showDetailedList" class="excerpt-wrapper"> 1485 <div v-if="showDetailedList" class="excerpt-wrapper">
1350 <div v-if="p.text" class="excerpt" inert> 1486 <div v-if="p.text" class="excerpt" inert>
1351 <div class="vp-doc" v-html="p.text" /> 1487 <div class="vp-doc" v-html="p.text" />
1352 </div>
1353 <div class="excerpt-gradient-bottom" />
1354 <div class="excerpt-gradient-top" />
1355 </div> 1488 </div>
1489 <div class="excerpt-gradient-bottom" />
1490 <div class="excerpt-gradient-top" />
1356 </div> 1491 </div>
1357 </a> 1492 </div>
1358 </li> 1493 </a>
1359 </template> 1494 </li>
1360 </ul> 1495 </template>
1361 1496 </ul>
1362 <div class="search-keyboard-shortcuts"> 1497
1363 <span> 1498 <!-- Pagination controls (Fixed structural segment block style wrapper) -->
1364 <kbd 1499 <nav
1365 :aria-label="translate( 1500 v-if="(urlSearchMode ? urlTotalPages : normalTotalPages) > 1"
1366 'modal.footer.navigateUpKeyAriaLabel' 1501 class="url-pagination"
1367 )" 1502 aria-label="Search result pages"
1368 > 1503 >
1369 <span class="vpi-arrow-up navigate-icon" /> 1504 <div class="url-pagination-segment">
1370 </kbd> 1505 <button
1371 <kbd 1506 type="button"
1372 :aria-label="translate( 1507 class="url-page-btn url-page-nav"
1373 'modal.footer.navigateDownKeyAriaLabel' 1508 :disabled="(urlSearchMode ? urlCurrentPage : normalCurrentPage) <= 1"
1374 )" 1509 aria-label="Previous page"
1510 @click="urlSearchMode
1511 ? goToUrlPage(urlCurrentPage - 1)
1512 : goToNormalPage(normalCurrentPage - 1)"
1513 >
1514 <ChevronRight :size="14" stroke-width="2" style="transform: rotate(180deg)" />
1515 </button>
1516
1517 <template
1518 v-for="(p, pi) in (urlSearchMode ? urlPageList : normalPageList)"
1519 :key="pi"
1520 >
1521 <span v-if="p === '…'" class="url-page-ellipsis">…</span>
1522 <button
1523 v-else
1524 type="button"
1525 class="url-page-btn"
1526 :class="{ active: p === (urlSearchMode ? urlCurrentPage : normalCurrentPage) }"
1527 :aria-current="p === (urlSearchMode ? urlCurrentPage : normalCurrentPage) ? 'page' : undefined"
1528 @click="urlSearchMode ? goToUrlPage(p as number) : goToNormalPage(p as number)"
1375 > 1529 >
1376 <span class="vpi-arrow-down navigate-icon" /> 1530 {{ p }}
1377 </kbd> 1531 </button>
1378 {{ translate('modal.footer.navigateText') }} 1532 </template>
1379 </span> 1533
1380 <span> 1534 <button
1381 <kbd :aria-label="translate('modal.footer.selectKeyAriaLabel')"> 1535 type="button"
1382 <span class="vpi-corner-down-left navigate-icon" /> 1536 class="url-page-btn url-page-nav"
1383 </kbd> 1537 :disabled="(urlSearchMode ? urlCurrentPage : normalCurrentPage) >= (urlSearchMode ? urlTotalPages : normalTotalPages)"
1384 {{ translate('modal.footer.selectText') }} 1538 aria-label="Next page"
1385 </span> 1539 @click="urlSearchMode
1386 <span> 1540 ? goToUrlPage(urlCurrentPage + 1)
1387 <kbd :aria-label="translate('modal.footer.closeKeyAriaLabel')"> 1541 : goToNormalPage(normalCurrentPage + 1)"
1388 esc 1542 >
1389 </kbd> 1543 <ChevronRight :size="14" stroke-width="2" />
1390 {{ translate('modal.footer.closeText') }} 1544 </button>
1391 </span>
1392 </div> 1545 </div>
1546 </nav>
1547
1548 <div class="search-keyboard-shortcuts">
1549 <span>
1550 <kbd
1551 :aria-label="translate(
1552 'modal.footer.navigateUpKeyAriaLabel'
1553 )"
1554 >
1555 <span class="vpi-arrow-up navigate-icon" />
1556 </kbd>
1557 <kbd
1558 :aria-label="translate(
1559 'modal.footer.navigateDownKeyAriaLabel'
1560 )"
1561 >
1562 <span class="vpi-arrow-down navigate-icon" />
1563 </kbd>
1564 {{ translate('modal.footer.navigateText') }}
1565 </span>
1566 <span>
1567 <kbd :aria-label="translate('modal.footer.selectKeyAriaLabel')">
1568 <span class="vpi-corner-down-left navigate-icon" />
1569 </kbd>
1570 {{ translate('modal.footer.selectText') }}
1571 </span>
1572 <span>
1573 <kbd :aria-label="translate('modal.footer.closeKeyAriaLabel')">
1574 esc
1575 </kbd>
1576 {{ translate('modal.footer.closeText') }}
1577 </span>
1393 </div> 1578 </div>
1579 </div>
1394 1580
1395 <button v-if="!showSearch" /> 1581 <button v-if="!showSearch" />
1396 </div> 1582 </div>
@@ -1403,6 +1589,13 @@ function onMouseMove(e: MouseEvent) {
1403 z-index: 100; 1589 z-index: 100;
1404 inset: 0; 1590 inset: 0;
1405 display: flex; 1591 display: flex;
1592 align-items: flex-start;
1593}
1594
1595@media (max-width: 767px) {
1596 .VPLocalSearchBox {
1597 align-items: stretch;
1598 }
1406} 1599}
1407 1600
1408.backdrop { 1601.backdrop {
@@ -1413,6 +1606,7 @@ function onMouseMove(e: MouseEvent) {
1413 1606
1414.shell { 1607.shell {
1415 position: relative; 1608 position: relative;
1609 box-sizing: border-box;
1416 padding: 12px; 1610 padding: 12px;
1417 margin: 64px auto; 1611 margin: 64px auto;
1418 display: flex; 1612 display: flex;
@@ -1420,7 +1614,7 @@ function onMouseMove(e: MouseEvent) {
1420 gap: 16px; 1614 gap: 16px;
1421 background: var(--vp-local-search-bg); 1615 background: var(--vp-local-search-bg);
1422 width: min(100vw - 60px, 900px); 1616 width: min(100vw - 60px, 900px);
1423 height: min-content; 1617 height: 100%;
1424 max-height: min(100vh - 128px, 900px); 1618 max-height: min(100vh - 128px, 900px);
1425 border-radius: 6px; 1619 border-radius: 6px;
1426} 1620}
@@ -1430,12 +1624,17 @@ function onMouseMove(e: MouseEvent) {
1430 margin: 0; 1624 margin: 0;
1431 width: 100vw; 1625 width: 100vw;
1432 height: 100vh; 1626 height: 100vh;
1627 height: 100dvh;
1433 max-height: none; 1628 max-height: none;
1434 border-radius: 0; 1629 border-radius: 0;
1630 overflow: hidden;
1631 gap: 8px;
1435 } 1632 }
1436} 1633}
1437 1634
1438.search-bar { 1635.search-bar {
1636 flex: 0 0 auto !important;
1637 min-height: 44px !important;
1439 border: 1px solid var(--vp-c-divider); 1638 border: 1px solid var(--vp-c-divider);
1440 border-radius: 4px; 1639 border-radius: 4px;
1441 display: flex; 1640 display: flex;
@@ -1447,6 +1646,7 @@ function onMouseMove(e: MouseEvent) {
1447@media (max-width: 767px) { 1646@media (max-width: 767px) {
1448 .search-bar { 1647 .search-bar {
1449 padding: 0 8px; 1648 padding: 0 8px;
1649 min-height: 40px !important;
1450 } 1650 }
1451} 1651}
1452 1652
@@ -1687,6 +1887,8 @@ function onMouseMove(e: MouseEvent) {
1687 display: flex; 1887 display: flex;
1688 flex-direction: column; 1888 flex-direction: column;
1689 gap: 6px; 1889 gap: 6px;
1890 flex: 1 1 auto;
1891 min-height: 0 !important;
1690 overflow-x: hidden; 1892 overflow-x: hidden;
1691 overflow-y: auto; 1893 overflow-y: auto;
1692 overscroll-behavior: contain; 1894 overscroll-behavior: contain;
@@ -1725,6 +1927,17 @@ function onMouseMove(e: MouseEvent) {
1725 align-items: center; 1927 align-items: center;
1726} 1928}
1727 1929
1930/* URL-mode card: breadcrumb text wraps freely, open-link button is pinned
1931 to the top-right corner so it never detaches when the title wraps. */
1932.url-result-body {
1933 position: relative;
1934 padding-right: 28px;
1935}
1936
1937.url-titles {
1938 z-index: auto;
1939}
1940
1728.titles > svg { 1941.titles > svg {
1729 flex-shrink: 0; 1942 flex-shrink: 0;
1730 align-self: center; 1943 align-self: center;
@@ -1749,6 +1962,15 @@ function onMouseMove(e: MouseEvent) {
1749 opacity: 0.5; 1962 opacity: 0.5;
1750} 1963}
1751 1964
1965.url-titles .title.main {
1966 min-width: 0;
1967}
1968
1969.url-titles .title.main .text {
1970 overflow-wrap: anywhere;
1971 word-break: break-word;
1972}
1973
1752.result.selected { 1974.result.selected {
1753 --vp-local-search-result-bg: var(--vp-local-search-result-selected-bg); 1975 --vp-local-search-result-bg: var(--vp-local-search-result-selected-bg);
1754 border-color: var(--vp-local-search-result-selected-border); 1976 border-color: var(--vp-local-search-result-selected-border);
@@ -1898,6 +2120,9 @@ svg {
1898} 2120}
1899 2121
1900.url-open-btn { 2122.url-open-btn {
2123 position: absolute;
2124 top: 0;
2125 right: 0;
1901 flex: none; 2126 flex: none;
1902 display: flex; 2127 display: flex;
1903 align-items: center; 2128 align-items: center;
@@ -1908,7 +2133,6 @@ svg {
1908 color: var(--vp-c-text-3); 2133 color: var(--vp-c-text-3);
1909 opacity: 0; 2134 opacity: 0;
1910 transition: opacity 0.15s, color 0.15s, background 0.15s; 2135 transition: opacity 0.15s, color 0.15s, background 0.15s;
1911 margin-left: auto;
1912} 2136}
1913 2137
1914.result:hover .url-open-btn, 2138.result:hover .url-open-btn,
@@ -1938,4 +2162,85 @@ svg {
1938 padding: 0 2px; 2162 padding: 0 2px;
1939 font-style: normal; 2163 font-style: normal;
1940} 2164}
2165
2166/* Redesigned Unified Mode Switching Segmented Style Pagination Controls */
2167.url-pagination {
2168 display: flex;
2169 align-items: center;
2170 justify-content: center;
2171 flex: 0 0 auto !important;
2172 padding: 10px 8px;
2173 border-top: 1px solid var(--vp-c-divider);
2174}
2175
2176@media (max-width: 767px) {
2177 .url-pagination {
2178 padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
2179 }
2180}
2181
2182.url-pagination-segment {
2183 display: flex;
2184 align-items: center;
2185 border: 1px solid var(--vp-c-divider);
2186 border-radius: 5px;
2187 overflow: hidden;
2188 background: transparent;
2189}
2190
2191.url-page-btn {
2192 display: flex;
2193 align-items: center;
2194 justify-content: center;
2195 min-width: 32px;
2196 height: 28px;
2197 padding: 0 8px;
2198 border: none;
2199 background: transparent;
2200 color: var(--vp-c-text-2);
2201 font-size: 0.82rem;
2202 cursor: pointer;
2203 transition: color 0.15s, background-color 0.15s;
2204 border-radius: 0;
2205}
2206
2207.url-page-btn + .url-page-btn,
2208.url-page-ellipsis + .url-page-btn,
2209.url-page-btn + .url-page-ellipsis {
2210 border-left: 1px solid var(--vp-c-divider);
2211}
2212
2213.url-page-btn:hover:not(:disabled):not(.active) {
2214 color: var(--vp-c-text-1);
2215 background: var(--vp-c-default-soft);
2216}
2217
2218.url-page-btn.active {
2219 color: var(--vp-c-brand-1);
2220 background: rgba(60, 120, 210, 0.10);
2221 font-weight: 500;
2222 cursor: default;
2223}
2224
2225.url-page-btn:disabled {
2226 opacity: 0.25;
2227 cursor: not-allowed;
2228 background: transparent;
2229}
2230
2231.url-page-nav {
2232 padding: 0 6px;
2233}
2234
2235.url-page-ellipsis {
2236 display: flex;
2237 align-items: center;
2238 justify-content: center;
2239 min-width: 28px;
2240 height: 28px;
2241 color: var(--vp-c-text-3);
2242 font-size: 0.8rem;
2243 user-select: none;
2244 background: transparent;
2245}
1941</style>\ No newline at end of file 2246</style>\ No newline at end of file