Commit 765d1c8a97
Unsigned
Layout: unified · split
docs/.vitepress/theme/Layout.vue +14
| @@ -1004,6 +1004,17 @@ function initTitleOnly() { | |||
| 1004 | }) | 1004 | }) |
| 1005 | } | 1005 | } |
| 1006 | 1006 | ||
| 1007 | // Wrap bare tables in their own scroll container so they scroll independently of sibling content. | ||
| 1008 | function wrapTablesInRoot(root: ParentNode) { | ||
| 1009 | root.querySelectorAll<HTMLTableElement>('table:not(.scrape-table)').forEach(table => { | ||
| 1010 | if (table.parentElement?.classList.contains('table-scroll')) return | ||
| 1011 | const wrapper = document.createElement('div') | ||
| 1012 | wrapper.className = 'table-scroll' | ||
| 1013 | table.replaceWith(wrapper) | ||
| 1014 | wrapper.appendChild(table) | ||
| 1015 | }) | ||
| 1016 | } | ||
| 1017 | |||
| 1007 | function initCopyButtonsInRoot(root: ParentNode) { | 1018 | function initCopyButtonsInRoot(root: ParentNode) { |
| 1008 | root.querySelectorAll<HTMLTableElement>('table').forEach(table => { | 1019 | root.querySelectorAll<HTMLTableElement>('table').forEach(table => { |
| 1009 | const headers = table.querySelectorAll<HTMLTableCellElement>('thead th') | 1020 | const headers = table.querySelectorAll<HTMLTableCellElement>('thead th') |
| @@ -1084,6 +1095,7 @@ function initCopyButtonsInRoot(root: ParentNode) { | |||
| 1084 | let copyButtonObserver: MutationObserver | null = null | 1095 | let copyButtonObserver: MutationObserver | null = null |
| 1085 | 1096 | ||
| 1086 | function setupManualCopyButtons() { | 1097 | function setupManualCopyButtons() { |
| 1098 | wrapTablesInRoot(document) | ||
| 1087 | initCopyButtonsInRoot(document) | 1099 | initCopyButtonsInRoot(document) |
| 1088 | 1100 | ||
| 1089 | copyButtonObserver?.disconnect() | 1101 | copyButtonObserver?.disconnect() |
| @@ -1092,11 +1104,13 @@ function setupManualCopyButtons() { | |||
| 1092 | for (const node of mutation.addedNodes) { | 1104 | for (const node of mutation.addedNodes) { |
| 1093 | if (!(node instanceof HTMLElement)) continue | 1105 | if (!(node instanceof HTMLElement)) continue |
| 1094 | if (node.classList.contains('plugin-tabs--content')) { | 1106 | if (node.classList.contains('plugin-tabs--content')) { |
| 1107 | wrapTablesInRoot(node) | ||
| 1095 | initCopyButtonsInRoot(node) | 1108 | initCopyButtonsInRoot(node) |
| 1096 | if (faviconsEnabled.value) applyFavicons(node) | 1109 | if (faviconsEnabled.value) applyFavicons(node) |
| 1097 | } else { | 1110 | } else { |
| 1098 | node.querySelectorAll<HTMLElement>('.plugin-tabs--content').forEach( | 1111 | node.querySelectorAll<HTMLElement>('.plugin-tabs--content').forEach( |
| 1099 | (panel) => { | 1112 | (panel) => { |
| 1113 | wrapTablesInRoot(panel) | ||
| 1100 | initCopyButtonsInRoot(panel) | 1114 | initCopyButtonsInRoot(panel) |
| 1101 | if (faviconsEnabled.value) applyFavicons(panel) | 1115 | if (faviconsEnabled.value) applyFavicons(panel) |
| 1102 | } | 1116 | } |
docs/.vitepress/theme/styles/style.scss +17
| @@ -544,6 +544,23 @@ table tr:nth-child(odd) { | |||
| 544 | border-color: #3d3d3d; | 544 | border-color: #3d3d3d; |
| 545 | } | 545 | } |
| 546 | 546 | ||
| 547 | /* width: max-content forces exact column sizing so favicon toggling doesn't shrink the right-side gap. */ | ||
| 548 | @media (max-width: 767px) { | ||
| 549 | .vp-doc table:not(.scrape-table) { | ||
| 550 | width: max-content; | ||
| 551 | } | ||
| 552 | |||
| 553 | .vp-doc table:not(.scrape-table) th, | ||
| 554 | .vp-doc table:not(.scrape-table) td { | ||
| 555 | white-space: nowrap; | ||
| 556 | } | ||
| 557 | |||
| 558 | /* Scroll container injected by wrapTablesInRoot in Layout.vue, isolated from sibling content. */ | ||
| 559 | .table-scroll { | ||
| 560 | overflow-x: auto; | ||
| 561 | } | ||
| 562 | } | ||
| 563 | |||
| 547 | .tip.custom-block table tr, | 564 | .tip.custom-block table tr, |
| 548 | .tip.custom-block table td, | 565 | .tip.custom-block table td, |
| 549 | .tip.custom-block table th { | 566 | .tip.custom-block table th { |