MkDocs Plugin for embedding Drawio files
Sergey (onixpro) is the original creator of this plugin. Repo can be found here.
Features
This plugin enables you to embed interactive drawio diagrams in your documentation. Simply add your diagrams like you would any other image:
You can either use diagrams hosted within your own docs. Absolute as well as relative paths are allowed:
Absolute path:

Same directory as the markdown file:

Relative directory to the markdown file:

Or you can use external urls:

Additionally this plugin supports multi page diagrams by using the alt text to select the pages by name:


Setup
Install plugin using pip:
pip install mkdocs-drawio
Add the plugin to your mkdocs.yml
plugins:
- drawio
Configuration Options
By default the plugin uses the official url for the minified drawio javascript library. To use a custom source for the drawio viewer you can overwritte the url. This might be useful in airlocked environments.
If you want to use a self-hosted JavaScript viewer file. You should download the latest version from the official drawio repo.
plugins:
- drawio:
viewer_js: "https://viewer.diagrams.net/js/viewer-static.min.js"
Further options are:
plugins:
- drawio:
toolbar: true # control if hovering on a diagram shows a toolbar for zooming or not (default: true)
tooltips: true # control if tooltips will be shown (default: true)
border: 10 # increase or decrease the border / margin around your diagrams (default: 5)
Material Integration
If you are using the Material Theme and want to use the instant-loading feature. You will have to configure the following:
In your mkdocs.yaml:
theme:
name: material
features:
- navigation.instant
plugins:
- drawio
extra_javascript:
- https://viewer.diagrams.net/js/viewer-static.min.js
- javascripts/drawio-reload.js
Add docs/javascripts/drawio-reload.js to your project:
document$.subscribe(({ body }) => {
GraphViewer.processElements()
})
How it works
- mkdocs generates the html per page
mkdocs-drawioattaches to theon_post_pageevent. For more details, please have a look at the event lifecycle documentation- Adds the drawio viewer library
- Searches through the generated html for all
imgtags that have a source of type.drawio - Replaces the found
imgtags withmxgraphhtml blocks (actual drawio diagram content). For more details, please have a look at the official drawio.com documentation.
Contribution guide
- Either use the devcontainer or setup a venv with mkdocs installed
- Install your current local version:
pip install -e . - Add a test for your changes in the
exampledirectory - Test your changes by starting
mkdocs servein theexampledirectory - Increase the version
pyproject.toml - Open pull request
Metadata
Release files for mkdocs-drawio-km 1.7.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mkdocs_drawio_km-1.7.2.tar.gz | 7.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mkdocs_drawio_km-1.7.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.3 kB
Release files / mkdocs_drawio_km-1.7.2.tar.gz
| Download URL | mkdocs_drawio_km-1.7.2.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
98c73d05280a241979151891197444bf9ddba8d2d51831be65ce7c5bbf628314
|
|
BLAKE2b-256 checksum How to use checksums |
6851630f7b0db55166bda4167feed7bec445867bcf499a3ef6e3d7a2fb3fb38e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.12
|
Release files / mkdocs_drawio_km-1.7.2-py3-none-any.whl
| Download URL | mkdocs_drawio_km-1.7.2-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ea3d5cf3a29b8369976f1d0f6a1dc2cba13657578a2fbe38f1ead2676ea8d419
|
|
BLAKE2b-256 checksum How to use checksums |
da95ec88a2a7aa0329809bd7f42e36b5d5b5b41ed2cf55aef8695b7d99da6e5d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.12
|