cferrugem47 downloadsDrag any Mermaid diagram to resize it and right-click to align it. Desktop and mobile keep independent sizes, and everything is stored inside the block itself, so it survives re-renders and travels between your devices.
Resize Mermaid diagrams in Obsidian by dragging, and align them left, center, or right. The size is stored inside the diagram block itself, so it survives re-renders, travels with the note through sync and Git, and works on any device.
Obsidian renders Mermaid diagrams at whatever size Mermaid computes, and offers no resize handle like it does for images. Existing zoom plugins let you zoom while you look, but nothing is remembered — reopen the note and the diagram is back to where it started.
Hover a diagram in reading view: a handle appears in the bottom-right corner. Drag it. When you release, the size is written into the block:
```mermaid
%% cfr-size: 50 %%
flowchart LR
A --> B
```
Right-click the diagram to align it:
```mermaid
%% cfr-size: 50 %%
%% cfr-align: right %%
flowchart LR
A --> B
```
%% is Mermaid's own comment syntax, so the diagram renders exactly the same with or without this plugin.
| Key | What it stores | When absent |
|---|---|---|
cfr-size |
width on desktop, 10–100% of the note width | natural size, on desktop |
cfr-size-mobile |
width on mobile | natural size, on mobile |
cfr-align |
left or right — applies everywhere |
centered (the default) |
Sizes are a percentage of the note width, not pixels, so a diagram keeps its proportion on any screen.
Half of a monitor is comfortable; half of a phone screen is unreadable. Each device stores its own size and neither can see the other's: dragging on desktop touches only cfr-size, dragging on mobile touches only cfr-size-mobile.
The deliberate trade-off: a diagram you sized on desktop starts at its natural size on mobile until you adjust it there. Independence and inheritance are opposites — this plugin picks independence.
To clear a size, right-click (or long-press) the diagram and choose Clear desktop size / Clear mobile size. It removes that device's line only. You can also delete the line by hand.
Why the state lives in the note. The obvious alternative is a plugin data file keyed by note path plus block index. That breaks the moment you insert a block above, rename the note, or edit on two devices — and it makes the data invisible to you. Keeping it in the block means sync and version control come for free, the value is readable and editable by hand, and uninstalling the plugin leaves nothing but a harmless Mermaid comment.
Why edits never target a stale line. The block's position in the file is resolved at the moment you click, never remembered from render time — a line number goes stale if the file changes underneath (sync, another edit). Writes go through Vault.process, which reads and writes atomically.
Where the handle does not appear. In Live Preview and inside embeds, Obsidian does not give the plugin the block's position in the file. Without a position there is no safe way to write, so the handle is not installed at all rather than risking a write to the wrong place.
Not in the community plugin store yet. To install manually:
main.js, manifest.json and styles.css from the latest release<your vault>/.obsidian/plugins/cfr-mermaid-size/Plain JavaScript, single file, no build step — edit main.js and reload Obsidian.
npm test # node --test, no dependencies
The text-manipulation core (lerMarcas, gravarMarcas, tamanhoParaDispositivo) is pure and covered by 43 tests that run without Obsidian.
%% cfr-align: %% line by hand.MIT