joven1k downloadsEnhance Mermaid diagrams with click-to-zoom and custom CSS injection
An Obsidian plugin that enhances Mermaid diagram viewing experience with click-to-zoom, pan & zoom controls, and PNG export.
Click a Mermaid diagram → opens a floating modal with frosted glass controls:
main.js, manifest.json, and styles.css from the latest release.obsidian/plugins/obsidian-better-mermaid/ foldernpm install
npm run build
Then copy main.js, manifest.json, and styles.css to the plugin folder.
| Action | Control |
|---|---|
| Open modal | Click a Mermaid diagram in reading mode |
| Pan vertically | Scroll wheel |
| Pan horizontally | Shift + scroll wheel |
| Zoom | Ctrl + scroll wheel |
| Pan freely | Click and drag |
| Preset zoom | Select from dropdown (20% / 50% / 75% / 100%) |
| Download PNG | Click Download PNG button |
| Setting | Description | Default |
|---|---|---|
| Language | UI language (English / 中文) | English |
| Enable click to zoom | Toggle the click-to-zoom feature on/off | On |
| Enhance readability | Thicken lines; dark mode: brighten lines & darken subgraphs (off = match reading view) | On |
| Modal width | Width of the modal (% of viewport) | 80% |
| Modal height | Height of the modal (% of viewport) | 80% |
| Default zoom level | Initial zoom when opening a diagram | 100% |
| Custom CSS | CSS rules injected into Obsidian | (empty) |
Each slider has a reset button to restore default values.
.markdown-preview-view .mermaid svg,
.markdown-source-view .mermaid svg {
max-width: 100% !important;
height: auto !important;
}
/* 限制最大高度,避免纵向过长 */
.markdown-preview-view .mermaid,
.markdown-source-view .mermaid {
max-height: 80vh; /* 可根据需要调整,如 70vh、90vh */
overflow: auto; /* 超出时显示滚动条 */
}
Cannot open the plugin's settings tab (the page is blank/unresponsive, console shows TypeError: e.display is not a function)
getSettingDefinitions()), which requires Obsidian 1.13.0 or later. On older versions Obsidian still tries to render the tab through the legacy display() method, which is no longer implemented.manifest.json declares minAppVersion: 1.13.0, so installs from the community directory automatically block older Obsidian versions; only manually copied (sideloaded) plugins can end up running on an outdated Obsidian.MIT