markmap-cli 0.18.0 → 0.18.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +19 -19
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -226,37 +226,37 @@ function startServer(paddingBottom) {
|
|
|
226
226
|
let ts = 0;
|
|
227
227
|
let root;
|
|
228
228
|
let line;
|
|
229
|
-
let offset = 0;
|
|
230
229
|
const { mm, markmap } = window;
|
|
231
230
|
refresh();
|
|
232
231
|
function refresh() {
|
|
233
|
-
fetch(`/~data?ts=${ts}`).then((res) => res.json()).then(
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
line
|
|
245
|
-
|
|
246
|
-
|
|
232
|
+
fetch(`/~data?ts=${ts}`).then((res) => res.json()).then(
|
|
233
|
+
(res) => {
|
|
234
|
+
if (res.ts && res.ts > ts && res.result) {
|
|
235
|
+
let frontmatter;
|
|
236
|
+
({ root, frontmatter } = res.result);
|
|
237
|
+
mm.setOptions(markmap.deriveOptions(frontmatter == null ? void 0 : frontmatter.markmap));
|
|
238
|
+
mm.setData(root);
|
|
239
|
+
if (!ts) mm.fit();
|
|
240
|
+
ts = res.ts;
|
|
241
|
+
line = -1;
|
|
242
|
+
}
|
|
243
|
+
if (root && res.line != null && line !== res.line) {
|
|
244
|
+
line = res.line;
|
|
245
|
+
const active = findActiveNode();
|
|
246
|
+
if (active) mm.ensureView(active, { bottom: paddingBottom });
|
|
247
|
+
}
|
|
248
|
+
setTimeout(refresh, 300);
|
|
247
249
|
}
|
|
248
|
-
|
|
249
|
-
});
|
|
250
|
+
);
|
|
250
251
|
}
|
|
251
252
|
function findActiveNode() {
|
|
252
|
-
const lineWithoutFrontmatter = line - offset;
|
|
253
253
|
let best;
|
|
254
254
|
dfs(root);
|
|
255
255
|
return best;
|
|
256
256
|
function dfs(node) {
|
|
257
257
|
var _a, _b, _c;
|
|
258
258
|
const [start, end] = ((_b = (_a = node.payload) == null ? void 0 : _a.lines) == null ? void 0 : _b.split(",").map((s) => +s)) || [];
|
|
259
|
-
if (start >= 0 && start <=
|
|
259
|
+
if (start >= 0 && start <= line && line < end) {
|
|
260
260
|
best = node;
|
|
261
261
|
}
|
|
262
262
|
(_c = node.children) == null ? void 0 : _c.forEach(dfs);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markmap-cli",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.1-alpha.1+f00ade4",
|
|
4
4
|
"description": "Create markmaps from CLI",
|
|
5
5
|
"author": "Gerald <gera2ld@live.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"commander": "^12.1.0",
|
|
51
51
|
"hono": "^4.6.13",
|
|
52
52
|
"markmap-common": "0.18.0",
|
|
53
|
-
"markmap-lib": "0.18.
|
|
53
|
+
"markmap-lib": "0.18.1-alpha.1+f00ade4",
|
|
54
54
|
"markmap-render": "0.18.0",
|
|
55
55
|
"markmap-toolbar": "0.18.0",
|
|
56
56
|
"open": "^10.1.0",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"read-package-up": "^11.0.0",
|
|
59
59
|
"update-notifier": "^7.3.1"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "f00ade49c4b34f9c34579e67cd185ad29afd6950"
|
|
62
62
|
}
|