Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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();
})
```

Expand Down
7 changes: 5 additions & 2 deletions examples/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion mkdocs_drawio/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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"]),
Expand Down
Loading