Skip to content

feat: add fullscreen zoom modal for images and Mermaid diagrams#135

Merged
k1LoW merged 4 commits intok1LoW:mainfrom
harakeishi:feature/image-mermaid-zoom-modal
Mar 24, 2026
Merged

feat: add fullscreen zoom modal for images and Mermaid diagrams#135
k1LoW merged 4 commits intok1LoW:mainfrom
harakeishi:feature/image-mermaid-zoom-modal

Conversation

@harakeishi
Copy link
Copy Markdown
Contributor

@harakeishi harakeishi commented Mar 24, 2026

Summary

  • Add a fullscreen overlay modal that opens when clicking images or Mermaid diagrams in the Markdown preview
  • Support mouse wheel zoom and drag-to-pan via react-zoom-pan-pinch
  • Close the modal via ESC key, backdrop click, or close button
  • Content is automatically scaled to fit 85% of the viewport on open
  • Accessible: role="dialog", aria-modal, keyboard support

Details

  • New ZoomModal component rendered at App level, decoupled from MarkdownViewer
  • MarkdownViewer receives an optional onZoom callback — no behavioral change when omitted
  • e.preventDefault() + e.stopPropagation() on image click to prevent link navigation for linked images ([![](img)](url))
  • Fallback to initialScale=1 on image load error
2026-03-24.15.13.23.mov

Test plan

  • Click image in Markdown → fullscreen modal opens with image fitted to viewport
  • Click Mermaid diagram → fullscreen modal opens with SVG fitted to viewport
  • Mouse wheel zooms in/out, drag pans the content
  • ESC key, backdrop click, and X button all close the modal
  • Existing copy buttons (image copy, code copy) on Mermaid blocks still work
  • All 185 existing tests pass, lint and format checks pass

harakeishi and others added 3 commits March 24, 2026 12:57
Click images or Mermaid diagrams to open a fullscreen overlay with
zoom (mouse wheel) and pan (drag) support. Close via ESC, backdrop
click, or X button. Uses react-zoom-pan-pinch for zoom/pan controls.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…gation

- Add role="dialog", aria-modal, aria-label for screen readers
- Add aria-hidden to close button SVG icon
- Add onError fallback for image load failure in size measurement
- Extract calcScale helper to eliminate duplicate scale calculation
- Add preventDefault + stopPropagation on image click to prevent
  link navigation when image is inside an anchor tag

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace onClick with onMouseDown/onMouseUp to distinguish clicks from
drag-pan operations. Clicks on the actual content (image/SVG) no longer
close the modal, while clicks on the dark backdrop area do.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@harakeishi harakeishi marked this pull request as ready for review March 24, 2026 04:52
@k1LoW
Copy link
Copy Markdown
Owner

k1LoW commented Mar 24, 2026

@harakeishi That's an excellent feature!
I prefer having dedicated Zoom buttons over using mouse clicks for this.
GitHub's web UI also doesn't assign zoom functionality to mouse clicks.

How about adding the Zoom button to the list of buttons in the top-right corner of the image?

Please leave the button's icon as a placeholder. I'll likely adjust it later.

@k1LoW k1LoW added enhancement New feature or request tagpr:minor labels Mar 24, 2026
Replace mouse click zoom trigger on images and Mermaid diagrams with
dedicated Zoom buttons that appear on hover, matching the existing
copy button pattern. This aligns with GitHub's web UI convention of
not assigning zoom to mouse clicks.

Icon is a placeholder (magnifying glass with +) to be adjusted later.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@harakeishi
Copy link
Copy Markdown
Contributor Author

Thank you for the review! Addressed in a27d678 — replaced click-to-zoom with dedicated Zoom buttons on hover. Summary video has been updated as well.

@k1LoW
Copy link
Copy Markdown
Owner

k1LoW commented Mar 24, 2026

Thank you!!!

@k1LoW k1LoW merged commit 738858d into k1LoW:main Mar 24, 2026
3 checks passed
@github-actions github-actions bot mentioned this pull request Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request tagpr:minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants