Add opt-in mermaid pan/zoom/fullscreen support#1156
Open
yarikoptic wants to merge 1 commit intojpanther:devfrom
Open
Add opt-in mermaid pan/zoom/fullscreen support#1156yarikoptic wants to merge 1 commit intojpanther:devfrom
yarikoptic wants to merge 1 commit intojpanther:devfrom
Conversation
When `params.mermaid.panZoom = true`, mermaid diagrams get: - svg-pan-zoom integration (scroll to zoom, drag to pan) - Hover-to-show control overlay (fullscreen, zoom in, reset, zoom out) - Fullscreen toggle with state preservation on exit - No extra margins — diagram renders at natural size Controls appear on mouse hover and hide when the mouse leaves. All control positioning uses inline JS styles for reliability. The feature is off by default — existing behavior is unchanged. New files: - assets/lib/svg-pan-zoom/svg-pan-zoom.min.js (v3.6.2, MIT) Modified: - assets/js/mermaid.js: pan/zoom/fullscreen logic gated by window.mermaidPanZoom - layouts/_partials/vendor.html: conditionally bundles svg-pan-zoom + minimal CSS - layouts/_shortcodes/mermaid.html: adds mermaid-panzoom class when enabled Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
✅ Deploy Preview for hugo-congo ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds opt-in pan/zoom/fullscreen support for mermaid diagrams, gated by a new site parameter.
When
params.mermaid.panZoom = true:When the parameter is not set (default), behavior is completely unchanged.
Motivation
Complex mermaid diagrams (nested subgraphs, large flowcharts) are hard to read at the default prose width. Discussion #553 (Image Zooming) shows demand for interactive diagram viewing — 21% of readers attempt to click/zoom images. This addresses that need specifically for mermaid.
Implementation notes
assets/lib/svg-pan-zoom/svg-pan-zoom.min.js(~30KB) and only bundled intomermaid.bundle.jswhen the param is enabledcss/compiled/main.css(Tailwind pre-built) and additions tocss/main.cssrequire a Tailwind rebuildopacity: 0) and shown onmouseenter/ hidden onmouseleavemermaid-panzoomCSS class is added to the shortcode container when enabled, providing a hook for the JS<style>block invendor.htmlhandles only SVG max-width override and fullscreen backgroundFiles changed
assets/lib/svg-pan-zoom/svg-pan-zoom.min.js— new: vendored library (MIT)assets/js/mermaid.js— pan/zoom init, hover controls, fullscreen with state preservationlayouts/_partials/vendor.html— conditional svg-pan-zoom bundling + inline styleslayouts/_shortcodes/mermaid.html— conditionalmermaid-panzoomclassUsage
Demo
See it in action:
🤖 Generated with Claude Code and refined
edits:
post initial submission, force pushed to