markmap-lib 0.15.0-alpha.0 → 0.15.0
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 +225 -460
- package/dist/browser/index.mjs +244 -10860
- package/dist/index.js +179 -176
- package/dist/index.mjs +179 -176
- package/package.json +20 -8
- package/types/constants.d.ts +2 -0
- package/types/index.d.ts +2 -2
- package/types/plugins/base.d.ts +3 -3
- package/types/plugins/frontmatter.d.ts +1 -1
- package/types/plugins/hljs.d.ts +2 -0
- package/types/plugins/index.d.ts +1 -1
- package/types/plugins/katex.browser.d.ts +2 -2
- package/types/plugins/katex.config.d.ts +2 -1
- package/types/plugins/katex.d.ts +2 -2
- package/types/plugins/npm-url.d.ts +1 -1
- package/types/plugins/prism.browser.d.ts +2 -2
- package/types/plugins/prism.config.d.ts +2 -1
- package/types/plugins/prism.d.ts +2 -2
- package/types/plugins/util.d.ts +4 -0
- package/types/transform.d.ts +10 -4
- package/types/types.d.ts +6 -2
- package/types/template.d.ts +0 -8
package/dist/browser/index.js
CHANGED
|
@@ -1,47 +1,13 @@
|
|
|
1
|
-
/*! markmap-lib v0.15.0
|
|
1
|
+
/*! markmap-lib v0.15.0 | MIT License */
|
|
2
2
|
(function (global, factory) {
|
|
3
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('katex')) :
|
|
4
|
-
typeof define === 'function' && define.amd ? define(['exports', 'katex'], factory) :
|
|
5
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.markmap = global.markmap || {}, global.window.katex));
|
|
6
|
-
})(this, (function (exports, require$$0) { 'use strict';
|
|
3
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('markmap-common'), require('katex'), require('highlight.js')) :
|
|
4
|
+
typeof define === 'function' && define.amd ? define(['exports', 'markmap-common', 'katex', 'highlight.js'], factory) :
|
|
5
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.markmap = global.markmap || {}, global.markmap, global.window.katex, global.window.hljs));
|
|
6
|
+
})(this, (function (exports, markmapCommon, require$$0, hljs) { 'use strict';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
11
|
-
var source = arguments[i];
|
|
12
|
-
for (var key in source) {
|
|
13
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
14
|
-
target[key] = source[key];
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
return _extends$1.apply(this, arguments);
|
|
21
|
-
}
|
|
8
|
+
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" ;
|
|
9
|
+
const baseJsPaths = [`d3@${"7.8.5"}/dist/d3.min.js`, `markmap-view@${"0.15.0"}/dist/browser/index.js`];
|
|
22
10
|
|
|
23
|
-
/*! markmap-common v0.15.0-alpha.0 | MIT License */
|
|
24
|
-
class Hook {
|
|
25
|
-
constructor() {
|
|
26
|
-
this.listeners = [];
|
|
27
|
-
}
|
|
28
|
-
tap(fn) {
|
|
29
|
-
this.listeners.push(fn);
|
|
30
|
-
return () => this.revoke(fn);
|
|
31
|
-
}
|
|
32
|
-
revoke(fn) {
|
|
33
|
-
const i = this.listeners.indexOf(fn);
|
|
34
|
-
if (i >= 0) this.listeners.splice(i, 1);
|
|
35
|
-
}
|
|
36
|
-
revokeAll() {
|
|
37
|
-
this.listeners.splice(0);
|
|
38
|
-
}
|
|
39
|
-
call(...args) {
|
|
40
|
-
for (const fn of this.listeners) {
|
|
41
|
-
fn(...args);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
11
|
function _extends() {
|
|
46
12
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
47
13
|
for (var i = 1; i < arguments.length; i++) {
|
|
@@ -56,234 +22,6 @@ function _extends() {
|
|
|
56
22
|
};
|
|
57
23
|
return _extends.apply(this, arguments);
|
|
58
24
|
}
|
|
59
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
60
|
-
if (source == null) return {};
|
|
61
|
-
var target = {};
|
|
62
|
-
var sourceKeys = Object.keys(source);
|
|
63
|
-
var key, i;
|
|
64
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
65
|
-
key = sourceKeys[i];
|
|
66
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
67
|
-
target[key] = source[key];
|
|
68
|
-
}
|
|
69
|
-
return target;
|
|
70
|
-
}
|
|
71
|
-
const _excluded = ["textContent"];
|
|
72
|
-
function escapeHtml$1(html) {
|
|
73
|
-
return html.replace(/[&<"]/g, m => ({
|
|
74
|
-
'&': '&',
|
|
75
|
-
'<': '<',
|
|
76
|
-
'"': '"'
|
|
77
|
-
})[m]);
|
|
78
|
-
}
|
|
79
|
-
function escapeScript(content) {
|
|
80
|
-
return content.replace(/<(\/script>)/g, '\\x3c$2');
|
|
81
|
-
}
|
|
82
|
-
function htmlOpen(tagName, attrs) {
|
|
83
|
-
const attrStr = attrs ? Object.entries(attrs).map(([key, value]) => {
|
|
84
|
-
if (value == null || value === false) return;
|
|
85
|
-
key = ` ${escapeHtml$1(key)}`;
|
|
86
|
-
if (value === true) return key;
|
|
87
|
-
return `${key}="${escapeHtml$1(value)}"`;
|
|
88
|
-
}).filter(Boolean).join('') : '';
|
|
89
|
-
return `<${tagName}${attrStr}>`;
|
|
90
|
-
}
|
|
91
|
-
function htmlClose(tagName) {
|
|
92
|
-
return `</${tagName}>`;
|
|
93
|
-
}
|
|
94
|
-
function wrapHtml(tagName, content, attrs) {
|
|
95
|
-
if (content == null) return htmlOpen(tagName, attrs);
|
|
96
|
-
return htmlOpen(tagName, attrs) + (content || '') + htmlClose(tagName);
|
|
97
|
-
}
|
|
98
|
-
function buildCode(fn, args) {
|
|
99
|
-
const params = args.map(arg => {
|
|
100
|
-
if (typeof arg === 'function') return arg.toString();
|
|
101
|
-
return JSON.stringify(arg != null ? arg : null);
|
|
102
|
-
}).join(',');
|
|
103
|
-
return `(${fn.toString()})(${params})`;
|
|
104
|
-
}
|
|
105
|
-
function persistJS(items, context) {
|
|
106
|
-
return items.map(item => {
|
|
107
|
-
if (item.type === 'script') {
|
|
108
|
-
const _item$data = item.data,
|
|
109
|
-
{
|
|
110
|
-
textContent
|
|
111
|
-
} = _item$data,
|
|
112
|
-
rest = _objectWithoutPropertiesLoose(_item$data, _excluded);
|
|
113
|
-
return wrapHtml('script', textContent || '', rest);
|
|
114
|
-
}
|
|
115
|
-
if (item.type === 'iife') {
|
|
116
|
-
const {
|
|
117
|
-
fn,
|
|
118
|
-
getParams
|
|
119
|
-
} = item.data;
|
|
120
|
-
return wrapHtml('script', escapeScript(buildCode(fn, (getParams == null ? void 0 : getParams(context)) || [])));
|
|
121
|
-
}
|
|
122
|
-
return '';
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
function persistCSS(items) {
|
|
126
|
-
return items.map(item => {
|
|
127
|
-
if (item.type === 'stylesheet') {
|
|
128
|
-
return wrapHtml('link', null, _extends({
|
|
129
|
-
rel: 'stylesheet'
|
|
130
|
-
}, item.data));
|
|
131
|
-
}
|
|
132
|
-
/* else if (item.type === 'style') */
|
|
133
|
-
return wrapHtml('style', item.data);
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
Math.random().toString(36).slice(2, 8);
|
|
137
|
-
function noop() {
|
|
138
|
-
// noop
|
|
139
|
-
}
|
|
140
|
-
function wrapFunction(fn, wrapper) {
|
|
141
|
-
return (...args) => wrapper(fn, ...args);
|
|
142
|
-
}
|
|
143
|
-
function memoize(fn) {
|
|
144
|
-
const cache = {};
|
|
145
|
-
return function memoized(...args) {
|
|
146
|
-
const key = `${args[0]}`;
|
|
147
|
-
let data = cache[key];
|
|
148
|
-
if (!data) {
|
|
149
|
-
data = {
|
|
150
|
-
value: fn(...args)
|
|
151
|
-
};
|
|
152
|
-
cache[key] = data;
|
|
153
|
-
}
|
|
154
|
-
return data.value;
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
const providers = {
|
|
158
|
-
jsdelivr: path => `https://cdn.jsdelivr.net/npm/${path}`,
|
|
159
|
-
unpkg: path => `https://unpkg.com/${path}`
|
|
160
|
-
};
|
|
161
|
-
function cdnUrl(provider, path) {
|
|
162
|
-
const factory = providers[provider];
|
|
163
|
-
if (!factory) {
|
|
164
|
-
throw new Error(`Provider ${provider} not found`);
|
|
165
|
-
}
|
|
166
|
-
return factory(path);
|
|
167
|
-
}
|
|
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
|
-
const memoizedPreloadJS = memoize(url => {
|
|
183
|
-
document.head.append(createElement('link', {
|
|
184
|
-
rel: 'preload',
|
|
185
|
-
as: 'script',
|
|
186
|
-
href: url
|
|
187
|
-
}));
|
|
188
|
-
});
|
|
189
|
-
async function loadJSItem(item, context) {
|
|
190
|
-
if (!item.loaded) {
|
|
191
|
-
if (item.type === 'script') {
|
|
192
|
-
item.loaded = new Promise((resolve, reject) => {
|
|
193
|
-
var _item$data;
|
|
194
|
-
document.head.append(createElement('script', _extends({}, item.data, {
|
|
195
|
-
onload: resolve,
|
|
196
|
-
onerror: reject
|
|
197
|
-
})));
|
|
198
|
-
// Run inline script synchronously
|
|
199
|
-
if (!((_item$data = item.data) != null && _item$data.src)) resolve(undefined);
|
|
200
|
-
}).then(() => {
|
|
201
|
-
item.loaded = true;
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
if (item.type === 'iife') {
|
|
205
|
-
const {
|
|
206
|
-
fn,
|
|
207
|
-
getParams
|
|
208
|
-
} = item.data;
|
|
209
|
-
fn(...((getParams == null ? void 0 : getParams(context)) || []));
|
|
210
|
-
item.loaded = true;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
await item.loaded;
|
|
214
|
-
}
|
|
215
|
-
async function loadJS(items, context) {
|
|
216
|
-
const needPreload = items.filter(item => {
|
|
217
|
-
var _item$data2;
|
|
218
|
-
return item.type === 'script' && ((_item$data2 = item.data) == null ? void 0 : _item$data2.src);
|
|
219
|
-
});
|
|
220
|
-
if (needPreload.length > 1) needPreload.forEach(item => memoizedPreloadJS(item.data.src));
|
|
221
|
-
context = _extends({
|
|
222
|
-
getMarkmap: () => window.markmap
|
|
223
|
-
}, context);
|
|
224
|
-
for (const item of items) {
|
|
225
|
-
await loadJSItem(item, context);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
let provider = 'jsdelivr';
|
|
229
|
-
function getFullUrl(path) {
|
|
230
|
-
if (path.includes('://')) return path;
|
|
231
|
-
return cdnUrl(provider, path);
|
|
232
|
-
}
|
|
233
|
-
function buildJSItem(path) {
|
|
234
|
-
return {
|
|
235
|
-
type: 'script',
|
|
236
|
-
data: {
|
|
237
|
-
src: getFullUrl(path)
|
|
238
|
-
}
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
function buildCSSItem(path) {
|
|
242
|
-
return {
|
|
243
|
-
type: 'stylesheet',
|
|
244
|
-
data: {
|
|
245
|
-
href: getFullUrl(path)
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
|
|
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"}`, `markmap-view@${"0.15.0-alpha.0"}`];
|
|
252
|
-
function fillTemplate(root, assets, extra) {
|
|
253
|
-
var _extra, _extra$baseJs;
|
|
254
|
-
extra = _extends$1({}, extra);
|
|
255
|
-
(_extra$baseJs = (_extra = extra).baseJs) != null ? _extra$baseJs : _extra.baseJs = baseJsPaths.map(buildJSItem);
|
|
256
|
-
const {
|
|
257
|
-
scripts,
|
|
258
|
-
styles
|
|
259
|
-
} = assets;
|
|
260
|
-
const cssList = [...(styles ? persistCSS(styles) : [])];
|
|
261
|
-
const context = {
|
|
262
|
-
getMarkmap: () => window.markmap,
|
|
263
|
-
getOptions: extra.getOptions,
|
|
264
|
-
jsonOptions: extra.jsonOptions,
|
|
265
|
-
root
|
|
266
|
-
};
|
|
267
|
-
const jsList = [...persistJS([...extra.baseJs, ...(scripts || []), {
|
|
268
|
-
type: 'iife',
|
|
269
|
-
data: {
|
|
270
|
-
fn: (getMarkmap, getOptions, root, jsonOptions) => {
|
|
271
|
-
const markmap = getMarkmap();
|
|
272
|
-
window.mm = markmap.Markmap.create('svg#mindmap', (getOptions || markmap.deriveOptions)(jsonOptions), root);
|
|
273
|
-
},
|
|
274
|
-
getParams: ({
|
|
275
|
-
getMarkmap,
|
|
276
|
-
getOptions,
|
|
277
|
-
root,
|
|
278
|
-
jsonOptions
|
|
279
|
-
}) => {
|
|
280
|
-
return [getMarkmap, getOptions, root, jsonOptions];
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}], context)];
|
|
284
|
-
const html = template.replace('<!--CSS-->', () => cssList.join('')).replace('<!--JS-->', () => jsList.join(''));
|
|
285
|
-
return html;
|
|
286
|
-
}
|
|
287
25
|
|
|
288
26
|
// List of valid entities
|
|
289
27
|
//
|
|
@@ -7213,7 +6951,7 @@ var commonmarkConfig = {
|
|
|
7213
6951
|
* Preset configs
|
|
7214
6952
|
*/
|
|
7215
6953
|
|
|
7216
|
-
var config = {
|
|
6954
|
+
var config$2 = {
|
|
7217
6955
|
'default': defaultConfig,
|
|
7218
6956
|
'full': fullConfig,
|
|
7219
6957
|
'commonmark': commonmarkConfig
|
|
@@ -7261,7 +6999,7 @@ function Remarkable(preset, options) {
|
|
|
7261
6999
|
this.renderer = new Renderer();
|
|
7262
7000
|
this.ruler = new Ruler();
|
|
7263
7001
|
this.options = {};
|
|
7264
|
-
this.configure(config[preset]);
|
|
7002
|
+
this.configure(config$2[preset]);
|
|
7265
7003
|
this.set(options || {});
|
|
7266
7004
|
}
|
|
7267
7005
|
|
|
@@ -7545,40 +7283,39 @@ var remarkableKatex = rkatex;
|
|
|
7545
7283
|
|
|
7546
7284
|
var remarkableKatex$1 = /*@__PURE__*/getDefaultExportFromCjs(remarkableKatex);
|
|
7547
7285
|
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
|
|
7573
|
-
|
|
7574
|
-
|
|
7575
|
-
|
|
7576
|
-
}
|
|
7286
|
+
const name$3 = 'katex';
|
|
7287
|
+
const preloadScripts = [`katex@${"0.16.8"}/dist/katex.min.js`].map(path => markmapCommon.buildJSItem(path));
|
|
7288
|
+
const webfontloader = markmapCommon.buildJSItem(`webfontloader@${"1.6.28"}/webfontloader.js`);
|
|
7289
|
+
webfontloader.data.defer = true;
|
|
7290
|
+
const styles$1 = [`katex@${"0.16.8"}/dist/katex.min.css`].map(path => markmapCommon.buildCSSItem(path));
|
|
7291
|
+
const config$1 = {
|
|
7292
|
+
versions: {
|
|
7293
|
+
katex: "0.16.8" ,
|
|
7294
|
+
webfontloader: "1.6.28"
|
|
7295
|
+
},
|
|
7296
|
+
preloadScripts,
|
|
7297
|
+
scripts: [{
|
|
7298
|
+
type: 'iife',
|
|
7299
|
+
data: {
|
|
7300
|
+
fn: getMarkmap => {
|
|
7301
|
+
window.WebFontConfig = {
|
|
7302
|
+
custom: {
|
|
7303
|
+
families: ['KaTeX_AMS', 'KaTeX_Caligraphic:n4,n7', 'KaTeX_Fraktur:n4,n7', 'KaTeX_Main:n4,n7,i4,i7', 'KaTeX_Math:i4,i7', 'KaTeX_Script', 'KaTeX_SansSerif:n4,n7,i4', 'KaTeX_Size1', 'KaTeX_Size2', 'KaTeX_Size3', 'KaTeX_Size4', 'KaTeX_Typewriter']
|
|
7304
|
+
},
|
|
7305
|
+
active: () => {
|
|
7306
|
+
getMarkmap().refreshHook.call();
|
|
7307
|
+
}
|
|
7308
|
+
};
|
|
7309
|
+
},
|
|
7310
|
+
getParams({
|
|
7311
|
+
getMarkmap
|
|
7312
|
+
}) {
|
|
7313
|
+
return [getMarkmap];
|
|
7577
7314
|
}
|
|
7578
|
-
}
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
|
-
}
|
|
7315
|
+
}
|
|
7316
|
+
}, webfontloader],
|
|
7317
|
+
styles: styles$1
|
|
7318
|
+
};
|
|
7582
7319
|
|
|
7583
7320
|
/**
|
|
7584
7321
|
* Find NPM paths and resolve them to full URLs with the same package version as in this library.
|
|
@@ -7597,14 +7334,35 @@ function addDefaultVersions(paths, name, version) {
|
|
|
7597
7334
|
return path;
|
|
7598
7335
|
});
|
|
7599
7336
|
}
|
|
7337
|
+
function patchJSItem(transformer, item) {
|
|
7338
|
+
if (item.type === 'script' && item.data.src) {
|
|
7339
|
+
return _extends({}, item, {
|
|
7340
|
+
data: _extends({}, item.data, {
|
|
7341
|
+
src: transformer.urlBuilder.getFullUrl(item.data.src)
|
|
7342
|
+
})
|
|
7343
|
+
});
|
|
7344
|
+
}
|
|
7345
|
+
return item;
|
|
7346
|
+
}
|
|
7347
|
+
function patchCSSItem(transformer, item) {
|
|
7348
|
+
if (item.type === 'stylesheet' && item.data.href) {
|
|
7349
|
+
return _extends({}, item, {
|
|
7350
|
+
data: _extends({}, item.data, {
|
|
7351
|
+
href: transformer.urlBuilder.getFullUrl(item.data.href)
|
|
7352
|
+
})
|
|
7353
|
+
});
|
|
7354
|
+
}
|
|
7355
|
+
return item;
|
|
7356
|
+
}
|
|
7600
7357
|
|
|
7601
|
-
function createTransformHooks() {
|
|
7358
|
+
function createTransformHooks(transformer) {
|
|
7602
7359
|
return {
|
|
7603
|
-
|
|
7604
|
-
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
7360
|
+
transformer,
|
|
7361
|
+
parser: new markmapCommon.Hook(),
|
|
7362
|
+
beforeParse: new markmapCommon.Hook(),
|
|
7363
|
+
afterParse: new markmapCommon.Hook(),
|
|
7364
|
+
htmltag: new markmapCommon.Hook(),
|
|
7365
|
+
retransform: new markmapCommon.Hook()
|
|
7608
7366
|
};
|
|
7609
7367
|
}
|
|
7610
7368
|
|
|
@@ -7615,126 +7373,64 @@ function definePlugin(plugin) {
|
|
|
7615
7373
|
return plugin;
|
|
7616
7374
|
}
|
|
7617
7375
|
|
|
7618
|
-
const
|
|
7619
|
-
|
|
7620
|
-
|
|
7621
|
-
|
|
7622
|
-
config
|
|
7623
|
-
|
|
7624
|
-
|
|
7625
|
-
|
|
7626
|
-
|
|
7627
|
-
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
});
|
|
7638
|
-
}
|
|
7639
|
-
autoload().then(() => {
|
|
7640
|
-
transformHooks.retransform.call();
|
|
7376
|
+
const plugin$1 = definePlugin({
|
|
7377
|
+
name: name$3,
|
|
7378
|
+
config: config$1,
|
|
7379
|
+
transform(transformHooks) {
|
|
7380
|
+
var _plugin$config, _plugin$config3, _plugin$config4;
|
|
7381
|
+
let loading;
|
|
7382
|
+
const preloadScripts = ((_plugin$config = plugin$1.config) == null || (_plugin$config = _plugin$config.preloadScripts) == null ? void 0 : _plugin$config.map(item => patchJSItem(transformHooks.transformer, item))) || [];
|
|
7383
|
+
const autoload = () => {
|
|
7384
|
+
loading || (loading = markmapCommon.loadJS(preloadScripts));
|
|
7385
|
+
return loading;
|
|
7386
|
+
};
|
|
7387
|
+
const renderKatex = (source, displayMode) => {
|
|
7388
|
+
const {
|
|
7389
|
+
katex
|
|
7390
|
+
} = window;
|
|
7391
|
+
if (katex) {
|
|
7392
|
+
return katex.renderToString(source, {
|
|
7393
|
+
displayMode,
|
|
7394
|
+
throwOnError: false
|
|
7641
7395
|
});
|
|
7642
|
-
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
transformHooks.parser.tap(md => {
|
|
7646
|
-
md.use(remarkableKatex$1);
|
|
7647
|
-
md.renderer.rules.katex = (tokens, idx) => {
|
|
7648
|
-
enableFeature();
|
|
7649
|
-
const result = renderKatex(tokens[idx].content, tokens[idx].block);
|
|
7650
|
-
return result;
|
|
7651
|
-
};
|
|
7652
|
-
});
|
|
7653
|
-
transformHooks.beforeParse.tap((_, context) => {
|
|
7654
|
-
enableFeature = () => {
|
|
7655
|
-
context.features[name$3] = true;
|
|
7656
|
-
};
|
|
7657
|
-
});
|
|
7658
|
-
transformHooks.afterParse.tap((_, context) => {
|
|
7659
|
-
const {
|
|
7660
|
-
frontmatter
|
|
7661
|
-
} = context;
|
|
7662
|
-
if (frontmatter != null && frontmatter.markmap) {
|
|
7663
|
-
['extraJs', 'extraCss'].forEach(key => {
|
|
7664
|
-
if (frontmatter.markmap[key]) {
|
|
7665
|
-
frontmatter.markmap[key] = addDefaultVersions(frontmatter.markmap[key], name$3, plugin.config.versions.katex);
|
|
7666
|
-
}
|
|
7667
|
-
});
|
|
7668
|
-
}
|
|
7396
|
+
}
|
|
7397
|
+
autoload().then(() => {
|
|
7398
|
+
transformHooks.retransform.call();
|
|
7669
7399
|
});
|
|
7670
|
-
return
|
|
7671
|
-
|
|
7672
|
-
|
|
7400
|
+
return source;
|
|
7401
|
+
};
|
|
7402
|
+
let enableFeature = markmapCommon.noop;
|
|
7403
|
+
transformHooks.parser.tap(md => {
|
|
7404
|
+
md.use(remarkableKatex$1);
|
|
7405
|
+
md.renderer.rules.katex = (tokens, idx) => {
|
|
7406
|
+
enableFeature();
|
|
7407
|
+
const result = renderKatex(tokens[idx].content, !!tokens[idx].block);
|
|
7408
|
+
return result;
|
|
7673
7409
|
};
|
|
7674
|
-
}
|
|
7675
|
-
|
|
7676
|
-
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
function getConfig() {
|
|
7680
|
-
const preloadScripts = [`prismjs@${"1.28.0"}/components/prism-core.min.js`, `prismjs@${"1.28.0"}/plugins/autoloader/prism-autoloader.min.js`].map(buildJSItem);
|
|
7681
|
-
const styles = [`prismjs@${"1.28.0"}/themes/prism.css`].map(buildCSSItem);
|
|
7682
|
-
return {
|
|
7683
|
-
versions: {
|
|
7684
|
-
prismjs: "1.28.0"
|
|
7685
|
-
},
|
|
7686
|
-
preloadScripts,
|
|
7687
|
-
styles
|
|
7688
|
-
};
|
|
7689
|
-
}
|
|
7690
|
-
|
|
7691
|
-
const name$2 = 'prism';
|
|
7692
|
-
var prism = definePlugin(() => {
|
|
7693
|
-
const plugin = {
|
|
7694
|
-
name: name$2,
|
|
7695
|
-
config: getConfig(),
|
|
7696
|
-
transform(transformHooks) {
|
|
7697
|
-
let loading;
|
|
7698
|
-
const autoload = () => {
|
|
7699
|
-
loading || (loading = loadJS(plugin.config.preloadScripts));
|
|
7700
|
-
return loading;
|
|
7410
|
+
});
|
|
7411
|
+
transformHooks.beforeParse.tap((_, context) => {
|
|
7412
|
+
enableFeature = () => {
|
|
7413
|
+
context.features[name$3] = true;
|
|
7701
7414
|
};
|
|
7702
|
-
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
|
|
7707
|
-
|
|
7708
|
-
|
|
7709
|
-
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
highlight: (str, lang) => {
|
|
7713
|
-
var _Prism$languages;
|
|
7714
|
-
enableFeature();
|
|
7715
|
-
const {
|
|
7716
|
-
Prism
|
|
7717
|
-
} = window;
|
|
7718
|
-
const grammar = Prism == null || (_Prism$languages = Prism.languages) == null ? void 0 : _Prism$languages[lang];
|
|
7719
|
-
if (!grammar) {
|
|
7720
|
-
loadLanguageAndRefresh(lang, transformHooks);
|
|
7721
|
-
return '';
|
|
7722
|
-
}
|
|
7723
|
-
return Prism.highlight(str, grammar, lang);
|
|
7415
|
+
});
|
|
7416
|
+
transformHooks.afterParse.tap((_, context) => {
|
|
7417
|
+
var _context$frontmatter;
|
|
7418
|
+
const markmap = (_context$frontmatter = context.frontmatter) == null ? void 0 : _context$frontmatter.markmap;
|
|
7419
|
+
if (markmap) {
|
|
7420
|
+
['extraJs', 'extraCss'].forEach(key => {
|
|
7421
|
+
const value = markmap[key];
|
|
7422
|
+
if (value) {
|
|
7423
|
+
var _plugin$config2;
|
|
7424
|
+
markmap[key] = addDefaultVersions(value, name$3, ((_plugin$config2 = plugin$1.config) == null || (_plugin$config2 = _plugin$config2.versions) == null ? void 0 : _plugin$config2.katex) || '');
|
|
7724
7425
|
}
|
|
7725
7426
|
});
|
|
7726
|
-
}
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
|
|
7732
|
-
|
|
7733
|
-
styles: plugin.config.styles
|
|
7734
|
-
};
|
|
7735
|
-
}
|
|
7736
|
-
};
|
|
7737
|
-
return plugin;
|
|
7427
|
+
}
|
|
7428
|
+
});
|
|
7429
|
+
return {
|
|
7430
|
+
styles: (_plugin$config3 = plugin$1.config) == null ? void 0 : _plugin$config3.styles,
|
|
7431
|
+
scripts: (_plugin$config4 = plugin$1.config) == null ? void 0 : _plugin$config4.scripts
|
|
7432
|
+
};
|
|
7433
|
+
}
|
|
7738
7434
|
});
|
|
7739
7435
|
|
|
7740
7436
|
/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */
|
|
@@ -10848,9 +10544,9 @@ var jsYaml = {
|
|
|
10848
10544
|
safeDump: safeDump
|
|
10849
10545
|
};
|
|
10850
10546
|
|
|
10851
|
-
const name$
|
|
10547
|
+
const name$2 = 'frontmatter';
|
|
10852
10548
|
var frontmatter = definePlugin({
|
|
10853
|
-
name: name$
|
|
10549
|
+
name: name$2,
|
|
10854
10550
|
transform(transformHooks) {
|
|
10855
10551
|
transformHooks.beforeParse.tap((md, context) => {
|
|
10856
10552
|
const {
|
|
@@ -10898,20 +10594,22 @@ function normalizeNumber(value) {
|
|
|
10898
10594
|
return +value;
|
|
10899
10595
|
}
|
|
10900
10596
|
|
|
10901
|
-
const name = 'npmUrl';
|
|
10597
|
+
const name$1 = 'npmUrl';
|
|
10902
10598
|
var npmUrl = definePlugin({
|
|
10903
|
-
name,
|
|
10599
|
+
name: name$1,
|
|
10904
10600
|
transform(transformHooks) {
|
|
10905
10601
|
transformHooks.afterParse.tap((_, context) => {
|
|
10906
10602
|
const {
|
|
10907
10603
|
frontmatter
|
|
10908
10604
|
} = context;
|
|
10909
|
-
|
|
10605
|
+
const markmap = frontmatter == null ? void 0 : frontmatter.markmap;
|
|
10606
|
+
if (markmap) {
|
|
10910
10607
|
['extraJs', 'extraCss'].forEach(key => {
|
|
10911
|
-
|
|
10912
|
-
|
|
10608
|
+
const value = markmap[key];
|
|
10609
|
+
if (value) {
|
|
10610
|
+
markmap[key] = value.map(path => {
|
|
10913
10611
|
if (path.startsWith('npm:')) {
|
|
10914
|
-
return getFullUrl(path.slice(4));
|
|
10612
|
+
return transformHooks.transformer.urlBuilder.getFullUrl(path.slice(4));
|
|
10915
10613
|
}
|
|
10916
10614
|
return path;
|
|
10917
10615
|
});
|
|
@@ -10923,7 +10621,40 @@ var npmUrl = definePlugin({
|
|
|
10923
10621
|
}
|
|
10924
10622
|
});
|
|
10925
10623
|
|
|
10926
|
-
const
|
|
10624
|
+
const name = 'hljs';
|
|
10625
|
+
const styles = [`highlight.js@${"11.8.0"}/styles/default.css`].map(path => markmapCommon.buildCSSItem(path));
|
|
10626
|
+
const config = {
|
|
10627
|
+
versions: {
|
|
10628
|
+
hljs: "11.8.0"
|
|
10629
|
+
},
|
|
10630
|
+
styles
|
|
10631
|
+
};
|
|
10632
|
+
const plugin = definePlugin({
|
|
10633
|
+
name,
|
|
10634
|
+
config,
|
|
10635
|
+
transform(transformHooks) {
|
|
10636
|
+
var _plugin$config;
|
|
10637
|
+
let enableFeature = markmapCommon.noop;
|
|
10638
|
+
transformHooks.parser.tap(md => {
|
|
10639
|
+
md.set({
|
|
10640
|
+
highlight: (str, language) => {
|
|
10641
|
+
enableFeature();
|
|
10642
|
+
return hljs.highlightAuto(str, language ? [language] : undefined).value;
|
|
10643
|
+
}
|
|
10644
|
+
});
|
|
10645
|
+
});
|
|
10646
|
+
transformHooks.beforeParse.tap((_, context) => {
|
|
10647
|
+
enableFeature = () => {
|
|
10648
|
+
context.features[name] = true;
|
|
10649
|
+
};
|
|
10650
|
+
});
|
|
10651
|
+
return {
|
|
10652
|
+
styles: (_plugin$config = plugin.config) == null ? void 0 : _plugin$config.styles
|
|
10653
|
+
};
|
|
10654
|
+
}
|
|
10655
|
+
});
|
|
10656
|
+
|
|
10657
|
+
const plugins = [frontmatter, plugin$1, plugin, npmUrl];
|
|
10927
10658
|
|
|
10928
10659
|
function cleanNode(node) {
|
|
10929
10660
|
if (node.type === 'heading') {
|
|
@@ -10936,7 +10667,7 @@ function cleanNode(node) {
|
|
|
10936
10667
|
if (['paragraph', 'fence'].includes(item.type)) {
|
|
10937
10668
|
if (!node.content) {
|
|
10938
10669
|
node.content = item.content;
|
|
10939
|
-
node.payload = _extends
|
|
10670
|
+
node.payload = _extends({}, node.payload, item.payload);
|
|
10940
10671
|
}
|
|
10941
10672
|
return false;
|
|
10942
10673
|
}
|
|
@@ -10950,16 +10681,14 @@ function cleanNode(node) {
|
|
|
10950
10681
|
let index = (_node$payload$startIn = (_node$payload2 = node.payload) == null ? void 0 : _node$payload2.startIndex) != null ? _node$payload$startIn : 1;
|
|
10951
10682
|
node.children.forEach(item => {
|
|
10952
10683
|
if (item.type === 'list_item') {
|
|
10953
|
-
item.payload = _extends
|
|
10684
|
+
item.payload = _extends({}, item.payload, {
|
|
10954
10685
|
index
|
|
10955
10686
|
});
|
|
10956
10687
|
index += 1;
|
|
10957
10688
|
}
|
|
10958
10689
|
});
|
|
10959
10690
|
}
|
|
10960
|
-
if (node.children.length
|
|
10961
|
-
delete node.children;
|
|
10962
|
-
} else {
|
|
10691
|
+
if (node.children.length > 0) {
|
|
10963
10692
|
node.children.forEach(child => cleanNode(child));
|
|
10964
10693
|
if (node.children.length === 1 && !node.children[0].content) {
|
|
10965
10694
|
node.children = node.children[0].children;
|
|
@@ -10967,16 +10696,16 @@ function cleanNode(node) {
|
|
|
10967
10696
|
}
|
|
10968
10697
|
}
|
|
10969
10698
|
function resetDepth(node, depth = 0) {
|
|
10970
|
-
var _node$children;
|
|
10971
10699
|
node.depth = depth;
|
|
10972
|
-
|
|
10700
|
+
node.children.forEach(child => {
|
|
10973
10701
|
resetDepth(child, depth + 1);
|
|
10974
10702
|
});
|
|
10975
10703
|
}
|
|
10976
10704
|
class Transformer {
|
|
10977
10705
|
constructor(plugins$1 = plugins) {
|
|
10978
10706
|
this.assetsMap = {};
|
|
10979
|
-
this.
|
|
10707
|
+
this.urlBuilder = new markmapCommon.UrlBuilder();
|
|
10708
|
+
this.hooks = createTransformHooks(this);
|
|
10980
10709
|
this.plugins = plugins$1.map(plugin => typeof plugin === 'function' ? plugin() : plugin);
|
|
10981
10710
|
const assetsMap = {};
|
|
10982
10711
|
for (const {
|
|
@@ -10991,7 +10720,7 @@ class Transformer {
|
|
|
10991
10720
|
breaks: true,
|
|
10992
10721
|
maxNesting: Infinity
|
|
10993
10722
|
});
|
|
10994
|
-
md.renderer.rules.htmltag = wrapFunction(md.renderer.rules.htmltag, (render, ...args) => {
|
|
10723
|
+
md.renderer.rules.htmltag = markmapCommon.wrapFunction(md.renderer.rules.htmltag, (render, ...args) => {
|
|
10995
10724
|
const result = render(...args);
|
|
10996
10725
|
this.hooks.htmltag.call({
|
|
10997
10726
|
args,
|
|
@@ -11016,13 +10745,13 @@ class Transformer {
|
|
|
11016
10745
|
const stack = [root];
|
|
11017
10746
|
let depth = 0;
|
|
11018
10747
|
for (const token of tokens) {
|
|
10748
|
+
const payload = {};
|
|
10749
|
+
if (token.lines) {
|
|
10750
|
+
payload.lines = token.lines;
|
|
10751
|
+
}
|
|
11019
10752
|
let current = stack[stack.length - 1];
|
|
11020
10753
|
if (token.type.endsWith('_open')) {
|
|
11021
10754
|
const type = token.type.slice(0, -5);
|
|
11022
|
-
const payload = {};
|
|
11023
|
-
if (token.lines) {
|
|
11024
|
-
payload.lines = token.lines;
|
|
11025
|
-
}
|
|
11026
10755
|
if (type === 'heading') {
|
|
11027
10756
|
depth = token.hLevel;
|
|
11028
10757
|
while (((_current = current) == null ? void 0 : _current.depth) >= depth) {
|
|
@@ -11057,10 +10786,13 @@ class Transformer {
|
|
|
11057
10786
|
}
|
|
11058
10787
|
} else if (token.type === 'inline') {
|
|
11059
10788
|
const revoke = this.hooks.htmltag.tap(ctx => {
|
|
11060
|
-
|
|
10789
|
+
var _ctx$result;
|
|
10790
|
+
const comment = (_ctx$result = ctx.result) == null ? void 0 : _ctx$result.match(/^<!--([\s\S]*?)-->$/);
|
|
11061
10791
|
const data = comment == null ? void 0 : comment[1].trim().split(' ');
|
|
11062
|
-
if (data[0] === 'fold') {
|
|
11063
|
-
current.payload
|
|
10792
|
+
if ((data == null ? void 0 : data[0]) === 'fold') {
|
|
10793
|
+
current.payload = _extends({}, current.payload, {
|
|
10794
|
+
fold: ['all', 'recursively'].includes(data[1]) ? 2 : 1
|
|
10795
|
+
});
|
|
11064
10796
|
ctx.result = '';
|
|
11065
10797
|
}
|
|
11066
10798
|
});
|
|
@@ -11068,15 +10800,13 @@ class Transformer {
|
|
|
11068
10800
|
revoke();
|
|
11069
10801
|
current.content = `${current.content || ''}${text}`;
|
|
11070
10802
|
} else if (token.type === 'fence') {
|
|
11071
|
-
|
|
11072
|
-
// Remarkable only adds className to `<code>` but not `<pre>`, copy it to make PrismJS style work.
|
|
11073
|
-
const matches = result.match(/<code( class="[^"]*")>/);
|
|
11074
|
-
if (matches) result = result.replace('<pre>', `<pre${matches[1]}>`);
|
|
10803
|
+
const result = md.renderer.render([token], md.options, {});
|
|
11075
10804
|
current.children.push({
|
|
11076
10805
|
type: token.type,
|
|
11077
10806
|
depth: depth + 1,
|
|
11078
10807
|
content: result,
|
|
11079
|
-
children: []
|
|
10808
|
+
children: [],
|
|
10809
|
+
payload
|
|
11080
10810
|
});
|
|
11081
10811
|
} else ;
|
|
11082
10812
|
}
|
|
@@ -11096,7 +10826,7 @@ class Transformer {
|
|
|
11096
10826
|
cleanNode(root);
|
|
11097
10827
|
if (((_root$children = root.children) == null ? void 0 : _root$children.length) === 1) root = root.children[0];
|
|
11098
10828
|
resetDepth(root);
|
|
11099
|
-
return _extends
|
|
10829
|
+
return _extends({}, context, {
|
|
11100
10830
|
root
|
|
11101
10831
|
});
|
|
11102
10832
|
}
|
|
@@ -11116,8 +10846,8 @@ class Transformer {
|
|
|
11116
10846
|
}
|
|
11117
10847
|
}
|
|
11118
10848
|
return {
|
|
11119
|
-
styles,
|
|
11120
|
-
scripts
|
|
10849
|
+
styles: styles.map(item => patchCSSItem(this, item)),
|
|
10850
|
+
scripts: scripts.map(item => patchJSItem(this, item))
|
|
11121
10851
|
};
|
|
11122
10852
|
}
|
|
11123
10853
|
|
|
@@ -11128,17 +10858,52 @@ class Transformer {
|
|
|
11128
10858
|
const keys = this.plugins.map(plugin => plugin.name).filter(name => features[name]);
|
|
11129
10859
|
return this.getAssets(keys);
|
|
11130
10860
|
}
|
|
10861
|
+
fillTemplate(root, assets, extra) {
|
|
10862
|
+
var _extra, _extra$baseJs;
|
|
10863
|
+
extra = _extends({}, extra);
|
|
10864
|
+
(_extra$baseJs = (_extra = extra).baseJs) != null ? _extra$baseJs : _extra.baseJs = baseJsPaths.map(path => this.urlBuilder.getFullUrl(path)).map(path => markmapCommon.buildJSItem(path));
|
|
10865
|
+
const {
|
|
10866
|
+
scripts,
|
|
10867
|
+
styles
|
|
10868
|
+
} = assets;
|
|
10869
|
+
const cssList = [...(styles ? markmapCommon.persistCSS(styles) : [])];
|
|
10870
|
+
const context = {
|
|
10871
|
+
getMarkmap: () => window.markmap,
|
|
10872
|
+
getOptions: extra.getOptions,
|
|
10873
|
+
jsonOptions: extra.jsonOptions,
|
|
10874
|
+
root
|
|
10875
|
+
};
|
|
10876
|
+
const jsList = [...markmapCommon.persistJS([...extra.baseJs, ...(scripts || []), {
|
|
10877
|
+
type: 'iife',
|
|
10878
|
+
data: {
|
|
10879
|
+
fn: (getMarkmap, getOptions, root, jsonOptions) => {
|
|
10880
|
+
const markmap = getMarkmap();
|
|
10881
|
+
window.mm = markmap.Markmap.create('svg#mindmap', (getOptions || markmap.deriveOptions)(jsonOptions), root);
|
|
10882
|
+
},
|
|
10883
|
+
getParams: ({
|
|
10884
|
+
getMarkmap,
|
|
10885
|
+
getOptions,
|
|
10886
|
+
root,
|
|
10887
|
+
jsonOptions
|
|
10888
|
+
}) => {
|
|
10889
|
+
return [getMarkmap, getOptions, root, jsonOptions];
|
|
10890
|
+
}
|
|
10891
|
+
}
|
|
10892
|
+
}], context)];
|
|
10893
|
+
const html = template.replace('<!--CSS-->', () => cssList.join('')).replace('<!--JS-->', () => jsList.join(''));
|
|
10894
|
+
return html;
|
|
10895
|
+
}
|
|
11131
10896
|
}
|
|
11132
10897
|
|
|
11133
10898
|
const transformerVersions = {
|
|
11134
|
-
'markmap-lib': '0.15.0
|
|
11135
|
-
d3: "
|
|
10899
|
+
'markmap-lib': '0.15.0',
|
|
10900
|
+
d3: "7.8.5"
|
|
11136
10901
|
};
|
|
11137
10902
|
|
|
11138
10903
|
exports.Transformer = Transformer;
|
|
11139
10904
|
exports.baseJsPaths = baseJsPaths;
|
|
11140
10905
|
exports.builtInPlugins = plugins;
|
|
11141
|
-
exports.
|
|
10906
|
+
exports.template = template;
|
|
11142
10907
|
exports.transformerVersions = transformerVersions;
|
|
11143
10908
|
|
|
11144
10909
|
}));
|