Commit bd5ee0c5e9

bd5ee0c5e979eeadd8bde0ada5a266b781ba7748

parent: 3d6300af44

Unsigned

Duck <57977673+woducku@users.noreply.github.com> · 2026-09-19 14:02 UTC

c

Layout: unified · split

docs/.vitepress/theme/Layout.vue +35 −2
@@ -106,7 +106,22 @@ if (!import.meta.env.SSR) {
106106 if (!searchNavigated) return
107107 attempts++
108108 const currentHash = window.location.hash.slice(1)
109 if (!currentHash) return
109 if (!currentHash) {
110 if (attempts < 5) {
111 requestAnimationFrame(retryHighlight)
112 return
113 }
114 expandTablesForTerms(getSearchTerms(searchQuery))
115 const docRoot = document.querySelector<HTMLElement>('.VPDoc .vp-doc')
116 if (docRoot) highlightSearchResult(docRoot)
117 const tablePath = getOpenTableMorePath()
118 if (tablePath.length) {
119 window.history.replaceState(null, '', buildUrl({ tables: tablePath }))
120 rewriteAnchorLinks()
121 }
122 resetSearchNavigation()
123 return
124 }
110125 const target = getTargetByHash(currentHash)
111126 if (target) {
112127 scanSectionForTerms(
@@ -426,6 +441,13 @@ const expandTableMoreEl = (t: HTMLElement) => {
426441 if (box && !box.checked) box.checked = true
427442}
428443
444const expandTablesForTerms = (terms: string[]) => {
445 if (!terms.length) return
446 document.querySelectorAll('table').forEach((t) => {
447 if (tableContainsTerms(t, terms)) expandTableMoreEl(t)
448 })
449}
450
429451const scanSectionForTerms = (
430452 target: HTMLElement,
431453 terms: string[],
@@ -820,7 +842,18 @@ const tryOpenAnchoredContent = async () => {
820842 (selectedTabs
821843 ? getSelectedTabScrollTarget(selectedTabs)
822844 : document.querySelector<HTMLElement>('.VPDoc') ?? undefined)
823 if (searchNavigated) highlightSearchResult(scrollTarget)
845 if (searchNavigated) {
846 const terms = getSearchTerms(searchQuery)
847 scrollTarget?.querySelectorAll('table').forEach((t) => {
848 if (tableContainsTerms(t, terms)) expandTableMoreEl(t)
849 })
850 highlightSearchResult(scrollTarget)
851 const tablePath = getOpenTableMorePath()
852 if (tablePath.length) {
853 window.history.replaceState(null, '', buildUrl({ tables: tablePath }))
854 rewriteAnchorLinks()
855 }
856 }
824857 resetSearchNavigation()
825858 if (openedCollapsible) {
826859 scrollToElement(openedCollapsible, false)
docs/.vitepress/theme/components/search/Search.vue +5
@@ -846,6 +846,11 @@ function buildDocExcerpt(docId: string): Promise<void> {
846846 document.createElement = originalCreateElement
847847 }
848848 const headings = div.querySelectorAll('h1, h2, h3, h4, h5, h6')
849 div.querySelectorAll<HTMLInputElement>('.table-more-checkbox').forEach(
850 (box) => {
851 box.checked = true
852 }
853 )
849854 headings.forEach((heading) => {
850855 const href = heading.querySelector('a')?.getAttribute('href')
851856 const hashIndex = href?.indexOf('#') ?? -1