markmap-cli 0.5.4 → 0.13.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 +15 -35
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! markmap-cli v0.
|
|
1
|
+
/*! markmap-cli v0.13.1 | MIT License */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var fs = require('fs');
|
|
@@ -17,7 +17,7 @@ var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
|
|
|
17
17
|
var Koa__default = /*#__PURE__*/_interopDefaultLegacy(Koa);
|
|
18
18
|
var chokidar__default = /*#__PURE__*/_interopDefaultLegacy(chokidar);
|
|
19
19
|
|
|
20
|
-
const TOOLBAR_VERSION = "0.
|
|
20
|
+
const TOOLBAR_VERSION = "0.13.1";
|
|
21
21
|
const TOOLBAR_CSS = `npm/markmap-toolbar@${TOOLBAR_VERSION}/dist/style.min.css`;
|
|
22
22
|
const TOOLBAR_JS = `npm/markmap-toolbar@${TOOLBAR_VERSION}/dist/index.umd.min.js`;
|
|
23
23
|
|
|
@@ -167,51 +167,28 @@ class FileSystemProvider extends BufferContentProvider {
|
|
|
167
167
|
|
|
168
168
|
function startServer(paddingBottom) {
|
|
169
169
|
let ts = 0;
|
|
170
|
-
let root;
|
|
171
|
-
let line;
|
|
172
170
|
const {
|
|
173
|
-
mm
|
|
171
|
+
mm,
|
|
172
|
+
markmap
|
|
174
173
|
} = window;
|
|
175
174
|
refresh();
|
|
176
175
|
|
|
177
176
|
function refresh() {
|
|
178
177
|
fetch(`/data?ts=${ts}`).then(res => res.json()).then(res => {
|
|
179
178
|
if (res.ts && res.ts > ts && res.result) {
|
|
180
|
-
|
|
179
|
+
const {
|
|
180
|
+
root,
|
|
181
|
+
frontmatter
|
|
182
|
+
} = res.result;
|
|
183
|
+
mm.setOptions(markmap.deriveOptions(frontmatter == null ? void 0 : frontmatter.markmap));
|
|
184
|
+
mm.setData(root);
|
|
181
185
|
if (!ts) mm.fit();
|
|
182
186
|
ts = res.ts;
|
|
183
|
-
line = null;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if (root && res.line != null && line !== res.line) {
|
|
187
|
-
line = res.line;
|
|
188
|
-
const active = findActiveNode();
|
|
189
|
-
if (active) mm.ensureView(active, {
|
|
190
|
-
bottom: paddingBottom
|
|
191
|
-
});
|
|
192
187
|
}
|
|
193
188
|
|
|
194
189
|
setTimeout(refresh, 300);
|
|
195
190
|
});
|
|
196
191
|
}
|
|
197
|
-
|
|
198
|
-
function findActiveNode() {
|
|
199
|
-
let best;
|
|
200
|
-
dfs(root);
|
|
201
|
-
return best;
|
|
202
|
-
|
|
203
|
-
function dfs(node) {
|
|
204
|
-
var _node$p, _node$c;
|
|
205
|
-
|
|
206
|
-
const lines = (_node$p = node.p) == null ? void 0 : _node$p.lines;
|
|
207
|
-
|
|
208
|
-
if (lines && lines[0] <= line && line < lines[1]) {
|
|
209
|
-
best = node;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
(_node$c = node.c) == null ? void 0 : _node$c.forEach(dfs);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
192
|
}
|
|
216
193
|
|
|
217
194
|
function setUpServer(transformer, provider, options) {
|
|
@@ -270,11 +247,14 @@ async function createMarkmap(options) {
|
|
|
270
247
|
const transformer = new markmapLib.Transformer();
|
|
271
248
|
const {
|
|
272
249
|
root,
|
|
273
|
-
features
|
|
250
|
+
features,
|
|
251
|
+
frontmatter
|
|
274
252
|
} = transformer.transform(options.content || '');
|
|
275
253
|
let assets = transformer.getUsedAssets(features);
|
|
276
254
|
if (options.toolbar) assets = addToolbar(assets);
|
|
277
|
-
const html = markmapLib.fillTemplate(root, assets
|
|
255
|
+
const html = markmapLib.fillTemplate(root, assets, {
|
|
256
|
+
jsonOptions: frontmatter == null ? void 0 : frontmatter.markmap
|
|
257
|
+
});
|
|
278
258
|
const output = options.output || 'markmap.html';
|
|
279
259
|
await fs.promises.writeFile(output, html, 'utf8');
|
|
280
260
|
if (options.open) open__default(output);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markmap-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"description": "Create markmaps from CLI",
|
|
5
5
|
"author": "Gerald <gera2ld@live.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"chokidar": "^3.5.1",
|
|
43
43
|
"commander": "^7.1.0",
|
|
44
44
|
"koa": "^2.13.1",
|
|
45
|
-
"markmap-lib": "^0.
|
|
45
|
+
"markmap-lib": "^0.13.1",
|
|
46
46
|
"open": "^8.0.3",
|
|
47
47
|
"update-notifier": "^5.1.0"
|
|
48
48
|
},
|
|
49
49
|
"engines": {
|
|
50
50
|
"node": ">=10"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "c23f372da8c72b8053659cfbb9583c027dea6dab"
|
|
53
53
|
}
|