Skip to content

fix: center Mermaid diagrams in markdown view - #6

Merged
kooksee merged 2 commits into
masterfrom
fix/mermaid-center
Sep 19, 2026
Merged

kooksee merged 2 commits into
masterfrom
fix/mermaid-center

Conversation

@kooksee

@kooksee kooksee commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Center Mermaid diagrams horizontally instead of left-aligning them
  • Use xMidYMin preserveAspectRatio and flex-center the render container

Test plan

  • cd frontend && pnpm test src/components/MermaidBlock.test.tsx
  • Open a doc with a small Mermaid diagram — it should appear centered in the content column
  • Wide/tall diagrams and fullscreen still behave as before

Made with Cursor

kooksee and others added 2 commits September 18, 2026 23:03
Use mid-X preserveAspectRatio and flex-center the render
container so diagrams no longer hug the left edge.

Co-authored-by: Cursor <cursoragent@cursor.com>
Previous flex centering was a no-op because .mermaid-canvas stayed
width 100% while the SVG used a smaller pixel size. Shrink-wrap the
canvas, flex-center the SVG, and apply the same to PlantUML/SvgBob.

Co-authored-by: Cursor <cursoragent@cursor.com>

@kooksee kooksee left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

LGTM — correctly fixes left-aligned diagrams: shrink-wrap canvas + flex-center SVG (previous width: 100% canvas made flex centering a no-op). Also covers PlantUML/SvgBob.

Checks

  • Local: MermaidBlock tests pass (18)
  • Bugbot: no findings
  • CI oxfmt --check fail is pre-existing on master, not caused by this CSS/SVG change

Merging despite CI fmt noise.

@kooksee
kooksee merged commit 4cc2352 into master Sep 19, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant