Skip to content

Commit 01e4426

Browse files
mbheinentuunit
andauthored
feat: adds highlighting for hyperlinks on mouse hover (#41)
* Adds highlighting for hyperlinks on mouse hover This adds support for a new configuration parameter that allows users to set the color of the highlight that occurs when the mouse hovers over a drawing element that has a hyperlink on it. * Fixes items from code review * Fixes color on README example config * fix: bump version --------- Co-authored-by: Jan Larwig <jan@larwig.com>
1 parent f3cb068 commit 01e4426

File tree

7 files changed

+39
-6
lines changed

7 files changed

+39
-6
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,12 @@ Further options are:
7171
```yaml
7272
plugins:
7373
- drawio:
74-
toolbar: true # control if hovering on a diagram shows a toolbar for zooming or not (default: true)
75-
tooltips: true # control if tooltips will be shown (default: true)
76-
edit: true # control if edit button will be shown in the lightbox view (default: true)
77-
border: 10 # increase or decrease the border / margin around your diagrams (default: 0)
78-
darkmode: true # support darkmode. allows for automatic switching between dark and lightmode based on the theme toggle. (default: false)
74+
toolbar: true # control if hovering on a diagram shows a toolbar for zooming or not (default: true)
75+
tooltips: true # control if tooltips will be shown (default: true)
76+
edit: true # control if edit button will be shown in the lightbox view (default: true)
77+
border: 10 # increase or decrease the border / margin around your diagrams (default: 0)
78+
darkmode: true # support darkmode. allows for automatic switching between dark and lightmode based on the theme toggle. (default: false)
79+
highlight: "#0000FF" # color hyperlinks on mouse hover over (default: no color)
7980
```
8081
8182
## Material Integration

examples/docs/configuration.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ plugins:
3333
# When activated the color scheme for your diagrams is automatically toggled
3434
# based on the selected theme. Supports classic mkdocs and mkdocs-material.
3535
darkmode: true
36+
37+
# Set the color of hyperlink highlighting
38+
# When a diagram element has a hyperlink on it, the element is highlighted
39+
# on mouse hover over to better indicate a hylerlink is present. This
40+
# parameter controls the color of the highlight boarder. If omitted, no
41+
# highlighting happens.
42+
highlight: "#0000FF"
3643
```
3744
## HTML Attributes
3845
For each global configuration option you can also use the attribute in the diagram itself. This will override the global configuration. Here is an example:
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<mxfile host="Electron" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/28.2.5 Chrome/138.0.7204.251 Electron/37.6.1 Safari/537.36" version="28.2.5">
2+
<diagram name="Page-1" id="oQSh-LxvRU6CrudPoFx3">
3+
<mxGraphModel dx="1042" dy="626" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
4+
<root>
5+
<mxCell id="0" />
6+
<mxCell id="1" parent="0" />
7+
<UserObject label="I have a link!" link="https://github.com/tuunit/mkdocs-drawio" id="MJqBkFlVLDPoP-BwWEq9-1">
8+
<mxCell style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
9+
<mxGeometry x="365" y="210" width="120" height="60" as="geometry" />
10+
</mxCell>
11+
</UserObject>
12+
</root>
13+
</mxGraphModel>
14+
</diagram>
15+
</mxfile>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Hyperlinks
2+
3+
## Example
4+
This is an example of a drawing that has a hyperlink on one of the symbols. It should highlight on mouse hover over with the color set by the `highlight` configuration setting.
5+
6+
![](hyperlink.drawio)

examples/mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ nav:
1616
- Pagging: "tests/pagging/index.md"
1717
- External URL: "tests/external-url/index.md"
1818
- SVG Diagram: "tests/svg/index.md"
19+
- Hyperlinks: "tests/hyperlinks/index.md"
1920

2021
theme:
2122
name: material
@@ -49,6 +50,7 @@ plugins:
4950
edit: true
5051
border: 20
5152
darkmode: true
53+
highlight: "#0000FF"
5254
- print-site
5355

5456
repo_url: https://github.com/tuunit/mkdocs-drawio

mkdocs_drawio/plugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class DrawioConfig(base.Config):
2929
border = c.Type(int, default=0)
3030
edit = c.Type(bool, default=True)
3131
darkmode = c.Type(bool, default=False)
32+
highlight = c.Type(str, default="")
3233

3334

3435
class DrawioPlugin(BasePlugin[DrawioConfig]):
@@ -51,6 +52,7 @@ def render_drawio_diagrams(self, output_content, page):
5152
"border": self.config.border + 5,
5253
"resize": "1",
5354
"edit": "_blank" if self.config.edit else None,
55+
"highlight": self.config.highlight if self.config.highlight else None,
5456
}
5557

5658
# search for images using drawio extension

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "mkdocs-drawio"
3-
version = "1.11.3"
3+
version = "1.12.0"
44
description = "MkDocs plugin for embedding Drawio files"
55
authors = [
66
"Jan Larwig <jan@larwig.com>",

0 commit comments

Comments
 (0)