Commit cc4fc4d48b

cc4fc4d48b200b83cc619f49b4c5c27685b3c7fb

parent: 49d0900bcc

Unsigned

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

a

Layout: unified · split

docs/.vitepress/configs/markdown/tableMore.ts +3 −5
@@ -110,11 +110,9 @@ function countTableCols(tokens: any[], tableCloseIdx: number): number {
110110function stampTableAnchor(state: any, tokens: any[], tableCloseIdx: number) {
111111 const openIdx = findTableOpen(tokens, tableCloseIdx)
112112 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 )
113 const n = state.env.__tableMoreCount ?? 0
114 state.env.__tableMoreCount = n + 1
115 tokens[openIdx].attrJoin('data-table-more', String(n))
118116}
119117
120118export function tableMorePlugin(md: MarkdownIt): void {
docs/.vitepress/theme/Layout.vue +26 −5
@@ -384,8 +384,9 @@ const updateQueryForSelectedTab = async (tabs: HTMLElement) => {
384384 if (!tabPath.length) return
385385
386386 const collapsibles = getOpenCollapsiblePath(tabs)
387 const tables = getOpenTableMorePath(tabs)
387388
388 const nextUrl = buildUrl({ tabs: tabPath, collapsibles })
389 const nextUrl = buildUrl({ tabs: tabPath, collapsibles, tables })
389390 const currentUrl =
390391 `${window.location.pathname}${window.location.search}${window.location.hash}`
391392 if (nextUrl === currentUrl) return
@@ -506,9 +507,11 @@ const updateQueryForCollapsible = async (details: HTMLElement) => {
506507
507508 const collapsiblePath = getOpenCollapsiblePath(details)
508509 const tabPath = getEnclosingTabPath(details)
510 const tables = getOpenTableMorePath()
509511
510512 const nextUrl = buildUrl({
511513 tabs: tabPath.length ? tabPath : [],
514 tables,
512515 collapsibles: collapsiblePath
513516 })
514517 const currentUrl =
@@ -554,7 +557,19 @@ const queueTableMoreQueryUpdate = (target: EventTarget | null) => {
554557 const box = target.closest<HTMLInputElement>('.table-more-checkbox')
555558 if (!box) return
556559 const table = box.closest<HTMLElement>('table')
557 if (table) void updateQueryForTableMore(table)
560 if (!table) return
561 if (box.checked) {
562 // Accordion: opening one closes the others so only it stays in the URL.
563 document.querySelectorAll<HTMLTableElement>(TABLE_MORE_SELECTOR).forEach(
564 (other) => {
565 if (other !== table) {
566 const otherBox = getTableMoreCheckbox(other)
567 if (otherBox) otherBox.checked = false
568 }
569 }
570 )
571 }
572 void updateQueryForTableMore(table)
558573}
559574
560575const selectCollapsiblesByPath = async (collapsiblePath: string[]) => {
@@ -606,9 +621,9 @@ const selectTablesByPath = async (anchors: string[]) => {
606621 return opened
607622}
608623
609const getOpenTableMorePath = () => {
624const getOpenTableMorePath = (root: ParentNode = document) => {
610625 const anchors: string[] = []
611 document.querySelectorAll<HTMLTableElement>(TABLE_MORE_SELECTOR).forEach(
626 root.querySelectorAll<HTMLTableElement>(TABLE_MORE_SELECTOR).forEach(
612627 (table) => {
613628 if (getTableMoreCheckbox(table)?.checked) {
614629 const anchor = table.dataset.tableMore
@@ -708,7 +723,11 @@ const selectLegacyTabHash = async (hash: string) => {
708723
709724 const tabs = button.closest<HTMLElement>('.plugin-tabs')
710725 if (tabs) {
711 window.history.replaceState(null, '', buildUrlWithTabs([hash]))
726 window.history.replaceState(
727 null,
728 '',
729 buildUrl({ tabs: [hash], tables: getOpenTableMorePath(tabs) })
730 )
712731 }
713732 return tabs
714733}
@@ -1467,6 +1486,7 @@ function setupManualCopyButtons() {
14671486 wrapTablesInRoot(node)
14681487 resetTableMoreInRoot(node)
14691488 initCopyButtonsInRoot(node)
1489 void selectTablesByPath(getRequestedTableMorePath())
14701490 if (faviconsEnabled.value) applyFavicons(node)
14711491 reapplyHighlightIfNeeded(node)
14721492 } else {
@@ -1475,6 +1495,7 @@ function setupManualCopyButtons() {
14751495 wrapTablesInRoot(panel)
14761496 resetTableMoreInRoot(panel)
14771497 initCopyButtonsInRoot(panel)
1498 void selectTablesByPath(getRequestedTableMorePath())
14781499 if (faviconsEnabled.value) applyFavicons(panel)
14791500 reapplyHighlightIfNeeded(panel)
14801501 }