Skip to content

Copy Mermaid diagrams as an image - #12

Merged
AdiRishi merged 1 commit into
mainfrom
claude/mermaid-expand-fit-saonv2
Oct 14, 2026
Merged

AdiRishi merged 1 commit into
mainfrom
claude/mermaid-expand-fit-saonv2

Conversation

@AdiRishi

@AdiRishi AdiRishi commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

Requested by Adi · project thread

Before: the copy button on a Mermaid block could only copy the diagram's source code.

After: the copy button opens a menu like the download one, with Image (.png) and Mermaid source. A toast confirms each copy.

How: Diagram.tsx swaps the CopyButton for a dropdown. The image option reuses the PNG export from #8 and writes it with navigator.clipboard.write, handing ClipboardItem the pending PNG promise so Safari still treats the write as part of the click. Failures show an error toast.

Checked with pnpm check and in the dev server with Playwright: the image option puts a 1783×368 image/png on the clipboard, and the source option copies the Mermaid code.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Y8zZi9uphvmprNJWq9UTWm


Generated by Claude Code

Summary by CodeRabbit

  • New Features
    • Added options to copy diagrams as PNG images or Mermaid source.
    • PNG copy now reports whether the copy succeeded; source copy reports clipboard errors.
  • Bug Fixes
    • Disabled PNG copying when a diagram image is unavailable.

The diagram's copy button opens a menu like download's: Image (.png) puts
the same PNG export on the clipboard, and Mermaid source copies the code.
Each confirms with a toast.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y8zZi9uphvmprNJWq9UTWm
@AdiRishi AdiRishi self-assigned this Oct 14, 2026
@coderabbitai

coderabbitai Bot commented Oct 14, 2026

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 93ebd61c-23bd-4fbd-ac15-01b72edc8fb0
📥 Commits

Reviewing files that changed from the base of the PR and between 9d88e05 and bb2482f.

📒 Files selected for processing: 1
  • src/features/markdown/render/diagram/Diagram.tsx
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

🚀 Preview Deployment Ready!

Application Preview URL Status
Render MD Visit Preview ✅ Ready

@AdiRishi
AdiRishi merged commit c6e642c into main Oct 14, 2026
2 of 3 checks passed
@AdiRishi
AdiRishi deleted the claude/mermaid-expand-fit-saonv2 branch October 14, 2026 04:12
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.

2 participants