From c3e9be88d822b0c79974ccb247e6a7ac661f6b8a Mon Sep 17 00:00:00 2001 From: unsc9 <438590997@qq.com> Date: Wed, 4 Nov 2026 22:09:55 +0800 Subject: [PATCH] =?UTF-8?q?fix(mermaid):=20=E6=94=BE=E5=A4=A7=E8=A7=86?= =?UTF-8?q?=E5=9B=BE=E5=B7=A5=E5=85=B7=E6=A0=8F=E8=AE=A9=E5=87=BA=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E6=8E=A7=E4=BB=B6=E5=B8=A6=EF=BC=88#805=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 工具栏原本 top:16px、按钮 36px,在 42px 的原生窗口按钮带下只剩 10px 可点。 改为内联 top:16px+控件带高度,CSS 的 16px 保留为无 JS 时的降级;加 data-mermaid-toolbar 稳定选择器供 e2e 测量。 挂载 lane 注入可控的假 WCO(初始 0,不影响本 lane 其它断言),把带子调到 36px 后实测工具栏 top=52,调回 0 再实测回到 16。 --- src/client/mermaid.tsx | 9 +++++++- src/client/sidebar.module.css | 3 +++ tests/e2e/mount.e2e.ts | 43 +++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/src/client/mermaid.tsx b/src/client/mermaid.tsx index 16658246..76d646bd 100644 --- a/src/client/mermaid.tsx +++ b/src/client/mermaid.tsx @@ -32,6 +32,7 @@ import { isDarkScheme, subscribeColorScheme } from './theme.ts' import { markdownTextProps } from './markdown-labels.tsx' import { t } from './locales.ts' import { sanitizeSvg } from './mermaid-sanitize.ts' +import { useViewportInsetTop } from './viewport-inset.ts' import type { MermaidMarkdownProps } from './mermaid-blocks.ts' import { splitMermaidBlocks } from './mermaid-blocks.ts' import { renderMermaidDiagram, type MermaidTheme } from './mermaid-frame.ts' @@ -192,6 +193,8 @@ function MermaidZoomModal({ svg, onClose }: { svg: SVGSVGElement; onClose: () => const svgRef = useRef(null) const dragRef = useRef({ active: false, startX: 0, startY: 0 }) const zoomRef = useRef({ scale: 1, tx: 0, ty: 0 }) + /** The shell's native window-control band: it eats pointer events (#805). */ + const insetTop = useViewportInsetTop() const applyTransform = (): void => { const node = svgRef.current @@ -298,7 +301,11 @@ function MermaidZoomModal({ svg, onClose }: { svg: SVGSVGElement; onClose: () => return createPortal(
-
+