markmap-lib 0.14.5-alpha.19 → 0.14.5-alpha.22
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 +206 -587
- package/dist/browser/index.mjs +225 -10987
- package/dist/index.js +158 -158
- package/dist/index.mjs +158 -158
- package/package.json +5 -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 -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 +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.22+04afb38 | 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
|
-
import Prism from 'prismjs';
|
|
7
|
-
import loadLanguages from 'prismjs/components/index.js';
|
|
8
6
|
import yaml from 'js-yaml';
|
|
7
|
+
import hljs from 'highlight.js';
|
|
9
8
|
|
|
10
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" ;
|
|
11
|
-
const baseJsPaths = [`d3@${"7.8.5"}/dist/d3.min.js`, `markmap-view@${"0.14.5-alpha.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
root
|
|
26
|
-
};
|
|
27
|
-
const jsList = [...persistJS([...extra.baseJs, ...(scripts || []), {
|
|
10
|
+
const baseJsPaths = [`d3@${"7.8.5"}/dist/d3.min.js`, `markmap-view@${"0.14.5-alpha.22"}/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: [{
|
|
28
24
|
type: 'iife',
|
|
29
25
|
data: {
|
|
30
|
-
fn:
|
|
31
|
-
|
|
32
|
-
|
|
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
|
+
};
|
|
33
35
|
},
|
|
34
|
-
getParams
|
|
35
|
-
getMarkmap
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
jsonOptions
|
|
39
|
-
}) => {
|
|
40
|
-
return [getMarkmap, getOptions, root, jsonOptions];
|
|
36
|
+
getParams({
|
|
37
|
+
getMarkmap
|
|
38
|
+
}) {
|
|
39
|
+
return [getMarkmap];
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
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,85 +61,34 @@ function definePlugin(plugin) {
|
|
|
97
61
|
return plugin;
|
|
98
62
|
}
|
|
99
63
|
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
config
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return render(...args);
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
transformHooks.beforeParse.tap((_, context) => {
|
|
115
|
-
enableFeature = () => {
|
|
116
|
-
context.features[name$3] = true;
|
|
117
|
-
};
|
|
118
|
-
});
|
|
119
|
-
return {
|
|
120
|
-
styles: plugin.config.styles,
|
|
121
|
-
scripts: plugin.config.scripts
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
return plugin;
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
function getConfig() {
|
|
129
|
-
const preloadScripts = [`prismjs@${"1.29.0"}/components/prism-core.min.js`, `prismjs@${"1.29.0"}/plugins/autoloader/prism-autoloader.min.js`].map(path => buildJSItem(path));
|
|
130
|
-
const styles = [`prismjs@${"1.29.0"}/themes/prism.css`].map(path => buildCSSItem(path));
|
|
131
|
-
return {
|
|
132
|
-
versions: {
|
|
133
|
-
prismjs: "1.29.0"
|
|
134
|
-
},
|
|
135
|
-
preloadScripts,
|
|
136
|
-
styles
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const name$2 = 'prism';
|
|
141
|
-
var prism = definePlugin(() => {
|
|
142
|
-
const plugin = {
|
|
143
|
-
name: name$2,
|
|
144
|
-
config: getConfig(),
|
|
145
|
-
transform(transformHooks) {
|
|
146
|
-
let enableFeature = noop;
|
|
147
|
-
transformHooks.parser.tap(md => {
|
|
148
|
-
md.set({
|
|
149
|
-
highlight: (str, lang) => {
|
|
150
|
-
enableFeature();
|
|
151
|
-
let grammar = Prism.languages[lang];
|
|
152
|
-
if (!grammar && lang) {
|
|
153
|
-
loadLanguages([lang]);
|
|
154
|
-
grammar = Prism.languages[lang];
|
|
155
|
-
}
|
|
156
|
-
if (grammar) {
|
|
157
|
-
return Prism.highlight(str, grammar, lang);
|
|
158
|
-
}
|
|
159
|
-
return '';
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
transformHooks.beforeParse.tap((_, context) => {
|
|
164
|
-
enableFeature = () => {
|
|
165
|
-
context.features[name$2] = true;
|
|
166
|
-
};
|
|
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);
|
|
167
75
|
});
|
|
168
|
-
|
|
169
|
-
|
|
76
|
+
});
|
|
77
|
+
transformHooks.beforeParse.tap((_, context) => {
|
|
78
|
+
enableFeature = () => {
|
|
79
|
+
context.features[name$3] = true;
|
|
170
80
|
};
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
|
|
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
|
+
}
|
|
174
87
|
});
|
|
175
88
|
|
|
176
|
-
const name$
|
|
89
|
+
const name$2 = 'frontmatter';
|
|
177
90
|
var frontmatter = definePlugin({
|
|
178
|
-
name: name$
|
|
91
|
+
name: name$2,
|
|
179
92
|
transform(transformHooks) {
|
|
180
93
|
transformHooks.beforeParse.tap((md, context) => {
|
|
181
94
|
const {
|
|
@@ -223,9 +136,9 @@ function normalizeNumber(value) {
|
|
|
223
136
|
return +value;
|
|
224
137
|
}
|
|
225
138
|
|
|
226
|
-
const name = 'npmUrl';
|
|
139
|
+
const name$1 = 'npmUrl';
|
|
227
140
|
var npmUrl = definePlugin({
|
|
228
|
-
name,
|
|
141
|
+
name: name$1,
|
|
229
142
|
transform(transformHooks) {
|
|
230
143
|
transformHooks.afterParse.tap((_, context) => {
|
|
231
144
|
const {
|
|
@@ -238,7 +151,7 @@ var npmUrl = definePlugin({
|
|
|
238
151
|
if (value) {
|
|
239
152
|
markmap[key] = value.map(path => {
|
|
240
153
|
if (path.startsWith('npm:')) {
|
|
241
|
-
return getFullUrl(path.slice(4));
|
|
154
|
+
return transformHooks.transformer.urlBuilder.getFullUrl(path.slice(4));
|
|
242
155
|
}
|
|
243
156
|
return path;
|
|
244
157
|
});
|
|
@@ -250,7 +163,61 @@ var npmUrl = definePlugin({
|
|
|
250
163
|
}
|
|
251
164
|
});
|
|
252
165
|
|
|
253
|
-
const
|
|
166
|
+
const name = 'hljs';
|
|
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
|
+
}
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
transformHooks.beforeParse.tap((_, context) => {
|
|
189
|
+
enableFeature = () => {
|
|
190
|
+
context.features[name] = true;
|
|
191
|
+
};
|
|
192
|
+
});
|
|
193
|
+
return {
|
|
194
|
+
styles: (_plugin$config = plugin.config) == null ? void 0 : _plugin$config.styles
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
|
|
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
|
+
}
|
|
254
221
|
|
|
255
222
|
function cleanNode(node) {
|
|
256
223
|
if (node.type === 'heading') {
|
|
@@ -300,7 +267,8 @@ function resetDepth(node, depth = 0) {
|
|
|
300
267
|
class Transformer {
|
|
301
268
|
constructor(plugins$1 = plugins) {
|
|
302
269
|
this.assetsMap = {};
|
|
303
|
-
this.
|
|
270
|
+
this.urlBuilder = new UrlBuilder();
|
|
271
|
+
this.hooks = createTransformHooks(this);
|
|
304
272
|
this.plugins = plugins$1.map(plugin => typeof plugin === 'function' ? plugin() : plugin);
|
|
305
273
|
const assetsMap = {};
|
|
306
274
|
for (const {
|
|
@@ -395,10 +363,7 @@ class Transformer {
|
|
|
395
363
|
revoke();
|
|
396
364
|
current.content = `${current.content || ''}${text}`;
|
|
397
365
|
} else if (token.type === 'fence') {
|
|
398
|
-
|
|
399
|
-
// Remarkable only adds className to `<code>` but not `<pre>`, copy it to make PrismJS style work.
|
|
400
|
-
const matches = result.match(/<code( class="[^"]*")>/);
|
|
401
|
-
if (matches) result = result.replace('<pre>', `<pre${matches[1]}>`);
|
|
366
|
+
const result = md.renderer.render([token], md.options, {});
|
|
402
367
|
current.children.push({
|
|
403
368
|
type: token.type,
|
|
404
369
|
depth: depth + 1,
|
|
@@ -444,8 +409,8 @@ class Transformer {
|
|
|
444
409
|
}
|
|
445
410
|
}
|
|
446
411
|
return {
|
|
447
|
-
styles,
|
|
448
|
-
scripts
|
|
412
|
+
styles: styles.map(item => patchCSSItem(this, item)),
|
|
413
|
+
scripts: scripts.map(item => patchJSItem(this, item))
|
|
449
414
|
};
|
|
450
415
|
}
|
|
451
416
|
|
|
@@ -456,11 +421,46 @@ class Transformer {
|
|
|
456
421
|
const keys = this.plugins.map(plugin => plugin.name).filter(name => features[name]);
|
|
457
422
|
return this.getAssets(keys);
|
|
458
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
|
+
}
|
|
459
459
|
}
|
|
460
460
|
|
|
461
461
|
const transformerVersions = {
|
|
462
|
-
'markmap-lib': '0.14.5-alpha.
|
|
462
|
+
'markmap-lib': '0.14.5-alpha.22+04afb38',
|
|
463
463
|
d3: "7.8.5"
|
|
464
464
|
};
|
|
465
465
|
|
|
466
|
-
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.22+04afb38",
|
|
4
4
|
"description": "Visualize your Markdown as mindmaps with Markmap",
|
|
5
5
|
"author": "Gerald <gera2ld@live.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,12 +47,13 @@
|
|
|
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.22+04afb38",
|
|
51
|
+
"markmap-view": "0.14.5-alpha.22+04afb38",
|
|
52
52
|
"webfontloader": "^1.6.28"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@babel/runtime": "^7.22.6",
|
|
56
|
+
"highlight.js": "^11.8.0",
|
|
56
57
|
"js-yaml": "^4.1.0",
|
|
57
58
|
"katex": "^0.16.8",
|
|
58
59
|
"prismjs": "^1.29.0",
|
|
@@ -62,5 +63,5 @@
|
|
|
62
63
|
"peerDependencies": {
|
|
63
64
|
"markmap-common": "*"
|
|
64
65
|
},
|
|
65
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "04afb38dd0a6f3b5e8eaffde3c29e9e38b215c35"
|
|
66
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/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;
|