markmap-lib 0.15.1 → 0.15.2-alpha.1

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.
@@ -1,9 +1,9 @@
1
- /*! markmap-lib v0.15.1 | MIT License */
1
+ /*! markmap-lib v0.15.2-alpha.1+6800b6d | MIT License */
2
2
  (function (global, factory) {
3
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('katex'), require('highlight.js')) :
4
- typeof define === 'function' && define.amd ? define(['exports', 'katex', 'highlight.js'], factory) :
5
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.markmap = global.markmap || {}, global.window.katex, global.window.hljs));
6
- })(this, (function (exports, require$$0, hljs) { 'use strict';
3
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('katex')) :
4
+ typeof define === 'function' && define.amd ? define(['exports', 'katex'], factory) :
5
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.markmap = global.markmap || {}, global.window.katex));
6
+ })(this, (function (exports, require$$0) { 'use strict';
7
7
 
8
8
  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" ;
9
9
  const baseJsPaths = [`d3@${"7.8.5"}/dist/d3.min.js`, `markmap-view@${"0.15.0"}/dist/browser/index.js`];
@@ -7687,7 +7687,7 @@ var remarkableKatex = rkatex;
7687
7687
  var remarkableKatex$1 = /*@__PURE__*/getDefaultExportFromCjs(remarkableKatex);
7688
7688
 
7689
7689
  const name$3 = 'katex';
7690
- const preloadScripts = [`katex@${"0.16.8"}/dist/katex.min.js`].map(path => buildJSItem(path));
7690
+ const preloadScripts$1 = [`katex@${"0.16.8"}/dist/katex.min.js`].map(path => buildJSItem(path));
7691
7691
  const webfontloader = buildJSItem(`webfontloader@${"1.6.28"}/webfontloader.js`);
7692
7692
  webfontloader.data.defer = true;
7693
7693
  const styles$1 = [`katex@${"0.16.8"}/dist/katex.min.css`].map(path => buildCSSItem(path));
@@ -7696,7 +7696,7 @@ const config$1 = {
7696
7696
  katex: "0.16.8" ,
7697
7697
  webfontloader: "1.6.28"
7698
7698
  },
7699
- preloadScripts,
7699
+ preloadScripts: preloadScripts$1,
7700
7700
  scripts: [{
7701
7701
  type: 'iife',
7702
7702
  data: {
@@ -11025,24 +11025,44 @@ var npmUrl = definePlugin({
11025
11025
  });
11026
11026
 
11027
11027
  const name = 'hljs';
11028
- const styles = [`highlight.js@${"11.8.0"}/styles/default.css`].map(path => buildCSSItem(path));
11028
+ const preloadScripts = [`@highlightjs/cdn-assets@${"11.8.0"}/highlight.min.js`].map(path => buildJSItem(path));
11029
+ const styles = [`@highlightjs/cdn-assets@${"11.8.0"}/styles/default.min.css`
11030
+ // `highlight.js@${"11.8.0"}/styles/default.css`,
11031
+ ].map(path => buildCSSItem(path));
11029
11032
  const config = {
11030
11033
  versions: {
11031
11034
  hljs: "11.8.0"
11032
11035
  },
11036
+ preloadScripts,
11033
11037
  styles
11034
11038
  };
11039
+
11035
11040
  const plugin = definePlugin({
11036
11041
  name,
11037
11042
  config,
11038
11043
  transform(transformHooks) {
11039
- var _plugin$config;
11044
+ var _plugin$config, _plugin$config2;
11045
+ let loading;
11046
+ const preloadScripts = ((_plugin$config = plugin.config) == null || (_plugin$config = _plugin$config.preloadScripts) == null ? void 0 : _plugin$config.map(item => patchJSItem(transformHooks.transformer, item))) || [];
11047
+ const autoload = () => {
11048
+ loading || (loading = loadJS(preloadScripts));
11049
+ return loading;
11050
+ };
11040
11051
  let enableFeature = noop;
11041
11052
  transformHooks.parser.tap(md => {
11042
11053
  md.set({
11043
11054
  highlight: (str, language) => {
11044
11055
  enableFeature();
11045
- return hljs.highlightAuto(str, language ? [language] : undefined).value;
11056
+ const {
11057
+ hljs
11058
+ } = window;
11059
+ if (hljs) {
11060
+ return hljs.highlightAuto(str, language ? [language] : undefined).value;
11061
+ }
11062
+ autoload().then(() => {
11063
+ transformHooks.retransform.call();
11064
+ });
11065
+ return str;
11046
11066
  }
11047
11067
  });
11048
11068
  });
@@ -11052,7 +11072,7 @@ const plugin = definePlugin({
11052
11072
  };
11053
11073
  });
11054
11074
  return {
11055
- styles: (_plugin$config = plugin.config) == null ? void 0 : _plugin$config.styles
11075
+ styles: (_plugin$config2 = plugin.config) == null ? void 0 : _plugin$config2.styles
11056
11076
  };
11057
11077
  }
11058
11078
  });
@@ -11299,7 +11319,7 @@ class Transformer {
11299
11319
  }
11300
11320
 
11301
11321
  const transformerVersions = {
11302
- 'markmap-lib': '0.15.1',
11322
+ 'markmap-lib': '0.15.2-alpha.1+6800b6d',
11303
11323
  d3: "7.8.5"
11304
11324
  };
11305
11325
 
@@ -1,16 +1,15 @@
1
- /*! markmap-lib v0.15.1 | MIT License */
1
+ /*! markmap-lib v0.15.2-alpha.1+6800b6d | MIT License */
2
2
  import _extends from '@babel/runtime/helpers/esm/extends';
3
3
  import { Remarkable } from 'remarkable';
4
4
  import { buildJSItem, buildCSSItem, Hook, noop, loadJS, UrlBuilder, wrapFunction, persistCSS, persistJS } from 'markmap-common';
5
5
  import remarkableKatex from 'remarkable-katex';
6
6
  import yaml from 'js-yaml';
7
- import hljs from 'highlight.js';
8
7
 
9
8
  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
9
  const baseJsPaths = [`d3@${"7.8.5"}/dist/d3.min.js`, `markmap-view@${"0.15.0"}/dist/browser/index.js`];
11
10
 
12
11
  const name$3 = 'katex';
13
- const preloadScripts = [`katex@${"0.16.8"}/dist/katex.min.js`].map(path => buildJSItem(path));
12
+ const preloadScripts$1 = [`katex@${"0.16.8"}/dist/katex.min.js`].map(path => buildJSItem(path));
14
13
  const webfontloader = buildJSItem(`webfontloader@${"1.6.28"}/webfontloader.js`);
15
14
  webfontloader.data.defer = true;
16
15
  const styles$1 = [`katex@${"0.16.8"}/dist/katex.min.css`].map(path => buildCSSItem(path));
@@ -19,7 +18,7 @@ const config$1 = {
19
18
  katex: "0.16.8" ,
20
19
  webfontloader: "1.6.28"
21
20
  },
22
- preloadScripts,
21
+ preloadScripts: preloadScripts$1,
23
22
  scripts: [{
24
23
  type: 'iife',
25
24
  data: {
@@ -237,24 +236,44 @@ var npmUrl = definePlugin({
237
236
  });
238
237
 
239
238
  const name = 'hljs';
240
- const styles = [`highlight.js@${"11.8.0"}/styles/default.css`].map(path => buildCSSItem(path));
239
+ const preloadScripts = [`@highlightjs/cdn-assets@${"11.8.0"}/highlight.min.js`].map(path => buildJSItem(path));
240
+ const styles = [`@highlightjs/cdn-assets@${"11.8.0"}/styles/default.min.css`
241
+ // `highlight.js@${"11.8.0"}/styles/default.css`,
242
+ ].map(path => buildCSSItem(path));
241
243
  const config = {
242
244
  versions: {
243
245
  hljs: "11.8.0"
244
246
  },
247
+ preloadScripts,
245
248
  styles
246
249
  };
250
+
247
251
  const plugin = definePlugin({
248
252
  name,
249
253
  config,
250
254
  transform(transformHooks) {
251
- var _plugin$config;
255
+ var _plugin$config, _plugin$config2;
256
+ let loading;
257
+ const preloadScripts = ((_plugin$config = plugin.config) == null || (_plugin$config = _plugin$config.preloadScripts) == null ? void 0 : _plugin$config.map(item => patchJSItem(transformHooks.transformer, item))) || [];
258
+ const autoload = () => {
259
+ loading || (loading = loadJS(preloadScripts));
260
+ return loading;
261
+ };
252
262
  let enableFeature = noop;
253
263
  transformHooks.parser.tap(md => {
254
264
  md.set({
255
265
  highlight: (str, language) => {
256
266
  enableFeature();
257
- return hljs.highlightAuto(str, language ? [language] : undefined).value;
267
+ const {
268
+ hljs
269
+ } = window;
270
+ if (hljs) {
271
+ return hljs.highlightAuto(str, language ? [language] : undefined).value;
272
+ }
273
+ autoload().then(() => {
274
+ transformHooks.retransform.call();
275
+ });
276
+ return str;
258
277
  }
259
278
  });
260
279
  });
@@ -264,7 +283,7 @@ const plugin = definePlugin({
264
283
  };
265
284
  });
266
285
  return {
267
- styles: (_plugin$config = plugin.config) == null ? void 0 : _plugin$config.styles
286
+ styles: (_plugin$config2 = plugin.config) == null ? void 0 : _plugin$config2.styles
268
287
  };
269
288
  }
270
289
  });
@@ -511,7 +530,7 @@ class Transformer {
511
530
  }
512
531
 
513
532
  const transformerVersions = {
514
- 'markmap-lib': '0.15.1',
533
+ 'markmap-lib': '0.15.2-alpha.1+6800b6d',
515
534
  d3: "7.8.5"
516
535
  };
517
536
 
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! markmap-lib v0.15.1 | MIT License */
1
+ /*! markmap-lib v0.15.2-alpha.1+6800b6d | MIT License */
2
2
  'use strict';
3
3
 
4
4
  var _extends = require('@babel/runtime/helpers/extends');
@@ -12,7 +12,7 @@ const template = "<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\">\n<me
12
12
  const baseJsPaths = [`d3@${"7.8.5"}/dist/d3.min.js`, `markmap-view@${"0.15.0"}/dist/browser/index.js`];
13
13
 
14
14
  const name$3 = 'katex';
15
- const preloadScripts = [`katex@${"0.16.8"}/dist/katex.min.js`].map(path => markmapCommon.buildJSItem(path));
15
+ const preloadScripts$1 = [`katex@${"0.16.8"}/dist/katex.min.js`].map(path => markmapCommon.buildJSItem(path));
16
16
  const webfontloader = markmapCommon.buildJSItem(`webfontloader@${"1.6.28"}/webfontloader.js`);
17
17
  webfontloader.data.defer = true;
18
18
  const styles$1 = [`katex@${"0.16.8"}/dist/katex.min.css`].map(path => markmapCommon.buildCSSItem(path));
@@ -21,7 +21,7 @@ const config$1 = {
21
21
  katex: "0.16.8" ,
22
22
  webfontloader: "1.6.28"
23
23
  },
24
- preloadScripts,
24
+ preloadScripts: preloadScripts$1,
25
25
  scripts: [{
26
26
  type: 'iife',
27
27
  data: {
@@ -166,13 +166,18 @@ var npmUrl = definePlugin({
166
166
  });
167
167
 
168
168
  const name = 'hljs';
169
- const styles = [`highlight.js@${"11.8.0"}/styles/default.css`].map(path => markmapCommon.buildCSSItem(path));
169
+ const preloadScripts = [`@highlightjs/cdn-assets@${"11.8.0"}/highlight.min.js`].map(path => markmapCommon.buildJSItem(path));
170
+ const styles = [`@highlightjs/cdn-assets@${"11.8.0"}/styles/default.min.css`
171
+ // `highlight.js@${"11.8.0"}/styles/default.css`,
172
+ ].map(path => markmapCommon.buildCSSItem(path));
170
173
  const config = {
171
174
  versions: {
172
175
  hljs: "11.8.0"
173
176
  },
177
+ preloadScripts,
174
178
  styles
175
179
  };
180
+
176
181
  const plugin = definePlugin({
177
182
  name,
178
183
  config,
@@ -461,7 +466,7 @@ class Transformer {
461
466
  }
462
467
 
463
468
  const transformerVersions = {
464
- 'markmap-lib': '0.15.1',
469
+ 'markmap-lib': '0.15.2-alpha.1+6800b6d',
465
470
  d3: "7.8.5"
466
471
  };
467
472
 
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! markmap-lib v0.15.1 | MIT License */
1
+ /*! markmap-lib v0.15.2-alpha.1+6800b6d | MIT License */
2
2
  import _extends from '@babel/runtime/helpers/esm/extends';
3
3
  import { Remarkable } from 'remarkable';
4
4
  import { buildJSItem, buildCSSItem, Hook, wrapFunction, noop, UrlBuilder, persistCSS, persistJS } from 'markmap-common';
@@ -10,7 +10,7 @@ const template = "<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\">\n<me
10
10
  const baseJsPaths = [`d3@${"7.8.5"}/dist/d3.min.js`, `markmap-view@${"0.15.0"}/dist/browser/index.js`];
11
11
 
12
12
  const name$3 = 'katex';
13
- const preloadScripts = [`katex@${"0.16.8"}/dist/katex.min.js`].map(path => buildJSItem(path));
13
+ const preloadScripts$1 = [`katex@${"0.16.8"}/dist/katex.min.js`].map(path => buildJSItem(path));
14
14
  const webfontloader = buildJSItem(`webfontloader@${"1.6.28"}/webfontloader.js`);
15
15
  webfontloader.data.defer = true;
16
16
  const styles$1 = [`katex@${"0.16.8"}/dist/katex.min.css`].map(path => buildCSSItem(path));
@@ -19,7 +19,7 @@ const config$1 = {
19
19
  katex: "0.16.8" ,
20
20
  webfontloader: "1.6.28"
21
21
  },
22
- preloadScripts,
22
+ preloadScripts: preloadScripts$1,
23
23
  scripts: [{
24
24
  type: 'iife',
25
25
  data: {
@@ -164,13 +164,18 @@ var npmUrl = definePlugin({
164
164
  });
165
165
 
166
166
  const name = 'hljs';
167
- const styles = [`highlight.js@${"11.8.0"}/styles/default.css`].map(path => buildCSSItem(path));
167
+ const preloadScripts = [`@highlightjs/cdn-assets@${"11.8.0"}/highlight.min.js`].map(path => buildJSItem(path));
168
+ const styles = [`@highlightjs/cdn-assets@${"11.8.0"}/styles/default.min.css`
169
+ // `highlight.js@${"11.8.0"}/styles/default.css`,
170
+ ].map(path => buildCSSItem(path));
168
171
  const config = {
169
172
  versions: {
170
173
  hljs: "11.8.0"
171
174
  },
175
+ preloadScripts,
172
176
  styles
173
177
  };
178
+
174
179
  const plugin = definePlugin({
175
180
  name,
176
181
  config,
@@ -459,7 +464,7 @@ class Transformer {
459
464
  }
460
465
 
461
466
  const transformerVersions = {
462
- 'markmap-lib': '0.15.1',
467
+ 'markmap-lib': '0.15.2-alpha.1+6800b6d',
463
468
  d3: "7.8.5"
464
469
  };
465
470
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markmap-lib",
3
- "version": "0.15.1",
3
+ "version": "0.15.2-alpha.1+6800b6d",
4
4
  "description": "Visualize your Markdown as mindmaps with Markmap",
5
5
  "author": "Gerald <gera2ld@live.com>",
6
6
  "license": "MIT",
@@ -47,6 +47,7 @@
47
47
  "url": "https://github.com/markmap/markmap/issues"
48
48
  },
49
49
  "devDependencies": {
50
+ "@highlightjs/cdn-assets": "^11.8.0",
50
51
  "@types/remarkable": "^2.0.3",
51
52
  "markmap-common": "0.15.0",
52
53
  "markmap-view": "0.15.0",
@@ -74,5 +75,5 @@
74
75
  ]
75
76
  }
76
77
  },
77
- "gitHead": "66edd3e66f16930d15d763ec0ea7239372f3b9c8"
78
+ "gitHead": "6800b6db7cde4b2a27175091eeccc8abbf7fadba"
78
79
  }
@@ -0,0 +1,2 @@
1
+ declare const plugin: import("../types").ITransformPlugin;
2
+ export default plugin;
@@ -0,0 +1,8 @@
1
+ export declare const name = "hljs";
2
+ export declare const config: {
3
+ versions: {
4
+ hljs: string;
5
+ };
6
+ preloadScripts: import("markmap-common").JSScriptItem[];
7
+ styles: import("markmap-common").CSSStylesheetItem[];
8
+ };