Offline Diagrams

unlisted

by Alexander Bartz

Create and edit diagrams (.drawio.svg, .drawio.png, .drawio) with a bundled editor that runs fully offline. Unofficial integration of the open-source draw.io editor; not affiliated with draw.io.

Updated todayApache-2.0
View on GitHub

Offline Diagrams for Obsidian

An Obsidian plugin that bundles the open-source draw.io editor: no Docker, no server, no connection to diagrams.net. Built for corporate environments where plugins with internet access are not an option.

Unofficial integration of the draw.io editor (Apache 2.0). This project is not affiliated with, endorsed by or sponsored by draw.io or JGraph.

Features

  • Open and edit *.drawio.svg (default), *.drawio.png and *.drawio files
  • Diagrams are embedded as regular images (![[Diagram.drawio.svg]]), so they also render on Git hosting, in VS Code (hediet.vscode-drawio) and elsewhere. The diagram XML is stored uncompressed in the file, so it stays diffable and searchable
  • Edit button when hovering over embedded diagrams, double-click, context menu "Edit diagram"
  • Commands: New diagram, New diagram and embed it in the current note, ribbon icon, folder context menu
  • Autosave (like everything in Obsidian), reload on external changes (Sync, Git)
  • Dark mode and language follow Obsidian
  • Optional draw.io configuration (JSON), e.g. for company colors, fonts or default libraries
  • Alternatively: your own self-hosted draw.io URL

Installation

The plugin is not in the Obsidian community plugin directory. Obsidian (and BRAT) only download main.js, manifest.json and styles.css from a release, but this plugin also needs the bundled editor in the webapp/ folder.

  1. Download offline-diagrams-<version>.zip from the Releases page.
  2. Unzip it into <vault>/.obsidian/plugins/. This creates the folder offline-diagrams/.
  3. Restart Obsidian (or reload the list under Settings → Community plugins) and enable Offline Diagrams.

For centrally managed vaults, the plugin folder plus community-plugins.json can be rolled out via software distribution or a vault template.

Architecture

Obsidian (app://obsidian.md)                  draw.io (http://127.0.0.1:27384, own origin)
┌─────────────────────────────┐  postMessage  ┌──────────────────────────────────────────┐
│ DrawioView (src/view.ts)    │◄─────────────►│ draw.io webapp in embed mode             │
│ reads/writes vault files    │   (JSON)      │ (static files from plugin/webapp/)       │
└─────────────────────────────┘               └──────────────────────────────────────────┘
            │ starts on demand
            ▼
 WebappServer (src/server.ts): 127.0.0.1 only, GET only, only files below webapp/

Why a local mini server? Obsidian only allows app:// resources to be loaded from its own origin, so an iframe pointing at app://…/webapp/index.html cannot load its scripts. Running draw.io in Obsidian's origin would have given draw.io (and any XSS through a crafted diagram) full Node.js access. The loopback server keeps draw.io in an isolated, unprivileged origin. Diagram data never passes through the server, only through postMessage. Port 27384 (fallback: a random free port). The port is fixed so that draw.io's own preferences (localStorage) are kept.

draw.io's external services are disabled (stealth=1, lockdown=1, plugins=0, custom js/PreConfig.js). The E2E test checks that the editor makes no remote requests.

Development

Requirements: Node.js ≥ 20, Obsidian desktop.

npm install
npm run fetch-drawio      # downloads draw.war (version + SHA-256 from drawio.lock.json), strips it → ./webapp (~51 MB)
npm run build             # typecheck + bundle → dist/offline-diagrams/
npm run install-vault     # installs into ./test-vault (or: npm run install-vault -- "/path/to/vault")
npm run test:e2e          # starts an isolated Obsidian (own profile under .e2e/), 12 checks + screenshots
npm run package           # release/offline-diagrams-<version>.zip (+ .sha256) for distribution

node scripts/e2e.mjs --keep-open keeps the isolated Obsidian instance open for manual testing. The E2E test currently assumes Obsidian is installed at the default Windows location; set OBSIDIAN_EXE otherwise.

Updating draw.io

Change version and URL in drawio.lock.json and clear sha256 (or run npm run fetch-drawio -- --update-lock). Without internet access / through an internal artifact mirror:

DRAWIO_WAR_URL=https://artifactory.example.com/.../draw.war npm run fetch-drawio
DRAWIO_WAR_FILE=/path/to/draw.war npm run fetch-drawio

Bundled UI languages: languages in drawio.lock.json (English is always included).

Known limitations

  • Mobile: the bundled editor needs Obsidian desktop (Node.js for the loopback server). On mobile, only the "Custom URL" mode (self-hosted draw.io) can work; this is untested.
  • .drawio (plain XML) has no image representation in notes; use .drawio.svg instead.
  • Switching the Obsidian theme only affects already open editors after reopening them.

License

Plugin: Apache License 2.0.

The release ZIP bundles the draw.io webapp (Apache 2.0, © JGraph Ltd / draw.io AG) together with templates (CC BY 4.0), icon sets and third-party libraries under their own licenses. See THIRD_PARTY_NOTICES.md.

"draw.io" is a trademark of its respective owner and is used here only to describe compatibility.

For plugin developers

Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.