fix(docs): widen API drawer and fix TOC scroll hijacking window

- Add .api-drawer (1100px) so content area is ~880px instead of ~540px
- Replace scrollIntoView with apiDocContent.scrollBy to avoid scrolling
  the window and collapsing the drawer layout

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
caoqianming 2026-03-25 14:41:17 +08:00
parent 22ae4fa4b4
commit 13c4b515d7
3 changed files with 10 additions and 5 deletions

View File

@ -1,5 +1,5 @@
<div class="drawer-backdrop hidden" id="apiDocDrawer">
<aside class="drawer" role="dialog" aria-modal="true" aria-labelledby="apiDocTitle">
<aside class="drawer api-drawer" role="dialog" aria-modal="true" aria-labelledby="apiDocTitle">
<div class="drawer-head">
<h3 id="apiDocTitle">API.md</h3>
<button type="button" class="secondary" id="closeApiDoc">关闭</button>

View File

@ -103,10 +103,11 @@ export async function loadApiDoc() {
if (!id) {
return;
}
dom.apiDocContent.querySelector(`#${CSS.escape(id)}`)?.scrollIntoView({
behavior: "smooth",
block: "start",
});
const target = dom.apiDocContent.querySelector(`#${CSS.escape(id)}`);
if (target) {
const offset = target.getBoundingClientRect().top - dom.apiDocContent.getBoundingClientRect().top;
dom.apiDocContent.scrollBy({ top: offset, behavior: "smooth" });
}
});
});

View File

@ -968,6 +968,10 @@ button.danger:hover { background: var(--danger-hover); }
grid-template-columns: 220px minmax(0, 1fr);
}
.api-drawer {
width: min(1100px, 96vw);
}
.equipment-drawer {
width: min(1120px, 96vw);
}