markmap-lib 0.14.5-alpha.15 → 0.14.5-alpha.17
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/browser/index.js +197 -52
- package/dist/browser/index.mjs +197 -52
- package/dist/index.js +20 -18
- package/dist/index.mjs +20 -18
- package/package.json +4 -4
- package/types/index.d.ts +1 -1
- package/types/template.d.ts +2 -2
- package/types/transform.d.ts +2 -2
- package/types/types.d.ts +2 -2
package/dist/browser/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! markmap-lib v0.14.5-alpha.
|
|
1
|
+
/*! markmap-lib v0.14.5-alpha.17+0d6a717 | MIT License */
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('katex')) :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(['exports', 'katex'], factory) :
|
|
@@ -20,7 +20,7 @@ function _extends$1() {
|
|
|
20
20
|
return _extends$1.apply(this, arguments);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
/*! markmap-common v0.14.
|
|
23
|
+
/*! markmap-common v0.14.2 | MIT License */
|
|
24
24
|
class Hook {
|
|
25
25
|
constructor() {
|
|
26
26
|
this.listeners = [];
|
|
@@ -69,12 +69,13 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
69
69
|
return target;
|
|
70
70
|
}
|
|
71
71
|
const _excluded = ["textContent"];
|
|
72
|
+
const escapeChars = {
|
|
73
|
+
'&': '&',
|
|
74
|
+
'<': '<',
|
|
75
|
+
'"': '"'
|
|
76
|
+
};
|
|
72
77
|
function escapeHtml$1(html) {
|
|
73
|
-
return html.replace(/[&<"]/g, m =>
|
|
74
|
-
'&': '&',
|
|
75
|
-
'<': '<',
|
|
76
|
-
'"': '"'
|
|
77
|
-
})[m]);
|
|
78
|
+
return html.replace(/[&<"]/g, m => escapeChars[m]);
|
|
78
79
|
}
|
|
79
80
|
function escapeScript(content) {
|
|
80
81
|
return content.replace(/<(\/script>)/g, '\\x3c$2');
|
|
@@ -154,6 +155,161 @@ function memoize(fn) {
|
|
|
154
155
|
return data.value;
|
|
155
156
|
};
|
|
156
157
|
}
|
|
158
|
+
|
|
159
|
+
/*! @gera2ld/jsx-dom v2.2.2 | ISC License */
|
|
160
|
+
const VTYPE_ELEMENT = 1;
|
|
161
|
+
const VTYPE_FUNCTION = 2;
|
|
162
|
+
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
163
|
+
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
164
|
+
const NS_ATTRS = {
|
|
165
|
+
show: XLINK_NS,
|
|
166
|
+
actuate: XLINK_NS,
|
|
167
|
+
href: XLINK_NS
|
|
168
|
+
};
|
|
169
|
+
const isLeaf = c => typeof c === 'string' || typeof c === 'number';
|
|
170
|
+
const isElement = c => (c == null ? void 0 : c.vtype) === VTYPE_ELEMENT;
|
|
171
|
+
const isRenderFunction = c => (c == null ? void 0 : c.vtype) === VTYPE_FUNCTION;
|
|
172
|
+
function h(type, props, ...children) {
|
|
173
|
+
props = Object.assign({}, props, {
|
|
174
|
+
children: children.length === 1 ? children[0] : children
|
|
175
|
+
});
|
|
176
|
+
return jsx(type, props);
|
|
177
|
+
}
|
|
178
|
+
function jsx(type, props) {
|
|
179
|
+
let vtype;
|
|
180
|
+
if (typeof type === 'string') vtype = VTYPE_ELEMENT;else if (typeof type === 'function') vtype = VTYPE_FUNCTION;else throw new Error('Invalid VNode type');
|
|
181
|
+
return {
|
|
182
|
+
vtype,
|
|
183
|
+
type,
|
|
184
|
+
props
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function Fragment(props) {
|
|
188
|
+
return props.children;
|
|
189
|
+
}
|
|
190
|
+
const DEFAULT_ENV = {
|
|
191
|
+
isSvg: false
|
|
192
|
+
};
|
|
193
|
+
function insertDom(parent, nodes) {
|
|
194
|
+
if (!Array.isArray(nodes)) nodes = [nodes];
|
|
195
|
+
nodes = nodes.filter(Boolean);
|
|
196
|
+
if (nodes.length) parent.append(...nodes);
|
|
197
|
+
}
|
|
198
|
+
function mountAttributes(domElement, props, env) {
|
|
199
|
+
for (const key in props) {
|
|
200
|
+
if (key === 'key' || key === 'children' || key === 'ref') continue;
|
|
201
|
+
if (key === 'dangerouslySetInnerHTML') {
|
|
202
|
+
domElement.innerHTML = props[key].__html;
|
|
203
|
+
} else if (key === 'innerHTML' || key === 'textContent' || key === 'innerText' || key === 'value' && ['textarea', 'select'].includes(domElement.tagName)) {
|
|
204
|
+
const value = props[key];
|
|
205
|
+
if (value != null) domElement[key] = value;
|
|
206
|
+
} else if (key.startsWith('on')) {
|
|
207
|
+
domElement[key.toLowerCase()] = props[key];
|
|
208
|
+
} else {
|
|
209
|
+
setDOMAttribute(domElement, key, props[key], env.isSvg);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
const attrMap = {
|
|
214
|
+
className: 'class',
|
|
215
|
+
labelFor: 'for'
|
|
216
|
+
};
|
|
217
|
+
function setDOMAttribute(el, attr, value, isSVG) {
|
|
218
|
+
attr = attrMap[attr] || attr;
|
|
219
|
+
if (value === true) {
|
|
220
|
+
el.setAttribute(attr, '');
|
|
221
|
+
} else if (value === false) {
|
|
222
|
+
el.removeAttribute(attr);
|
|
223
|
+
} else {
|
|
224
|
+
const namespace = isSVG ? NS_ATTRS[attr] : undefined;
|
|
225
|
+
if (namespace !== undefined) {
|
|
226
|
+
el.setAttributeNS(namespace, attr, value);
|
|
227
|
+
} else {
|
|
228
|
+
el.setAttribute(attr, value);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
function flatten(arr) {
|
|
233
|
+
return arr.reduce((prev, item) => prev.concat(item), []);
|
|
234
|
+
}
|
|
235
|
+
function mountChildren(children, env) {
|
|
236
|
+
return Array.isArray(children) ? flatten(children.map(child => mountChildren(child, env))) : mount(children, env);
|
|
237
|
+
}
|
|
238
|
+
function mount(vnode, env = DEFAULT_ENV) {
|
|
239
|
+
if (vnode == null || typeof vnode === 'boolean') {
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
if (vnode instanceof Node) {
|
|
243
|
+
return vnode;
|
|
244
|
+
}
|
|
245
|
+
if (isRenderFunction(vnode)) {
|
|
246
|
+
const {
|
|
247
|
+
type,
|
|
248
|
+
props
|
|
249
|
+
} = vnode;
|
|
250
|
+
if (type === Fragment) {
|
|
251
|
+
const node = document.createDocumentFragment();
|
|
252
|
+
if (props.children) {
|
|
253
|
+
const children = mountChildren(props.children, env);
|
|
254
|
+
insertDom(node, children);
|
|
255
|
+
}
|
|
256
|
+
return node;
|
|
257
|
+
}
|
|
258
|
+
const childVNode = type(props);
|
|
259
|
+
return mount(childVNode, env);
|
|
260
|
+
}
|
|
261
|
+
if (isLeaf(vnode)) {
|
|
262
|
+
return document.createTextNode(`${vnode}`);
|
|
263
|
+
}
|
|
264
|
+
if (isElement(vnode)) {
|
|
265
|
+
let node;
|
|
266
|
+
const {
|
|
267
|
+
type,
|
|
268
|
+
props
|
|
269
|
+
} = vnode;
|
|
270
|
+
if (!env.isSvg && type === 'svg') {
|
|
271
|
+
env = Object.assign({}, env, {
|
|
272
|
+
isSvg: true
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
if (!env.isSvg) {
|
|
276
|
+
node = document.createElement(type);
|
|
277
|
+
} else {
|
|
278
|
+
node = document.createElementNS(SVG_NS, type);
|
|
279
|
+
}
|
|
280
|
+
mountAttributes(node, props, env);
|
|
281
|
+
if (props.children) {
|
|
282
|
+
let childEnv = env;
|
|
283
|
+
if (env.isSvg && type === 'foreignObject') {
|
|
284
|
+
childEnv = Object.assign({}, childEnv, {
|
|
285
|
+
isSvg: false
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
const children = mountChildren(props.children, childEnv);
|
|
289
|
+
if (children != null) insertDom(node, children);
|
|
290
|
+
}
|
|
291
|
+
const {
|
|
292
|
+
ref
|
|
293
|
+
} = props;
|
|
294
|
+
if (typeof ref === 'function') ref(node);
|
|
295
|
+
return node;
|
|
296
|
+
}
|
|
297
|
+
throw new Error('mount: Invalid Vnode!');
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Mount vdom as real DOM nodes.
|
|
302
|
+
*/
|
|
303
|
+
function mountDom(vnode) {
|
|
304
|
+
return mount(vnode);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Render and mount without returning VirtualDOM, useful when you don't need SVG support.
|
|
309
|
+
*/
|
|
310
|
+
function hm(...args) {
|
|
311
|
+
return mountDom(h(...args));
|
|
312
|
+
}
|
|
157
313
|
const providers = {
|
|
158
314
|
jsdelivr: path => `https://cdn.jsdelivr.net/npm/${path}`,
|
|
159
315
|
unpkg: path => `https://unpkg.com/${path}`
|
|
@@ -165,22 +321,8 @@ function cdnUrl(provider, path) {
|
|
|
165
321
|
}
|
|
166
322
|
return factory(path);
|
|
167
323
|
}
|
|
168
|
-
function createElement(tagName, props, attrs) {
|
|
169
|
-
const el = document.createElement(tagName);
|
|
170
|
-
if (props) {
|
|
171
|
-
Object.entries(props).forEach(([key, value]) => {
|
|
172
|
-
el[key] = value;
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
if (attrs) {
|
|
176
|
-
Object.entries(attrs).forEach(([key, value]) => {
|
|
177
|
-
el.setAttribute(key, value);
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
return el;
|
|
181
|
-
}
|
|
182
324
|
const memoizedPreloadJS = memoize(url => {
|
|
183
|
-
document.head.append(
|
|
325
|
+
document.head.append(hm('link', {
|
|
184
326
|
rel: 'preload',
|
|
185
327
|
as: 'script',
|
|
186
328
|
href: url
|
|
@@ -191,9 +333,9 @@ async function loadJSItem(item, context) {
|
|
|
191
333
|
if (item.type === 'script') {
|
|
192
334
|
item.loaded = new Promise((resolve, reject) => {
|
|
193
335
|
var _item$data;
|
|
194
|
-
document.head.append(
|
|
195
|
-
|
|
196
|
-
|
|
336
|
+
document.head.append(hm('script', _extends({}, item.data, {
|
|
337
|
+
onLoad: resolve,
|
|
338
|
+
onError: reject
|
|
197
339
|
})));
|
|
198
340
|
// Run inline script synchronously
|
|
199
341
|
if (!((_item$data = item.data) != null && _item$data.src)) resolve(undefined);
|
|
@@ -213,11 +355,12 @@ async function loadJSItem(item, context) {
|
|
|
213
355
|
await item.loaded;
|
|
214
356
|
}
|
|
215
357
|
async function loadJS(items, context) {
|
|
216
|
-
|
|
358
|
+
items.forEach(item => {
|
|
217
359
|
var _item$data2;
|
|
218
|
-
|
|
360
|
+
if (item.type === 'script' && (_item$data2 = item.data) != null && _item$data2.src) {
|
|
361
|
+
memoizedPreloadJS(item.data.src);
|
|
362
|
+
}
|
|
219
363
|
});
|
|
220
|
-
if (needPreload.length > 1) needPreload.forEach(item => memoizedPreloadJS(item.data.src));
|
|
221
364
|
context = _extends({
|
|
222
365
|
getMarkmap: () => window.markmap
|
|
223
366
|
}, context);
|
|
@@ -247,8 +390,8 @@ function buildCSSItem(path, overrideProvider) {
|
|
|
247
390
|
};
|
|
248
391
|
}
|
|
249
392
|
|
|
250
|
-
const template = "<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">\n<title>Markmap</title>\n<style>\n* {\n margin: 0;\n padding: 0;\n}\n#mindmap {\n display: block;\n width: 100vw;\n height: 100vh;\n}\n</style>\n<!--CSS-->\n</head>\n<body>\n<svg id=\"mindmap\"></svg>\n<!--JS-->\n</body>\n</html>\n";
|
|
251
|
-
const baseJsPaths = [`d3@${"6.2.0"}/dist/d3.min.js`, `markmap-view@${"0.14.5-alpha.
|
|
393
|
+
const template = "<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">\n<title>Markmap</title>\n<style>\n* {\n margin: 0;\n padding: 0;\n}\n#mindmap {\n display: block;\n width: 100vw;\n height: 100vh;\n}\n</style>\n<!--CSS-->\n</head>\n<body>\n<svg id=\"mindmap\"></svg>\n<!--JS-->\n</body>\n</html>\n" ;
|
|
394
|
+
const baseJsPaths = [`d3@${"6.2.0"}/dist/d3.min.js`, `markmap-view@${"0.14.5-alpha.17+0d6a717"}/dist/browser/index.js`];
|
|
252
395
|
function fillTemplate(root, assets, extra) {
|
|
253
396
|
var _extra, _extra$baseJs;
|
|
254
397
|
extra = _extends$1({}, extra);
|
|
@@ -7552,8 +7695,8 @@ function getConfig$1() {
|
|
|
7552
7695
|
const styles = [`katex@${"0.16.0"}/dist/katex.min.css`].map(path => buildCSSItem(path));
|
|
7553
7696
|
return {
|
|
7554
7697
|
versions: {
|
|
7555
|
-
katex: "0.16.0",
|
|
7556
|
-
webfontloader: "1.6.28"
|
|
7698
|
+
katex: "0.16.0" ,
|
|
7699
|
+
webfontloader: "1.6.28"
|
|
7557
7700
|
},
|
|
7558
7701
|
preloadScripts,
|
|
7559
7702
|
scripts: [{
|
|
@@ -7646,7 +7789,7 @@ var katex = definePlugin(() => {
|
|
|
7646
7789
|
md.use(remarkableKatex$1);
|
|
7647
7790
|
md.renderer.rules.katex = (tokens, idx) => {
|
|
7648
7791
|
enableFeature();
|
|
7649
|
-
const result = renderKatex(tokens[idx].content, tokens[idx].block);
|
|
7792
|
+
const result = renderKatex(tokens[idx].content, !!tokens[idx].block);
|
|
7650
7793
|
return result;
|
|
7651
7794
|
};
|
|
7652
7795
|
});
|
|
@@ -7656,13 +7799,13 @@ var katex = definePlugin(() => {
|
|
|
7656
7799
|
};
|
|
7657
7800
|
});
|
|
7658
7801
|
transformHooks.afterParse.tap((_, context) => {
|
|
7659
|
-
|
|
7660
|
-
|
|
7661
|
-
|
|
7662
|
-
if (frontmatter != null && frontmatter.markmap) {
|
|
7802
|
+
var _context$frontmatter;
|
|
7803
|
+
const markmap = (_context$frontmatter = context.frontmatter) == null ? void 0 : _context$frontmatter.markmap;
|
|
7804
|
+
if (markmap) {
|
|
7663
7805
|
['extraJs', 'extraCss'].forEach(key => {
|
|
7664
|
-
|
|
7665
|
-
|
|
7806
|
+
const value = markmap[key];
|
|
7807
|
+
if (value) {
|
|
7808
|
+
markmap[key] = addDefaultVersions(value, name$3, plugin.config.versions.katex);
|
|
7666
7809
|
}
|
|
7667
7810
|
});
|
|
7668
7811
|
}
|
|
@@ -7681,7 +7824,7 @@ function getConfig() {
|
|
|
7681
7824
|
const styles = [`prismjs@${"1.28.0"}/themes/prism.css`].map(path => buildCSSItem(path));
|
|
7682
7825
|
return {
|
|
7683
7826
|
versions: {
|
|
7684
|
-
prismjs: "1.28.0"
|
|
7827
|
+
prismjs: "1.28.0"
|
|
7685
7828
|
},
|
|
7686
7829
|
preloadScripts,
|
|
7687
7830
|
styles
|
|
@@ -10906,10 +11049,12 @@ var npmUrl = definePlugin({
|
|
|
10906
11049
|
const {
|
|
10907
11050
|
frontmatter
|
|
10908
11051
|
} = context;
|
|
10909
|
-
|
|
11052
|
+
const markmap = frontmatter == null ? void 0 : frontmatter.markmap;
|
|
11053
|
+
if (markmap) {
|
|
10910
11054
|
['extraJs', 'extraCss'].forEach(key => {
|
|
10911
|
-
|
|
10912
|
-
|
|
11055
|
+
const value = markmap[key];
|
|
11056
|
+
if (value) {
|
|
11057
|
+
markmap[key] = value.map(path => {
|
|
10913
11058
|
if (path.startsWith('npm:')) {
|
|
10914
11059
|
return getFullUrl(path.slice(4));
|
|
10915
11060
|
}
|
|
@@ -10957,9 +11102,7 @@ function cleanNode(node) {
|
|
|
10957
11102
|
}
|
|
10958
11103
|
});
|
|
10959
11104
|
}
|
|
10960
|
-
if (node.children.length
|
|
10961
|
-
delete node.children;
|
|
10962
|
-
} else {
|
|
11105
|
+
if (node.children.length > 0) {
|
|
10963
11106
|
node.children.forEach(child => cleanNode(child));
|
|
10964
11107
|
if (node.children.length === 1 && !node.children[0].content) {
|
|
10965
11108
|
node.children = node.children[0].children;
|
|
@@ -10967,9 +11110,8 @@ function cleanNode(node) {
|
|
|
10967
11110
|
}
|
|
10968
11111
|
}
|
|
10969
11112
|
function resetDepth(node, depth = 0) {
|
|
10970
|
-
var _node$children;
|
|
10971
11113
|
node.depth = depth;
|
|
10972
|
-
|
|
11114
|
+
node.children.forEach(child => {
|
|
10973
11115
|
resetDepth(child, depth + 1);
|
|
10974
11116
|
});
|
|
10975
11117
|
}
|
|
@@ -11057,10 +11199,13 @@ class Transformer {
|
|
|
11057
11199
|
}
|
|
11058
11200
|
} else if (token.type === 'inline') {
|
|
11059
11201
|
const revoke = this.hooks.htmltag.tap(ctx => {
|
|
11060
|
-
|
|
11202
|
+
var _ctx$result;
|
|
11203
|
+
const comment = (_ctx$result = ctx.result) == null ? void 0 : _ctx$result.match(/^<!--([\s\S]*?)-->$/);
|
|
11061
11204
|
const data = comment == null ? void 0 : comment[1].trim().split(' ');
|
|
11062
|
-
if (data[0] === 'fold') {
|
|
11063
|
-
current.payload
|
|
11205
|
+
if ((data == null ? void 0 : data[0]) === 'fold') {
|
|
11206
|
+
current.payload = _extends$1({}, current.payload, {
|
|
11207
|
+
fold: ['all', 'recursively'].includes(data[1]) ? 2 : 1
|
|
11208
|
+
});
|
|
11064
11209
|
ctx.result = '';
|
|
11065
11210
|
}
|
|
11066
11211
|
});
|
|
@@ -11131,7 +11276,7 @@ class Transformer {
|
|
|
11131
11276
|
}
|
|
11132
11277
|
|
|
11133
11278
|
const transformerVersions = {
|
|
11134
|
-
'markmap-lib': '0.14.5-alpha.
|
|
11279
|
+
'markmap-lib': '0.14.5-alpha.17+0d6a717',
|
|
11135
11280
|
d3: "6.2.0"
|
|
11136
11281
|
};
|
|
11137
11282
|
|
package/dist/browser/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! markmap-lib v0.14.5-alpha.
|
|
1
|
+
/*! markmap-lib v0.14.5-alpha.17+0d6a717 | MIT License */
|
|
2
2
|
import require$$0 from 'katex';
|
|
3
3
|
|
|
4
4
|
function _extends$1() {
|
|
@@ -16,7 +16,7 @@ function _extends$1() {
|
|
|
16
16
|
return _extends$1.apply(this, arguments);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
/*! markmap-common v0.14.
|
|
19
|
+
/*! markmap-common v0.14.2 | MIT License */
|
|
20
20
|
class Hook {
|
|
21
21
|
constructor() {
|
|
22
22
|
this.listeners = [];
|
|
@@ -65,12 +65,13 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
65
65
|
return target;
|
|
66
66
|
}
|
|
67
67
|
const _excluded = ["textContent"];
|
|
68
|
+
const escapeChars = {
|
|
69
|
+
'&': '&',
|
|
70
|
+
'<': '<',
|
|
71
|
+
'"': '"'
|
|
72
|
+
};
|
|
68
73
|
function escapeHtml$1(html) {
|
|
69
|
-
return html.replace(/[&<"]/g, m =>
|
|
70
|
-
'&': '&',
|
|
71
|
-
'<': '<',
|
|
72
|
-
'"': '"'
|
|
73
|
-
})[m]);
|
|
74
|
+
return html.replace(/[&<"]/g, m => escapeChars[m]);
|
|
74
75
|
}
|
|
75
76
|
function escapeScript(content) {
|
|
76
77
|
return content.replace(/<(\/script>)/g, '\\x3c$2');
|
|
@@ -150,6 +151,161 @@ function memoize(fn) {
|
|
|
150
151
|
return data.value;
|
|
151
152
|
};
|
|
152
153
|
}
|
|
154
|
+
|
|
155
|
+
/*! @gera2ld/jsx-dom v2.2.2 | ISC License */
|
|
156
|
+
const VTYPE_ELEMENT = 1;
|
|
157
|
+
const VTYPE_FUNCTION = 2;
|
|
158
|
+
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
159
|
+
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
160
|
+
const NS_ATTRS = {
|
|
161
|
+
show: XLINK_NS,
|
|
162
|
+
actuate: XLINK_NS,
|
|
163
|
+
href: XLINK_NS
|
|
164
|
+
};
|
|
165
|
+
const isLeaf = c => typeof c === 'string' || typeof c === 'number';
|
|
166
|
+
const isElement = c => (c == null ? void 0 : c.vtype) === VTYPE_ELEMENT;
|
|
167
|
+
const isRenderFunction = c => (c == null ? void 0 : c.vtype) === VTYPE_FUNCTION;
|
|
168
|
+
function h(type, props, ...children) {
|
|
169
|
+
props = Object.assign({}, props, {
|
|
170
|
+
children: children.length === 1 ? children[0] : children
|
|
171
|
+
});
|
|
172
|
+
return jsx(type, props);
|
|
173
|
+
}
|
|
174
|
+
function jsx(type, props) {
|
|
175
|
+
let vtype;
|
|
176
|
+
if (typeof type === 'string') vtype = VTYPE_ELEMENT;else if (typeof type === 'function') vtype = VTYPE_FUNCTION;else throw new Error('Invalid VNode type');
|
|
177
|
+
return {
|
|
178
|
+
vtype,
|
|
179
|
+
type,
|
|
180
|
+
props
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function Fragment(props) {
|
|
184
|
+
return props.children;
|
|
185
|
+
}
|
|
186
|
+
const DEFAULT_ENV = {
|
|
187
|
+
isSvg: false
|
|
188
|
+
};
|
|
189
|
+
function insertDom(parent, nodes) {
|
|
190
|
+
if (!Array.isArray(nodes)) nodes = [nodes];
|
|
191
|
+
nodes = nodes.filter(Boolean);
|
|
192
|
+
if (nodes.length) parent.append(...nodes);
|
|
193
|
+
}
|
|
194
|
+
function mountAttributes(domElement, props, env) {
|
|
195
|
+
for (const key in props) {
|
|
196
|
+
if (key === 'key' || key === 'children' || key === 'ref') continue;
|
|
197
|
+
if (key === 'dangerouslySetInnerHTML') {
|
|
198
|
+
domElement.innerHTML = props[key].__html;
|
|
199
|
+
} else if (key === 'innerHTML' || key === 'textContent' || key === 'innerText' || key === 'value' && ['textarea', 'select'].includes(domElement.tagName)) {
|
|
200
|
+
const value = props[key];
|
|
201
|
+
if (value != null) domElement[key] = value;
|
|
202
|
+
} else if (key.startsWith('on')) {
|
|
203
|
+
domElement[key.toLowerCase()] = props[key];
|
|
204
|
+
} else {
|
|
205
|
+
setDOMAttribute(domElement, key, props[key], env.isSvg);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
const attrMap = {
|
|
210
|
+
className: 'class',
|
|
211
|
+
labelFor: 'for'
|
|
212
|
+
};
|
|
213
|
+
function setDOMAttribute(el, attr, value, isSVG) {
|
|
214
|
+
attr = attrMap[attr] || attr;
|
|
215
|
+
if (value === true) {
|
|
216
|
+
el.setAttribute(attr, '');
|
|
217
|
+
} else if (value === false) {
|
|
218
|
+
el.removeAttribute(attr);
|
|
219
|
+
} else {
|
|
220
|
+
const namespace = isSVG ? NS_ATTRS[attr] : undefined;
|
|
221
|
+
if (namespace !== undefined) {
|
|
222
|
+
el.setAttributeNS(namespace, attr, value);
|
|
223
|
+
} else {
|
|
224
|
+
el.setAttribute(attr, value);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function flatten(arr) {
|
|
229
|
+
return arr.reduce((prev, item) => prev.concat(item), []);
|
|
230
|
+
}
|
|
231
|
+
function mountChildren(children, env) {
|
|
232
|
+
return Array.isArray(children) ? flatten(children.map(child => mountChildren(child, env))) : mount(children, env);
|
|
233
|
+
}
|
|
234
|
+
function mount(vnode, env = DEFAULT_ENV) {
|
|
235
|
+
if (vnode == null || typeof vnode === 'boolean') {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
if (vnode instanceof Node) {
|
|
239
|
+
return vnode;
|
|
240
|
+
}
|
|
241
|
+
if (isRenderFunction(vnode)) {
|
|
242
|
+
const {
|
|
243
|
+
type,
|
|
244
|
+
props
|
|
245
|
+
} = vnode;
|
|
246
|
+
if (type === Fragment) {
|
|
247
|
+
const node = document.createDocumentFragment();
|
|
248
|
+
if (props.children) {
|
|
249
|
+
const children = mountChildren(props.children, env);
|
|
250
|
+
insertDom(node, children);
|
|
251
|
+
}
|
|
252
|
+
return node;
|
|
253
|
+
}
|
|
254
|
+
const childVNode = type(props);
|
|
255
|
+
return mount(childVNode, env);
|
|
256
|
+
}
|
|
257
|
+
if (isLeaf(vnode)) {
|
|
258
|
+
return document.createTextNode(`${vnode}`);
|
|
259
|
+
}
|
|
260
|
+
if (isElement(vnode)) {
|
|
261
|
+
let node;
|
|
262
|
+
const {
|
|
263
|
+
type,
|
|
264
|
+
props
|
|
265
|
+
} = vnode;
|
|
266
|
+
if (!env.isSvg && type === 'svg') {
|
|
267
|
+
env = Object.assign({}, env, {
|
|
268
|
+
isSvg: true
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
if (!env.isSvg) {
|
|
272
|
+
node = document.createElement(type);
|
|
273
|
+
} else {
|
|
274
|
+
node = document.createElementNS(SVG_NS, type);
|
|
275
|
+
}
|
|
276
|
+
mountAttributes(node, props, env);
|
|
277
|
+
if (props.children) {
|
|
278
|
+
let childEnv = env;
|
|
279
|
+
if (env.isSvg && type === 'foreignObject') {
|
|
280
|
+
childEnv = Object.assign({}, childEnv, {
|
|
281
|
+
isSvg: false
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
const children = mountChildren(props.children, childEnv);
|
|
285
|
+
if (children != null) insertDom(node, children);
|
|
286
|
+
}
|
|
287
|
+
const {
|
|
288
|
+
ref
|
|
289
|
+
} = props;
|
|
290
|
+
if (typeof ref === 'function') ref(node);
|
|
291
|
+
return node;
|
|
292
|
+
}
|
|
293
|
+
throw new Error('mount: Invalid Vnode!');
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Mount vdom as real DOM nodes.
|
|
298
|
+
*/
|
|
299
|
+
function mountDom(vnode) {
|
|
300
|
+
return mount(vnode);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Render and mount without returning VirtualDOM, useful when you don't need SVG support.
|
|
305
|
+
*/
|
|
306
|
+
function hm(...args) {
|
|
307
|
+
return mountDom(h(...args));
|
|
308
|
+
}
|
|
153
309
|
const providers = {
|
|
154
310
|
jsdelivr: path => `https://cdn.jsdelivr.net/npm/${path}`,
|
|
155
311
|
unpkg: path => `https://unpkg.com/${path}`
|
|
@@ -161,22 +317,8 @@ function cdnUrl(provider, path) {
|
|
|
161
317
|
}
|
|
162
318
|
return factory(path);
|
|
163
319
|
}
|
|
164
|
-
function createElement(tagName, props, attrs) {
|
|
165
|
-
const el = document.createElement(tagName);
|
|
166
|
-
if (props) {
|
|
167
|
-
Object.entries(props).forEach(([key, value]) => {
|
|
168
|
-
el[key] = value;
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
if (attrs) {
|
|
172
|
-
Object.entries(attrs).forEach(([key, value]) => {
|
|
173
|
-
el.setAttribute(key, value);
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
return el;
|
|
177
|
-
}
|
|
178
320
|
const memoizedPreloadJS = memoize(url => {
|
|
179
|
-
document.head.append(
|
|
321
|
+
document.head.append(hm('link', {
|
|
180
322
|
rel: 'preload',
|
|
181
323
|
as: 'script',
|
|
182
324
|
href: url
|
|
@@ -187,9 +329,9 @@ async function loadJSItem(item, context) {
|
|
|
187
329
|
if (item.type === 'script') {
|
|
188
330
|
item.loaded = new Promise((resolve, reject) => {
|
|
189
331
|
var _item$data;
|
|
190
|
-
document.head.append(
|
|
191
|
-
|
|
192
|
-
|
|
332
|
+
document.head.append(hm('script', _extends({}, item.data, {
|
|
333
|
+
onLoad: resolve,
|
|
334
|
+
onError: reject
|
|
193
335
|
})));
|
|
194
336
|
// Run inline script synchronously
|
|
195
337
|
if (!((_item$data = item.data) != null && _item$data.src)) resolve(undefined);
|
|
@@ -209,11 +351,12 @@ async function loadJSItem(item, context) {
|
|
|
209
351
|
await item.loaded;
|
|
210
352
|
}
|
|
211
353
|
async function loadJS(items, context) {
|
|
212
|
-
|
|
354
|
+
items.forEach(item => {
|
|
213
355
|
var _item$data2;
|
|
214
|
-
|
|
356
|
+
if (item.type === 'script' && (_item$data2 = item.data) != null && _item$data2.src) {
|
|
357
|
+
memoizedPreloadJS(item.data.src);
|
|
358
|
+
}
|
|
215
359
|
});
|
|
216
|
-
if (needPreload.length > 1) needPreload.forEach(item => memoizedPreloadJS(item.data.src));
|
|
217
360
|
context = _extends({
|
|
218
361
|
getMarkmap: () => window.markmap
|
|
219
362
|
}, context);
|
|
@@ -243,8 +386,8 @@ function buildCSSItem(path, overrideProvider) {
|
|
|
243
386
|
};
|
|
244
387
|
}
|
|
245
388
|
|
|
246
|
-
const template = "<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">\n<title>Markmap</title>\n<style>\n* {\n margin: 0;\n padding: 0;\n}\n#mindmap {\n display: block;\n width: 100vw;\n height: 100vh;\n}\n</style>\n<!--CSS-->\n</head>\n<body>\n<svg id=\"mindmap\"></svg>\n<!--JS-->\n</body>\n</html>\n";
|
|
247
|
-
const baseJsPaths = [`d3@${"6.2.0"}/dist/d3.min.js`, `markmap-view@${"0.14.5-alpha.
|
|
389
|
+
const template = "<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">\n<title>Markmap</title>\n<style>\n* {\n margin: 0;\n padding: 0;\n}\n#mindmap {\n display: block;\n width: 100vw;\n height: 100vh;\n}\n</style>\n<!--CSS-->\n</head>\n<body>\n<svg id=\"mindmap\"></svg>\n<!--JS-->\n</body>\n</html>\n" ;
|
|
390
|
+
const baseJsPaths = [`d3@${"6.2.0"}/dist/d3.min.js`, `markmap-view@${"0.14.5-alpha.17+0d6a717"}/dist/browser/index.js`];
|
|
248
391
|
function fillTemplate(root, assets, extra) {
|
|
249
392
|
var _extra, _extra$baseJs;
|
|
250
393
|
extra = _extends$1({}, extra);
|
|
@@ -7548,8 +7691,8 @@ function getConfig$1() {
|
|
|
7548
7691
|
const styles = [`katex@${"0.16.0"}/dist/katex.min.css`].map(path => buildCSSItem(path));
|
|
7549
7692
|
return {
|
|
7550
7693
|
versions: {
|
|
7551
|
-
katex: "0.16.0",
|
|
7552
|
-
webfontloader: "1.6.28"
|
|
7694
|
+
katex: "0.16.0" ,
|
|
7695
|
+
webfontloader: "1.6.28"
|
|
7553
7696
|
},
|
|
7554
7697
|
preloadScripts,
|
|
7555
7698
|
scripts: [{
|
|
@@ -7642,7 +7785,7 @@ var katex = definePlugin(() => {
|
|
|
7642
7785
|
md.use(remarkableKatex$1);
|
|
7643
7786
|
md.renderer.rules.katex = (tokens, idx) => {
|
|
7644
7787
|
enableFeature();
|
|
7645
|
-
const result = renderKatex(tokens[idx].content, tokens[idx].block);
|
|
7788
|
+
const result = renderKatex(tokens[idx].content, !!tokens[idx].block);
|
|
7646
7789
|
return result;
|
|
7647
7790
|
};
|
|
7648
7791
|
});
|
|
@@ -7652,13 +7795,13 @@ var katex = definePlugin(() => {
|
|
|
7652
7795
|
};
|
|
7653
7796
|
});
|
|
7654
7797
|
transformHooks.afterParse.tap((_, context) => {
|
|
7655
|
-
|
|
7656
|
-
|
|
7657
|
-
|
|
7658
|
-
if (frontmatter != null && frontmatter.markmap) {
|
|
7798
|
+
var _context$frontmatter;
|
|
7799
|
+
const markmap = (_context$frontmatter = context.frontmatter) == null ? void 0 : _context$frontmatter.markmap;
|
|
7800
|
+
if (markmap) {
|
|
7659
7801
|
['extraJs', 'extraCss'].forEach(key => {
|
|
7660
|
-
|
|
7661
|
-
|
|
7802
|
+
const value = markmap[key];
|
|
7803
|
+
if (value) {
|
|
7804
|
+
markmap[key] = addDefaultVersions(value, name$3, plugin.config.versions.katex);
|
|
7662
7805
|
}
|
|
7663
7806
|
});
|
|
7664
7807
|
}
|
|
@@ -7677,7 +7820,7 @@ function getConfig() {
|
|
|
7677
7820
|
const styles = [`prismjs@${"1.28.0"}/themes/prism.css`].map(path => buildCSSItem(path));
|
|
7678
7821
|
return {
|
|
7679
7822
|
versions: {
|
|
7680
|
-
prismjs: "1.28.0"
|
|
7823
|
+
prismjs: "1.28.0"
|
|
7681
7824
|
},
|
|
7682
7825
|
preloadScripts,
|
|
7683
7826
|
styles
|
|
@@ -10902,10 +11045,12 @@ var npmUrl = definePlugin({
|
|
|
10902
11045
|
const {
|
|
10903
11046
|
frontmatter
|
|
10904
11047
|
} = context;
|
|
10905
|
-
|
|
11048
|
+
const markmap = frontmatter == null ? void 0 : frontmatter.markmap;
|
|
11049
|
+
if (markmap) {
|
|
10906
11050
|
['extraJs', 'extraCss'].forEach(key => {
|
|
10907
|
-
|
|
10908
|
-
|
|
11051
|
+
const value = markmap[key];
|
|
11052
|
+
if (value) {
|
|
11053
|
+
markmap[key] = value.map(path => {
|
|
10909
11054
|
if (path.startsWith('npm:')) {
|
|
10910
11055
|
return getFullUrl(path.slice(4));
|
|
10911
11056
|
}
|
|
@@ -10953,9 +11098,7 @@ function cleanNode(node) {
|
|
|
10953
11098
|
}
|
|
10954
11099
|
});
|
|
10955
11100
|
}
|
|
10956
|
-
if (node.children.length
|
|
10957
|
-
delete node.children;
|
|
10958
|
-
} else {
|
|
11101
|
+
if (node.children.length > 0) {
|
|
10959
11102
|
node.children.forEach(child => cleanNode(child));
|
|
10960
11103
|
if (node.children.length === 1 && !node.children[0].content) {
|
|
10961
11104
|
node.children = node.children[0].children;
|
|
@@ -10963,9 +11106,8 @@ function cleanNode(node) {
|
|
|
10963
11106
|
}
|
|
10964
11107
|
}
|
|
10965
11108
|
function resetDepth(node, depth = 0) {
|
|
10966
|
-
var _node$children;
|
|
10967
11109
|
node.depth = depth;
|
|
10968
|
-
|
|
11110
|
+
node.children.forEach(child => {
|
|
10969
11111
|
resetDepth(child, depth + 1);
|
|
10970
11112
|
});
|
|
10971
11113
|
}
|
|
@@ -11053,10 +11195,13 @@ class Transformer {
|
|
|
11053
11195
|
}
|
|
11054
11196
|
} else if (token.type === 'inline') {
|
|
11055
11197
|
const revoke = this.hooks.htmltag.tap(ctx => {
|
|
11056
|
-
|
|
11198
|
+
var _ctx$result;
|
|
11199
|
+
const comment = (_ctx$result = ctx.result) == null ? void 0 : _ctx$result.match(/^<!--([\s\S]*?)-->$/);
|
|
11057
11200
|
const data = comment == null ? void 0 : comment[1].trim().split(' ');
|
|
11058
|
-
if (data[0] === 'fold') {
|
|
11059
|
-
current.payload
|
|
11201
|
+
if ((data == null ? void 0 : data[0]) === 'fold') {
|
|
11202
|
+
current.payload = _extends$1({}, current.payload, {
|
|
11203
|
+
fold: ['all', 'recursively'].includes(data[1]) ? 2 : 1
|
|
11204
|
+
});
|
|
11060
11205
|
ctx.result = '';
|
|
11061
11206
|
}
|
|
11062
11207
|
});
|
|
@@ -11127,7 +11272,7 @@ class Transformer {
|
|
|
11127
11272
|
}
|
|
11128
11273
|
|
|
11129
11274
|
const transformerVersions = {
|
|
11130
|
-
'markmap-lib': '0.14.5-alpha.
|
|
11275
|
+
'markmap-lib': '0.14.5-alpha.17+0d6a717',
|
|
11131
11276
|
d3: "6.2.0"
|
|
11132
11277
|
};
|
|
11133
11278
|
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! markmap-lib v0.14.5-alpha.
|
|
1
|
+
/*! markmap-lib v0.14.5-alpha.17+0d6a717 | MIT License */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
@@ -9,8 +9,8 @@ var Prism = require('prismjs');
|
|
|
9
9
|
var loadLanguages = require('prismjs/components/index.js');
|
|
10
10
|
var yaml = require('js-yaml');
|
|
11
11
|
|
|
12
|
-
const template = "<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">\n<title>Markmap</title>\n<style>\n* {\n margin: 0;\n padding: 0;\n}\n#mindmap {\n display: block;\n width: 100vw;\n height: 100vh;\n}\n</style>\n<!--CSS-->\n</head>\n<body>\n<svg id=\"mindmap\"></svg>\n<!--JS-->\n</body>\n</html>\n";
|
|
13
|
-
const baseJsPaths = [`d3@${"6.2.0"}/dist/d3.min.js`, `markmap-view@${"0.14.5-alpha.
|
|
12
|
+
const template = "<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">\n<title>Markmap</title>\n<style>\n* {\n margin: 0;\n padding: 0;\n}\n#mindmap {\n display: block;\n width: 100vw;\n height: 100vh;\n}\n</style>\n<!--CSS-->\n</head>\n<body>\n<svg id=\"mindmap\"></svg>\n<!--JS-->\n</body>\n</html>\n" ;
|
|
13
|
+
const baseJsPaths = [`d3@${"6.2.0"}/dist/d3.min.js`, `markmap-view@${"0.14.5-alpha.17+0d6a717"}/dist/browser/index.js`];
|
|
14
14
|
function fillTemplate(root, assets, extra) {
|
|
15
15
|
var _extra, _extra$baseJs;
|
|
16
16
|
extra = _extends({}, extra);
|
|
@@ -54,8 +54,8 @@ function getConfig$1() {
|
|
|
54
54
|
const styles = [`katex@${"0.16.0"}/dist/katex.min.css`].map(path => markmapCommon.buildCSSItem(path));
|
|
55
55
|
return {
|
|
56
56
|
versions: {
|
|
57
|
-
katex: "0.16.0",
|
|
58
|
-
webfontloader: "1.6.28"
|
|
57
|
+
katex: "0.16.0" ,
|
|
58
|
+
webfontloader: "1.6.28"
|
|
59
59
|
},
|
|
60
60
|
preloadScripts,
|
|
61
61
|
scripts: [{
|
|
@@ -132,7 +132,7 @@ function getConfig() {
|
|
|
132
132
|
const styles = [`prismjs@${"1.28.0"}/themes/prism.css`].map(path => markmapCommon.buildCSSItem(path));
|
|
133
133
|
return {
|
|
134
134
|
versions: {
|
|
135
|
-
prismjs: "1.28.0"
|
|
135
|
+
prismjs: "1.28.0"
|
|
136
136
|
},
|
|
137
137
|
preloadScripts,
|
|
138
138
|
styles
|
|
@@ -233,10 +233,12 @@ var npmUrl = definePlugin({
|
|
|
233
233
|
const {
|
|
234
234
|
frontmatter
|
|
235
235
|
} = context;
|
|
236
|
-
|
|
236
|
+
const markmap = frontmatter == null ? void 0 : frontmatter.markmap;
|
|
237
|
+
if (markmap) {
|
|
237
238
|
['extraJs', 'extraCss'].forEach(key => {
|
|
238
|
-
|
|
239
|
-
|
|
239
|
+
const value = markmap[key];
|
|
240
|
+
if (value) {
|
|
241
|
+
markmap[key] = value.map(path => {
|
|
240
242
|
if (path.startsWith('npm:')) {
|
|
241
243
|
return markmapCommon.getFullUrl(path.slice(4));
|
|
242
244
|
}
|
|
@@ -284,9 +286,7 @@ function cleanNode(node) {
|
|
|
284
286
|
}
|
|
285
287
|
});
|
|
286
288
|
}
|
|
287
|
-
if (node.children.length
|
|
288
|
-
delete node.children;
|
|
289
|
-
} else {
|
|
289
|
+
if (node.children.length > 0) {
|
|
290
290
|
node.children.forEach(child => cleanNode(child));
|
|
291
291
|
if (node.children.length === 1 && !node.children[0].content) {
|
|
292
292
|
node.children = node.children[0].children;
|
|
@@ -294,9 +294,8 @@ function cleanNode(node) {
|
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
296
|
function resetDepth(node, depth = 0) {
|
|
297
|
-
var _node$children;
|
|
298
297
|
node.depth = depth;
|
|
299
|
-
|
|
298
|
+
node.children.forEach(child => {
|
|
300
299
|
resetDepth(child, depth + 1);
|
|
301
300
|
});
|
|
302
301
|
}
|
|
@@ -384,10 +383,13 @@ class Transformer {
|
|
|
384
383
|
}
|
|
385
384
|
} else if (token.type === 'inline') {
|
|
386
385
|
const revoke = this.hooks.htmltag.tap(ctx => {
|
|
387
|
-
|
|
386
|
+
var _ctx$result;
|
|
387
|
+
const comment = (_ctx$result = ctx.result) == null ? void 0 : _ctx$result.match(/^<!--([\s\S]*?)-->$/);
|
|
388
388
|
const data = comment == null ? void 0 : comment[1].trim().split(' ');
|
|
389
|
-
if (data[0] === 'fold') {
|
|
390
|
-
current.payload
|
|
389
|
+
if ((data == null ? void 0 : data[0]) === 'fold') {
|
|
390
|
+
current.payload = _extends({}, current.payload, {
|
|
391
|
+
fold: ['all', 'recursively'].includes(data[1]) ? 2 : 1
|
|
392
|
+
});
|
|
391
393
|
ctx.result = '';
|
|
392
394
|
}
|
|
393
395
|
});
|
|
@@ -458,7 +460,7 @@ class Transformer {
|
|
|
458
460
|
}
|
|
459
461
|
|
|
460
462
|
const transformerVersions = {
|
|
461
|
-
'markmap-lib': '0.14.5-alpha.
|
|
463
|
+
'markmap-lib': '0.14.5-alpha.17+0d6a717',
|
|
462
464
|
d3: "6.2.0"
|
|
463
465
|
};
|
|
464
466
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! markmap-lib v0.14.5-alpha.
|
|
1
|
+
/*! markmap-lib v0.14.5-alpha.17+0d6a717 | MIT License */
|
|
2
2
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
3
3
|
import { buildJSItem, persistCSS, persistJS, buildCSSItem, Hook, wrapFunction, noop, getFullUrl } from 'markmap-common';
|
|
4
4
|
import { Remarkable } from 'remarkable';
|
|
@@ -7,8 +7,8 @@ import Prism from 'prismjs';
|
|
|
7
7
|
import loadLanguages from 'prismjs/components/index.js';
|
|
8
8
|
import yaml from 'js-yaml';
|
|
9
9
|
|
|
10
|
-
const template = "<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">\n<title>Markmap</title>\n<style>\n* {\n margin: 0;\n padding: 0;\n}\n#mindmap {\n display: block;\n width: 100vw;\n height: 100vh;\n}\n</style>\n<!--CSS-->\n</head>\n<body>\n<svg id=\"mindmap\"></svg>\n<!--JS-->\n</body>\n</html>\n";
|
|
11
|
-
const baseJsPaths = [`d3@${"6.2.0"}/dist/d3.min.js`, `markmap-view@${"0.14.5-alpha.
|
|
10
|
+
const template = "<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">\n<title>Markmap</title>\n<style>\n* {\n margin: 0;\n padding: 0;\n}\n#mindmap {\n display: block;\n width: 100vw;\n height: 100vh;\n}\n</style>\n<!--CSS-->\n</head>\n<body>\n<svg id=\"mindmap\"></svg>\n<!--JS-->\n</body>\n</html>\n" ;
|
|
11
|
+
const baseJsPaths = [`d3@${"6.2.0"}/dist/d3.min.js`, `markmap-view@${"0.14.5-alpha.17+0d6a717"}/dist/browser/index.js`];
|
|
12
12
|
function fillTemplate(root, assets, extra) {
|
|
13
13
|
var _extra, _extra$baseJs;
|
|
14
14
|
extra = _extends({}, extra);
|
|
@@ -52,8 +52,8 @@ function getConfig$1() {
|
|
|
52
52
|
const styles = [`katex@${"0.16.0"}/dist/katex.min.css`].map(path => buildCSSItem(path));
|
|
53
53
|
return {
|
|
54
54
|
versions: {
|
|
55
|
-
katex: "0.16.0",
|
|
56
|
-
webfontloader: "1.6.28"
|
|
55
|
+
katex: "0.16.0" ,
|
|
56
|
+
webfontloader: "1.6.28"
|
|
57
57
|
},
|
|
58
58
|
preloadScripts,
|
|
59
59
|
scripts: [{
|
|
@@ -130,7 +130,7 @@ function getConfig() {
|
|
|
130
130
|
const styles = [`prismjs@${"1.28.0"}/themes/prism.css`].map(path => buildCSSItem(path));
|
|
131
131
|
return {
|
|
132
132
|
versions: {
|
|
133
|
-
prismjs: "1.28.0"
|
|
133
|
+
prismjs: "1.28.0"
|
|
134
134
|
},
|
|
135
135
|
preloadScripts,
|
|
136
136
|
styles
|
|
@@ -231,10 +231,12 @@ var npmUrl = definePlugin({
|
|
|
231
231
|
const {
|
|
232
232
|
frontmatter
|
|
233
233
|
} = context;
|
|
234
|
-
|
|
234
|
+
const markmap = frontmatter == null ? void 0 : frontmatter.markmap;
|
|
235
|
+
if (markmap) {
|
|
235
236
|
['extraJs', 'extraCss'].forEach(key => {
|
|
236
|
-
|
|
237
|
-
|
|
237
|
+
const value = markmap[key];
|
|
238
|
+
if (value) {
|
|
239
|
+
markmap[key] = value.map(path => {
|
|
238
240
|
if (path.startsWith('npm:')) {
|
|
239
241
|
return getFullUrl(path.slice(4));
|
|
240
242
|
}
|
|
@@ -282,9 +284,7 @@ function cleanNode(node) {
|
|
|
282
284
|
}
|
|
283
285
|
});
|
|
284
286
|
}
|
|
285
|
-
if (node.children.length
|
|
286
|
-
delete node.children;
|
|
287
|
-
} else {
|
|
287
|
+
if (node.children.length > 0) {
|
|
288
288
|
node.children.forEach(child => cleanNode(child));
|
|
289
289
|
if (node.children.length === 1 && !node.children[0].content) {
|
|
290
290
|
node.children = node.children[0].children;
|
|
@@ -292,9 +292,8 @@ function cleanNode(node) {
|
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
294
|
function resetDepth(node, depth = 0) {
|
|
295
|
-
var _node$children;
|
|
296
295
|
node.depth = depth;
|
|
297
|
-
|
|
296
|
+
node.children.forEach(child => {
|
|
298
297
|
resetDepth(child, depth + 1);
|
|
299
298
|
});
|
|
300
299
|
}
|
|
@@ -382,10 +381,13 @@ class Transformer {
|
|
|
382
381
|
}
|
|
383
382
|
} else if (token.type === 'inline') {
|
|
384
383
|
const revoke = this.hooks.htmltag.tap(ctx => {
|
|
385
|
-
|
|
384
|
+
var _ctx$result;
|
|
385
|
+
const comment = (_ctx$result = ctx.result) == null ? void 0 : _ctx$result.match(/^<!--([\s\S]*?)-->$/);
|
|
386
386
|
const data = comment == null ? void 0 : comment[1].trim().split(' ');
|
|
387
|
-
if (data[0] === 'fold') {
|
|
388
|
-
current.payload
|
|
387
|
+
if ((data == null ? void 0 : data[0]) === 'fold') {
|
|
388
|
+
current.payload = _extends({}, current.payload, {
|
|
389
|
+
fold: ['all', 'recursively'].includes(data[1]) ? 2 : 1
|
|
390
|
+
});
|
|
389
391
|
ctx.result = '';
|
|
390
392
|
}
|
|
391
393
|
});
|
|
@@ -456,7 +458,7 @@ class Transformer {
|
|
|
456
458
|
}
|
|
457
459
|
|
|
458
460
|
const transformerVersions = {
|
|
459
|
-
'markmap-lib': '0.14.5-alpha.
|
|
461
|
+
'markmap-lib': '0.14.5-alpha.17+0d6a717',
|
|
460
462
|
d3: "6.2.0"
|
|
461
463
|
};
|
|
462
464
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markmap-lib",
|
|
3
|
-
"version": "0.14.5-alpha.
|
|
3
|
+
"version": "0.14.5-alpha.17+0d6a717",
|
|
4
4
|
"description": "Visualize your Markdown as mindmaps with Markmap",
|
|
5
5
|
"author": "Gerald <gera2ld@live.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/remarkable": "^2.0.3",
|
|
50
|
-
"markmap-common": "0.14.
|
|
51
|
-
"markmap-view": "0.14.5-alpha.
|
|
50
|
+
"markmap-common": "0.14.2",
|
|
51
|
+
"markmap-view": "0.14.5-alpha.17+0d6a717",
|
|
52
52
|
"webfontloader": "^1.6.28"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"markmap-common": "*"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "0d6a717b05c622a23faa501e79a7da7cda3ea0b6"
|
|
66
66
|
}
|
package/types/index.d.ts
CHANGED
package/types/template.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { JSItem,
|
|
1
|
+
import { JSItem, IMarkmapOptions, IMarkmapJSONOptions, IPureNode } from 'markmap-common';
|
|
2
2
|
import { IAssets } from './types';
|
|
3
3
|
export declare const baseJsPaths: string[];
|
|
4
|
-
export declare function fillTemplate(root:
|
|
4
|
+
export declare function fillTemplate(root: IPureNode | null, assets: IAssets, extra?: {
|
|
5
5
|
baseJs?: JSItem[];
|
|
6
6
|
jsonOptions?: IMarkmapJSONOptions;
|
|
7
7
|
getOptions?: (jsonOptions: IMarkmapJSONOptions) => Partial<IMarkmapOptions>;
|
package/types/transform.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Remarkable } from 'remarkable';
|
|
2
|
-
import {
|
|
2
|
+
import { IPureNode } from 'markmap-common';
|
|
3
3
|
import { ITransformResult, ITransformPlugin, IAssets, ITransformHooks, IFeatures } from './types';
|
|
4
4
|
import { plugins as builtInPlugins } from './plugins';
|
|
5
5
|
export { builtInPlugins };
|
|
@@ -9,7 +9,7 @@ export declare class Transformer {
|
|
|
9
9
|
assetsMap: Record<string, IAssets>;
|
|
10
10
|
plugins: ITransformPlugin[];
|
|
11
11
|
constructor(plugins?: Array<ITransformPlugin | (() => ITransformPlugin)>);
|
|
12
|
-
buildTree(tokens: Remarkable.Token[]):
|
|
12
|
+
buildTree(tokens: Remarkable.Token[]): IPureNode;
|
|
13
13
|
transform(content: string): ITransformResult;
|
|
14
14
|
/**
|
|
15
15
|
* Get all assets from enabled plugins or filter them by plugin names as keys.
|
package/types/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Remarkable } from 'remarkable';
|
|
2
|
-
import { CSSItem, JSItem,
|
|
2
|
+
import { CSSItem, JSItem, IPureNode, IWrapContext, Hook, IMarkmapJSONOptions } from 'markmap-common';
|
|
3
3
|
type Htmltag = Remarkable.Rule<Remarkable.HtmlTagToken, string>;
|
|
4
4
|
export interface ITransformHooks {
|
|
5
5
|
/**
|
|
@@ -51,7 +51,7 @@ export interface ITransformContext {
|
|
|
51
51
|
contentLineOffset: number;
|
|
52
52
|
}
|
|
53
53
|
export interface ITransformResult extends ITransformContext {
|
|
54
|
-
root:
|
|
54
|
+
root: IPureNode;
|
|
55
55
|
}
|
|
56
56
|
export interface ITransformPlugin {
|
|
57
57
|
name: string;
|