markmap-lib 0.15.9-alpha.5 → 0.16.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.
Files changed (35) hide show
  1. package/dist/browser/index.iife.js +417 -482
  2. package/dist/browser/index.mjs +242 -248
  3. package/dist/index.d.ts +1 -3
  4. package/dist/index.js +17 -314
  5. package/dist/index.mjs +18 -315
  6. package/dist/index.no-plugins.js +136 -0
  7. package/dist/index.no-plugins.mjs +136 -0
  8. package/dist/plugins/checkbox/index.d.ts +2 -0
  9. package/dist/plugins/frontmatter/index.d.ts +2 -0
  10. package/dist/plugins/hljs/index.browser.d.ts +2 -0
  11. package/dist/plugins/hljs/index.d.ts +2 -0
  12. package/dist/plugins/index.d.ts +7 -0
  13. package/dist/plugins/katex/index.browser.d.ts +2 -0
  14. package/dist/plugins/katex/index.d.ts +2 -0
  15. package/dist/plugins/npm-url/index.d.ts +2 -0
  16. package/dist/plugins/prism/index.browser.d.ts +2 -0
  17. package/dist/plugins/prism/index.d.ts +2 -0
  18. package/dist/plugins/source-lines/index.d.ts +2 -0
  19. package/dist/plugins.js +307 -0
  20. package/dist/plugins.mjs +307 -0
  21. package/dist/transform.d.ts +3 -9
  22. package/package.json +23 -7
  23. package/dist/constants.d.ts +0 -4
  24. package/dist/plugins/checkbox.d.ts +0 -2
  25. package/dist/plugins/frontmatter.d.ts +0 -2
  26. package/dist/plugins/hljs.browser.d.ts +0 -2
  27. package/dist/plugins/hljs.d.ts +0 -2
  28. package/dist/plugins/katex.browser.d.ts +0 -2
  29. package/dist/plugins/katex.d.ts +0 -2
  30. package/dist/plugins/npm-url.d.ts +0 -2
  31. package/dist/plugins/prism.browser.d.ts +0 -2
  32. package/dist/plugins/prism.d.ts +0 -2
  33. /package/dist/plugins/{hljs.config.d.ts → hljs/config.d.ts} +0 -0
  34. /package/dist/plugins/{katex.config.d.ts → katex/config.d.ts} +0 -0
  35. /package/dist/plugins/{prism.config.d.ts → prism/config.d.ts} +0 -0
@@ -1,32 +1,209 @@
1
- import { buildJSItem, buildCSSItem, Hook, noop, loadJS, UrlBuilder, wrapFunction, persistCSS, persistJS } from "markmap-common";
1
+ import { Hook, buildJSItem, buildCSSItem, loadJS, noop, wrapFunction, UrlBuilder } from "markmap-common";
2
2
  import { buildTree } from "markmap-html-parser";
3
3
  import { Remarkable } from "remarkable";
4
- import remarkableKatex from "remarkable-katex";
5
4
  import yaml from "js-yaml";
6
- 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';
7
- const baseJsPaths = [
8
- `d3@${"7.8.5"}/dist/d3.min.js`,
9
- `markmap-view@${"0.15.9-alpha.5"}/dist/browser/index.js`
10
- ];
11
- const svg_marked = `<svg width="16" height="16" fill="currentColor" viewBox="0 -3 24 24"><path d="M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2m-9 14-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8z"/></svg>`;
12
- const svg_unmarked = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 -3 24 24"><path fill-rule="evenodd" d="M6 5a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1zM3 6a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v12a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3v-5z" clip-rule="evenodd"/></svg>`;
13
- const name$4 = "katex";
5
+ import remarkableKatex from "remarkable-katex";
6
+ function createTransformHooks(transformer) {
7
+ return {
8
+ transformer,
9
+ parser: new Hook(),
10
+ beforeParse: new Hook(),
11
+ afterParse: new Hook(),
12
+ htmltag: new Hook(),
13
+ retransform: new Hook()
14
+ };
15
+ }
16
+ function definePlugin(plugin2) {
17
+ return plugin2;
18
+ }
19
+ const svgMarked = '<svg width="16" height="16" viewBox="0 -3 24 24"><path d="M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2m-9 14-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8z"/></svg>\n';
20
+ const svgUnmarked = '<svg width="16" height="16" viewBox="0 -3 24 24"><path fill-rule="evenodd" d="M6 5a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1zM3 6a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v12a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3v-5z" clip-rule="evenodd"/></svg>\n';
21
+ const name$5 = "checkbox";
22
+ const images = {
23
+ " ": svgUnmarked.trim(),
24
+ x: svgMarked.trim()
25
+ };
26
+ const plugin$3 = definePlugin({
27
+ name: name$5,
28
+ transform(transformHooks) {
29
+ transformHooks.parser.tap((md) => {
30
+ md.core.ruler.before(
31
+ "inline",
32
+ "checkbox",
33
+ (state) => {
34
+ for (let i = 2; i < state.tokens.length; i += 1) {
35
+ const token = state.tokens[i];
36
+ if (token.type === "inline" && token.content) {
37
+ const prevType = state.tokens[i - 1].type;
38
+ const prevPrevType = state.tokens[i - 2].type;
39
+ if (prevType === "heading_open" || prevType === "paragraph_open" && prevPrevType === "list_item_open") {
40
+ token.content = token.content.replace(
41
+ /^\[(.)\] /,
42
+ (m, g) => images[g] ? `${images[g]} ` : m
43
+ );
44
+ }
45
+ }
46
+ }
47
+ return false;
48
+ },
49
+ {}
50
+ );
51
+ });
52
+ return {};
53
+ }
54
+ });
55
+ const pluginCheckbox = plugin$3;
56
+ const name$4 = "frontmatter";
57
+ const pluginFrontmatter = definePlugin({
58
+ name: name$4,
59
+ transform(transformHooks) {
60
+ transformHooks.beforeParse.tap((md, context) => {
61
+ const { content } = context;
62
+ if (!/^---\r?\n/.test(content))
63
+ return;
64
+ const match = /\n---\r?\n/.exec(content);
65
+ if (!match)
66
+ return;
67
+ const raw = content.slice(4, match.index);
68
+ let frontmatter;
69
+ try {
70
+ frontmatter = yaml.load(raw);
71
+ if (frontmatter == null ? void 0 : frontmatter.markmap) {
72
+ frontmatter.markmap = normalizeMarkmapJsonOptions(
73
+ frontmatter.markmap
74
+ );
75
+ }
76
+ } catch {
77
+ return;
78
+ }
79
+ context.frontmatter = frontmatter;
80
+ context.content = content.slice(match.index + match[0].length);
81
+ context.contentLineOffset = content.slice(0, match.index).split("\n").length + 1;
82
+ });
83
+ return {};
84
+ }
85
+ });
86
+ function normalizeMarkmapJsonOptions(options) {
87
+ if (!options)
88
+ return;
89
+ ["color", "extraJs", "extraCss"].forEach((key) => {
90
+ if (options[key] != null)
91
+ options[key] = normalizeStringArray(options[key]);
92
+ });
93
+ ["duration", "maxWidth", "initialExpandLevel"].forEach((key) => {
94
+ if (options[key] != null)
95
+ options[key] = normalizeNumber(options[key]);
96
+ });
97
+ return options;
98
+ }
99
+ function normalizeStringArray(value) {
100
+ let result;
101
+ if (typeof value === "string")
102
+ result = [value];
103
+ else if (Array.isArray(value))
104
+ result = value.filter((item) => item && typeof item === "string");
105
+ return (result == null ? void 0 : result.length) ? result : void 0;
106
+ }
107
+ function normalizeNumber(value) {
108
+ if (isNaN(+value))
109
+ return;
110
+ return +value;
111
+ }
112
+ function patchJSItem(urlBuilder, item) {
113
+ if (item.type === "script" && item.data.src) {
114
+ return {
115
+ ...item,
116
+ data: {
117
+ ...item.data,
118
+ src: urlBuilder.getFullUrl(item.data.src)
119
+ }
120
+ };
121
+ }
122
+ return item;
123
+ }
124
+ function patchCSSItem(urlBuilder, item) {
125
+ if (item.type === "stylesheet" && item.data.href) {
126
+ return {
127
+ ...item,
128
+ data: {
129
+ ...item.data,
130
+ href: urlBuilder.getFullUrl(item.data.href)
131
+ }
132
+ };
133
+ }
134
+ return item;
135
+ }
136
+ const name$3 = "hljs";
14
137
  const preloadScripts$1 = [
138
+ `@highlightjs/cdn-assets@${"11.8.0"}/highlight.min.js`
139
+ ].map((path) => buildJSItem(path));
140
+ const styles$1 = [
141
+ `@highlightjs/cdn-assets@${"11.8.0"}/styles/default.min.css`
142
+ ].map((path) => buildCSSItem(path));
143
+ const config$1 = {
144
+ versions: {
145
+ hljs: "11.8.0"
146
+ },
147
+ preloadScripts: preloadScripts$1,
148
+ styles: styles$1
149
+ };
150
+ const plugin$2 = definePlugin({
151
+ name: name$3,
152
+ config: config$1,
153
+ transform(transformHooks) {
154
+ var _a, _b, _c;
155
+ let loading;
156
+ const preloadScripts2 = ((_b = (_a = plugin$2.config) == null ? void 0 : _a.preloadScripts) == null ? void 0 : _b.map(
157
+ (item) => patchJSItem(transformHooks.transformer.urlBuilder, item)
158
+ )) || [];
159
+ const autoload = () => {
160
+ loading || (loading = loadJS(preloadScripts2));
161
+ return loading;
162
+ };
163
+ let enableFeature = noop;
164
+ transformHooks.parser.tap((md) => {
165
+ md.set({
166
+ highlight: (str, language) => {
167
+ enableFeature();
168
+ const { hljs } = window;
169
+ if (hljs) {
170
+ return hljs.highlightAuto(str, language ? [language] : void 0).value;
171
+ }
172
+ autoload().then(() => {
173
+ transformHooks.retransform.call();
174
+ });
175
+ return str;
176
+ }
177
+ });
178
+ });
179
+ transformHooks.beforeParse.tap((_, context) => {
180
+ enableFeature = () => {
181
+ context.features[name$3] = true;
182
+ };
183
+ });
184
+ return {
185
+ styles: (_c = plugin$2.config) == null ? void 0 : _c.styles
186
+ };
187
+ }
188
+ });
189
+ const pluginHljs = plugin$2;
190
+ const name$2 = "katex";
191
+ const preloadScripts = [
15
192
  `katex@${"0.16.8"}/dist/katex.min.js`
16
193
  ].map((path) => buildJSItem(path));
17
194
  const webfontloader = buildJSItem(
18
195
  `webfontloader@${"1.6.28"}/webfontloader.js`
19
196
  );
20
197
  webfontloader.data.defer = true;
21
- const styles$1 = [`katex@${"0.16.8"}/dist/katex.min.css`].map(
198
+ const styles = [`katex@${"0.16.8"}/dist/katex.min.css`].map(
22
199
  (path) => buildCSSItem(path)
23
200
  );
24
- const config$1 = {
201
+ const config = {
25
202
  versions: {
26
203
  katex: "0.16.8",
27
204
  webfontloader: "1.6.28"
28
205
  },
29
- preloadScripts: preloadScripts$1,
206
+ preloadScripts,
30
207
  scripts: [
31
208
  {
32
209
  type: "iife",
@@ -61,7 +238,7 @@ const config$1 = {
61
238
  },
62
239
  webfontloader
63
240
  ],
64
- styles: styles$1
241
+ styles
65
242
  };
66
243
  function addDefaultVersions(paths, name2, version) {
67
244
  return paths.map((path) => {
@@ -79,50 +256,13 @@ function addDefaultVersions(paths, name2, version) {
79
256
  return path;
80
257
  });
81
258
  }
82
- function patchJSItem(urlBuilder, item) {
83
- if (item.type === "script" && item.data.src) {
84
- return {
85
- ...item,
86
- data: {
87
- ...item.data,
88
- src: urlBuilder.getFullUrl(item.data.src)
89
- }
90
- };
91
- }
92
- return item;
93
- }
94
- function patchCSSItem(urlBuilder, item) {
95
- if (item.type === "stylesheet" && item.data.href) {
96
- return {
97
- ...item,
98
- data: {
99
- ...item.data,
100
- href: urlBuilder.getFullUrl(item.data.href)
101
- }
102
- };
103
- }
104
- return item;
105
- }
106
- function createTransformHooks(transformer) {
107
- return {
108
- transformer,
109
- parser: new Hook(),
110
- beforeParse: new Hook(),
111
- afterParse: new Hook(),
112
- htmltag: new Hook(),
113
- retransform: new Hook()
114
- };
115
- }
116
- function definePlugin(plugin2) {
117
- return plugin2;
118
- }
119
- const plugin$2 = definePlugin({
120
- name: name$4,
121
- config: config$1,
259
+ const plugin$1 = definePlugin({
260
+ name: name$2,
261
+ config,
122
262
  transform(transformHooks) {
123
263
  var _a, _b, _c, _d;
124
264
  let loading;
125
- const preloadScripts2 = ((_b = (_a = plugin$2.config) == null ? void 0 : _a.preloadScripts) == null ? void 0 : _b.map(
265
+ const preloadScripts2 = ((_b = (_a = plugin$1.config) == null ? void 0 : _a.preloadScripts) == null ? void 0 : _b.map(
126
266
  (item) => patchJSItem(transformHooks.transformer.urlBuilder, item)
127
267
  )) || [];
128
268
  const autoload = () => {
@@ -153,7 +293,7 @@ const plugin$2 = definePlugin({
153
293
  });
154
294
  transformHooks.beforeParse.tap((_, context) => {
155
295
  enableFeature = () => {
156
- context.features[name$4] = true;
296
+ context.features[name$2] = true;
157
297
  };
158
298
  });
159
299
  transformHooks.afterParse.tap((_, context) => {
@@ -166,82 +306,27 @@ const plugin$2 = definePlugin({
166
306
  if (value) {
167
307
  markmap[key] = addDefaultVersions(
168
308
  value,
169
- name$4,
170
- ((_b2 = (_a3 = plugin$2.config) == null ? void 0 : _a3.versions) == null ? void 0 : _b2.katex) || ""
309
+ name$2,
310
+ ((_b2 = (_a3 = plugin$1.config) == null ? void 0 : _a3.versions) == null ? void 0 : _b2.katex) || ""
171
311
  );
172
312
  }
173
313
  });
174
314
  }
175
315
  });
176
316
  return {
177
- styles: (_c = plugin$2.config) == null ? void 0 : _c.styles,
178
- scripts: (_d = plugin$2.config) == null ? void 0 : _d.scripts
317
+ styles: (_c = plugin$1.config) == null ? void 0 : _c.styles,
318
+ scripts: (_d = plugin$1.config) == null ? void 0 : _d.scripts
179
319
  };
180
320
  }
181
321
  });
182
- const name$3 = "frontmatter";
183
- const frontmatter = definePlugin({
184
- name: name$3,
185
- transform(transformHooks) {
186
- transformHooks.beforeParse.tap((md, context) => {
187
- const { content } = context;
188
- if (!/^---\r?\n/.test(content))
189
- return;
190
- const match = /\n---\r?\n/.exec(content);
191
- if (!match)
192
- return;
193
- const raw = content.slice(4, match.index);
194
- let frontmatter2;
195
- try {
196
- frontmatter2 = yaml.load(raw);
197
- if (frontmatter2 == null ? void 0 : frontmatter2.markmap) {
198
- frontmatter2.markmap = normalizeMarkmapJsonOptions(
199
- frontmatter2.markmap
200
- );
201
- }
202
- } catch {
203
- return;
204
- }
205
- context.frontmatter = frontmatter2;
206
- context.content = content.slice(match.index + match[0].length);
207
- context.contentLineOffset = content.slice(0, match.index).split("\n").length + 1;
208
- });
209
- return {};
210
- }
211
- });
212
- function normalizeMarkmapJsonOptions(options) {
213
- if (!options)
214
- return;
215
- ["color", "extraJs", "extraCss"].forEach((key) => {
216
- if (options[key] != null)
217
- options[key] = normalizeStringArray(options[key]);
218
- });
219
- ["duration", "maxWidth", "initialExpandLevel"].forEach((key) => {
220
- if (options[key] != null)
221
- options[key] = normalizeNumber(options[key]);
222
- });
223
- return options;
224
- }
225
- function normalizeStringArray(value) {
226
- let result;
227
- if (typeof value === "string")
228
- result = [value];
229
- else if (Array.isArray(value))
230
- result = value.filter((item) => item && typeof item === "string");
231
- return (result == null ? void 0 : result.length) ? result : void 0;
232
- }
233
- function normalizeNumber(value) {
234
- if (isNaN(+value))
235
- return;
236
- return +value;
237
- }
238
- const name$2 = "npmUrl";
239
- const npmUrl = definePlugin({
240
- name: name$2,
322
+ const pluginKatex = plugin$1;
323
+ const name$1 = "npmUrl";
324
+ const pluginNpmUrl = definePlugin({
325
+ name: name$1,
241
326
  transform(transformHooks) {
242
327
  transformHooks.afterParse.tap((_, context) => {
243
- const { frontmatter: frontmatter2 } = context;
244
- const markmap = frontmatter2 == null ? void 0 : frontmatter2.markmap;
328
+ const { frontmatter } = context;
329
+ const markmap = frontmatter == null ? void 0 : frontmatter.markmap;
245
330
  if (markmap) {
246
331
  ["extraJs", "extraCss"].forEach((key) => {
247
332
  const value = markmap[key];
@@ -261,92 +346,47 @@ const npmUrl = definePlugin({
261
346
  return {};
262
347
  }
263
348
  });
264
- const name$1 = "hljs";
265
- const preloadScripts = [
266
- `@highlightjs/cdn-assets@${"11.8.0"}/highlight.min.js`
267
- ].map((path) => buildJSItem(path));
268
- const styles = [
269
- `@highlightjs/cdn-assets@${"11.8.0"}/styles/default.min.css`
270
- // `highlight.js@${process.env.HLJS_VERSION}/styles/default.css`,
271
- ].map((path) => buildCSSItem(path));
272
- const config = {
273
- versions: {
274
- hljs: "11.8.0"
275
- },
276
- preloadScripts,
277
- styles
278
- };
279
- const plugin$1 = definePlugin({
280
- name: name$1,
281
- config,
349
+ const name = "sourceLines";
350
+ const plugin = definePlugin({
351
+ name,
282
352
  transform(transformHooks) {
283
- var _a, _b, _c;
284
- let loading;
285
- const preloadScripts2 = ((_b = (_a = plugin$1.config) == null ? void 0 : _a.preloadScripts) == null ? void 0 : _b.map(
286
- (item) => patchJSItem(transformHooks.transformer.urlBuilder, item)
287
- )) || [];
288
- const autoload = () => {
289
- loading || (loading = loadJS(preloadScripts2));
290
- return loading;
291
- };
292
- let enableFeature = noop;
293
353
  transformHooks.parser.tap((md) => {
294
- md.set({
295
- highlight: (str, language) => {
296
- enableFeature();
297
- const { hljs } = window;
298
- if (hljs) {
299
- return hljs.highlightAuto(str, language ? [language] : void 0).value;
300
- }
301
- autoload().then(() => {
302
- transformHooks.retransform.call();
354
+ Object.entries(md.renderer.rules).forEach(([key, value]) => {
355
+ if (typeof value === "function") {
356
+ md.renderer.rules[key] = patchRule(value);
357
+ } else {
358
+ Object.entries(value).forEach(([k, v]) => {
359
+ value[k] = patchRule(v);
303
360
  });
304
- return str;
305
361
  }
306
362
  });
307
363
  });
308
- transformHooks.beforeParse.tap((_, context) => {
309
- enableFeature = () => {
310
- context.features[name$1] = true;
311
- };
312
- });
313
- return {
314
- styles: (_c = plugin$1.config) == null ? void 0 : _c.styles
315
- };
316
- }
317
- });
318
- const name = "checkbox";
319
- const plugin = definePlugin({
320
- name,
321
- transform(transformHooks) {
322
- transformHooks.parser.tap((md) => {
323
- md.core.ruler.before(
324
- "inline",
325
- "checkbox",
326
- (state) => {
327
- for (let i = 2; i < state.tokens.length; i += 1) {
328
- const token = state.tokens[i];
329
- if (token.type === "inline" && token.content) {
330
- const prevType = state.tokens[i - 1].type;
331
- const prevPrevType = state.tokens[i - 2].type;
332
- if (prevType === "heading_open" || prevType === "paragraph_open" && prevPrevType === "list_item_open") {
333
- if (token.content.startsWith("[ ]")) {
334
- token.content = `${svg_unmarked} ${token.content.slice(3)}`;
335
- } else if (token.content.startsWith("[x]")) {
336
- token.content = `${svg_marked} ${token.content.slice(3)}`;
337
- }
338
- }
339
- }
340
- }
341
- return false;
342
- },
343
- {}
344
- );
345
- });
346
364
  return {};
347
365
  }
348
366
  });
349
- const plugins = [frontmatter, plugin$2, plugin$1, npmUrl, plugin];
367
+ function patchRule(rule, _key) {
368
+ return wrapFunction(rule, (render, tokens, idx, ...rest) => {
369
+ let html = render(tokens, idx, ...rest);
370
+ const { lines } = tokens[idx];
371
+ if (lines) {
372
+ html = html.replace(
373
+ /^<[\w-]+/,
374
+ (m) => `${m} data-lines="${lines.join(",")}"`
375
+ );
376
+ }
377
+ return html;
378
+ });
379
+ }
380
+ const pluginSourceLines = plugin;
381
+ const plugins = [
382
+ pluginFrontmatter,
383
+ pluginKatex,
384
+ pluginHljs,
385
+ pluginNpmUrl,
386
+ pluginCheckbox,
387
+ pluginSourceLines
388
+ ];
389
+ const builtInPlugins = plugins;
350
390
  function cleanNode(node) {
351
391
  while (!node.content && node.children.length === 1) {
352
392
  node = node.children[0];
@@ -363,11 +403,11 @@ function cleanNode(node) {
363
403
  };
364
404
  }
365
405
  class Transformer {
366
- constructor(plugins$1 = plugins) {
406
+ constructor(plugins2 = builtInPlugins) {
367
407
  this.assetsMap = {};
368
408
  this.urlBuilder = new UrlBuilder();
369
409
  this.hooks = createTransformHooks(this);
370
- this.plugins = plugins$1.map(
410
+ this.plugins = plugins2.map(
371
411
  (plugin2) => typeof plugin2 === "function" ? plugin2() : plugin2
372
412
  );
373
413
  const assetsMap = {};
@@ -436,58 +476,12 @@ class Transformer {
436
476
  const keys = this.plugins.map((plugin2) => plugin2.name).filter((name2) => features[name2]);
437
477
  return this.getAssets(keys);
438
478
  }
439
- fillTemplate(root, assets, extra) {
440
- extra = {
441
- ...extra
442
- };
443
- extra.baseJs ?? (extra.baseJs = baseJsPaths.map((path) => this.urlBuilder.getFullUrl(path)).map((path) => buildJSItem(path)));
444
- const { scripts, styles: styles2 } = assets;
445
- const cssList = [...styles2 ? persistCSS(styles2) : []];
446
- const context = {
447
- getMarkmap: () => window.markmap,
448
- getOptions: extra.getOptions,
449
- jsonOptions: extra.jsonOptions,
450
- root
451
- };
452
- const jsList = [
453
- ...persistJS(
454
- [
455
- ...extra.baseJs,
456
- ...scripts || [],
457
- {
458
- type: "iife",
459
- data: {
460
- fn: (getMarkmap, getOptions, root2, jsonOptions) => {
461
- const markmap = getMarkmap();
462
- window.mm = markmap.Markmap.create(
463
- "svg#mindmap",
464
- (getOptions || markmap.deriveOptions)(jsonOptions),
465
- root2
466
- );
467
- },
468
- getParams: ({ getMarkmap, getOptions, root: root2, jsonOptions }) => {
469
- return [getMarkmap, getOptions, root2, jsonOptions];
470
- }
471
- }
472
- }
473
- ],
474
- context
475
- )
476
- ];
477
- const html = template.replace("<!--CSS-->", () => cssList.join("")).replace("<!--JS-->", () => jsList.join(""));
478
- return html;
479
- }
480
479
  }
481
480
  const transformerVersions = {
482
- "markmap-lib": "process.env.VERSION",
483
- d3: "7.8.5"
481
+ "markmap-lib": "0.16.0"
484
482
  };
485
483
  export {
486
484
  Transformer,
487
- baseJsPaths,
488
- plugins as builtInPlugins,
489
- svg_marked,
490
- svg_unmarked,
491
- template,
485
+ builtInPlugins,
492
486
  transformerVersions
493
487
  };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  export * from './types';
2
- export * from './constants';
3
2
  export * from './transform';
4
3
  export declare const transformerVersions: {
5
- 'markmap-lib': string;
6
- d3: string | undefined;
4
+ 'markmap-lib': string | undefined;
7
5
  };