markmap-lib 0.15.9-alpha.6 → 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 (36) hide show
  1. package/dist/browser/index.iife.js +38 -150
  2. package/dist/browser/index.mjs +37 -81
  3. package/dist/index.d.ts +1 -3
  4. package/dist/index.js +17 -352
  5. package/dist/index.mjs +18 -353
  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/source-lines.d.ts +0 -2
  34. /package/dist/plugins/{hljs.config.d.ts → hljs/config.d.ts} +0 -0
  35. /package/dist/plugins/{katex.config.d.ts → katex/config.d.ts} +0 -0
  36. /package/dist/plugins/{prism.config.d.ts → prism/config.d.ts} +0 -0
@@ -1,12 +1,5 @@
1
1
  (function(exports, require$$0) {
2
2
  "use strict";
3
- 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';
4
- const baseJsPaths = [
5
- `d3@${"7.8.5"}/dist/d3.min.js`,
6
- `markmap-view@${"0.15.9-alpha.6"}/dist/browser/index.js`
7
- ];
8
- 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>`;
9
- 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>`;
10
3
  const testPath = "npm2url/dist/index.cjs";
11
4
  const defaultProviders = {
12
5
  jsdelivr: (path) => `https://cdn.jsdelivr.net/npm/${path}`,
@@ -98,75 +91,6 @@
98
91
  }
99
92
  }
100
93
  }
101
- const escapeChars = {
102
- "&": "&amp;",
103
- "<": "&lt;",
104
- '"': "&quot;"
105
- };
106
- function escapeHtml$1(html2) {
107
- return html2.replace(/[&<"]/g, (m) => escapeChars[m]);
108
- }
109
- function escapeScript(content) {
110
- return content.replace(/<(\/script>)/g, "\\x3c$2");
111
- }
112
- function htmlOpen(tagName, attrs) {
113
- const attrStr = attrs ? Object.entries(attrs).map(([key, value]) => {
114
- if (value == null || value === false)
115
- return;
116
- key = ` ${escapeHtml$1(key)}`;
117
- if (value === true)
118
- return key;
119
- return `${key}="${escapeHtml$1(value)}"`;
120
- }).filter(Boolean).join("") : "";
121
- return `<${tagName}${attrStr}>`;
122
- }
123
- function htmlClose(tagName) {
124
- return `</${tagName}>`;
125
- }
126
- function wrapHtml(tagName, content, attrs) {
127
- if (content == null)
128
- return htmlOpen(tagName, attrs);
129
- return htmlOpen(tagName, attrs) + (content || "") + htmlClose(tagName);
130
- }
131
- function buildCode(fn, args) {
132
- const params = args.map((arg) => {
133
- if (typeof arg === "function")
134
- return arg.toString();
135
- return JSON.stringify(arg ?? null);
136
- }).join(",");
137
- return `(${fn.toString()})(${params})`;
138
- }
139
- function persistJS(items, context) {
140
- return items.map((item) => {
141
- if (item.type === "script") {
142
- const { textContent: textContent2, ...rest } = item.data;
143
- return wrapHtml(
144
- "script",
145
- textContent2 || "",
146
- rest
147
- );
148
- }
149
- if (item.type === "iife") {
150
- const { fn, getParams } = item.data;
151
- return wrapHtml(
152
- "script",
153
- escapeScript(buildCode(fn, (getParams == null ? void 0 : getParams(context)) || []))
154
- );
155
- }
156
- return "";
157
- });
158
- }
159
- function persistCSS(items) {
160
- return items.map((item) => {
161
- if (item.type === "stylesheet") {
162
- return wrapHtml("link", null, {
163
- rel: "stylesheet",
164
- ...item.data
165
- });
166
- }
167
- return wrapHtml("style", item.data);
168
- });
169
- }
170
94
  Math.random().toString(36).slice(2, 8);
171
95
  function noop() {
172
96
  }
@@ -14073,7 +13997,7 @@
14073
13997
  const SELECTOR_LIST = /^[uo]l$/;
14074
13998
  const SELECTOR_LIST_ITEM = /^li$/;
14075
13999
  const defaultOptions = {
14076
- selector: "h1,h2,h3,h4,h5,h6,ul,ol,li,table,pre,p>img:first-child:last-child",
14000
+ selector: "h1,h2,h3,h4,h5,h6,ul,ol,li,table,pre,p>img:only-child",
14077
14001
  selectorWrapper: "div,p",
14078
14002
  selectorNesting: "ul,ol,li",
14079
14003
  selectorPreserveTag: "table,pre,img"
@@ -18047,7 +17971,13 @@
18047
17971
  function definePlugin(plugin2) {
18048
17972
  return plugin2;
18049
17973
  }
17974
+ 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';
17975
+ 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';
18050
17976
  const name$5 = "checkbox";
17977
+ const images = {
17978
+ " ": svgUnmarked.trim(),
17979
+ x: svgMarked.trim()
17980
+ };
18051
17981
  const plugin$3 = definePlugin({
18052
17982
  name: name$5,
18053
17983
  transform(transformHooks) {
@@ -18062,11 +17992,10 @@
18062
17992
  const prevType = state.tokens[i2 - 1].type;
18063
17993
  const prevPrevType = state.tokens[i2 - 2].type;
18064
17994
  if (prevType === "heading_open" || prevType === "paragraph_open" && prevPrevType === "list_item_open") {
18065
- if (token.content.startsWith("[ ]")) {
18066
- token.content = `${svg_unmarked} ${token.content.slice(3)}`;
18067
- } else if (token.content.startsWith("[x]")) {
18068
- token.content = `${svg_marked} ${token.content.slice(3)}`;
18069
- }
17995
+ token.content = token.content.replace(
17996
+ /^\[(.)\] /,
17997
+ (m, g) => images[g] ? `${images[g]} ` : m
17998
+ );
18070
17999
  }
18071
18000
  }
18072
18001
  }
@@ -18078,6 +18007,7 @@
18078
18007
  return {};
18079
18008
  }
18080
18009
  });
18010
+ const pluginCheckbox = plugin$3;
18081
18011
  /*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */
18082
18012
  function isNothing(subject) {
18083
18013
  return typeof subject === "undefined" || subject === null;
@@ -20766,8 +20696,9 @@
20766
20696
  safeLoadAll,
20767
20697
  safeDump
20768
20698
  };
20699
+ const yaml = jsYaml;
20769
20700
  const name$4 = "frontmatter";
20770
- const frontmatter = definePlugin({
20701
+ const pluginFrontmatter = definePlugin({
20771
20702
  name: name$4,
20772
20703
  transform(transformHooks) {
20773
20704
  transformHooks.beforeParse.tap((md, context) => {
@@ -20778,18 +20709,18 @@
20778
20709
  if (!match)
20779
20710
  return;
20780
20711
  const raw = content.slice(4, match.index);
20781
- let frontmatter2;
20712
+ let frontmatter;
20782
20713
  try {
20783
- frontmatter2 = jsYaml.load(raw);
20784
- if (frontmatter2 == null ? void 0 : frontmatter2.markmap) {
20785
- frontmatter2.markmap = normalizeMarkmapJsonOptions(
20786
- frontmatter2.markmap
20714
+ frontmatter = yaml.load(raw);
20715
+ if (frontmatter == null ? void 0 : frontmatter.markmap) {
20716
+ frontmatter.markmap = normalizeMarkmapJsonOptions(
20717
+ frontmatter.markmap
20787
20718
  );
20788
20719
  }
20789
20720
  } catch {
20790
20721
  return;
20791
20722
  }
20792
- context.frontmatter = frontmatter2;
20723
+ context.frontmatter = frontmatter;
20793
20724
  context.content = content.slice(match.index + match[0].length);
20794
20725
  context.contentLineOffset = content.slice(0, match.index).split("\n").length + 1;
20795
20726
  });
@@ -20852,7 +20783,6 @@
20852
20783
  ].map((path) => buildJSItem(path));
20853
20784
  const styles$1 = [
20854
20785
  `@highlightjs/cdn-assets@${"11.8.0"}/styles/default.min.css`
20855
- // `highlight.js@${process.env.HLJS_VERSION}/styles/default.css`,
20856
20786
  ].map((path) => buildCSSItem(path));
20857
20787
  const config$1 = {
20858
20788
  versions: {
@@ -20900,6 +20830,7 @@
20900
20830
  };
20901
20831
  }
20902
20832
  });
20833
+ const pluginHljs = plugin$2;
20903
20834
  const rkatex = (md, options) => {
20904
20835
  const backslash = "\\";
20905
20836
  const dollar = "$";
@@ -21162,13 +21093,14 @@
21162
21093
  };
21163
21094
  }
21164
21095
  });
21096
+ const pluginKatex = plugin$1;
21165
21097
  const name$1 = "npmUrl";
21166
- const npmUrl = definePlugin({
21098
+ const pluginNpmUrl = definePlugin({
21167
21099
  name: name$1,
21168
21100
  transform(transformHooks) {
21169
21101
  transformHooks.afterParse.tap((_, context) => {
21170
- const { frontmatter: frontmatter2 } = context;
21171
- const markmap = frontmatter2 == null ? void 0 : frontmatter2.markmap;
21102
+ const { frontmatter } = context;
21103
+ const markmap = frontmatter == null ? void 0 : frontmatter.markmap;
21172
21104
  if (markmap) {
21173
21105
  ["extraJs", "extraCss"].forEach((key) => {
21174
21106
  const value = markmap[key];
@@ -21206,7 +21138,7 @@
21206
21138
  return {};
21207
21139
  }
21208
21140
  });
21209
- function patchRule(rule) {
21141
+ function patchRule(rule, _key) {
21210
21142
  return wrapFunction(rule, (render2, tokens, idx, ...rest) => {
21211
21143
  let html2 = render2(tokens, idx, ...rest);
21212
21144
  const { lines } = tokens[idx];
@@ -21219,14 +21151,16 @@
21219
21151
  return html2;
21220
21152
  });
21221
21153
  }
21154
+ const pluginSourceLines = plugin;
21222
21155
  const plugins = [
21223
- frontmatter,
21224
- plugin$1,
21225
- plugin$2,
21226
- npmUrl,
21227
- plugin$3,
21228
- plugin
21156
+ pluginFrontmatter,
21157
+ pluginKatex,
21158
+ pluginHljs,
21159
+ pluginNpmUrl,
21160
+ pluginCheckbox,
21161
+ pluginSourceLines
21229
21162
  ];
21163
+ const builtInPlugins = plugins;
21230
21164
  function cleanNode(node) {
21231
21165
  while (!node.content && node.children.length === 1) {
21232
21166
  node = node.children[0];
@@ -21243,11 +21177,11 @@
21243
21177
  };
21244
21178
  }
21245
21179
  class Transformer {
21246
- constructor(plugins$1 = plugins) {
21180
+ constructor(plugins2 = builtInPlugins) {
21247
21181
  this.assetsMap = {};
21248
21182
  this.urlBuilder = new UrlBuilder();
21249
21183
  this.hooks = createTransformHooks(this);
21250
- this.plugins = plugins$1.map(
21184
+ this.plugins = plugins2.map(
21251
21185
  (plugin2) => typeof plugin2 === "function" ? plugin2() : plugin2
21252
21186
  );
21253
21187
  const assetsMap = {};
@@ -21316,58 +21250,12 @@
21316
21250
  const keys = this.plugins.map((plugin2) => plugin2.name).filter((name2) => features[name2]);
21317
21251
  return this.getAssets(keys);
21318
21252
  }
21319
- fillTemplate(root2, assets, extra) {
21320
- extra = {
21321
- ...extra
21322
- };
21323
- extra.baseJs ?? (extra.baseJs = baseJsPaths.map((path) => this.urlBuilder.getFullUrl(path)).map((path) => buildJSItem(path)));
21324
- const { scripts, styles: styles2 } = assets;
21325
- const cssList = [...styles2 ? persistCSS(styles2) : []];
21326
- const context = {
21327
- getMarkmap: () => window.markmap,
21328
- getOptions: extra.getOptions,
21329
- jsonOptions: extra.jsonOptions,
21330
- root: root2
21331
- };
21332
- const jsList = [
21333
- ...persistJS(
21334
- [
21335
- ...extra.baseJs,
21336
- ...scripts || [],
21337
- {
21338
- type: "iife",
21339
- data: {
21340
- fn: (getMarkmap, getOptions, root22, jsonOptions) => {
21341
- const markmap = getMarkmap();
21342
- window.mm = markmap.Markmap.create(
21343
- "svg#mindmap",
21344
- (getOptions || markmap.deriveOptions)(jsonOptions),
21345
- root22
21346
- );
21347
- },
21348
- getParams: ({ getMarkmap, getOptions, root: root22, jsonOptions }) => {
21349
- return [getMarkmap, getOptions, root22, jsonOptions];
21350
- }
21351
- }
21352
- }
21353
- ],
21354
- context
21355
- )
21356
- ];
21357
- const html2 = template.replace("<!--CSS-->", () => cssList.join("")).replace("<!--JS-->", () => jsList.join(""));
21358
- return html2;
21359
- }
21360
21253
  }
21361
21254
  const transformerVersions = {
21362
- "markmap-lib": "process.env.VERSION",
21363
- d3: "7.8.5"
21255
+ "markmap-lib": "0.16.0"
21364
21256
  };
21365
21257
  exports.Transformer = Transformer;
21366
- exports.baseJsPaths = baseJsPaths;
21367
- exports.builtInPlugins = plugins;
21368
- exports.svg_marked = svg_marked;
21369
- exports.svg_unmarked = svg_unmarked;
21370
- exports.template = template;
21258
+ exports.builtInPlugins = builtInPlugins;
21371
21259
  exports.transformerVersions = transformerVersions;
21372
21260
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
21373
21261
  })(this.markmap = this.markmap || {}, window.katex);
@@ -1,15 +1,8 @@
1
- import { Hook, buildJSItem, buildCSSItem, loadJS, noop, wrapFunction, UrlBuilder, 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
4
  import yaml from "js-yaml";
5
5
  import remarkableKatex from "remarkable-katex";
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.6"}/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
6
  function createTransformHooks(transformer) {
14
7
  return {
15
8
  transformer,
@@ -23,7 +16,13 @@ function createTransformHooks(transformer) {
23
16
  function definePlugin(plugin2) {
24
17
  return plugin2;
25
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';
26
21
  const name$5 = "checkbox";
22
+ const images = {
23
+ " ": svgUnmarked.trim(),
24
+ x: svgMarked.trim()
25
+ };
27
26
  const plugin$3 = definePlugin({
28
27
  name: name$5,
29
28
  transform(transformHooks) {
@@ -38,11 +37,10 @@ const plugin$3 = definePlugin({
38
37
  const prevType = state.tokens[i - 1].type;
39
38
  const prevPrevType = state.tokens[i - 2].type;
40
39
  if (prevType === "heading_open" || prevType === "paragraph_open" && prevPrevType === "list_item_open") {
41
- if (token.content.startsWith("[ ]")) {
42
- token.content = `${svg_unmarked} ${token.content.slice(3)}`;
43
- } else if (token.content.startsWith("[x]")) {
44
- token.content = `${svg_marked} ${token.content.slice(3)}`;
45
- }
40
+ token.content = token.content.replace(
41
+ /^\[(.)\] /,
42
+ (m, g) => images[g] ? `${images[g]} ` : m
43
+ );
46
44
  }
47
45
  }
48
46
  }
@@ -54,8 +52,9 @@ const plugin$3 = definePlugin({
54
52
  return {};
55
53
  }
56
54
  });
55
+ const pluginCheckbox = plugin$3;
57
56
  const name$4 = "frontmatter";
58
- const frontmatter = definePlugin({
57
+ const pluginFrontmatter = definePlugin({
59
58
  name: name$4,
60
59
  transform(transformHooks) {
61
60
  transformHooks.beforeParse.tap((md, context) => {
@@ -66,18 +65,18 @@ const frontmatter = definePlugin({
66
65
  if (!match)
67
66
  return;
68
67
  const raw = content.slice(4, match.index);
69
- let frontmatter2;
68
+ let frontmatter;
70
69
  try {
71
- frontmatter2 = yaml.load(raw);
72
- if (frontmatter2 == null ? void 0 : frontmatter2.markmap) {
73
- frontmatter2.markmap = normalizeMarkmapJsonOptions(
74
- frontmatter2.markmap
70
+ frontmatter = yaml.load(raw);
71
+ if (frontmatter == null ? void 0 : frontmatter.markmap) {
72
+ frontmatter.markmap = normalizeMarkmapJsonOptions(
73
+ frontmatter.markmap
75
74
  );
76
75
  }
77
76
  } catch {
78
77
  return;
79
78
  }
80
- context.frontmatter = frontmatter2;
79
+ context.frontmatter = frontmatter;
81
80
  context.content = content.slice(match.index + match[0].length);
82
81
  context.contentLineOffset = content.slice(0, match.index).split("\n").length + 1;
83
82
  });
@@ -140,7 +139,6 @@ const preloadScripts$1 = [
140
139
  ].map((path) => buildJSItem(path));
141
140
  const styles$1 = [
142
141
  `@highlightjs/cdn-assets@${"11.8.0"}/styles/default.min.css`
143
- // `highlight.js@${process.env.HLJS_VERSION}/styles/default.css`,
144
142
  ].map((path) => buildCSSItem(path));
145
143
  const config$1 = {
146
144
  versions: {
@@ -188,6 +186,7 @@ const plugin$2 = definePlugin({
188
186
  };
189
187
  }
190
188
  });
189
+ const pluginHljs = plugin$2;
191
190
  const name$2 = "katex";
192
191
  const preloadScripts = [
193
192
  `katex@${"0.16.8"}/dist/katex.min.js`
@@ -320,13 +319,14 @@ const plugin$1 = definePlugin({
320
319
  };
321
320
  }
322
321
  });
322
+ const pluginKatex = plugin$1;
323
323
  const name$1 = "npmUrl";
324
- const npmUrl = definePlugin({
324
+ const pluginNpmUrl = definePlugin({
325
325
  name: name$1,
326
326
  transform(transformHooks) {
327
327
  transformHooks.afterParse.tap((_, context) => {
328
- const { frontmatter: frontmatter2 } = context;
329
- const markmap = frontmatter2 == null ? void 0 : frontmatter2.markmap;
328
+ const { frontmatter } = context;
329
+ const markmap = frontmatter == null ? void 0 : frontmatter.markmap;
330
330
  if (markmap) {
331
331
  ["extraJs", "extraCss"].forEach((key) => {
332
332
  const value = markmap[key];
@@ -364,7 +364,7 @@ const plugin = definePlugin({
364
364
  return {};
365
365
  }
366
366
  });
367
- function patchRule(rule) {
367
+ function patchRule(rule, _key) {
368
368
  return wrapFunction(rule, (render, tokens, idx, ...rest) => {
369
369
  let html = render(tokens, idx, ...rest);
370
370
  const { lines } = tokens[idx];
@@ -377,14 +377,16 @@ function patchRule(rule) {
377
377
  return html;
378
378
  });
379
379
  }
380
+ const pluginSourceLines = plugin;
380
381
  const plugins = [
381
- frontmatter,
382
- plugin$1,
383
- plugin$2,
384
- npmUrl,
385
- plugin$3,
386
- plugin
382
+ pluginFrontmatter,
383
+ pluginKatex,
384
+ pluginHljs,
385
+ pluginNpmUrl,
386
+ pluginCheckbox,
387
+ pluginSourceLines
387
388
  ];
389
+ const builtInPlugins = plugins;
388
390
  function cleanNode(node) {
389
391
  while (!node.content && node.children.length === 1) {
390
392
  node = node.children[0];
@@ -401,11 +403,11 @@ function cleanNode(node) {
401
403
  };
402
404
  }
403
405
  class Transformer {
404
- constructor(plugins$1 = plugins) {
406
+ constructor(plugins2 = builtInPlugins) {
405
407
  this.assetsMap = {};
406
408
  this.urlBuilder = new UrlBuilder();
407
409
  this.hooks = createTransformHooks(this);
408
- this.plugins = plugins$1.map(
410
+ this.plugins = plugins2.map(
409
411
  (plugin2) => typeof plugin2 === "function" ? plugin2() : plugin2
410
412
  );
411
413
  const assetsMap = {};
@@ -474,58 +476,12 @@ class Transformer {
474
476
  const keys = this.plugins.map((plugin2) => plugin2.name).filter((name2) => features[name2]);
475
477
  return this.getAssets(keys);
476
478
  }
477
- fillTemplate(root, assets, extra) {
478
- extra = {
479
- ...extra
480
- };
481
- extra.baseJs ?? (extra.baseJs = baseJsPaths.map((path) => this.urlBuilder.getFullUrl(path)).map((path) => buildJSItem(path)));
482
- const { scripts, styles: styles2 } = assets;
483
- const cssList = [...styles2 ? persistCSS(styles2) : []];
484
- const context = {
485
- getMarkmap: () => window.markmap,
486
- getOptions: extra.getOptions,
487
- jsonOptions: extra.jsonOptions,
488
- root
489
- };
490
- const jsList = [
491
- ...persistJS(
492
- [
493
- ...extra.baseJs,
494
- ...scripts || [],
495
- {
496
- type: "iife",
497
- data: {
498
- fn: (getMarkmap, getOptions, root2, jsonOptions) => {
499
- const markmap = getMarkmap();
500
- window.mm = markmap.Markmap.create(
501
- "svg#mindmap",
502
- (getOptions || markmap.deriveOptions)(jsonOptions),
503
- root2
504
- );
505
- },
506
- getParams: ({ getMarkmap, getOptions, root: root2, jsonOptions }) => {
507
- return [getMarkmap, getOptions, root2, jsonOptions];
508
- }
509
- }
510
- }
511
- ],
512
- context
513
- )
514
- ];
515
- const html = template.replace("<!--CSS-->", () => cssList.join("")).replace("<!--JS-->", () => jsList.join(""));
516
- return html;
517
- }
518
479
  }
519
480
  const transformerVersions = {
520
- "markmap-lib": "process.env.VERSION",
521
- d3: "7.8.5"
481
+ "markmap-lib": "0.16.0"
522
482
  };
523
483
  export {
524
484
  Transformer,
525
- baseJsPaths,
526
- plugins as builtInPlugins,
527
- svg_marked,
528
- svg_unmarked,
529
- template,
485
+ builtInPlugins,
530
486
  transformerVersions
531
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
  };