markmap-cli 0.14.5-alpha.16 → 0.14.5-alpha.18
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 +43 -7
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! markmap-cli v0.14.5-alpha.
|
|
1
|
+
/*! markmap-cli v0.14.5-alpha.18+44c9639 | MIT License */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var fs = require('fs');
|
|
@@ -27,7 +27,7 @@ function _extends() {
|
|
|
27
27
|
return _extends.apply(this, arguments);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const TOOLBAR_VERSION = "0.14.5-alpha.
|
|
30
|
+
const TOOLBAR_VERSION = "0.14.5-alpha.18+44c9639";
|
|
31
31
|
const TOOLBAR_CSS = `markmap-toolbar@${TOOLBAR_VERSION}/dist/style.css`;
|
|
32
32
|
const TOOLBAR_JS = `markmap-toolbar@${TOOLBAR_VERSION}/dist/index.js`;
|
|
33
33
|
const renderToolbar = () => {
|
|
@@ -55,9 +55,18 @@ function addToolbar(assets) {
|
|
|
55
55
|
}]
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
+
function removeVersionString(part) {
|
|
59
|
+
return part.replace(/@.+$/, '');
|
|
60
|
+
}
|
|
58
61
|
function localProvider(path) {
|
|
59
62
|
const parts = path.split('/');
|
|
60
|
-
|
|
63
|
+
// xxx@0.0.0-alpha.0+aaaaaa
|
|
64
|
+
// @scope/xxx@0.0.0-alpha.0+aaaaaa
|
|
65
|
+
if (parts[0].startsWith('@')) {
|
|
66
|
+
parts[1] = removeVersionString(parts[1]);
|
|
67
|
+
} else {
|
|
68
|
+
parts[0] = removeVersionString(parts[0]);
|
|
69
|
+
}
|
|
61
70
|
path = parts.join('/');
|
|
62
71
|
return `/node_modules/${path}`;
|
|
63
72
|
}
|
|
@@ -145,6 +154,9 @@ class FileSystemProvider extends BufferContentProvider {
|
|
|
145
154
|
}
|
|
146
155
|
function startServer(paddingBottom) {
|
|
147
156
|
let ts = 0;
|
|
157
|
+
let root;
|
|
158
|
+
let line;
|
|
159
|
+
let offset = 0;
|
|
148
160
|
const {
|
|
149
161
|
mm,
|
|
150
162
|
markmap
|
|
@@ -153,19 +165,43 @@ function startServer(paddingBottom) {
|
|
|
153
165
|
function refresh() {
|
|
154
166
|
fetch(`/data?ts=${ts}`).then(res => res.json()).then(res => {
|
|
155
167
|
if (res.ts && res.ts > ts && res.result) {
|
|
156
|
-
|
|
168
|
+
var _frontmatter;
|
|
169
|
+
let frontmatter;
|
|
170
|
+
({
|
|
157
171
|
root,
|
|
158
172
|
frontmatter,
|
|
159
|
-
contentLineOffset
|
|
160
|
-
} = res.result;
|
|
161
|
-
mm.setOptions(markmap.deriveOptions(frontmatter == null ? void 0 :
|
|
173
|
+
contentLineOffset: offset
|
|
174
|
+
} = res.result);
|
|
175
|
+
mm.setOptions(markmap.deriveOptions((_frontmatter = frontmatter) == null ? void 0 : _frontmatter.markmap));
|
|
162
176
|
mm.setData(root);
|
|
163
177
|
if (!ts) mm.fit();
|
|
164
178
|
ts = res.ts;
|
|
179
|
+
line = -1;
|
|
180
|
+
}
|
|
181
|
+
if (root && res.line != null && line !== res.line) {
|
|
182
|
+
line = res.line;
|
|
183
|
+
const active = findActiveNode();
|
|
184
|
+
if (active) mm.ensureView(active, {
|
|
185
|
+
bottom: paddingBottom
|
|
186
|
+
});
|
|
165
187
|
}
|
|
166
188
|
setTimeout(refresh, 300);
|
|
167
189
|
});
|
|
168
190
|
}
|
|
191
|
+
function findActiveNode() {
|
|
192
|
+
const lineWithoutFrontmatter = line - offset;
|
|
193
|
+
let best;
|
|
194
|
+
dfs(root);
|
|
195
|
+
return best;
|
|
196
|
+
function dfs(node) {
|
|
197
|
+
var _node$payload, _node$children;
|
|
198
|
+
const lines = (_node$payload = node.payload) == null ? void 0 : _node$payload.lines;
|
|
199
|
+
if (lines && lines[0] <= lineWithoutFrontmatter && lineWithoutFrontmatter < lines[1]) {
|
|
200
|
+
best = node;
|
|
201
|
+
}
|
|
202
|
+
(_node$children = node.children) == null ? void 0 : _node$children.forEach(dfs);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
169
205
|
}
|
|
170
206
|
function setUpServer(transformer, provider, options) {
|
|
171
207
|
let assets = transformer.getAssets();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markmap-cli",
|
|
3
|
-
"version": "0.14.5-alpha.
|
|
3
|
+
"version": "0.14.5-alpha.18+44c9639",
|
|
4
4
|
"description": "Create markmaps from CLI",
|
|
5
5
|
"author": "Gerald <gera2ld@live.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,14 +44,14 @@
|
|
|
44
44
|
"d3": "^6.2.0",
|
|
45
45
|
"katex": "^0.16.0",
|
|
46
46
|
"koa": "^2.13.1",
|
|
47
|
-
"markmap-common": "0.14.5-alpha.
|
|
48
|
-
"markmap-lib": "0.14.5-alpha.
|
|
49
|
-
"markmap-toolbar": "0.14.5-alpha.
|
|
50
|
-
"markmap-view": "0.14.5-alpha.
|
|
47
|
+
"markmap-common": "0.14.5-alpha.18+44c9639",
|
|
48
|
+
"markmap-lib": "0.14.5-alpha.18+44c9639",
|
|
49
|
+
"markmap-toolbar": "0.14.5-alpha.18+44c9639",
|
|
50
|
+
"markmap-view": "0.14.5-alpha.18+44c9639",
|
|
51
51
|
"open": "^8.0.3",
|
|
52
52
|
"prismjs": "^1.28.0",
|
|
53
53
|
"update-notifier": "^5.1.0",
|
|
54
54
|
"webfontloader": "^1.6.28"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "44c96396827295d0b30c41404b95f688e3bff1e6"
|
|
57
57
|
}
|