markmap-lib 0.13.6-alpha.4 → 0.14.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 +25 -17
- package/dist/browser/index.min.js +4 -4
- package/dist/index.esm.js +46 -12
- package/dist/index.js +46 -12
- package/package.json +9 -9
- package/types/types.d.ts +7 -4
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! markmap-lib v0.
|
|
1
|
+
/*! markmap-lib v0.14.0 | MIT License */
|
|
2
2
|
import _extends$1 from '@babel/runtime/helpers/esm/extends';
|
|
3
3
|
import { Remarkable } from 'remarkable';
|
|
4
4
|
import remarkableKatex from 'remarkable-katex';
|
|
@@ -6,7 +6,7 @@ import Prism from 'prismjs';
|
|
|
6
6
|
import loadLanguages from 'prismjs/components/';
|
|
7
7
|
import yaml from 'js-yaml';
|
|
8
8
|
|
|
9
|
-
/*! markmap-common v0.
|
|
9
|
+
/*! markmap-common v0.14.0 | MIT License */
|
|
10
10
|
class Hook {
|
|
11
11
|
constructor() {
|
|
12
12
|
this.listeners = [];
|
|
@@ -175,7 +175,7 @@ function wrapFunction(fn, {
|
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
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";
|
|
178
|
-
const BASE_JS = [`https://cdn.jsdelivr.net/npm/d3@${"6.7.0"}`, `https://cdn.jsdelivr.net/npm/markmap-view@${"0.
|
|
178
|
+
const BASE_JS = [`https://cdn.jsdelivr.net/npm/d3@${"6.7.0"}`, `https://cdn.jsdelivr.net/npm/markmap-view@${"0.14.0"}`].map(src => ({
|
|
179
179
|
type: 'script',
|
|
180
180
|
data: {
|
|
181
181
|
src
|
|
@@ -219,13 +219,13 @@ function fillTemplate(root, assets, extra) {
|
|
|
219
219
|
|
|
220
220
|
var config$1 = {
|
|
221
221
|
versions: {
|
|
222
|
-
katex: "0.
|
|
222
|
+
katex: "0.16.0",
|
|
223
223
|
webfontloader: "1.6.28"
|
|
224
224
|
},
|
|
225
225
|
preloadScripts: [{
|
|
226
226
|
type: 'script',
|
|
227
227
|
data: {
|
|
228
|
-
src: `https://cdn.jsdelivr.net/npm/katex@${"0.
|
|
228
|
+
src: `https://cdn.jsdelivr.net/npm/katex@${"0.16.0"}/dist/katex.min.js`
|
|
229
229
|
}
|
|
230
230
|
}],
|
|
231
231
|
scripts: [{
|
|
@@ -259,11 +259,30 @@ var config$1 = {
|
|
|
259
259
|
styles: [{
|
|
260
260
|
type: 'stylesheet',
|
|
261
261
|
data: {
|
|
262
|
-
href: `https://cdn.jsdelivr.net/npm/katex@${"0.
|
|
262
|
+
href: `https://cdn.jsdelivr.net/npm/katex@${"0.16.0"}/dist/katex.min.css`
|
|
263
263
|
}
|
|
264
264
|
}]
|
|
265
265
|
};
|
|
266
266
|
|
|
267
|
+
const npmPrefix = 'https://cdn.jsdelivr.net/npm/';
|
|
268
|
+
/**
|
|
269
|
+
* Find NPM paths and resolve them to full URLs with the same package version as in this library.
|
|
270
|
+
*/
|
|
271
|
+
|
|
272
|
+
function resolveNpmPaths(paths, name, version) {
|
|
273
|
+
return paths.map(path => {
|
|
274
|
+
if (typeof path === 'string') {
|
|
275
|
+
if (path.startsWith(`${name}/`)) {
|
|
276
|
+
path = `${npmPrefix}${name}@${version}${path.slice(name.length)}`;
|
|
277
|
+
} else if (path.startsWith(`${name}@`)) {
|
|
278
|
+
path = `${npmPrefix}${path}`;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return path;
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
|
|
267
286
|
const name$2 = 'katex';
|
|
268
287
|
function transform$2(transformHooks) {
|
|
269
288
|
let enableFeature = () => {};
|
|
@@ -276,11 +295,24 @@ function transform$2(transformHooks) {
|
|
|
276
295
|
}
|
|
277
296
|
});
|
|
278
297
|
});
|
|
279
|
-
transformHooks.
|
|
298
|
+
transformHooks.beforeParse.tap((_, context) => {
|
|
280
299
|
enableFeature = () => {
|
|
281
300
|
context.features[name$2] = true;
|
|
282
301
|
};
|
|
283
302
|
});
|
|
303
|
+
transformHooks.afterParse.tap((_, context) => {
|
|
304
|
+
const {
|
|
305
|
+
frontmatter
|
|
306
|
+
} = context;
|
|
307
|
+
|
|
308
|
+
if (frontmatter != null && frontmatter.markmap) {
|
|
309
|
+
['extraJs', 'extraCss'].forEach(key => {
|
|
310
|
+
if (frontmatter.markmap[key]) {
|
|
311
|
+
frontmatter.markmap[key] = resolveNpmPaths(frontmatter.markmap[key], name$2, config$1.versions.katex);
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
});
|
|
284
316
|
return {
|
|
285
317
|
styles: config$1.styles,
|
|
286
318
|
scripts: config$1.scripts
|
|
@@ -340,7 +372,7 @@ function transform$1(transformHooks) {
|
|
|
340
372
|
}
|
|
341
373
|
});
|
|
342
374
|
});
|
|
343
|
-
transformHooks.
|
|
375
|
+
transformHooks.beforeParse.tap((_, context) => {
|
|
344
376
|
enableFeature = () => {
|
|
345
377
|
context.features[name$1] = true;
|
|
346
378
|
};
|
|
@@ -359,7 +391,7 @@ transform: transform$1
|
|
|
359
391
|
|
|
360
392
|
const name = 'frontmatter';
|
|
361
393
|
function transform(transformHooks) {
|
|
362
|
-
transformHooks.
|
|
394
|
+
transformHooks.beforeParse.tap((md, context) => {
|
|
363
395
|
const origParse = md.parse;
|
|
364
396
|
md.parse = wrapFunction(origParse, {
|
|
365
397
|
before(ctx) {
|
|
@@ -429,7 +461,8 @@ transform: transform
|
|
|
429
461
|
function createTransformHooks() {
|
|
430
462
|
return {
|
|
431
463
|
parser: new Hook(),
|
|
432
|
-
|
|
464
|
+
beforeParse: new Hook(),
|
|
465
|
+
afterParse: new Hook(),
|
|
433
466
|
htmltag: new Hook(),
|
|
434
467
|
retransform: new Hook()
|
|
435
468
|
};
|
|
@@ -621,8 +654,9 @@ class Transformer {
|
|
|
621
654
|
const context = {
|
|
622
655
|
features: {}
|
|
623
656
|
};
|
|
624
|
-
this.hooks.
|
|
657
|
+
this.hooks.beforeParse.call(this.md, context);
|
|
625
658
|
const tokens = this.md.parse(content, {});
|
|
659
|
+
this.hooks.afterParse.call(this.md, context);
|
|
626
660
|
let root = this.buildTree(tokens);
|
|
627
661
|
cleanNode(root);
|
|
628
662
|
if (((_root$children = root.children) == null ? void 0 : _root$children.length) === 1) root = root.children[0];
|
|
@@ -668,7 +702,7 @@ class Transformer {
|
|
|
668
702
|
}
|
|
669
703
|
|
|
670
704
|
const transformerVersions = {
|
|
671
|
-
'markmap-lib': '0.
|
|
705
|
+
'markmap-lib': '0.14.0',
|
|
672
706
|
d3: "6.7.0"
|
|
673
707
|
};
|
|
674
708
|
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! markmap-lib v0.
|
|
1
|
+
/*! markmap-lib v0.14.0 | MIT License */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var _extends$1 = require('@babel/runtime/helpers/extends');
|
|
@@ -16,7 +16,7 @@ var Prism__default = /*#__PURE__*/_interopDefaultLegacy(Prism);
|
|
|
16
16
|
var loadLanguages__default = /*#__PURE__*/_interopDefaultLegacy(loadLanguages);
|
|
17
17
|
var yaml__default = /*#__PURE__*/_interopDefaultLegacy(yaml);
|
|
18
18
|
|
|
19
|
-
/*! markmap-common v0.
|
|
19
|
+
/*! markmap-common v0.14.0 | MIT License */
|
|
20
20
|
class Hook {
|
|
21
21
|
constructor() {
|
|
22
22
|
this.listeners = [];
|
|
@@ -185,7 +185,7 @@ function wrapFunction(fn, {
|
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
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";
|
|
188
|
-
const BASE_JS = [`https://cdn.jsdelivr.net/npm/d3@${"6.7.0"}`, `https://cdn.jsdelivr.net/npm/markmap-view@${"0.
|
|
188
|
+
const BASE_JS = [`https://cdn.jsdelivr.net/npm/d3@${"6.7.0"}`, `https://cdn.jsdelivr.net/npm/markmap-view@${"0.14.0"}`].map(src => ({
|
|
189
189
|
type: 'script',
|
|
190
190
|
data: {
|
|
191
191
|
src
|
|
@@ -229,13 +229,13 @@ function fillTemplate(root, assets, extra) {
|
|
|
229
229
|
|
|
230
230
|
var config$1 = {
|
|
231
231
|
versions: {
|
|
232
|
-
katex: "0.
|
|
232
|
+
katex: "0.16.0",
|
|
233
233
|
webfontloader: "1.6.28"
|
|
234
234
|
},
|
|
235
235
|
preloadScripts: [{
|
|
236
236
|
type: 'script',
|
|
237
237
|
data: {
|
|
238
|
-
src: `https://cdn.jsdelivr.net/npm/katex@${"0.
|
|
238
|
+
src: `https://cdn.jsdelivr.net/npm/katex@${"0.16.0"}/dist/katex.min.js`
|
|
239
239
|
}
|
|
240
240
|
}],
|
|
241
241
|
scripts: [{
|
|
@@ -269,11 +269,30 @@ var config$1 = {
|
|
|
269
269
|
styles: [{
|
|
270
270
|
type: 'stylesheet',
|
|
271
271
|
data: {
|
|
272
|
-
href: `https://cdn.jsdelivr.net/npm/katex@${"0.
|
|
272
|
+
href: `https://cdn.jsdelivr.net/npm/katex@${"0.16.0"}/dist/katex.min.css`
|
|
273
273
|
}
|
|
274
274
|
}]
|
|
275
275
|
};
|
|
276
276
|
|
|
277
|
+
const npmPrefix = 'https://cdn.jsdelivr.net/npm/';
|
|
278
|
+
/**
|
|
279
|
+
* Find NPM paths and resolve them to full URLs with the same package version as in this library.
|
|
280
|
+
*/
|
|
281
|
+
|
|
282
|
+
function resolveNpmPaths(paths, name, version) {
|
|
283
|
+
return paths.map(path => {
|
|
284
|
+
if (typeof path === 'string') {
|
|
285
|
+
if (path.startsWith(`${name}/`)) {
|
|
286
|
+
path = `${npmPrefix}${name}@${version}${path.slice(name.length)}`;
|
|
287
|
+
} else if (path.startsWith(`${name}@`)) {
|
|
288
|
+
path = `${npmPrefix}${path}`;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
return path;
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
|
|
277
296
|
const name$2 = 'katex';
|
|
278
297
|
function transform$2(transformHooks) {
|
|
279
298
|
let enableFeature = () => {};
|
|
@@ -286,11 +305,24 @@ function transform$2(transformHooks) {
|
|
|
286
305
|
}
|
|
287
306
|
});
|
|
288
307
|
});
|
|
289
|
-
transformHooks.
|
|
308
|
+
transformHooks.beforeParse.tap((_, context) => {
|
|
290
309
|
enableFeature = () => {
|
|
291
310
|
context.features[name$2] = true;
|
|
292
311
|
};
|
|
293
312
|
});
|
|
313
|
+
transformHooks.afterParse.tap((_, context) => {
|
|
314
|
+
const {
|
|
315
|
+
frontmatter
|
|
316
|
+
} = context;
|
|
317
|
+
|
|
318
|
+
if (frontmatter != null && frontmatter.markmap) {
|
|
319
|
+
['extraJs', 'extraCss'].forEach(key => {
|
|
320
|
+
if (frontmatter.markmap[key]) {
|
|
321
|
+
frontmatter.markmap[key] = resolveNpmPaths(frontmatter.markmap[key], name$2, config$1.versions.katex);
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
});
|
|
294
326
|
return {
|
|
295
327
|
styles: config$1.styles,
|
|
296
328
|
scripts: config$1.scripts
|
|
@@ -350,7 +382,7 @@ function transform$1(transformHooks) {
|
|
|
350
382
|
}
|
|
351
383
|
});
|
|
352
384
|
});
|
|
353
|
-
transformHooks.
|
|
385
|
+
transformHooks.beforeParse.tap((_, context) => {
|
|
354
386
|
enableFeature = () => {
|
|
355
387
|
context.features[name$1] = true;
|
|
356
388
|
};
|
|
@@ -369,7 +401,7 @@ transform: transform$1
|
|
|
369
401
|
|
|
370
402
|
const name = 'frontmatter';
|
|
371
403
|
function transform(transformHooks) {
|
|
372
|
-
transformHooks.
|
|
404
|
+
transformHooks.beforeParse.tap((md, context) => {
|
|
373
405
|
const origParse = md.parse;
|
|
374
406
|
md.parse = wrapFunction(origParse, {
|
|
375
407
|
before(ctx) {
|
|
@@ -439,7 +471,8 @@ transform: transform
|
|
|
439
471
|
function createTransformHooks() {
|
|
440
472
|
return {
|
|
441
473
|
parser: new Hook(),
|
|
442
|
-
|
|
474
|
+
beforeParse: new Hook(),
|
|
475
|
+
afterParse: new Hook(),
|
|
443
476
|
htmltag: new Hook(),
|
|
444
477
|
retransform: new Hook()
|
|
445
478
|
};
|
|
@@ -631,8 +664,9 @@ class Transformer {
|
|
|
631
664
|
const context = {
|
|
632
665
|
features: {}
|
|
633
666
|
};
|
|
634
|
-
this.hooks.
|
|
667
|
+
this.hooks.beforeParse.call(this.md, context);
|
|
635
668
|
const tokens = this.md.parse(content, {});
|
|
669
|
+
this.hooks.afterParse.call(this.md, context);
|
|
636
670
|
let root = this.buildTree(tokens);
|
|
637
671
|
cleanNode(root);
|
|
638
672
|
if (((_root$children = root.children) == null ? void 0 : _root$children.length) === 1) root = root.children[0];
|
|
@@ -678,7 +712,7 @@ class Transformer {
|
|
|
678
712
|
}
|
|
679
713
|
|
|
680
714
|
const transformerVersions = {
|
|
681
|
-
'markmap-lib': '0.
|
|
715
|
+
'markmap-lib': '0.14.0',
|
|
682
716
|
d3: "6.7.0"
|
|
683
717
|
};
|
|
684
718
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markmap-lib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Visualize your Markdown as mindmaps with Markmap",
|
|
5
5
|
"author": "Gerald <gera2ld@live.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,20 +42,20 @@
|
|
|
42
42
|
"repository": "git@github.com:gera2ld/markmap.git",
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/remarkable": "^2.0.3",
|
|
45
|
-
"markmap-common": "^0.
|
|
46
|
-
"markmap-view": "^0.
|
|
45
|
+
"markmap-common": "^0.14.0",
|
|
46
|
+
"markmap-view": "^0.14.0",
|
|
47
47
|
"webfontloader": "^1.6.28"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@babel/runtime": "^7.
|
|
50
|
+
"@babel/runtime": "^7.18.9",
|
|
51
51
|
"js-yaml": "^4.1.0",
|
|
52
|
-
"katex": "^0.
|
|
53
|
-
"prismjs": "^1.
|
|
52
|
+
"katex": "^0.16.0",
|
|
53
|
+
"prismjs": "^1.28.0",
|
|
54
54
|
"remarkable": "^2.0.1",
|
|
55
|
-
"remarkable-katex": "^1.1
|
|
55
|
+
"remarkable-katex": "^1.2.1"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"markmap-common": "
|
|
58
|
+
"markmap-common": "*"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "2d6a50992256a2d2e4d945c2c075ddc42d6ccb0d"
|
|
61
61
|
}
|
package/types/types.d.ts
CHANGED
|
@@ -7,16 +7,19 @@ export interface ITransformHooks {
|
|
|
7
7
|
*/
|
|
8
8
|
parser: Hook<[md: Remarkable]>;
|
|
9
9
|
/**
|
|
10
|
-
* Tapped every time
|
|
10
|
+
* Tapped every time before Markdown content is parsed.
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
beforeParse: Hook<[md: Remarkable, context: ITransformContext]>;
|
|
13
|
+
/**
|
|
14
|
+
* Tapped every time after Markdown content is parsed.
|
|
15
|
+
*/
|
|
16
|
+
afterParse: Hook<[md: Remarkable, context: ITransformContext]>;
|
|
13
17
|
/**
|
|
14
18
|
* Tapped when Remarkable renders an HTML tag in Markdown.
|
|
15
19
|
*/
|
|
16
20
|
htmltag: Hook<[ctx: IWrapContext<Parameters<Htmltag>, ReturnType<Htmltag>>]>;
|
|
17
21
|
/**
|
|
18
|
-
*
|
|
19
|
-
* lack of resources and is called when it is ready for a new transformation.
|
|
22
|
+
* Used in autoloader to force rerender when resource is loaded.
|
|
20
23
|
*/
|
|
21
24
|
retransform: Hook<[]>;
|
|
22
25
|
}
|