markmap-lib 0.15.1 → 0.15.2-alpha.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.
@@ -1,9 +1,9 @@
1
- /*! markmap-lib v0.15.1 | MIT License */
1
+ /*! markmap-lib v0.15.2-alpha.0+3e3da98 | 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`];
@@ -11032,17 +11032,33 @@ const config = {
11032
11032
  },
11033
11033
  styles
11034
11034
  };
11035
+
11035
11036
  const plugin = definePlugin({
11036
11037
  name,
11037
11038
  config,
11038
11039
  transform(transformHooks) {
11039
- var _plugin$config;
11040
+ var _plugin$config, _plugin$config2;
11041
+ let loading;
11042
+ const preloadScripts = ((_plugin$config = plugin.config) == null || (_plugin$config = _plugin$config.preloadScripts) == null ? void 0 : _plugin$config.map(item => patchJSItem(transformHooks.transformer, item))) || [];
11043
+ const autoload = () => {
11044
+ loading || (loading = loadJS(preloadScripts));
11045
+ return loading;
11046
+ };
11040
11047
  let enableFeature = noop;
11041
11048
  transformHooks.parser.tap(md => {
11042
11049
  md.set({
11043
11050
  highlight: (str, language) => {
11044
11051
  enableFeature();
11045
- return hljs.highlightAuto(str, language ? [language] : undefined).value;
11052
+ const {
11053
+ hljs
11054
+ } = window;
11055
+ if (hljs) {
11056
+ return hljs.highlightAuto(str, language ? [language] : undefined).value;
11057
+ }
11058
+ autoload().then(() => {
11059
+ transformHooks.retransform.call();
11060
+ });
11061
+ return str;
11046
11062
  }
11047
11063
  });
11048
11064
  });
@@ -11052,7 +11068,7 @@ const plugin = definePlugin({
11052
11068
  };
11053
11069
  });
11054
11070
  return {
11055
- styles: (_plugin$config = plugin.config) == null ? void 0 : _plugin$config.styles
11071
+ styles: (_plugin$config2 = plugin.config) == null ? void 0 : _plugin$config2.styles
11056
11072
  };
11057
11073
  }
11058
11074
  });
@@ -11299,7 +11315,7 @@ class Transformer {
11299
11315
  }
11300
11316
 
11301
11317
  const transformerVersions = {
11302
- 'markmap-lib': '0.15.1',
11318
+ 'markmap-lib': '0.15.2-alpha.0+3e3da98',
11303
11319
  d3: "7.8.5"
11304
11320
  };
11305
11321
 
@@ -1,10 +1,9 @@
1
- /*! markmap-lib v0.15.1 | MIT License */
1
+ /*! markmap-lib v0.15.2-alpha.0+3e3da98 | 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`];
@@ -244,17 +243,33 @@ const config = {
244
243
  },
245
244
  styles
246
245
  };
246
+
247
247
  const plugin = definePlugin({
248
248
  name,
249
249
  config,
250
250
  transform(transformHooks) {
251
- var _plugin$config;
251
+ var _plugin$config, _plugin$config2;
252
+ let loading;
253
+ const preloadScripts = ((_plugin$config = plugin.config) == null || (_plugin$config = _plugin$config.preloadScripts) == null ? void 0 : _plugin$config.map(item => patchJSItem(transformHooks.transformer, item))) || [];
254
+ const autoload = () => {
255
+ loading || (loading = loadJS(preloadScripts));
256
+ return loading;
257
+ };
252
258
  let enableFeature = noop;
253
259
  transformHooks.parser.tap(md => {
254
260
  md.set({
255
261
  highlight: (str, language) => {
256
262
  enableFeature();
257
- return hljs.highlightAuto(str, language ? [language] : undefined).value;
263
+ const {
264
+ hljs
265
+ } = window;
266
+ if (hljs) {
267
+ return hljs.highlightAuto(str, language ? [language] : undefined).value;
268
+ }
269
+ autoload().then(() => {
270
+ transformHooks.retransform.call();
271
+ });
272
+ return str;
258
273
  }
259
274
  });
260
275
  });
@@ -264,7 +279,7 @@ const plugin = definePlugin({
264
279
  };
265
280
  });
266
281
  return {
267
- styles: (_plugin$config = plugin.config) == null ? void 0 : _plugin$config.styles
282
+ styles: (_plugin$config2 = plugin.config) == null ? void 0 : _plugin$config2.styles
268
283
  };
269
284
  }
270
285
  });
@@ -511,7 +526,7 @@ class Transformer {
511
526
  }
512
527
 
513
528
  const transformerVersions = {
514
- 'markmap-lib': '0.15.1',
529
+ 'markmap-lib': '0.15.2-alpha.0+3e3da98',
515
530
  d3: "7.8.5"
516
531
  };
517
532
 
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! markmap-lib v0.15.1 | MIT License */
1
+ /*! markmap-lib v0.15.2-alpha.0+3e3da98 | MIT License */
2
2
  'use strict';
3
3
 
4
4
  var _extends = require('@babel/runtime/helpers/extends');
@@ -173,6 +173,7 @@ const config = {
173
173
  },
174
174
  styles
175
175
  };
176
+
176
177
  const plugin = definePlugin({
177
178
  name,
178
179
  config,
@@ -461,7 +462,7 @@ class Transformer {
461
462
  }
462
463
 
463
464
  const transformerVersions = {
464
- 'markmap-lib': '0.15.1',
465
+ 'markmap-lib': '0.15.2-alpha.0+3e3da98',
465
466
  d3: "7.8.5"
466
467
  };
467
468
 
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! markmap-lib v0.15.1 | MIT License */
1
+ /*! markmap-lib v0.15.2-alpha.0+3e3da98 | 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';
@@ -171,6 +171,7 @@ const config = {
171
171
  },
172
172
  styles
173
173
  };
174
+
174
175
  const plugin = definePlugin({
175
176
  name,
176
177
  config,
@@ -459,7 +460,7 @@ class Transformer {
459
460
  }
460
461
 
461
462
  const transformerVersions = {
462
- 'markmap-lib': '0.15.1',
463
+ 'markmap-lib': '0.15.2-alpha.0+3e3da98',
463
464
  d3: "7.8.5"
464
465
  };
465
466
 
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.0+3e3da98",
4
4
  "description": "Visualize your Markdown as mindmaps with Markmap",
5
5
  "author": "Gerald <gera2ld@live.com>",
6
6
  "license": "MIT",
@@ -74,5 +74,5 @@
74
74
  ]
75
75
  }
76
76
  },
77
- "gitHead": "66edd3e66f16930d15d763ec0ea7239372f3b9c8"
77
+ "gitHead": "3e3da98311de8c23efd74f08919a960fa87956b8"
78
78
  }
@@ -0,0 +1,2 @@
1
+ declare const plugin: import("../types").ITransformPlugin;
2
+ export default plugin;
@@ -0,0 +1,7 @@
1
+ export declare const name = "hljs";
2
+ export declare const config: {
3
+ versions: {
4
+ hljs: string;
5
+ };
6
+ styles: import("markmap-common").CSSStylesheetItem[];
7
+ };