Skip to content

Mermaid diagrams clipped due to fixed SVG dimensions #155

@j-token

Description

@j-token

Bug Description

Mermaid diagrams are rendered at a fixed/constrained size instead of filling the available container width, causing them to appear clipped or cut off.

Root Cause

Mermaid v11 outputs SVGs with:

  1. Fixed width and height attributes (e.g., width="814")
  2. An inline style="max-width: 814px;" on the root <svg> element

The current code in MermaidBlock.tsx strips the width/height attributes but does not replace them, causing the SVG to fall back to the browser default size (300x150px). Additionally, the inline max-width style is never removed, preventing the SVG from expanding beyond its intrinsic pixel width.

Expected Behavior

Mermaid diagrams should scale to fill the available container width, with the viewBox handling proper content scaling.

Steps to Reproduce

  1. Create a plan with a mermaid code block containing a moderately complex diagram (e.g., a flowchart with several nodes)
  2. Open in Plannotator
  3. Toggle from source to diagram view
  4. Observe the diagram is clipped/truncated rather than filling the container

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions