From 4e0a1e496d9f3197dc4e5a8d3b83bdbf443a8056 Mon Sep 17 00:00:00 2001 From: Manuel Widmer Date: Fri, 23 Jan 2026 15:01:15 +0100 Subject: [PATCH 1/2] add support to show the filename as title, add documentation to fix toolbar button corruption issue when toolbar is too small, fix duplicate display of external graphs --- README.md | 10 ++++++++-- examples/docs/configuration.md | 7 +++++-- mkdocs_drawio/plugin.py | 7 ++++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9f6da47..16824fb 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ [![Publish Badge](https://github.com/tuunit/mkdocs-drawio/workflows/Publish/badge.svg)](https://github.com/tuunit/mkdocs-drawio/actions) [![PyPI](https://img.shields.io/pypi/v/mkdocs-drawio)](https://pypi.org/project/mkdocs-drawio/) -Sergey ([onixpro](https://github.com/onixpro)) is the original creator of this plugin but since his repository isn't maintained anymore we forked it on the 19th December of 2023 and have been keeping it up-to-date and expanding on the features since then. -[Buy Sergey a ☕](https://www.buymeacoffee.com/SergeyLukin) +Sergey ([onixpro](https://github.com/onixpro)) is the original creator of this plugin but since his repository isn't maintained anymore we forked it on the 19th December of 2023 and have been keeping it up-to-date and expanding on the features since then. +[Buy Sergey a ☕](https://www.buymeacoffee.com/SergeyLukin) ## Features @@ -85,6 +85,7 @@ plugins: lightbox: true # Display the lightbox / fullscreen button position: "top" # Control the position of the toolbar (top or bottom) no_hide: false # Do not hide the toolbar when not hovering over diagrams + show_title: false # Show the diagram title in the toolbar based on the file name ``` ## Material Integration @@ -111,7 +112,12 @@ Add `docs/javascripts/drawio-reload.js` to your project: ```js document$.subscribe(({ body }) => { + // if drawio toolbar icons/buttons are not showing or missing due to title being longer than the image width + // you can set a minimum width for the graph viewer by uncommenting the following line + // GraphViewer.prototype.minWidth = 500; GraphViewer.processElements() + // required to fix duplicate display of external drawio graphs (via http) + reload(); }) ``` diff --git a/examples/docs/configuration.md b/examples/docs/configuration.md index 1b7cfc8..208b5a5 100644 --- a/examples/docs/configuration.md +++ b/examples/docs/configuration.md @@ -31,8 +31,8 @@ plugins: # Enable dark mode support # When activated the color scheme for your diagrams is automatically toggled # based on the selected theme. Supports classic mkdocs and mkdocs-material. - darkmode: true - + darkmode: true + # Highlight color for hyperlinks # When a diagram element has a hyperlink on it, the element is highlighted # on mouse hover over to better indicate a hyperlink is present. @@ -63,6 +63,9 @@ plugins: # Do not hide the toolbar when not hovering over diagrams no_hide: false + + # Show the diagram title in the toolbar based on the file name + show_title: false ``` ## Material Integration diff --git a/mkdocs_drawio/plugin.py b/mkdocs_drawio/plugin.py index cb3209c..ca1e12a 100644 --- a/mkdocs_drawio/plugin.py +++ b/mkdocs_drawio/plugin.py @@ -44,6 +44,8 @@ class Toolbar(base.Config): no_hide = c.Type(bool, default=False) """ Do not hide the toolbar when not hovering over diagrams """ + show_title = c.Type(bool, default=False) + """ Will display the original filename as toolbar title if true, no title if false """ class DrawioConfig(base.Config): """Configuration options for the Drawio Plugin""" @@ -125,7 +127,7 @@ def get_toolbar_config(self, toolbar_config) -> Toolbar: if isinstance(toolbar_config, bool): if toolbar_config is False: # Flip all toolbar items off but keep other defaults intact. - for key in ("pages", "tags", "zoom", "layers", "lightbox"): + for key in ("pages", "tags", "zoom", "layers", "lightbox", "show_title"): setattr(config, key, False) if isinstance(toolbar_config, dict): @@ -161,6 +163,9 @@ def render_drawio_diagrams(self, output_content, page): diagram_config = self.get_diagram_config() for diagram in diagrams: + if self.toolbar_config.show_title: + diagram_config["title"] = diagram["src"].split('/')[-1] + if re.search("^https?://", diagram["src"]): mxgraph = BeautifulSoup( DrawioPlugin.substitute_with_url(diagram_config, diagram["src"]), From e5a1ad60a808ef520f1c842e95d63d13cf8f8ab5 Mon Sep 17 00:00:00 2001 From: Jan Larwig Date: Sat, 14 Mar 2026 12:34:31 +0800 Subject: [PATCH 2/2] doc: formatting and version bump to 1.14.0 Signed-off-by: Jan Larwig --- README.md | 2 ++ examples/docs/configuration.md | 7 +++++++ mkdocs_drawio/plugin.py | 12 ++++++++++-- pyproject.toml | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 16824fb..9a95fa1 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,9 @@ document$.subscribe(({ body }) => { // if drawio toolbar icons/buttons are not showing or missing due to title being longer than the image width // you can set a minimum width for the graph viewer by uncommenting the following line // GraphViewer.prototype.minWidth = 500; + GraphViewer.processElements() + // required to fix duplicate display of external drawio graphs (via http) reload(); }) diff --git a/examples/docs/configuration.md b/examples/docs/configuration.md index 208b5a5..e5ec1df 100644 --- a/examples/docs/configuration.md +++ b/examples/docs/configuration.md @@ -92,6 +92,13 @@ Add `docs/javascripts/drawio-reload.js` to your project: ```js document$.subscribe(({ body }) => { + // if drawio toolbar icons/buttons are not showing or missing due to title being longer than the image width + // you can set a minimum width for the graph viewer by uncommenting the following line + // GraphViewer.prototype.minWidth = 500; + GraphViewer.processElements() + + // required to fix duplicate display of external drawio graphs (via http) + reload(); }) ``` diff --git a/mkdocs_drawio/plugin.py b/mkdocs_drawio/plugin.py index ca1e12a..117620f 100644 --- a/mkdocs_drawio/plugin.py +++ b/mkdocs_drawio/plugin.py @@ -47,6 +47,7 @@ class Toolbar(base.Config): show_title = c.Type(bool, default=False) """ Will display the original filename as toolbar title if true, no title if false """ + class DrawioConfig(base.Config): """Configuration options for the Drawio Plugin""" @@ -127,7 +128,14 @@ def get_toolbar_config(self, toolbar_config) -> Toolbar: if isinstance(toolbar_config, bool): if toolbar_config is False: # Flip all toolbar items off but keep other defaults intact. - for key in ("pages", "tags", "zoom", "layers", "lightbox", "show_title"): + for key in ( + "pages", + "tags", + "zoom", + "layers", + "lightbox", + "show_title", + ): setattr(config, key, False) if isinstance(toolbar_config, dict): @@ -164,7 +172,7 @@ def render_drawio_diagrams(self, output_content, page): for diagram in diagrams: if self.toolbar_config.show_title: - diagram_config["title"] = diagram["src"].split('/')[-1] + diagram_config["title"] = diagram["src"].split("/")[-1] if re.search("^https?://", diagram["src"]): mxgraph = BeautifulSoup( diff --git a/pyproject.toml b/pyproject.toml index 0dbe793..3f0712a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "mkdocs-drawio" -version = "1.13.0" +version = "1.14.0" description = "MkDocs plugin for embedding Drawio files" authors = [ "Jan Larwig ",