Commit 49d0900bcc

49d0900bcc0ebff8bae8207d42986611be60f0af

parent: 1b82d38766

Unsigned

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

init

Layout: unified · split

docs/.vitepress/configs/markdown/index.ts +3 −3
@@ -28,6 +28,7 @@ import { extRepoPlugin } from './extRepoPlugin'
2828import { nestedContainersPlugin } from './nestedContainers'
2929import { scrapeTablePlugin } from './scrapeTablePlugin'
3030import markdownSteps from './steps'
31import { tableMorePlugin } from './tableMore'
3132import { tabsMarkdownPlugin } from './tabs'
3233
3334export function configureMarkdown(md: MarkdownRenderer) {
@@ -50,6 +51,7 @@ export function configureMarkdown(md: MarkdownRenderer) {
5051 renderTooltip(md)
5152 renderInlineTooltip(md)
5253 md.use(markdownSteps)
54 md.use(tableMorePlugin)
5355 md.use(scrapeTablePlugin)
5456 md.use(extRepoPlugin)
5557 renderHighlight(md)
@@ -260,9 +262,7 @@ function injectSearchHeadings(src: string) {
260262 i + 1,
261263 0,
262264 '',
263 `${indent}${
264 '#'.repeat(headingLevel)
265 } ${headingTitle} {#${
265 `${indent}${'#'.repeat(headingLevel)} ${headingTitle} {#${
266266 getCollapsibleHeadingAnchor(collapsibleAnchor)
267267 } .collapsible-search-heading}`,
268268 ''
docs/.vitepress/configs/markdown/tableMore.ts added +336
@@ -0,0 +1,336 @@
1import type MarkdownIt from 'markdown-it'
2
3const MARKER_RE = /^<more\s*\/?>$/i
4
5const ROW_TOKEN_TYPES = new Set([
6 'tr_open',
7 'tr_close',
8 'td_open',
9 'td_close',
10 'th_open',
11 'th_close',
12 'inline'
13])
14
15function buildToggleHtml(cols: number): string {
16 return `<tbody class="table-more-toggle">\n` +
17 `<tr class="table-more-toggle-row">\n` +
18 `<td colspan="${cols}">\n` +
19 `<label class="table-more-label">\n` +
20 `<input type="checkbox" class="table-more-checkbox" aria-label="Toggle more rows">\n` +
21 `<span class="table-more-text table-more-text--more">Show more</span>\n` +
22 `<span class="table-more-text table-more-text--less">Show less</span>\n` +
23 `<span class="table-more-icon i-mdi-chevron-down" aria-hidden="true"></span>\n` +
24 `</label>\n</td>\n</tr>\n</tbody>\n`
25}
26
27function getLine(state: any, n: number): string {
28 return state.src.slice(
29 state.bMarks[n] + state.tShift[n],
30 state.eMarks[n]
31 )
32}
33
34function isPipeLine(line: string): boolean {
35 return line.trim().startsWith('|')
36}
37
38function splitCells(line: string): string[] {
39 let s = line.trim()
40 if (s.startsWith('|')) s = s.slice(1)
41 if (s.endsWith('|') && !s.endsWith('\\|')) s = s.slice(0, -1)
42 return s.split(/(?<!\\)\|/).map((c) =>
43 c.replace(/\\\|/g, '|').replace(/\\\\/g, '\\')
44 )
45}
46
47function isDelimiterRow(line: string): boolean {
48 const cells = splitCells(line)
49 return cells.length > 0 &&
50 cells.every((c) => /^:?-+:?$/.test(c.trim()))
51}
52
53function findTableClose(tokens: any[], from: number): number {
54 let depth = 0
55 for (let j = from; j < tokens.length; j++) {
56 if (tokens[j].type === 'table_open') depth++
57 else if (tokens[j].type === 'table_close') {
58 depth--
59 if (depth === 0) return j
60 }
61 }
62 return -1
63}
64
65function countCells(
66 tokens: any[],
67 from: number,
68 to: number,
69 type: string
70): number {
71 let count = 0
72 for (let k = from; k < to; k++) {
73 if (tokens[k].type === type) count++
74 }
75 return count
76}
77
78function findTableOpen(tokens: any[], tableCloseIdx: number): number {
79 let depth = 0
80 for (let k = tableCloseIdx; k >= 0; k--) {
81 if (tokens[k].type === 'table_close') depth++
82 else if (tokens[k].type === 'table_open') {
83 if (depth <= 1) return k
84 depth--
85 }
86 }
87 return -1
88}
89
90function countTableCols(tokens: any[], tableCloseIdx: number): number {
91 const openIdx = findTableOpen(tokens, tableCloseIdx)
92 if (openIdx === -1) return 0
93 let theadOpen = -1
94 let theadClose = -1
95 for (let k = openIdx; k < tableCloseIdx; k++) {
96 if (tokens[k].type === 'thead_open' && theadOpen === -1) {
97 theadOpen = k
98 }
99 if (tokens[k].type === 'thead_close') {
100 theadClose = k
101 break
102 }
103 }
104 if (theadOpen !== -1 && theadClose !== -1) {
105 return countCells(tokens, theadOpen, theadClose, 'th_open')
106 }
107 return 0
108}
109
110function stampTableAnchor(state: any, tokens: any[], tableCloseIdx: number) {
111 const openIdx = findTableOpen(tokens, tableCloseIdx)
112 if (openIdx === -1) return
113 state.env.__tableMoreCount = (state.env.__tableMoreCount ?? 0) + 1
114 tokens[openIdx].attrJoin(
115 'data-table-more',
116 `table-more-${state.env.__tableMoreCount}`
117 )
118}
119
120export function tableMorePlugin(md: MarkdownIt): void {
121 md.block.ruler.before(
122 'html_block',
123 'table_more_marker',
124 (state, startLine, endLine, silent) => {
125 const pos = state.bMarks[startLine] + state.tShift[startLine]
126 const max = state.eMarks[startLine]
127 if (!MARKER_RE.test(state.src.slice(pos, max).trim())) {
128 return false
129 }
130 // Only a marker directly after a table; otherwise literal text.
131 const prev = state.tokens[state.tokens.length - 1]
132 if (!prev || prev.type !== 'table_close') return false
133 if (silent) return true
134
135 // Full table follows: let the table parser handle it, merge later.
136 const next1 = startLine + 1 < endLine
137 ? getLine(state, startLine + 1)
138 : ''
139 const next2 = startLine + 2 < endLine
140 ? getLine(state, startLine + 2)
141 : ''
142 const fullTableFollows = isPipeLine(next1) && isDelimiterRow(next2)
143
144 const marker = state.push('table_more', '', 0)
145 marker.map = [startLine, startLine + 1]
146 marker.content = ''
147
148 if (fullTableFollows) {
149 state.line = startLine + 1
150 return true
151 }
152
153 // Else consume pipe rows as bare continuation rows (no header needed).
154 let line = startLine + 1
155 let rows = 0
156 while (line < endLine && isPipeLine(getLine(state, line))) {
157 const cells = splitCells(getLine(state, line))
158 const trOpen = state.push('tr_open', 'tr', 1)
159 trOpen.map = [line, line + 1]
160 let openTd: any = null
161 let span = 1
162 const flush = () => {
163 if (openTd && span > 1) openTd.attrJoin('colspan', String(span))
164 openTd = null
165 span = 1
166 }
167 for (const raw of cells) {
168 if (raw === '' && openTd) {
169 span++
170 continue
171 }
172 flush()
173 const td = state.push('td_open', 'td', 1)
174 td.attrs = []
175 const inline = state.push('inline', '', 0)
176 inline.content = raw.trim()
177 inline.map = [line, line + 1]
178 inline.children = []
179 state.push('td_close', 'td', -1)
180 openTd = td
181 }
182 flush()
183 state.push('tr_close', 'tr', -1)
184 rows++
185 line++
186 }
187
188 if (rows > 0) {
189 const closer = state.push('html_block', '', 0)
190 closer.map = [line, line]
191 closer.content = '</tbody>\n'
192 }
193 state.line = line
194 return true
195 }
196 )
197
198 // Unmatched markers (no second table) render as nothing.
199 md.renderer.rules.table_more = () => ''
200
201 md.core.ruler.after('block', 'table_more_merge', (state: any) => {
202 const tokens = state.tokens as any[]
203 let i = 0
204 while (i < tokens.length) {
205 if (
206 tokens[i].type !== 'table_close' ||
207 tokens[i + 1]?.type !== 'table_more'
208 ) {
209 i++
210 continue
211 }
212
213 // full second table follows the marker.
214 if (tokens[i + 2]?.type === 'table_open') {
215 const openIdx = i + 2
216 const closeIdx = findTableClose(tokens, openIdx)
217 if (closeIdx === -1) {
218 i++
219 continue
220 }
221
222 let theadOpen = -1
223 let theadClose = -1
224 for (let k = openIdx; k < closeIdx; k++) {
225 if (tokens[k].type === 'thead_open' && theadOpen === -1) {
226 theadOpen = k
227 }
228 if (tokens[k].type === 'thead_close') {
229 theadClose = k
230 break
231 }
232 }
233 const bodyStart = theadClose !== -1 ? theadClose + 1 : openIdx + 1
234 const kept = tokens.slice(bodyStart, closeIdx)
235
236 let cols = theadOpen !== -1 && theadClose !== -1
237 ? countCells(tokens, theadOpen, theadClose, 'th_open')
238 : 0
239 if (cols <= 0) cols = countTableCols(tokens, i)
240 if (cols <= 0) cols = 1
241
242 const hidden = kept.filter((t) => t.type === 'tr_open').length
243 if (hidden === 0) {
244 i = closeIdx + 1
245 continue
246 }
247
248 for (const t of kept) {
249 if (t.type === 'tbody_open') t.attrJoin('class', 'table-more-hidden')
250 }
251
252 stampTableAnchor(state, tokens, i)
253
254 // Toggle + hidden rows go inside the first table, before its close.
255 const marker = tokens[i + 1]
256 marker.type = 'html_block'
257 marker.tag = ''
258 marker.nesting = 0
259 marker.attrs = null
260 marker.children = null
261 marker.info = ''
262 marker.markup = ''
263 marker.content = buildToggleHtml(cols)
264
265 const merged = tokens.slice(0, i)
266 merged.push(marker)
267 merged.push(...kept)
268 merged.push(tokens[i])
269 merged.push(...tokens.slice(closeIdx + 1))
270 tokens.splice(0, tokens.length, ...merged)
271 i += 2 + kept.length
272 continue
273 }
274
275 // bare continuation rows follow the marker.
276 if (tokens[i + 2]?.type === 'tr_open') {
277 let j = i + 2
278 while (j < tokens.length && ROW_TOKEN_TYPES.has(tokens[j].type)) j++
279 const closer = tokens[j]
280 if (
281 !closer || closer.type !== 'html_block' ||
282 !closer.content.includes('</tbody>')
283 ) {
284 i++
285 continue
286 }
287 const kept = tokens.slice(i + 2, j)
288 const hidden = kept.filter((t) => t.type === 'tr_open').length
289 if (hidden === 0) {
290 tokens.splice(i + 1, j - i)
291 continue
292 }
293
294 let cols = countTableCols(tokens, i)
295 if (cols <= 0) {
296 const firstTr = kept.findIndex((t) => t.type === 'tr_open')
297 const end = kept.findIndex(
298 (t, idx) => idx > firstTr && t.type === 'tr_close'
299 )
300 cols = countCells(
301 kept,
302 firstTr,
303 end === -1 ? kept.length : end,
304 'td_open'
305 )
306 }
307 if (cols <= 0) cols = 1
308
309 stampTableAnchor(state, tokens, i)
310
311 const marker = tokens[i + 1]
312 marker.type = 'html_block'
313 marker.tag = ''
314 marker.nesting = 0
315 marker.attrs = null
316 marker.children = null
317 marker.info = ''
318 marker.markup = ''
319 marker.content = buildToggleHtml(cols) +
320 '<tbody class="table-more-hidden">\n'
321
322 // Move the toggle + bare rows inside the first table.
323 const segment = tokens.slice(i + 1, j + 1)
324 const merged = tokens.slice(0, i)
325 merged.push(...segment)
326 merged.push(tokens[i])
327 merged.push(...tokens.slice(j + 1))
328 tokens.splice(0, tokens.length, ...merged)
329 i += segment.length + 1
330 continue
331 }
332
333 i++
334 }
335 })
336}
docs/.vitepress/theme/Layout.vue +294 −92
@@ -6,11 +6,7 @@
66 All rights reserved. This code and its associated files may not be copied, modified, distributed, sublicensed, or used in any form, in whole or in part, without prior written permission from the copyright holder.
77-->
88<script setup lang="ts">
9import {
10 useEventListener,
11 useStorage,
12 useThrottleFn
13} from '@vueuse/core'
9import { useEventListener, useStorage, useThrottleFn } from '@vueuse/core'
1410import { getScrollOffset, useData, useRoute } from 'vitepress'
1511import type { DefaultTheme as Theme } from 'vitepress'
1612import VPSidebarGroup from 'vitepress/dist/client/theme-default/components/VPSidebarGroup.vue'
@@ -26,16 +22,24 @@ import {
2622 watchEffect
2723} from 'vue'
2824import { sidebar } from '../configs/constants'
29import { useBookmarks, BOOKMARK_CHANGE_EVENT } from './composables/useBookmarks'
3025import AnnouncementPill from './components/AnnouncementPill.vue'
31import SiteFooter from './components/SiteFooter.vue'
26import NavActions from './components/NavActions.vue'
3227import NotFoundComponent from './components/NotFound.vue'
3328import { NolebaseEnhancedReadabilitiesScreenMenu } from './components/settings'
34import NavActions from './components/NavActions.vue'
3529import SidebarCard from './components/SidebarCard.vue'
36import { AccentBgStorageKey, AccentBgStrengthStorageKey, AccentColorStorageKey } from './constants'
30import SiteFooter from './components/SiteFooter.vue'
31import { BOOKMARK_CHANGE_EVENT, useBookmarks } from './composables/useBookmarks'
3732import { useEffects } from './composables/useEffects'
38import { applyFavicons, removeFavicons, useFavicons } from './composables/useFavicons'
33import {
34 applyFavicons,
35 removeFavicons,
36 useFavicons
37} from './composables/useFavicons'
38import {
39 AccentBgStorageKey,
40 AccentBgStrengthStorageKey,
41 AccentColorStorageKey
42} from './constants'
3943import { searchResultHighlightMode } from './searchState'
4044
4145const route = useRoute()
@@ -84,6 +88,12 @@ if (!import.meta.env.SSR) {
8488 if (target) {
8589 void nextTick(() => {
8690 if (searchNavigated) {
91 scanSectionForTerms(
92 target,
93 getSearchTerms(searchQuery),
94 () => {},
95 expandTableMoreEl
96 )
8797 highlightSearchResult(target)
8898 resetSearchNavigation()
8999 }
@@ -99,6 +109,12 @@ if (!import.meta.env.SSR) {
99109 if (!currentHash) return
100110 const target = getTargetByHash(currentHash)
101111 if (target) {
112 scanSectionForTerms(
113 target,
114 getSearchTerms(searchQuery),
115 () => {},
116 expandTableMoreEl
117 )
102118 highlightSearchResult(target)
103119 resetSearchNavigation()
104120 } else if (attempts < 15) {
@@ -131,7 +147,6 @@ const removeSearchResultHighlights = () => {
131147 )
132148}
133149
134
135150let highlightTerm = ''
136151let highlightTabPath: string[] | null = null
137152
@@ -164,7 +179,9 @@ const applyHighlightWithin = (root: HTMLElement, term: string) => {
164179 const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, {
165180 acceptNode(node) {
166181 const parent = node.parentElement
167 if (!parent || parent.closest('.search-result-highlight, script, style')) {
182 if (
183 !parent || parent.closest('.search-result-highlight, script, style')
184 ) {
168185 return NodeFilter.FILTER_REJECT
169186 }
170187 return NodeFilter.FILTER_ACCEPT
@@ -225,7 +242,7 @@ const highlightSearchResult = (target?: HTMLElement) => {
225242 )
226243 highlightTabPath = panel ? getPanelTabPath(panel) : null
227244 highlightTerm = term
228
245
229246 if (!applyHighlightWithin(target, term)) {
230247 const docRoot = document.querySelector<HTMLElement>('.VPDoc .vp-doc')
231248 if (docRoot) {
@@ -271,6 +288,7 @@ const getScrollTargetForAnchor = (target: HTMLElement) => {
271288
272289const TAB_QUERY_PARAM = 't'
273290const COLLAPSIBLE_QUERY_PARAM = 'c'
291const TABLE_MORE_QUERY_PARAM = 'm'
274292
275293const getRequestedAnchorPath = (param: string) => {
276294 const value = new URLSearchParams(window.location.search).get(param)
@@ -283,29 +301,43 @@ const getRequestedAnchorPath = (param: string) => {
283301const getRequestedTabPath = () => getRequestedAnchorPath(TAB_QUERY_PARAM)
284302const getRequestedCollapsiblePath = () =>
285303 getRequestedAnchorPath(COLLAPSIBLE_QUERY_PARAM)
304const getRequestedTableMorePath = () =>
305 getRequestedAnchorPath(TABLE_MORE_QUERY_PARAM)
286306
287307const encodeAnchorList = (anchors: string[]) =>
288308 anchors.map((anchor) => encodeURIComponent(anchor)).join(',')
289309
290310const buildUrl = (
291 options: { tabs?: string[]; collapsibles?: string[]; hash?: string } = {}
311 options: {
312 tabs?: string[]
313 collapsibles?: string[]
314 tables?: string[]
315 hash?: string
316 } = {}
292317) => {
293318 const params = new URLSearchParams(window.location.search)
294319 const currentTabs = params.get(TAB_QUERY_PARAM)
295320 const currentCollapsibles = params.get(COLLAPSIBLE_QUERY_PARAM)
321 const currentTables = params.get(TABLE_MORE_QUERY_PARAM)
296322 params.delete(TAB_QUERY_PARAM)
297323 params.delete(COLLAPSIBLE_QUERY_PARAM)
324 params.delete(TABLE_MORE_QUERY_PARAM)
298325
299326 const tabs = options.tabs ??
300327 (currentTabs ? currentTabs.split(',').filter(Boolean) : [])
301328 const collapsibles = options.collapsibles ??
302329 (currentCollapsibles ? currentCollapsibles.split(',').filter(Boolean) : [])
330 const tables = options.tables ??
331 (currentTables ? currentTables.split(',').filter(Boolean) : [])
303332
304333 const queryParts = [
305334 params.toString(),
306335 tabs.length ? `${TAB_QUERY_PARAM}=${encodeAnchorList(tabs)}` : '',
307336 collapsibles.length
308337 ? `${COLLAPSIBLE_QUERY_PARAM}=${encodeAnchorList(collapsibles)}`
338 : '',
339 tables.length
340 ? `${TABLE_MORE_QUERY_PARAM}=${encodeAnchorList(tables)}`
309341 : ''
310342 ].filter(Boolean)
311343
@@ -374,6 +406,73 @@ const queueTabQueryUpdateForSelection = (target: EventTarget | null) => {
374406
375407const COLLAPSIBLE_SELECTOR = 'details[data-collapsible-anchor]'
376408
409const detailsContainsTerms = (d: HTMLElement, terms: string[]) => {
410 if (!terms.length) return false
411 const text = (d.textContent ?? '').toLowerCase()
412 return terms.every((term) => text.includes(term))
413}
414
415// Expand tables whose hidden rows hold all searched terms.
416const tableContainsTerms = (t: HTMLElement, terms: string[]) => {
417 if (!terms.length) return false
418 const hidden = t.querySelector('tbody.table-more-hidden')
419 const text = ((hidden ?? t).textContent ?? '').toLowerCase()
420 return terms.every((term) => text.includes(term))
421}
422
423const expandTableMoreEl = (t: HTMLElement) => {
424 const box = getTableMoreCheckbox(t)
425 if (box && !box.checked) box.checked = true
426}
427
428const scanSectionForTerms = (
429 target: HTMLElement,
430 terms: string[],
431 onDetails: (d: HTMLElement) => void,
432 onTable: (t: HTMLElement) => void
433) => {
434 const tagName = target.tagName
435 if (tagName.length !== 2 || tagName[0] !== 'H') return
436 const level = +tagName[1]
437 if (level < 1 || level > 6 || !terms.length) return
438
439 let sibling = target.nextElementSibling
440
441 while (sibling) {
442 const siblingTag = sibling.tagName
443 if (
444 siblingTag.length === 2 && siblingTag[0] === 'H' &&
445 +siblingTag[1] <= level
446 ) break
447
448 if (siblingTag === 'DETAILS') {
449 if (detailsContainsTerms(sibling as HTMLElement, terms)) {
450 onDetails(sibling as HTMLElement)
451 }
452 }
453
454 const nested = sibling.getElementsByTagName('details')
455 for (let i = 0, len = nested.length; i < len; i++) {
456 if (detailsContainsTerms(nested[i], terms)) onDetails(nested[i])
457 }
458
459 if (siblingTag === 'TABLE') {
460 if (tableContainsTerms(sibling as HTMLElement, terms)) {
461 onTable(sibling as HTMLElement)
462 }
463 }
464
465 const nestedTables = sibling.getElementsByTagName('table')
466 for (let i = 0, len = nestedTables.length; i < len; i++) {
467 if (tableContainsTerms(nestedTables[i], terms)) {
468 onTable(nestedTables[i])
469 }
470 }
471
472 sibling = sibling.nextElementSibling
473 }
474}
475
377476const getOpenCollapsiblePath = (details: HTMLElement) => {
378477 const path: string[] = []
379478 let el: HTMLElement | null = details
@@ -430,6 +529,34 @@ const queueCollapsibleQueryUpdate = (target: EventTarget | null) => {
430529 }
431530}
432531
532const updateQueryForTableMore = async (table: HTMLElement) => {
533 await nextTick()
534 await nextFrame()
535
536 const tables = getOpenTableMorePath()
537 const tabPath = getEnclosingTabPath(table)
538
539 const nextUrl = buildUrl({
540 tabs: tabPath.length ? tabPath : undefined,
541 tables
542 })
543 const currentUrl =
544 `${window.location.pathname}${window.location.search}${window.location.hash}`
545 if (nextUrl === currentUrl) return
546
547 window.history.pushState(null, '', nextUrl)
548 rewriteAnchorLinks()
549}
550
551const queueTableMoreQueryUpdate = (target: EventTarget | null) => {
552 if (!(target instanceof HTMLElement)) return
553
554 const box = target.closest<HTMLInputElement>('.table-more-checkbox')
555 if (!box) return
556 const table = box.closest<HTMLElement>('table')
557 if (table) void updateQueryForTableMore(table)
558}
559
433560const selectCollapsiblesByPath = async (collapsiblePath: string[]) => {
434561 let root: ParentNode = document
435562 let opened: HTMLElement | undefined
@@ -453,6 +580,45 @@ const selectCollapsiblesByPath = async (collapsiblePath: string[]) => {
453580 return opened
454581}
455582
583const TABLE_MORE_SELECTOR = 'table[data-table-more]'
584
585const getTableMoreCheckbox = (table: HTMLElement) =>
586 table.querySelector<HTMLInputElement>('.table-more-checkbox')
587
588const selectTablesByPath = async (anchors: string[]) => {
589 let opened: HTMLTableElement | undefined
590
591 for (const anchor of anchors) {
592 const table = document.querySelector<HTMLTableElement>(
593 `table[data-table-more="${CSS.escape(anchor)}"]`
594 )
595 if (!table) continue
596
597 const box = getTableMoreCheckbox(table)
598 if (box && !box.checked) {
599 box.checked = true
600 await nextTick()
601 await nextFrame()
602 }
603 opened = table
604 }
605
606 return opened
607}
608
609const getOpenTableMorePath = () => {
610 const anchors: string[] = []
611 document.querySelectorAll<HTMLTableElement>(TABLE_MORE_SELECTOR).forEach(
612 (table) => {
613 if (getTableMoreCheckbox(table)?.checked) {
614 const anchor = table.dataset.tableMore
615 if (anchor) anchors.push(anchor)
616 }
617 }
618 )
619 return anchors
620}
621
456622const TAB_LINK_MARKER = 'tab-'
457623
458624const rewriteAnchorLinks = () => {
@@ -585,44 +751,19 @@ const openCollapsibles = async (target: HTMLElement) => {
585751
586752 const tagName = activeTarget.tagName
587753 if (tagName.length === 2 && tagName[0] === 'H') {
588 const level = +tagName[1]
589 if (level >= 1 && level <= 6) {
590 const terms = getSearchTerms(searchQuery)
591 const detailsContainsTerms = (d: HTMLElement) => {
592 if (!terms.length) return false
593 const text = (d.textContent ?? '').toLowerCase()
594 return terms.every((term) => text.includes(term))
595 }
596
597 let sibling = activeTarget.nextElementSibling
598
599 while (sibling) {
600 const siblingTag = sibling.tagName
601 if (
602 siblingTag.length === 2 && siblingTag[0] === 'H' &&
603 +siblingTag[1] <= level
604 ) break
605
606 if (siblingTag === 'DETAILS') {
607 if (detailsContainsTerms(sibling as HTMLElement)) {
608 ;(sibling as HTMLDetailsElement).open = true
609 if (scrollTarget === activeTarget) {
610 scrollTarget = sibling as HTMLElement
611 }
612 }
613 }
614
615 const nested = sibling.getElementsByTagName('details')
616 for (let i = 0, len = nested.length; i < len; i++) {
617 if (detailsContainsTerms(nested[i])) {
618 nested[i].open = true
619 if (scrollTarget === activeTarget) scrollTarget = nested[i]
620 }
621 }
622
623 sibling = sibling.nextElementSibling
754 const terms = getSearchTerms(searchQuery)
755 scanSectionForTerms(
756 activeTarget,
757 terms,
758 (d) => {
759 ;(d as HTMLDetailsElement).open = true
760 if (scrollTarget === activeTarget) scrollTarget = d
761 },
762 (t) => {
763 expandTableMoreEl(t)
764 if (scrollTarget === activeTarget) scrollTarget = t
624765 }
625 }
766 )
626767 }
627768
628769 await nextTick()
@@ -649,6 +790,10 @@ const tryOpenAnchoredContent = async () => {
649790 const openedCollapsible = requestedCollapsibles.length
650791 ? await selectCollapsiblesByPath(requestedCollapsibles)
651792 : undefined
793 const requestedTables = getRequestedTableMorePath()
794 const openedTable = requestedTables.length
795 ? await selectTablesByPath(requestedTables)
796 : undefined
652797 const hash = window.location.hash.slice(1)
653798
654799 if (!hash) {
@@ -662,6 +807,8 @@ const tryOpenAnchoredContent = async () => {
662807 scrollToElement(openedCollapsible, false)
663808 } else if (selectedTabs) {
664809 scrollToElement(getSelectedTabScrollTarget(selectedTabs), false)
810 } else if (openedTable) {
811 scrollToElement(openedTable, false)
665812 }
666813 return
667814 }
@@ -686,14 +833,16 @@ const tryOpenAnchoredContent = async () => {
686833 await openCollapsibles(target)
687834 highlightSearchResult(target)
688835 const collapsiblePath = getOpenCollapsiblePath(target)
689 if (collapsiblePath.length) {
836 const tablePath = getOpenTableMorePath()
837 if (collapsiblePath.length || tablePath.length) {
690838 const tabPath = getEnclosingTabPath(target)
691839 window.history.replaceState(
692840 null,
693841 '',
694842 buildUrl({
695843 tabs: tabPath.length ? tabPath : undefined,
696 collapsibles: collapsiblePath
844 collapsibles: collapsiblePath,
845 tables: tablePath
697846 })
698847 )
699848 rewriteAnchorLinks()
@@ -833,7 +982,8 @@ const setupOutlineFollow = () => {
833982 followActiveOutlineLink()
834983}
835984
836const BOOKMARK_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z"/></svg>`
985const BOOKMARK_SVG =
986 `<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z"/></svg>`
837987
838988function syncTocBookmarkStates() {
839989 const path = route.path
@@ -877,14 +1027,20 @@ let tocRaf = 0
8771027
8781028function scanTocItems(path: string) {
8791029 // Desktop sidebar — VPDocOutlineItem is called with :root="true"
880 document.querySelectorAll<HTMLElement>('.VPDocOutlineItem.root > li').forEach(li => addBookmarkBtnToLi(li, path))
1030 document.querySelectorAll<HTMLElement>('.VPDocOutlineItem.root > li').forEach(
1031 li => addBookmarkBtnToLi(li, path)
1032 )
8811033 // Mobile dropdown — VPDocOutlineItem is called without root prop, so the ul gets class "nested"
882 document.querySelectorAll<HTMLElement>('.VPLocalNavOutlineDropdown .outline > .VPDocOutlineItem > li').forEach(li => addBookmarkBtnToLi(li, path))
1034 document.querySelectorAll<HTMLElement>(
1035 '.VPLocalNavOutlineDropdown .outline > .VPDocOutlineItem > li'
1036 ).forEach(li => addBookmarkBtnToLi(li, path))
8831037}
8841038
8851039function setupTocBookmarks() {
8861040 const path = route.path
887 document.querySelectorAll<HTMLElement>('.toc-bookmark-btn').forEach(btn => btn.remove())
1041 document.querySelectorAll<HTMLElement>('.toc-bookmark-btn').forEach(btn =>
1042 btn.remove()
1043 )
8881044 scanTocItems(path)
8891045
8901046 // Mobile dropdown items are v-if rendered on open — watch for them being added
@@ -903,7 +1059,9 @@ onMounted(tryOpenAnchoredContent)
9031059onMounted(rewriteAnchorLinksDeferred)
9041060onMounted(() => nextTick(setupOutlineFollow))
9051061onMounted(() => nextTick(setupTocBookmarks))
906onMounted(() => window.addEventListener('scroll', onMobileOutlineScroll, { passive: true }))
1062onMounted(() =>
1063 window.addEventListener('scroll', onMobileOutlineScroll, { passive: true })
1064)
9071065onUnmounted(() => window.removeEventListener('scroll', onMobileOutlineScroll))
9081066watch(() => route.data, () => {
9091067 void tryOpenAnchoredContent()
@@ -987,7 +1145,10 @@ watch(faviconsEnabled, (enabled) => {
9871145
9881146watch(
9891147 () => route.path,
990 () => nextTick(() => { if (faviconsEnabled.value) applyFavicons(document) }),
1148 () =>
1149 nextTick(() => {
1150 if (faviconsEnabled.value) applyFavicons(document)
1151 }),
9911152 { flush: 'post' }
9921153)
9931154
@@ -1000,56 +1161,56 @@ const accentPalettes: Record<string, PaletteEntry> = {
10001161 500: 'oklch(0.626 0.098 247.46)',
10011162 600: 'oklch(0.523 0.081 246.86)',
10021163 700: 'oklch(0.43 0.066 246.75)',
1003 800: 'oklch(0.335 0.052 246.76)',
1164 800: 'oklch(0.335 0.052 246.76)'
10041165 },
10051166 asuka: {
10061167 400: 'oklch(0.740 0.210 32)',
10071168 500: 'oklch(0.650 0.240 30)',
10081169 600: 'oklch(0.555 0.238 28)',
10091170 700: 'oklch(0.455 0.205 26)',
1010 800: 'oklch(0.370 0.165 24)',
1171 800: 'oklch(0.370 0.165 24)'
10111172 },
10121173 irys: {
10131174 400: 'oklch(0.716 0.188 5.18)',
10141175 500: 'oklch(0.659 0.237 8.99)',
10151176 600: 'oklch(0.584 0.229 10.32)',
10161177 700: 'oklch(0.538 0.213 9.67)',
1017 800: 'oklch(0.475 0.187 5.94)',
1178 800: 'oklch(0.475 0.187 5.94)'
10181179 },
10191180 inanis: {
10201181 400: 'oklch(0.762 0.073 302.02)',
10211182 500: 'oklch(0.663 0.102 301.22)',
10221183 600: 'oklch(0.580 0.119 301.34)',
10231184 700: 'oklch(0.508 0.114 301.00)',
1024 800: 'oklch(0.452 0.094 302.20)',
1185 800: 'oklch(0.452 0.094 302.20)'
10251186 },
10261187 baelz: {
10271188 400: 'oklch(0.720 0.215 22.00)',
10281189 500: 'oklch(0.640 0.255 22.00)',
10291190 600: 'oklch(0.555 0.268 22.00)',
10301191 700: 'oklch(0.472 0.248 22.00)',
1031 800: 'oklch(0.395 0.208 22.00)',
1192 800: 'oklch(0.395 0.208 22.00)'
10321193 },
10331194 amelia: {
10341195 400: 'oklch(0.800 0.085 75.49)',
10351196 500: 'oklch(0.710 0.090 72.47)',
10361197 600: 'oklch(0.594 0.085 69.07)',
10371198 700: 'oklch(0.496 0.078 72.12)',
1038 800: 'oklch(0.391 0.062 68.86)',
1199 800: 'oklch(0.391 0.062 68.86)'
10391200 },
10401201 suisei: {
10411202 400: 'oklch(0.827 0.096 224.60)',
10421203 500: 'oklch(0.740 0.119 230.91)',
10431204 600: 'oklch(0.645 0.127 236.29)',
10441205 700: 'oklch(0.548 0.120 241.26)',
1045 800: 'oklch(0.451 0.106 244.63)',
1206 800: 'oklch(0.451 0.106 244.63)'
10461207 },
10471208 miku: {
10481209 400: 'oklch(0.788 0.133 184.43)',
10491210 500: 'oklch(0.711 0.123 185.28)',
10501211 600: 'oklch(0.607 0.104 187.31)',
10511212 700: 'oklch(0.515 0.086 189.60)',
1052 800: 'oklch(0.441 0.071 190.95)',
1213 800: 'oklch(0.441 0.071 190.95)'
10531214 },
10541215 fubuki: {
10551216 dark: {
@@ -1057,16 +1218,16 @@ const accentPalettes: Record<string, PaletteEntry> = {
10571218 500: 'oklch(0.78 0 0)',
10581219 600: 'oklch(0.68 0 0)',
10591220 700: 'oklch(0.58 0 0)',
1060 800: 'oklch(0.48 0 0)',
1221 800: 'oklch(0.48 0 0)'
10611222 },
10621223 light: {
10631224 400: 'oklch(0.52 0 0)',
10641225 500: 'oklch(0.42 0 0)',
10651226 600: 'oklch(0.32 0 0)',
10661227 700: 'oklch(0.22 0 0)',
1067 800: 'oklch(0.12 0 0)',
1068 },
1069 },
1228 800: 'oklch(0.12 0 0)'
1229 }
1230 }
10701231}
10711232
10721233const accentColor = useStorage(AccentColorStorageKey, 'ayanami')
@@ -1091,7 +1252,7 @@ const accentBgTokens: Record<'dark' | 'light', Record<string, TintEntry>> = {
10911252 '--wk-c-menu-bg': [0.295, 0.032],
10921253 '--wk-c-nav-solid-bg': [0.2, 0.024],
10931254 '--nav-pill-bg': [0.205, 0.024, 0.7],
1094 '--wk-fs-header-divider': [0.44, 0.02, 0.65],
1255 '--wk-fs-header-divider': [0.44, 0.02, 0.65]
10951256 },
10961257 light: {
10971258 '--vp-c-bg': [0.986, 0.012],
@@ -1107,13 +1268,15 @@ const accentBgTokens: Record<'dark' | 'light', Record<string, TintEntry>> = {
11071268 '--wk-c-menu-bg': [0.928, 0.026],
11081269 '--wk-c-nav-solid-bg': [0.986, 0.012],
11091270 '--nav-pill-bg': [0.99, 0.01, 0.8],
1110 '--wk-fs-header-divider': [0.715, 0.02, 0.25],
1111 },
1271 '--wk-fs-header-divider': [0.715, 0.02, 0.25]
1272 }
11121273}
1113const accentBgTokenKeys = [...new Set([
1114 ...Object.keys(accentBgTokens.dark),
1115 ...Object.keys(accentBgTokens.light),
1116])]
1274const accentBgTokenKeys = [
1275 ...new Set([
1276 ...Object.keys(accentBgTokens.dark),
1277 ...Object.keys(accentBgTokens.light)
1278 ])
1279]
11171280
11181281const applyAccentTheme = () => {
11191282 if (import.meta.env.SSR) return
@@ -1126,14 +1289,26 @@ const applyAccentTheme = () => {
11261289 el.style.setProperty('--vp-c-brand-1', shades['400'])
11271290 el.style.setProperty('--vp-c-brand-2', shades['500'])
11281291 el.style.setProperty('--vp-c-brand-3', shades['700'])
1129 el.style.setProperty('--vp-c-brand-soft', `color-mix(in srgb, ${shades['500']} 20%, transparent)`)
1130 el.style.setProperty('--vp-c-sidebar-active', `color-mix(in srgb, ${shades['500']} 15%, transparent)`)
1292 el.style.setProperty(
1293 '--vp-c-brand-soft',
1294 `color-mix(in srgb, ${shades['500']} 20%, transparent)`
1295 )
1296 el.style.setProperty(
1297 '--vp-c-sidebar-active',
1298 `color-mix(in srgb, ${shades['500']} 15%, transparent)`
1299 )
11311300 } else {
11321301 el.style.setProperty('--vp-c-brand-1', shades['500'])
11331302 el.style.setProperty('--vp-c-brand-2', shades['600'])
11341303 el.style.setProperty('--vp-c-brand-3', shades['800'])
1135 el.style.setProperty('--vp-c-brand-soft', `color-mix(in srgb, ${shades['400']} 40%, transparent)`)
1136 el.style.setProperty('--vp-c-sidebar-active', `color-mix(in srgb, ${shades['800']} 15%, transparent)`)
1304 el.style.setProperty(
1305 '--vp-c-brand-soft',
1306 `color-mix(in srgb, ${shades['400']} 40%, transparent)`
1307 )
1308 el.style.setProperty(
1309 '--vp-c-sidebar-active',
1310 `color-mix(in srgb, ${shades['800']} 15%, transparent)`
1311 )
11371312 }
11381313
11391314 for (const key of accentBgTokenKeys) el.style.removeProperty(key)
@@ -1145,7 +1320,8 @@ const applyAccentTheme = () => {
11451320 if (parsed) {
11461321 // Tint scales with the accent's own chroma (full tint at C >= 0.10,
11471322 // grayscale accents stay gray), then with the intensity preset.
1148 const strength = Math.min(1, Number(parsed[1]) / 0.10) * userStrength * 1.5
1323 const strength = Math.min(1, Number(parsed[1]) / 0.10) * userStrength *
1324 1.5
11491325 const hue = parsed[2]
11501326 const tokens = accentBgTokens[isDark.value ? 'dark' : 'light']
11511327 for (const [key, [l, c, alpha]] of Object.entries(tokens)) {
@@ -1177,15 +1353,25 @@ function initTitleOnly() {
11771353 })
11781354}
11791355
1356// Browsers restore checkbox state on reload; always start collapsed.
1357function resetTableMoreInRoot(root: ParentNode) {
1358 root.querySelectorAll<HTMLInputElement>('.table-more-checkbox:checked')
1359 .forEach((el) => {
1360 el.checked = false
1361 })
1362}
1363
11801364// Wrap bare tables in their own scroll container so they scroll independently of sibling content.
11811365function wrapTablesInRoot(root: ParentNode) {
1182 root.querySelectorAll<HTMLTableElement>('table:not(.scrape-table)').forEach(table => {
1183 if (table.parentElement?.classList.contains('table-scroll')) return
1184 const wrapper = document.createElement('div')
1185 wrapper.className = 'table-scroll'
1186 table.replaceWith(wrapper)
1187 wrapper.appendChild(table)
1188 })
1366 root.querySelectorAll<HTMLTableElement>('table:not(.scrape-table)').forEach(
1367 table => {
1368 if (table.parentElement?.classList.contains('table-scroll')) return
1369 const wrapper = document.createElement('div')
1370 wrapper.className = 'table-scroll'
1371 table.replaceWith(wrapper)
1372 wrapper.appendChild(table)
1373 }
1374 )
11891375}
11901376
11911377function initCopyButtonsInRoot(root: ParentNode) {
@@ -1269,6 +1455,7 @@ let copyButtonObserver: MutationObserver | null = null
12691455
12701456function setupManualCopyButtons() {
12711457 wrapTablesInRoot(document)
1458 resetTableMoreInRoot(document)
12721459 initCopyButtonsInRoot(document)
12731460
12741461 copyButtonObserver?.disconnect()
@@ -1278,6 +1465,7 @@ function setupManualCopyButtons() {
12781465 if (!(node instanceof HTMLElement)) continue
12791466 if (node.classList.contains('plugin-tabs--content')) {
12801467 wrapTablesInRoot(node)
1468 resetTableMoreInRoot(node)
12811469 initCopyButtonsInRoot(node)
12821470 if (faviconsEnabled.value) applyFavicons(node)
12831471 reapplyHighlightIfNeeded(node)
@@ -1285,6 +1473,7 @@ function setupManualCopyButtons() {
12851473 node.querySelectorAll<HTMLElement>('.plugin-tabs--content').forEach(
12861474 (panel) => {
12871475 wrapTablesInRoot(panel)
1476 resetTableMoreInRoot(panel)
12881477 initCopyButtonsInRoot(panel)
12891478 if (faviconsEnabled.value) applyFavicons(panel)
12901479 reapplyHighlightIfNeeded(panel)
@@ -1302,7 +1491,10 @@ watch(
13021491 () => {
13031492 highlightTerm = ''
13041493 highlightTabPath = null
1305 nextTick(() => { initTitleOnly(); setupManualCopyButtons() })
1494 nextTick(() => {
1495 initTitleOnly()
1496 setupManualCopyButtons()
1497 })
13061498 },
13071499 { flush: 'post' }
13081500)
@@ -1315,6 +1507,11 @@ onMounted(() => {
13151507 initTitleOnly()
13161508 nextTick(setupManualCopyButtons)
13171509
1510 // bfcache can restore the <more> table checkboxes as checked.
1511 window.addEventListener('pageshow', (e) => {
1512 if (e.persisted) resetTableMoreInRoot(document)
1513 })
1514
13181515 // Icon tooltip: fixed-position popup appended to <body> to escape table overflow clipping
13191516 const tooltipEl = document.createElement('div')
13201517 tooltipEl.className = 'icon-tip-popup'
@@ -1421,6 +1618,11 @@ onMounted(() => {
14211618 queueCollapsibleQueryUpdate(e.target)
14221619 })
14231620
1621 useEventListener(document, 'change', (e: Event) => {
1622 if (!e.isTrusted) return
1623 queueTableMoreQueryUpdate(e.target)
1624 })
1625
14241626 useEventListener(document, 'keydown', (e: KeyboardEvent) => {
14251627 if (!e.isTrusted || (e.key !== 'ArrowLeft' && e.key !== 'ArrowRight')) {
14261628 return
@@ -1627,4 +1829,4 @@ onUnmounted(() => {
16271829 </span>
16281830 </template>
16291831 </Layout>
1630</template>
\ No newline at end of file
1832</template>
docs/.vitepress/theme/index.ts +2 −1
@@ -17,6 +17,7 @@ import { createMediumZoomProvider } from './composables/medium-zoom'
1717import 'virtual:uno.css'
1818import Layout from './Layout.vue'
1919import './styles/tooltip-hint.css'
20import './styles/table-more.css'
2021import './styles/steps.css'
2122import { enhanceAppWithTabs } from './components/tabs'
2223import { registerGlobalComponents } from './globalComponents'
@@ -91,4 +92,4 @@ export default {
9192 ]
9293 )
9394 }
94} satisfies Theme
\ No newline at end of file
95} satisfies Theme
docs/.vitepress/theme/styles/table-more.css added +85
@@ -0,0 +1,85 @@
1/* Expandable table sections ("<more>" marker). Pure CSS toggle
2 (hidden checkbox + :has()): no JS, SSR-safe. */
3
4.vp-doc table tbody.table-more-hidden {
5 display: none;
6}
7
8.vp-doc table:has(.table-more-checkbox:checked) tbody.table-more-hidden {
9 display: table-row-group;
10}
11
12.table-more-toggle-row > td {
13 padding: 0 !important;
14 text-align: center;
15}
16
17.table-more-label {
18 display: flex;
19 align-items: center;
20 justify-content: center;
21 gap: 0.4em;
22 padding: 8px 16px;
23 cursor: pointer;
24 font-size: 0.875rem;
25 font-weight: 600;
26 color: var(--vp-c-text-2);
27 user-select: none;
28}
29
30.table-more-label:hover {
31 color: var(--vp-c-brand-1);
32}
33
34.table-more-label:focus-within .table-more-text,
35.table-more-label:focus-within .table-more-icon {
36 color: var(--vp-c-brand-1);
37}
38
39/* Keep the checkbox keyboard-focusable but invisible. */
40.table-more-checkbox {
41 position: absolute;
42 opacity: 0;
43 pointer-events: none;
44}
45
46.table-more-icon {
47 transition: transform 0.2s;
48}
49
50.vp-doc table:has(.table-more-checkbox:checked) .table-more-icon {
51 transform: rotate(180deg);
52}
53
54.table-more-text--less {
55 display: none;
56}
57
58.vp-doc table:has(.table-more-checkbox:checked) .table-more-text--more {
59 display: none;
60}
61
62.vp-doc table:has(.table-more-checkbox:checked) .table-more-text--less {
63 display: inline;
64}
65
66@media (prefers-reduced-motion: reduce) {
67 .table-more-icon {
68 transition: none;
69 }
70}
71
72/* Respect the "Effects: OFF" site setting. */
73html.effects-disabled .table-more-icon {
74 transition: none;
75}
76
77@media print {
78 .vp-doc table tbody.table-more-hidden {
79 display: table-row-group !important;
80 }
81
82 .vp-doc table tbody.table-more-toggle {
83 display: none !important;
84 }
85}
unocss.config.ts +8 −2
@@ -18,7 +18,10 @@ import {
1818 transformerDirectives
1919} from 'unocss'
2020import { aliases } from './docs/.vitepress/configs/markdown/emoji'
21import { LANG_FLAG_FALLBACK, LANG_FLAG_ICONS } from './docs/.vitepress/configs/markdown/langFlags'
21import {
22 LANG_FLAG_FALLBACK,
23 LANG_FLAG_ICONS
24} from './docs/.vitepress/configs/markdown/langFlags'
2225
2326const iconPrefixes = [
2427 'octicon-',
@@ -79,6 +82,7 @@ const safelist = [
7982 'i-lucide:settings',
8083 'i-lucide:download',
8184 'i-lucide:chevron-down',
85 'i-mdi-chevron-down',
8286 'i-lucide:search',
8387 'i-lucide:languages',
8488 'i-lucide:shield',
@@ -97,7 +101,9 @@ const safelist = [
97101 'i-twemoji-growing-heart',
98102 'i-twemoji-folded-hands',
99103 'i-twemoji-glowing-star',
100 ...Array.from(new Set([...Object.values(LANG_FLAG_ICONS), LANG_FLAG_FALLBACK])).map(
104 ...Array.from(
105 new Set([...Object.values(LANG_FLAG_ICONS), LANG_FLAG_FALLBACK])
106 ).map(
101107 (icon) => `i-twemoji-${icon}`
102108 )
103109]