fix(mermaid): remove zoom cap and export full diagrams - #2035
Conversation
解决 Mermaid 大图无法继续放大,以及 PNG 下载尺寸被当前缩放和拖拽状态污染的问题。 **缩放行为** 1. 移除滚轮与放大按钮的 3 倍硬上限。 2. 保留 0.5 倍最小值和既有重置行为。 **完整导出** 1. 基于 SVG 原始 viewBox 或固有尺寸生成 PNG。 2. 克隆并移除交互 transform、transition 与 cursor 样式。 3. 仅在缺失固有尺寸时回退到去缩放后的 DOM 边界。 **验证说明** - Mermaid 测试 70/70 通过,新增无限放大与变换后完整导出回归覆盖。 - TypeScript、Biome 与 git diff --check 通过。
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughMermaid 组件取消缩放上限,并改用未缩放的 SVG 副本生成下载图像。测试覆盖实际 SVG 渲染、连续放大、原始尺寸和设备像素比。 ChangesMermaid 交互行为
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This localized change removes the Mermaid zoom cap and makes PNG exports independent of the current view state; the reported tests and checks pass, so no actionable merge-blocking risk remains beyond normal review. Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
nrps9909
left a comment
There was a problem hiding this comment.
Reviewed exact head d55222f against base 25aad7b.
Both behavioral changes are scoped correctly. Zoom keeps the existing 0.5 minimum while removing only the requested upper cap. Downloading clones the SVG, removes the four interaction-only inline styles, prefers intrinsic viewBox or SVG dimensions, and sizes both the serialized clone and DPR canvas independently of the current pan/zoom transform.
Validation performed:
- Restored the old 3x cap locally: the new zoom regression failed with scale exactly 3 rather than greater than 3.
- Restored the old download implementation locally: the new export regression failed because it serialized the transformed live node rather than an untransformed clone.
- Exact head complete Mermaid suite: 70/70 passed.
- A temporary no-viewBox fallback probe zoomed through the public controls to about 3x, supplied transformed 1920x1440 bounds, and verified that the fallback divided them back to about 640x480 while still serializing a clean clone.
- packages/x TypeScript noEmit passed.
- Biome passed both changed files; git diff --check passed.
- Live PR head still matches the tested SHA; current remote checks are green.
AI assistance disclosure: Codex was used to inspect the exact diff, run independent red/green and fallback probes, execute static checks, and draft this review. I verified the reported commands and outcomes.
🤔 This is a ...
🔗 Related Issues
Fixes #1875
💡 Background and Solution
Large Mermaid diagrams had two related problems: zooming stopped at 3×, and PNG export measured the transformed DOM rectangle, so the downloaded result changed with the current zoom/drag state and could be clipped or low-resolution.
🎥 Before / After
Before — zoom is capped at 3.0× and export dimensions change with the current zoom state.
before.mp4
After — zoom reaches 3.6× and the complete export keeps the same intrinsic dimensions.
after.mp4
Observed in Chromium with the same 15-node diagram:
📝 Change Log
✅ Verification
tsc --noEmit -p packages/x/tsconfig.jsonSummary by CodeRabbit