Skip to content

Commit 723338e

Browse files
committed
fix: update to markmap v0.18
1 parent 512bf91 commit 723338e

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ plugins:
7373
encoding: utf-8
7474
file_extension: .mm.md
7575
d3_version: 7
76-
lib_version: 0.15.3
77-
view_version: 0.15.3
76+
lib_version: 0.18
77+
view_version: 0.18
7878
```
7979
8080
In addition, feel free to define your favourite source urls like this:
@@ -89,8 +89,8 @@ plugins:
8989
9090
extra_javascript:
9191
- https://unpkg.com/d3@7/dist/d3.min.js
92-
- https://unpkg.com/markmap-lib@0.15.3/dist/browser/index.js
93-
- https://unpkg.com/markmap-view@0.15.3/dist/browser/index.js
92+
- https://unpkg.com/markmap-lib@0.18/dist/browser/index.iife.js
93+
- https://unpkg.com/markmap-view@0.18/dist/browser/index.js
9494
```
9595
9696
## Troubleshooting

mkdocs_markmap/defaults.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ class JsModuleConfig(object):
1414
)
1515

1616
MARKMAP_LIB: JsModuleConfig = JsModuleConfig(
17-
version="0.15.4",
17+
version="0.18",
1818
uri="https://unpkg.com/markmap-lib@{}",
1919
)
2020

2121
MARKMAP_VIEW: JsModuleConfig = JsModuleConfig(
22-
version="0.15.4",
22+
version="0.18",
2323
uri="https://unpkg.com/markmap-view@{}",
2424
)
2525

mkdocs_markmap/static_files/mkdocs-markmap.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
(function initializeMarkmap() {
22
const transformer = new markmap.Transformer();
3+
const preloadAssets = transformer.getPreloadScripts();
34
const assets = transformer.getAssets();
45
const loading = Promise.all([
56
assets.styles && markmap.loadCSS(assets.styles),
6-
assets.scripts && markmap.loadJS(assets.scripts),
7+
markmap.loadJS([...preloadAssets.scripts, ...assets.scripts]),
78
]);
89

910
function parseData(content) {
@@ -19,8 +20,9 @@
1920
}
2021

2122
function resetMarkmap(m, el) {
22-
const { minX, maxX, minY, maxY } = m.state;
23-
const height = (el.clientWidth * (maxX - minX)) / (maxY - minY);
23+
if (!m.state.rect) return;
24+
const { x1, y1, x2, y2 } = m.state.rect;
25+
const height = (el.offsetWidth / (x2 - x1)) * (y2 - y1);
2426
el.style.height = height + "px";
2527
m.fit();
2628
}
@@ -44,11 +46,9 @@
4446
el.innerHTML = "<svg>";
4547
svg = el.firstChild;
4648
const { root, options } = parseData(content);
47-
const m = markmap.Markmap.create(svg, options, root);
48-
resetMarkmap(m, el);
49-
transformer.hooks.retransform.tap(() => {
50-
const { root, options } = parseData(content);
51-
m.setData(root, options);
49+
const m = markmap.Markmap.create(svg, options);
50+
m.setData(root);
51+
requestAnimationFrame(() => {
5252
resetMarkmap(m, el);
5353
});
5454
}

0 commit comments

Comments
 (0)