doge-liang190 downloadsEmbed, preview, and edit draw.io diagrams directly in your notes.
Embed, preview, and edit draw.io (diagrams.net) diagrams directly in your notes. Fully offline by default with a bundled editor; falls back to the online diagrams.net editor when the bundle isn't installed.
```drawio block, preview it as SVG (in both editing and reading views), and click to edit it in a full-screen modal..drawio files: open a .drawio file in a dedicated tab with the drawio editor embedded inline (Excalidraw-style), edited directly in place.![[diagram.drawio]]; it renders inline in both editing and reading views, and click opens a quick-edit modal.With the bundled offline editor (the default when installed), this plugin makes no network requests — the editor is served from a local 127.0.0.1 HTTP server. If the bundled webapp isn't present, the editor falls back to loading the UI from diagrams.net (https://embed.diagrams.net/); in that case your diagram content still stays on your device (it is passed to the editor in the page and is not uploaded), but the editor's assets are fetched over the network. You can also explicitly choose Online or a Custom URL in settings. Diagram previews never use the network: they are rendered by drawio's viewer.min.js, which is bundled into the plugin.
The Online editor needs a network connection. For a fully offline editor, build from source so the bundled webapp is available:
npm installnpm run fetch-drawio — downloads the offline drawio webapp (draw.war download; requires network access to GitHub, plus either unzip or python3 on PATH for extraction). This populates webapp/ (src/preview/viewer.min.txt.npm run buildmain.js, manifest.json, styles.css, and the webapp/ folder into your vault at <vault>/.obsidian/plugins/drawio/. Note: webapp/ is ~145 MB, so the installed plugin folder is large.Untitled Diagram <timestamp>.drawio file with the editor embedded in the tab.```drawio code block (paste drawio XML, or start empty and edit). It renders as a preview in both editing and reading views.![[your-diagram.drawio]] in any note..drawio files open the editor directly in their tab. Changes autosave back to the source (the code block, or the file).https://embed.diagrams.net/).npm run dev — watch build (rebuilds main.js on change).npm test — unit tests (vitest): XML utils, code-block locating/replacement, embed protocol messages, SVG sanitizer, port detection, the local server, and the preview renderer error path.npm run build — type-check + production bundle.main.js includes drawio's viewer.min.js (~2.3 MB) inlined for offline previews, so the built main.js is ~2.4 MB. This is expected.![[file.drawio]] embed re-renders automatically when the file is modified (including edits made through this plugin elsewhere).![[file.drawio#Page-2]] is ignored — the embed always shows the first page.<script>/embedding elements, inline event handlers, script-bearing URL schemes (normalised to defeat control-character obfuscation), external <use> references, SMIL attribute injection, and dangerous CSS are removed, while drawio's foreignObject text labels are preserved. The bundled drawio preview engine (viewer.min.js) is run in the page's global scope without injecting a <script> element, and its one external-script loader (a MathJax-from-CDN helper, unused by offline previews) is stripped at build time — so previews fetch and execute no external code. In Offline mode the local server binds to 127.0.0.1 only and serves solely the bundled webapp/ directory.MIT