markmap-lib 0.14.5-alpha.21 → 0.14.5-alpha.24
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 +186 -170
- package/dist/browser/index.mjs +181 -165
- package/dist/index.js +148 -133
- package/dist/index.mjs +148 -133
- package/package.json +4 -4
- package/types/constants.d.ts +2 -0
- package/types/index.d.ts +1 -1
- package/types/plugins/base.d.ts +3 -3
- package/types/plugins/frontmatter.d.ts +1 -1
- package/types/plugins/hljs.d.ts +2 -2
- package/types/plugins/index.d.ts +1 -1
- package/types/plugins/katex.browser.d.ts +2 -2
- package/types/plugins/katex.config.d.ts +1 -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 +1 -1
- package/types/plugins/prism.d.ts +2 -2
- package/types/plugins/util.d.ts +4 -0
- package/types/transform.d.ts +9 -3
- package/types/types.d.ts +5 -1
- package/types/template.d.ts +0 -8
package/dist/index.mjs
CHANGED
|
@@ -1,87 +1,51 @@
|
|
|
1
|
-
/*! markmap-lib v0.14.5-alpha.
|
|
1
|
+
/*! markmap-lib v0.14.5-alpha.24+08dd40c | MIT License */
|
|
2
2
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
3
|
-
import { buildJSItem, persistCSS, persistJS, buildCSSItem, Hook, wrapFunction, noop, getFullUrl } from 'markmap-common';
|
|
4
3
|
import { Remarkable } from 'remarkable';
|
|
4
|
+
import { buildJSItem, buildCSSItem, Hook, wrapFunction, noop, UrlBuilder, persistCSS, persistJS } from 'markmap-common';
|
|
5
5
|
import remarkableKatex from 'remarkable-katex';
|
|
6
6
|
import yaml from 'js-yaml';
|
|
7
|
-
import hljs
|
|
7
|
+
import hljs from 'highlight.js';
|
|
8
8
|
|
|
9
9
|
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" ;
|
|
10
|
-
const baseJsPaths = [`d3@${"7.8.5"}/dist/d3.min.js`, `markmap-view@${"0.14.5-alpha.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
root
|
|
25
|
-
};
|
|
26
|
-
const jsList = [...persistJS([...extra.baseJs, ...(scripts || []), {
|
|
10
|
+
const baseJsPaths = [`d3@${"7.8.5"}/dist/d3.min.js`, `markmap-view@${"0.14.5-alpha.24"}/dist/browser/index.js`];
|
|
11
|
+
|
|
12
|
+
const name$3 = 'katex';
|
|
13
|
+
const preloadScripts = [`katex@${"0.16.8"}/dist/katex.min.js`].map(path => buildJSItem(path));
|
|
14
|
+
const webfontloader = buildJSItem(`webfontloader@${"1.6.28"}/webfontloader.js`);
|
|
15
|
+
webfontloader.data.defer = true;
|
|
16
|
+
const styles$1 = [`katex@${"0.16.8"}/dist/katex.min.css`].map(path => buildCSSItem(path));
|
|
17
|
+
const config$1 = {
|
|
18
|
+
versions: {
|
|
19
|
+
katex: "0.16.8" ,
|
|
20
|
+
webfontloader: "1.6.28"
|
|
21
|
+
},
|
|
22
|
+
preloadScripts,
|
|
23
|
+
scripts: [{
|
|
27
24
|
type: 'iife',
|
|
28
25
|
data: {
|
|
29
|
-
fn:
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
fn: getMarkmap => {
|
|
27
|
+
window.WebFontConfig = {
|
|
28
|
+
custom: {
|
|
29
|
+
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']
|
|
30
|
+
},
|
|
31
|
+
active: () => {
|
|
32
|
+
getMarkmap().refreshHook.call();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
32
35
|
},
|
|
33
|
-
getParams
|
|
34
|
-
getMarkmap
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
jsonOptions
|
|
38
|
-
}) => {
|
|
39
|
-
return [getMarkmap, getOptions, root, jsonOptions];
|
|
36
|
+
getParams({
|
|
37
|
+
getMarkmap
|
|
38
|
+
}) {
|
|
39
|
+
return [getMarkmap];
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const name$3 = 'katex';
|
|
48
|
-
function getConfig$1() {
|
|
49
|
-
const preloadScripts = [`katex@${"0.16.8"}/dist/katex.min.js`].map(path => buildJSItem(path));
|
|
50
|
-
const webfontloader = buildJSItem(`webfontloader@${"1.6.28"}/webfontloader.js`);
|
|
51
|
-
webfontloader.data.defer = true;
|
|
52
|
-
const styles = [`katex@${"0.16.8"}/dist/katex.min.css`].map(path => buildCSSItem(path));
|
|
53
|
-
return {
|
|
54
|
-
versions: {
|
|
55
|
-
katex: "0.16.8" ,
|
|
56
|
-
webfontloader: "1.6.28"
|
|
57
|
-
},
|
|
58
|
-
preloadScripts,
|
|
59
|
-
scripts: [{
|
|
60
|
-
type: 'iife',
|
|
61
|
-
data: {
|
|
62
|
-
fn: getMarkmap => {
|
|
63
|
-
window.WebFontConfig = {
|
|
64
|
-
custom: {
|
|
65
|
-
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']
|
|
66
|
-
},
|
|
67
|
-
active: () => {
|
|
68
|
-
getMarkmap().refreshHook.call();
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
},
|
|
72
|
-
getParams({
|
|
73
|
-
getMarkmap
|
|
74
|
-
}) {
|
|
75
|
-
return [getMarkmap];
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}, webfontloader],
|
|
79
|
-
styles
|
|
80
|
-
};
|
|
81
|
-
}
|
|
42
|
+
}, webfontloader],
|
|
43
|
+
styles: styles$1
|
|
44
|
+
};
|
|
82
45
|
|
|
83
|
-
function createTransformHooks() {
|
|
46
|
+
function createTransformHooks(transformer) {
|
|
84
47
|
return {
|
|
48
|
+
transformer,
|
|
85
49
|
parser: new Hook(),
|
|
86
50
|
beforeParse: new Hook(),
|
|
87
51
|
afterParse: new Hook(),
|
|
@@ -97,31 +61,29 @@ function definePlugin(plugin) {
|
|
|
97
61
|
return plugin;
|
|
98
62
|
}
|
|
99
63
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
transformHooks.beforeParse.tap((_, context) => {
|
|
114
|
-
enableFeature = () => {
|
|
115
|
-
context.features[name$3] = true;
|
|
116
|
-
};
|
|
64
|
+
const plugin$1 = definePlugin({
|
|
65
|
+
name: name$3,
|
|
66
|
+
config: config$1,
|
|
67
|
+
transform(transformHooks) {
|
|
68
|
+
var _plugin$config, _plugin$config2;
|
|
69
|
+
let enableFeature = noop;
|
|
70
|
+
transformHooks.parser.tap(md => {
|
|
71
|
+
md.use(remarkableKatex);
|
|
72
|
+
md.renderer.rules.katex = wrapFunction(md.renderer.rules.katex, (render, ...args) => {
|
|
73
|
+
enableFeature();
|
|
74
|
+
return render(...args);
|
|
117
75
|
});
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
76
|
+
});
|
|
77
|
+
transformHooks.beforeParse.tap((_, context) => {
|
|
78
|
+
enableFeature = () => {
|
|
79
|
+
context.features[name$3] = true;
|
|
121
80
|
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
styles: (_plugin$config = plugin$1.config) == null ? void 0 : _plugin$config.styles,
|
|
84
|
+
scripts: (_plugin$config2 = plugin$1.config) == null ? void 0 : _plugin$config2.scripts
|
|
85
|
+
};
|
|
86
|
+
}
|
|
125
87
|
});
|
|
126
88
|
|
|
127
89
|
const name$2 = 'frontmatter';
|
|
@@ -189,7 +151,7 @@ var npmUrl = definePlugin({
|
|
|
189
151
|
if (value) {
|
|
190
152
|
markmap[key] = value.map(path => {
|
|
191
153
|
if (path.startsWith('npm:')) {
|
|
192
|
-
return getFullUrl(path.slice(4));
|
|
154
|
+
return transformHooks.transformer.urlBuilder.getFullUrl(path.slice(4));
|
|
193
155
|
}
|
|
194
156
|
return path;
|
|
195
157
|
});
|
|
@@ -202,43 +164,60 @@ var npmUrl = definePlugin({
|
|
|
202
164
|
});
|
|
203
165
|
|
|
204
166
|
const name = 'hljs';
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
return hljs$1.highlightAuto(str, language ? [language] : undefined).value;
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
transformHooks.beforeParse.tap((_, context) => {
|
|
229
|
-
enableFeature = () => {
|
|
230
|
-
context.features[name] = true;
|
|
231
|
-
};
|
|
167
|
+
const styles = [`highlight.js@${"11.8.0"}/styles/default.css`].map(path => buildCSSItem(path));
|
|
168
|
+
const config = {
|
|
169
|
+
versions: {
|
|
170
|
+
hljs: "11.8.0"
|
|
171
|
+
},
|
|
172
|
+
styles
|
|
173
|
+
};
|
|
174
|
+
const plugin = definePlugin({
|
|
175
|
+
name,
|
|
176
|
+
config,
|
|
177
|
+
transform(transformHooks) {
|
|
178
|
+
var _plugin$config;
|
|
179
|
+
let enableFeature = noop;
|
|
180
|
+
transformHooks.parser.tap(md => {
|
|
181
|
+
md.set({
|
|
182
|
+
highlight: (str, language) => {
|
|
183
|
+
enableFeature();
|
|
184
|
+
return hljs.highlightAuto(str, language ? [language] : undefined).value;
|
|
185
|
+
}
|
|
232
186
|
});
|
|
233
|
-
|
|
234
|
-
|
|
187
|
+
});
|
|
188
|
+
transformHooks.beforeParse.tap((_, context) => {
|
|
189
|
+
enableFeature = () => {
|
|
190
|
+
context.features[name] = true;
|
|
235
191
|
};
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
192
|
+
});
|
|
193
|
+
return {
|
|
194
|
+
styles: (_plugin$config = plugin.config) == null ? void 0 : _plugin$config.styles
|
|
195
|
+
};
|
|
196
|
+
}
|
|
239
197
|
});
|
|
240
198
|
|
|
241
|
-
const plugins = [frontmatter,
|
|
199
|
+
const plugins = [frontmatter, plugin$1, plugin, npmUrl];
|
|
200
|
+
|
|
201
|
+
function patchJSItem(transformer, item) {
|
|
202
|
+
if (item.type === 'script' && item.data.src) {
|
|
203
|
+
return _extends({}, item, {
|
|
204
|
+
data: _extends({}, item.data, {
|
|
205
|
+
src: transformer.urlBuilder.getFullUrl(item.data.src)
|
|
206
|
+
})
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
return item;
|
|
210
|
+
}
|
|
211
|
+
function patchCSSItem(transformer, item) {
|
|
212
|
+
if (item.type === 'stylesheet' && item.data.href) {
|
|
213
|
+
return _extends({}, item, {
|
|
214
|
+
data: _extends({}, item.data, {
|
|
215
|
+
href: transformer.urlBuilder.getFullUrl(item.data.href)
|
|
216
|
+
})
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
return item;
|
|
220
|
+
}
|
|
242
221
|
|
|
243
222
|
function cleanNode(node) {
|
|
244
223
|
if (node.type === 'heading') {
|
|
@@ -288,7 +267,8 @@ function resetDepth(node, depth = 0) {
|
|
|
288
267
|
class Transformer {
|
|
289
268
|
constructor(plugins$1 = plugins) {
|
|
290
269
|
this.assetsMap = {};
|
|
291
|
-
this.
|
|
270
|
+
this.urlBuilder = new UrlBuilder();
|
|
271
|
+
this.hooks = createTransformHooks(this);
|
|
292
272
|
this.plugins = plugins$1.map(plugin => typeof plugin === 'function' ? plugin() : plugin);
|
|
293
273
|
const assetsMap = {};
|
|
294
274
|
for (const {
|
|
@@ -429,8 +409,8 @@ class Transformer {
|
|
|
429
409
|
}
|
|
430
410
|
}
|
|
431
411
|
return {
|
|
432
|
-
styles,
|
|
433
|
-
scripts
|
|
412
|
+
styles: styles.map(item => patchCSSItem(this, item)),
|
|
413
|
+
scripts: scripts.map(item => patchJSItem(this, item))
|
|
434
414
|
};
|
|
435
415
|
}
|
|
436
416
|
|
|
@@ -441,11 +421,46 @@ class Transformer {
|
|
|
441
421
|
const keys = this.plugins.map(plugin => plugin.name).filter(name => features[name]);
|
|
442
422
|
return this.getAssets(keys);
|
|
443
423
|
}
|
|
424
|
+
fillTemplate(root, assets, extra) {
|
|
425
|
+
var _extra, _extra$baseJs;
|
|
426
|
+
extra = _extends({}, extra);
|
|
427
|
+
(_extra$baseJs = (_extra = extra).baseJs) != null ? _extra$baseJs : _extra.baseJs = baseJsPaths.map(path => this.urlBuilder.getFullUrl(path)).map(path => buildJSItem(path));
|
|
428
|
+
const {
|
|
429
|
+
scripts,
|
|
430
|
+
styles
|
|
431
|
+
} = assets;
|
|
432
|
+
const cssList = [...(styles ? persistCSS(styles) : [])];
|
|
433
|
+
const context = {
|
|
434
|
+
getMarkmap: () => window.markmap,
|
|
435
|
+
getOptions: extra.getOptions,
|
|
436
|
+
jsonOptions: extra.jsonOptions,
|
|
437
|
+
root
|
|
438
|
+
};
|
|
439
|
+
const jsList = [...persistJS([...extra.baseJs, ...(scripts || []), {
|
|
440
|
+
type: 'iife',
|
|
441
|
+
data: {
|
|
442
|
+
fn: (getMarkmap, getOptions, root, jsonOptions) => {
|
|
443
|
+
const markmap = getMarkmap();
|
|
444
|
+
window.mm = markmap.Markmap.create('svg#mindmap', (getOptions || markmap.deriveOptions)(jsonOptions), root);
|
|
445
|
+
},
|
|
446
|
+
getParams: ({
|
|
447
|
+
getMarkmap,
|
|
448
|
+
getOptions,
|
|
449
|
+
root,
|
|
450
|
+
jsonOptions
|
|
451
|
+
}) => {
|
|
452
|
+
return [getMarkmap, getOptions, root, jsonOptions];
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}], context)];
|
|
456
|
+
const html = template.replace('<!--CSS-->', () => cssList.join('')).replace('<!--JS-->', () => jsList.join(''));
|
|
457
|
+
return html;
|
|
458
|
+
}
|
|
444
459
|
}
|
|
445
460
|
|
|
446
461
|
const transformerVersions = {
|
|
447
|
-
'markmap-lib': '0.14.5-alpha.
|
|
462
|
+
'markmap-lib': '0.14.5-alpha.24+08dd40c',
|
|
448
463
|
d3: "7.8.5"
|
|
449
464
|
};
|
|
450
465
|
|
|
451
|
-
export { Transformer, baseJsPaths, plugins as builtInPlugins,
|
|
466
|
+
export { Transformer, baseJsPaths, plugins as builtInPlugins, template, transformerVersions };
|
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.24+08dd40c",
|
|
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.5-alpha.
|
|
51
|
-
"markmap-view": "0.14.5-alpha.
|
|
50
|
+
"markmap-common": "0.14.5-alpha.24+08dd40c",
|
|
51
|
+
"markmap-view": "0.14.5-alpha.24+08dd40c",
|
|
52
52
|
"webfontloader": "^1.6.28"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"markmap-common": "*"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "08dd40c9353058928a148f6b97d11e98ec1d328b"
|
|
67
67
|
}
|
package/types/index.d.ts
CHANGED
package/types/plugins/base.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ITransformHooks, ITransformPlugin } from '../types';
|
|
2
|
-
export declare function createTransformHooks(): ITransformHooks;
|
|
1
|
+
import { ITransformer, ITransformHooks, ITransformPlugin } from '../types';
|
|
2
|
+
export declare function createTransformHooks(transformer: ITransformer): ITransformHooks;
|
|
3
3
|
/**
|
|
4
4
|
* This function is only used to help type checking.
|
|
5
5
|
*/
|
|
6
|
-
export declare function definePlugin(plugin: ITransformPlugin
|
|
6
|
+
export declare function definePlugin(plugin: ITransformPlugin): ITransformPlugin;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("../types").ITransformPlugin
|
|
1
|
+
declare const _default: import("../types").ITransformPlugin;
|
|
2
2
|
export default _default;
|
package/types/plugins/hljs.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
export default
|
|
1
|
+
declare const plugin: import("../types").ITransformPlugin;
|
|
2
|
+
export default plugin;
|
package/types/plugins/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './base';
|
|
2
|
-
export declare const plugins:
|
|
2
|
+
export declare const plugins: import("..").ITransformPlugin[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
export default
|
|
1
|
+
declare const plugin: import("../types").ITransformPlugin;
|
|
2
|
+
export default plugin;
|
package/types/plugins/katex.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
export default
|
|
1
|
+
declare const plugin: import("../types").ITransformPlugin;
|
|
2
|
+
export default plugin;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("../types").ITransformPlugin
|
|
1
|
+
declare const _default: import("../types").ITransformPlugin;
|
|
2
2
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
export default
|
|
1
|
+
declare const plugin: import("../types").ITransformPlugin;
|
|
2
|
+
export default plugin;
|
package/types/plugins/prism.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
export default
|
|
1
|
+
declare const plugin: import("../types").ITransformPlugin;
|
|
2
|
+
export default plugin;
|
package/types/plugins/util.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { CSSItem, JSItem } from 'markmap-common';
|
|
2
|
+
import { ITransformer } from '../types';
|
|
1
3
|
/**
|
|
2
4
|
* Find NPM paths and resolve them to full URLs with the same package version as in this library.
|
|
3
5
|
*/
|
|
4
6
|
export declare function addDefaultVersions(paths: string[], name: string, version: string): string[];
|
|
7
|
+
export declare function patchJSItem(transformer: ITransformer, item: JSItem): JSItem;
|
|
8
|
+
export declare function patchCSSItem(transformer: ITransformer, item: CSSItem): CSSItem;
|
package/types/transform.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Remarkable } from 'remarkable';
|
|
2
|
-
import { IPureNode } from 'markmap-common';
|
|
3
|
-
import { ITransformResult, ITransformPlugin, IAssets, ITransformHooks, IFeatures } from './types';
|
|
2
|
+
import { UrlBuilder, JSItem, IMarkmapOptions, IMarkmapJSONOptions, IPureNode } from 'markmap-common';
|
|
3
|
+
import { ITransformResult, ITransformPlugin, IAssets, ITransformHooks, IFeatures, ITransformer } from './types';
|
|
4
4
|
import { plugins as builtInPlugins } from './plugins';
|
|
5
5
|
export { builtInPlugins };
|
|
6
|
-
export declare class Transformer {
|
|
6
|
+
export declare class Transformer implements ITransformer {
|
|
7
7
|
hooks: ITransformHooks;
|
|
8
8
|
md: Remarkable;
|
|
9
9
|
assetsMap: Record<string, IAssets>;
|
|
10
|
+
urlBuilder: UrlBuilder;
|
|
10
11
|
plugins: ITransformPlugin[];
|
|
11
12
|
constructor(plugins?: Array<ITransformPlugin | (() => ITransformPlugin)>);
|
|
12
13
|
buildTree(tokens: Remarkable.Token[]): IPureNode;
|
|
@@ -19,4 +20,9 @@ export declare class Transformer {
|
|
|
19
20
|
* Get used assets by features object returned by `transform`.
|
|
20
21
|
*/
|
|
21
22
|
getUsedAssets(features: IFeatures): IAssets;
|
|
23
|
+
fillTemplate(root: IPureNode | null, assets: IAssets, extra?: {
|
|
24
|
+
baseJs?: JSItem[];
|
|
25
|
+
jsonOptions?: IMarkmapJSONOptions;
|
|
26
|
+
getOptions?: (jsonOptions: IMarkmapJSONOptions) => Partial<IMarkmapOptions>;
|
|
27
|
+
}): string;
|
|
22
28
|
}
|
package/types/types.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Remarkable } from 'remarkable';
|
|
2
|
-
import { CSSItem, JSItem, IPureNode, IWrapContext, Hook, IMarkmapJSONOptions } from 'markmap-common';
|
|
2
|
+
import { UrlBuilder, CSSItem, JSItem, IPureNode, IWrapContext, Hook, IMarkmapJSONOptions } from 'markmap-common';
|
|
3
3
|
type Htmltag = Remarkable.Rule<Remarkable.HtmlTagToken, string>;
|
|
4
4
|
export interface ITransformHooks {
|
|
5
|
+
transformer: ITransformer;
|
|
5
6
|
/**
|
|
6
7
|
* Tapped once when the parser is created.
|
|
7
8
|
*/
|
|
@@ -41,6 +42,9 @@ export interface IMarkmapCreateOptions {
|
|
|
41
42
|
export interface IFeatures {
|
|
42
43
|
[key: string]: boolean;
|
|
43
44
|
}
|
|
45
|
+
export interface ITransformer {
|
|
46
|
+
urlBuilder: UrlBuilder;
|
|
47
|
+
}
|
|
44
48
|
export interface ITransformContext {
|
|
45
49
|
features: IFeatures;
|
|
46
50
|
content: string;
|
package/types/template.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { JSItem, IMarkmapOptions, IMarkmapJSONOptions, IPureNode } from 'markmap-common';
|
|
2
|
-
import { IAssets } from './types';
|
|
3
|
-
export declare const baseJsPaths: string[];
|
|
4
|
-
export declare function fillTemplate(root: IPureNode | null, assets: IAssets, extra?: {
|
|
5
|
-
baseJs?: JSItem[];
|
|
6
|
-
jsonOptions?: IMarkmapJSONOptions;
|
|
7
|
-
getOptions?: (jsonOptions: IMarkmapJSONOptions) => Partial<IMarkmapOptions>;
|
|
8
|
-
}): string;
|