markmap-lib 0.13.5-alpha.0 → 0.13.6-alpha.3
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 +77 -6
- package/dist/browser/index.min.js +3 -3
- package/dist/index.esm.js +52 -7
- package/dist/index.js +52 -6
- package/package.json +11 -4
- package/types/index.d.ts +4 -0
- package/types/plugins/katex.config.d.ts +4 -0
- package/types/plugins/prism.config.d.ts +3 -0
- package/types/plugins/util.d.ts +4 -0
- package/types/types.d.ts +4 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! markmap-lib v0.13.
|
|
1
|
+
/*! markmap-lib v0.13.6-alpha.3+3e26a91 | MIT License */
|
|
2
2
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
3
3
|
import { persistCSS, persistJS, wrapFunction, Hook } from 'markmap-common';
|
|
4
4
|
import { Remarkable } from 'remarkable';
|
|
@@ -8,7 +8,7 @@ import loadLanguages from 'prismjs/components/';
|
|
|
8
8
|
import yaml from 'js-yaml';
|
|
9
9
|
|
|
10
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 BASE_JS = [`https://cdn.jsdelivr.net/npm/d3@${"6.7.0"}`, `https://cdn.jsdelivr.net/npm/markmap-view@${"0.13.5
|
|
11
|
+
const BASE_JS = [`https://cdn.jsdelivr.net/npm/d3@${"6.7.0"}`, `https://cdn.jsdelivr.net/npm/markmap-view@${"0.13.5"}`].map(src => ({
|
|
12
12
|
type: 'script',
|
|
13
13
|
data: {
|
|
14
14
|
src
|
|
@@ -51,6 +51,10 @@ function fillTemplate(root, assets, extra) {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
var config$1 = {
|
|
54
|
+
versions: {
|
|
55
|
+
katex: "0.15.3",
|
|
56
|
+
webfontloader: "1.6.28"
|
|
57
|
+
},
|
|
54
58
|
preloadScripts: [{
|
|
55
59
|
type: 'script',
|
|
56
60
|
data: {
|
|
@@ -124,6 +128,9 @@ transform: transform$2
|
|
|
124
128
|
});
|
|
125
129
|
|
|
126
130
|
var config = {
|
|
131
|
+
versions: {
|
|
132
|
+
prismjs: "1.28.0"
|
|
133
|
+
},
|
|
127
134
|
preloadScripts: [{
|
|
128
135
|
type: 'script',
|
|
129
136
|
data: {
|
|
@@ -194,13 +201,21 @@ function transform(transformHooks) {
|
|
|
194
201
|
const endOffset = content.indexOf('\n---\n');
|
|
195
202
|
if (endOffset < 0) return;
|
|
196
203
|
const raw = content.slice(4, endOffset);
|
|
204
|
+
let frontmatter;
|
|
197
205
|
|
|
198
206
|
try {
|
|
199
|
-
|
|
207
|
+
var _frontmatter;
|
|
208
|
+
|
|
209
|
+
frontmatter = yaml.load(raw);
|
|
210
|
+
|
|
211
|
+
if ((_frontmatter = frontmatter) != null && _frontmatter.markmap) {
|
|
212
|
+
frontmatter.markmap = normalizeMarkmapJsonOptions(frontmatter.markmap);
|
|
213
|
+
}
|
|
200
214
|
} catch (_unused) {
|
|
201
215
|
return;
|
|
202
216
|
}
|
|
203
217
|
|
|
218
|
+
context.frontmatter = frontmatter;
|
|
204
219
|
const offset = endOffset + 5;
|
|
205
220
|
ctx.args[0] = content.slice(offset);
|
|
206
221
|
},
|
|
@@ -214,6 +229,30 @@ function transform(transformHooks) {
|
|
|
214
229
|
return {};
|
|
215
230
|
}
|
|
216
231
|
|
|
232
|
+
function normalizeMarkmapJsonOptions(options) {
|
|
233
|
+
if (!options) return;
|
|
234
|
+
['color', 'extraJs', 'extraCss'].forEach(key => {
|
|
235
|
+
if (options[key] != null) options[key] = normalizeStringArray(options[key]);
|
|
236
|
+
});
|
|
237
|
+
['duration', 'maxWidth', 'initialExpandLevel'].forEach(key => {
|
|
238
|
+
if (options[key] != null) options[key] = normalizeNumber(options[key]);
|
|
239
|
+
});
|
|
240
|
+
return options;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function normalizeStringArray(value) {
|
|
244
|
+
var _result;
|
|
245
|
+
|
|
246
|
+
let result;
|
|
247
|
+
if (typeof value === 'string') result = [value];else if (Array.isArray(value)) result = value.filter(item => item && typeof item === 'string');
|
|
248
|
+
return (_result = result) != null && _result.length ? result : undefined;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function normalizeNumber(value) {
|
|
252
|
+
if (isNaN(+value)) return;
|
|
253
|
+
return +value;
|
|
254
|
+
}
|
|
255
|
+
|
|
217
256
|
var frontmatter = /*#__PURE__*/Object.freeze({
|
|
218
257
|
__proto__: null,
|
|
219
258
|
name: name,
|
|
@@ -229,7 +268,7 @@ function createTransformHooks() {
|
|
|
229
268
|
};
|
|
230
269
|
}
|
|
231
270
|
|
|
232
|
-
const plugins = [katex, prism
|
|
271
|
+
const plugins = [frontmatter, katex, prism];
|
|
233
272
|
|
|
234
273
|
function cleanNode(node) {
|
|
235
274
|
if (node.type === 'heading') {
|
|
@@ -435,7 +474,7 @@ class Transformer {
|
|
|
435
474
|
|
|
436
475
|
const styles = [];
|
|
437
476
|
const scripts = [];
|
|
438
|
-
(_keys = keys) != null ? _keys : keys =
|
|
477
|
+
(_keys = keys) != null ? _keys : keys = this.plugins.map(plugin => plugin.name);
|
|
439
478
|
|
|
440
479
|
for (const assets of keys.map(key => this.assetsMap[key])) {
|
|
441
480
|
if (assets) {
|
|
@@ -455,9 +494,15 @@ class Transformer {
|
|
|
455
494
|
|
|
456
495
|
|
|
457
496
|
getUsedAssets(features) {
|
|
458
|
-
|
|
497
|
+
const keys = this.plugins.map(plugin => plugin.name).filter(name => features[name]);
|
|
498
|
+
return this.getAssets(keys);
|
|
459
499
|
}
|
|
460
500
|
|
|
461
501
|
}
|
|
462
502
|
|
|
463
|
-
|
|
503
|
+
const transformerVersions = {
|
|
504
|
+
'markmap-lib': '0.13.6-alpha.3+3e26a91',
|
|
505
|
+
d3: "6.7.0"
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
export { Transformer, plugins as builtInPlugins, fillTemplate, transformerVersions };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! markmap-lib v0.13.
|
|
1
|
+
/*! markmap-lib v0.13.6-alpha.3+3e26a91 | MIT License */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
@@ -18,7 +18,7 @@ var loadLanguages__default = /*#__PURE__*/_interopDefaultLegacy(loadLanguages);
|
|
|
18
18
|
var yaml__default = /*#__PURE__*/_interopDefaultLegacy(yaml);
|
|
19
19
|
|
|
20
20
|
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";
|
|
21
|
-
const BASE_JS = [`https://cdn.jsdelivr.net/npm/d3@${"6.7.0"}`, `https://cdn.jsdelivr.net/npm/markmap-view@${"0.13.5
|
|
21
|
+
const BASE_JS = [`https://cdn.jsdelivr.net/npm/d3@${"6.7.0"}`, `https://cdn.jsdelivr.net/npm/markmap-view@${"0.13.5"}`].map(src => ({
|
|
22
22
|
type: 'script',
|
|
23
23
|
data: {
|
|
24
24
|
src
|
|
@@ -61,6 +61,10 @@ function fillTemplate(root, assets, extra) {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
var config$1 = {
|
|
64
|
+
versions: {
|
|
65
|
+
katex: "0.15.3",
|
|
66
|
+
webfontloader: "1.6.28"
|
|
67
|
+
},
|
|
64
68
|
preloadScripts: [{
|
|
65
69
|
type: 'script',
|
|
66
70
|
data: {
|
|
@@ -134,6 +138,9 @@ transform: transform$2
|
|
|
134
138
|
});
|
|
135
139
|
|
|
136
140
|
var config = {
|
|
141
|
+
versions: {
|
|
142
|
+
prismjs: "1.28.0"
|
|
143
|
+
},
|
|
137
144
|
preloadScripts: [{
|
|
138
145
|
type: 'script',
|
|
139
146
|
data: {
|
|
@@ -204,13 +211,21 @@ function transform(transformHooks) {
|
|
|
204
211
|
const endOffset = content.indexOf('\n---\n');
|
|
205
212
|
if (endOffset < 0) return;
|
|
206
213
|
const raw = content.slice(4, endOffset);
|
|
214
|
+
let frontmatter;
|
|
207
215
|
|
|
208
216
|
try {
|
|
209
|
-
|
|
217
|
+
var _frontmatter;
|
|
218
|
+
|
|
219
|
+
frontmatter = yaml__default.load(raw);
|
|
220
|
+
|
|
221
|
+
if ((_frontmatter = frontmatter) != null && _frontmatter.markmap) {
|
|
222
|
+
frontmatter.markmap = normalizeMarkmapJsonOptions(frontmatter.markmap);
|
|
223
|
+
}
|
|
210
224
|
} catch (_unused) {
|
|
211
225
|
return;
|
|
212
226
|
}
|
|
213
227
|
|
|
228
|
+
context.frontmatter = frontmatter;
|
|
214
229
|
const offset = endOffset + 5;
|
|
215
230
|
ctx.args[0] = content.slice(offset);
|
|
216
231
|
},
|
|
@@ -224,6 +239,30 @@ function transform(transformHooks) {
|
|
|
224
239
|
return {};
|
|
225
240
|
}
|
|
226
241
|
|
|
242
|
+
function normalizeMarkmapJsonOptions(options) {
|
|
243
|
+
if (!options) return;
|
|
244
|
+
['color', 'extraJs', 'extraCss'].forEach(key => {
|
|
245
|
+
if (options[key] != null) options[key] = normalizeStringArray(options[key]);
|
|
246
|
+
});
|
|
247
|
+
['duration', 'maxWidth', 'initialExpandLevel'].forEach(key => {
|
|
248
|
+
if (options[key] != null) options[key] = normalizeNumber(options[key]);
|
|
249
|
+
});
|
|
250
|
+
return options;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function normalizeStringArray(value) {
|
|
254
|
+
var _result;
|
|
255
|
+
|
|
256
|
+
let result;
|
|
257
|
+
if (typeof value === 'string') result = [value];else if (Array.isArray(value)) result = value.filter(item => item && typeof item === 'string');
|
|
258
|
+
return (_result = result) != null && _result.length ? result : undefined;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function normalizeNumber(value) {
|
|
262
|
+
if (isNaN(+value)) return;
|
|
263
|
+
return +value;
|
|
264
|
+
}
|
|
265
|
+
|
|
227
266
|
var frontmatter = /*#__PURE__*/Object.freeze({
|
|
228
267
|
__proto__: null,
|
|
229
268
|
name: name,
|
|
@@ -239,7 +278,7 @@ function createTransformHooks() {
|
|
|
239
278
|
};
|
|
240
279
|
}
|
|
241
280
|
|
|
242
|
-
const plugins = [katex, prism
|
|
281
|
+
const plugins = [frontmatter, katex, prism];
|
|
243
282
|
|
|
244
283
|
function cleanNode(node) {
|
|
245
284
|
if (node.type === 'heading') {
|
|
@@ -445,7 +484,7 @@ class Transformer {
|
|
|
445
484
|
|
|
446
485
|
const styles = [];
|
|
447
486
|
const scripts = [];
|
|
448
|
-
(_keys = keys) != null ? _keys : keys =
|
|
487
|
+
(_keys = keys) != null ? _keys : keys = this.plugins.map(plugin => plugin.name);
|
|
449
488
|
|
|
450
489
|
for (const assets of keys.map(key => this.assetsMap[key])) {
|
|
451
490
|
if (assets) {
|
|
@@ -465,11 +504,18 @@ class Transformer {
|
|
|
465
504
|
|
|
466
505
|
|
|
467
506
|
getUsedAssets(features) {
|
|
468
|
-
|
|
507
|
+
const keys = this.plugins.map(plugin => plugin.name).filter(name => features[name]);
|
|
508
|
+
return this.getAssets(keys);
|
|
469
509
|
}
|
|
470
510
|
|
|
471
511
|
}
|
|
472
512
|
|
|
513
|
+
const transformerVersions = {
|
|
514
|
+
'markmap-lib': '0.13.6-alpha.3+3e26a91',
|
|
515
|
+
d3: "6.7.0"
|
|
516
|
+
};
|
|
517
|
+
|
|
473
518
|
exports.Transformer = Transformer;
|
|
474
519
|
exports.builtInPlugins = plugins;
|
|
475
520
|
exports.fillTemplate = fillTemplate;
|
|
521
|
+
exports.transformerVersions = transformerVersions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markmap-lib",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.6-alpha.3+3e26a91",
|
|
4
4
|
"description": "Visualize your Markdown as mindmaps with Markmap",
|
|
5
5
|
"author": "Gerald <gera2ld@live.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,9 +19,16 @@
|
|
|
19
19
|
},
|
|
20
20
|
"main": "dist/index.js",
|
|
21
21
|
"module": "dist/index.esm.js",
|
|
22
|
-
"browser": "dist/browser/index.js",
|
|
23
22
|
"unpkg": "dist/browser/index.min.js",
|
|
24
23
|
"jsdelivr": "dist/browser/index.min.js",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"browser": "./dist/browser/index.js",
|
|
27
|
+
"require": "./dist/index.js",
|
|
28
|
+
"default": "./dist/index.esm.js"
|
|
29
|
+
},
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
25
32
|
"typings": "types/index.d.ts",
|
|
26
33
|
"files": [
|
|
27
34
|
"dist",
|
|
@@ -35,7 +42,7 @@
|
|
|
35
42
|
"repository": "git@github.com:gera2ld/markmap.git",
|
|
36
43
|
"devDependencies": {
|
|
37
44
|
"@types/remarkable": "^2.0.3",
|
|
38
|
-
"markmap-view": "^0.13.5
|
|
45
|
+
"markmap-view": "^0.13.5",
|
|
39
46
|
"webfontloader": "^1.6.28"
|
|
40
47
|
},
|
|
41
48
|
"dependencies": {
|
|
@@ -47,5 +54,5 @@
|
|
|
47
54
|
"remarkable": "^2.0.1",
|
|
48
55
|
"remarkable-katex": "^1.1.8"
|
|
49
56
|
},
|
|
50
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "3e26a917be187039277d215033fcd537915bb837"
|
|
51
58
|
}
|
package/types/index.d.ts
CHANGED
package/types/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Remarkable } from 'remarkable';
|
|
2
|
-
import { CSSItem, JSItem, INode, IWrapContext, Hook } from 'markmap-common';
|
|
2
|
+
import { CSSItem, JSItem, INode, IWrapContext, Hook, IMarkmapJSONOptions } from 'markmap-common';
|
|
3
3
|
declare type Htmltag = Remarkable.Rule<Remarkable.HtmlTagToken, string>;
|
|
4
4
|
export interface ITransformHooks {
|
|
5
5
|
/**
|
|
@@ -43,7 +43,9 @@ export interface IFeatures {
|
|
|
43
43
|
}
|
|
44
44
|
export interface ITransformContext {
|
|
45
45
|
features: IFeatures;
|
|
46
|
-
frontmatter?:
|
|
46
|
+
frontmatter?: {
|
|
47
|
+
markmap?: IMarkmapJSONOptions;
|
|
48
|
+
};
|
|
47
49
|
}
|
|
48
50
|
export interface ITransformResult extends ITransformContext {
|
|
49
51
|
root: INode;
|