From 525ee7f22264bb2132a92ba056ab0a39f18ff46a Mon Sep 17 00:00:00 2001 From: "paseo-bot[bot]" <266920839+paseo-bot[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2026 17:11:35 +0000 Subject: [PATCH] fix(app): keep Mermaid chart axes from overlapping and clipping (#9483) * fix(app): render Mermaid diagrams in an unscaled offscreen staging container * fix(app): keep gantt charts at a fixed width in the Mermaid staging container Rendering into the oversized staging container gave gantt charts its 16384px width, because Mermaid sizes a gantt chart from the element it renders in. The host then fit that width into the message column and the chart drew a few pixels tall. Give gantt charts the 1200px width Mermaid uses when there is no container width, so they report the same size whatever frame the host gives the runtime. Co-authored-by: FluidXin <266379324+FluidXin@users.noreply.github.com> * fix(app): keep gantt charts as wide as the Mermaid frame Pinning gantt charts to 1200px shrank them on iOS and Android, where the measuring frame is as wide as the message column and gantt charts used to fill it. Use the frame's own width instead, which is what Mermaid read from the page before rendering moved into the staging container. Co-authored-by: FluidXin <266379324+FluidXin@users.noreply.github.com> --------- Co-authored-by: FluidXin <266379324+FluidXin@users.noreply.github.com> Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com> --- .../markdown/fence/mermaid/build-runtime.mjs | 15 +++ .../markdown/fence/mermaid/runtime/entry.ts | 13 ++- .../fence/mermaid/runtime/html.gen.ts | 2 +- .../mermaid/runtime/runtime.browser.test.ts | 105 +++++++++++++++++- 4 files changed, 132 insertions(+), 3 deletions(-) diff --git a/packages/app/src/components/markdown/fence/mermaid/build-runtime.mjs b/packages/app/src/components/markdown/fence/mermaid/build-runtime.mjs index 6ed821cea..26ffd2489 100644 --- a/packages/app/src/components/markdown/fence/mermaid/build-runtime.mjs +++ b/packages/app/src/components/markdown/fence/mermaid/build-runtime.mjs @@ -63,10 +63,25 @@ const html = ` #diagram svg { display: block; } + /* Keep Mermaid's temporary render container unscaled when the host mounts this frame + at 0x0 or 240x240 before the diagram's own dimensions are known. */ + #staging-clip { + position: fixed; + width: 0; + height: 0; + overflow: hidden; + visibility: hidden; + pointer-events: none; + } + #staging { + width: 16384px; + height: 16384px; + }
+