Skip to content

feat(mermaid): interactive Mermaid diagrams (0.6.0) - #24

Merged
CharanMN7 merged 3 commits into
mainfrom
feat/mermaid
Sep 27, 2026
Merged

CharanMN7 merged 3 commits into
mainfrom
feat/mermaid

Conversation

@CharanMN7

Copy link
Copy Markdown
Contributor

What

```mermaid fences now render as interactive diagrams.

  • Inline: Ctrl/⌘ + scroll, trackpad pinch, double-click, or +/-/0 to zoom; drag or arrow keys to pan once zoomed. A plain scroll still scrolls the page (a hint explains the modifier). On touch, vertical swipes scroll the page until the reader zooms in.
  • Fullscreen (<dialog>): scroll zooms, drag pans, a minimap appears once zoomed in (click/drag to move the view), Esc closes.
  • Toolbar: zoom out / % (reset) / zoom in, copy Mermaid source, download SVG, fullscreen.
  • Theming: colors derive from --fw-* tokens (node tint from --fw-primary, a categorical palette rotated from the brand hue for pie/mindmap/timeline), re-rendered when html.dark flips. Author style lines still win.
  • Captions: ```mermaid title="…" → figcaption, fullscreen title, download filename, accessible name.
  • Errors: invalid source shows mermaid's message next to the source.

How it stays light

  • remarkMermaid turns fences into <Mermaid chart caption>, the same node hand-written JSX produces.
  • The built-in Mermaid is a static source block. The interactive one is @inkform/framework/mermaid, and mermaid is an optional peer dependency, so docs sites that never draw diagrams don't install it.
  • Opting in: npm i mermaid + mdxComponents({ Mermaid }). The three templates and the inkform-docs example ship with it on.
  • mermaid and the viewer (+ @panzoom/panzoom, ~4 KB gz) are dynamic chunks, fetched only when a diagram nears the viewport. Verified in the production build: neither is referenced by the initial HTML of a page without diagrams.

Also

  • New docs page guides/diagrams, API reference + READMEs + skill updated, CHANGELOG 0.6.0.
  • Version bump 0.5.0 → 0.6.0; templates/examples depend on ^0.6.0.
  • Root override lodash-es: ^4.18.1. mermaid's deps (chevrotain, dagre-d3-es) pull a lodash-es with a high advisory that would fail npm audit --audit-level=high.

Verified

  • npm run lint, typecheck, test (4 new tests for the plugin + fallback), build, audit --audit-level=high: all green locally.
  • Headless Chrome against the production build of inkform-docs: all 6 diagram types render; zoom buttons/Ctrl+wheel/dblclick/keyboard/drag; plain wheel scrolls the page and shows the hint; copy + SVG download; fullscreen + minimap + Esc; light↔dark re-render; 390px mobile (no horizontal overflow, toolbar visible). No console errors.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EaJaU595iENT8fc7mcHDWC

```mermaid fences (and <Mermaid chart="…" />) now render as diagrams:
pan, zoom (Ctrl/⌘+wheel, pinch, double-click, keyboard), a fullscreen
view with a minimap, copy source, and SVG download. Colors derive from
the --fw-* tokens and re-render on light/dark switches; captions come
from the fence meta (```mermaid title="…").

Opt-in: `mermaid` is an optional peer dependency and the viewer lives at
@inkform/framework/mermaid. Without it, fences render as a static source
block. Templates ship with it enabled. Both mermaid and the viewer are
lazy chunks loaded only when a diagram nears the viewport.

Also: remarkMermaid exported from ./mdx, docs page + API reference,
templates/examples bumped to ^0.6.0, lodash-es override (^4.18.1) for
the advisory pulled in through mermaid's deps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EaJaU595iENT8fc7mcHDWC
@vercel

vercel Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
framework-inkform-docs Ready Ready Preview Sep 27, 2026 1:52pm UTC
pokeapi Ready Ready Preview Sep 27, 2026 1:52pm UTC

Request Review

remark-directive parses "re:Work" in prose as a text directive. Nothing
renders text directives, so <Mdx> emitted <div></div> inside the <p>:
the "Work" was lost and React threw hydration error #418. Unknown text
directives now become literal text again, in <Mdx> (callout plugin moved
to remark-directives.ts) and in the per-page Markdown export.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EaJaU595iENT8fc7mcHDWC
Mermaid measures labels outside the page, then renders them as HTML
inside the SVG, where rules like `.prose p { font-size: 1.125rem }`
reached them and overflowed the node boxes (clipped text). Pin label
font-size/margins to what mermaid measured.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EaJaU595iENT8fc7mcHDWC

This branch was successfully deployed

2 active deployments
Preview – framework-inkform-docs — b643b019 Deployed Sep 27, 2026 by vercel[bot]
Preview – pokeapi — b643b019 Deployed Sep 27, 2026 by vercel[bot]
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