[Feature] Support image-viewer interactive controls (zoom in/out, pan, lightbox) for Mermaid diagrams · Issue #5508 · marktext/marktext · GitHub
Skip to content

[Feature] Support image-viewer interactive controls (zoom in/out, pan, lightbox) for Mermaid diagrams #5508

Closed

Description

@YANGyq1999

Summary

Support interactive image-viewer features (such as zoom in/out, pan/drag, and lightbox/full-screen preview) for rendered Mermaid diagrams in MarkText.

Problem it solves

When viewing complex or large Mermaid diagrams in MarkText, the rendered SVG is displayed at a fixed/static size within the editor. Unlike standard image previewers, users cannot zoom in to examine small text/details, zoom out for an overall view, or pan around large diagrams smoothly. This makes reading large flowcharts, sequence diagrams, or architecture diagrams difficult inside the editor.

Proposed solution

Treat rendered Mermaid diagrams similarly to images with full viewing interaction support:

  1. Zoom & Pan Controls:
    • Ability to zoom in and zoom out (via mouse wheel, gesture, or toolbar buttons).
    • Drag to pan around the diagram when zoomed in.
    • A "Reset Zoom / Fit to Window" button to restore default scaling.
  2. Lightbox / Full-screen Preview:
    • Double-clicking or clicking an "Enlarge / Full Screen" icon on the diagram block toolbar to open the rendered graphic in a dedicated lightbox modal window with complete zoom/pan controls.

Alternatives considered

  • Exporting the document to HTML/PDF or opening rendered graphics in external vector tools, which interrupts the writing and reading workflow inside MarkText.
  • Adjusting global editor container width settings, which changes the overall document layout rather than addressing diagram inspection specifically.

Additional context

Integrating an SVG pan/zoom or lightbox library (such as viewerjs or svg-pan-zoom) for rendered diagram blocks would provide a consistent, user-friendly image-viewing experience.

Activity

  1. Jocs commented on Sep 24, 2026

    @Jocs
    Member

    Dup with #4363

  2. Jocs commented on Sep 25, 2026

    @Jocs
    Member

    Implemented in #5554: hovering a diagram now shows a toolbar whose magnifier opens it full-screen, with wheel/button/keyboard zoom, drag or arrow-key panning, fit-to-window and actual-size, and Esc to close. The same view can save the diagram as SVG or PNG, or copy it to the clipboard as an image.

    Zoom and pan live in that view rather than on the inline block on purpose — wheel-zoom on a block inside a scrolling document either hijacks the scroll or fights it.

    Worth noting since svg-pan-zoom was suggested: it only operates on <svg> elements, so PlantUML (which renders to an <img> from a server) and the existing image preview would have needed a second implementation. This shares one code path with the image viewer instead.

    This will close when #5554 lands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions