Skip to content

Feat/mermaid copy button#549

Open
JWhiteCat wants to merge 2 commits intoslopus:mainfrom
JWhiteCat:feat/mermaid-copy-button
Open

Feat/mermaid copy button#549
JWhiteCat wants to merge 2 commits intoslopus:mainfrom
JWhiteCat:feat/mermaid-copy-button

Conversation

@JWhiteCat
Copy link

Summary

Adds a copy button to Mermaid diagrams for easy source code copying on both Web and Mobile platforms.

Changes

  • Copy button - Hover to show on Web, always visible on Mobile
  • Clipboard integration - Copies raw Mermaid source code
  • User feedback - Success/error modal alerts
  • 10 languages - Full i18n support

Implementation

Key additions:

  • copyMermaidSource() - Async clipboard copy handler
  • renderCopyButton(visible) - Reusable button component
  • Platform-specific visibility control (hover vs. always-on)

Files changed: 11 files (+72, -2)

  • MermaidRenderer.tsx - Core functionality
  • Translation files (ca, en, es, it, ja, pl, pt, ru, zh-Hans, zh-Hant)

Testing

Tested:

  • ✅ Web (localhost:8081) - Hover, copy, paste
  • ✅ Translations defined for all languages
  • ⏳ Mobile - Pending device access

Test with:

```mermaid
graph TD;
    A[Start] --> B[End];
```

Design Decisions

  1. Follows existing code block copy button pattern
  2. DRY principle - Single reusable function
  3. Mobile-friendly - No hidden hover states
  4. Performance - Uses React.useCallback

Generated with Claude Code via Happy

JWhiteCat and others added 2 commits February 6, 2026 23:52
- Add copy button to Mermaid diagrams on both Web and Mobile platforms
- Web: Copy button appears on hover
- Mobile: Copy button is always visible
- Reusable renderCopyButton function reduces code duplication
- Add translations for "Mermaid source copied" in English and Chinese

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
Add "Mermaid source copied" translation for:
- Catalan (ca): Codi font de Mermaid copiat
- Spanish (es): Código fuente de Mermaid copiado
- Italian (it): Codice sorgente Mermaid copiato
- Japanese (ja): Mermaidソースコードをコピーしました
- Polish (pl): Kod źródłowy Mermaid skopiowany
- Portuguese (pt): Código fonte Mermaid copiado
- Russian (ru): Исходный код Mermaid скопирован
- Traditional Chinese (zh-Hant): Mermaid 原始碼已複製

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
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