markmap-lib 0.13.3-alpha.2 → 0.13.4

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,4 +1,4 @@
1
- /*! markmap-lib v0.13.3-alpha.2+a5a159b | MIT License */
1
+ /*! markmap-lib v0.13.4 | MIT License */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('katex')) :
4
4
  typeof define === 'function' && define.amd ? define(['exports', 'katex'], factory) :
@@ -27,7 +27,7 @@ function _extends$1() {
27
27
  return _extends$1.apply(this, arguments);
28
28
  }
29
29
 
30
- /*! markmap-common v0.13.3-alpha.2+a5a159b | MIT License */
30
+ /*! markmap-common v0.13.4 | MIT License */
31
31
  class Hook {
32
32
  constructor() {
33
33
  this.listeners = [];
@@ -138,7 +138,7 @@ function persistJS(items, context) {
138
138
  } = _item$data,
139
139
  rest = _objectWithoutPropertiesLoose(_item$data, _excluded);
140
140
 
141
- return wrapHtml('script', textContent, rest);
141
+ return wrapHtml('script', textContent || '', rest);
142
142
  }
143
143
 
144
144
  if (item.type === 'iife') {
@@ -278,7 +278,7 @@ async function loadJS(items, context) {
278
278
  }
279
279
 
280
280
  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";
281
- const BASE_JS = [`https://cdn.jsdelivr.net/npm/d3@${"6.7.0"}`, `https://cdn.jsdelivr.net/npm/markmap-view@${"0.13.3-alpha.2+a5a159b"}`].map(src => ({
281
+ const BASE_JS = [`https://cdn.jsdelivr.net/npm/d3@${"6.7.0"}`, `https://cdn.jsdelivr.net/npm/markmap-view@${"0.13.4"}`].map(src => ({
282
282
  type: 'script',
283
283
  data: {
284
284
  src
@@ -8243,7 +8243,7 @@ var commonmarkConfig = {
8243
8243
  * Preset configs
8244
8244
  */
8245
8245
 
8246
- var config = {
8246
+ var config$2 = {
8247
8247
  'default': defaultConfig,
8248
8248
  'full': fullConfig,
8249
8249
  'commonmark': commonmarkConfig
@@ -8292,7 +8292,7 @@ function Remarkable(preset, options) {
8292
8292
  this.renderer = new Renderer();
8293
8293
  this.ruler = new Ruler();
8294
8294
  this.options = {};
8295
- this.configure(config[preset]);
8295
+ this.configure(config$2[preset]);
8296
8296
  this.set(options || {});
8297
8297
  }
8298
8298
  /**
@@ -8610,7 +8610,7 @@ const rkatex = (md, options) => {
8610
8610
 
8611
8611
  var remarkableKatex = rkatex;
8612
8612
 
8613
- var options$1 = {
8613
+ var config$1 = {
8614
8614
  preloadScripts: [{
8615
8615
  type: 'script',
8616
8616
  data: {
@@ -8656,7 +8656,7 @@ var options$1 = {
8656
8656
  let loading$1;
8657
8657
 
8658
8658
  const autoload$1 = () => {
8659
- loading$1 || (loading$1 = loadJS(options$1.preloadScripts));
8659
+ loading$1 || (loading$1 = loadJS(config$1.preloadScripts));
8660
8660
  return loading$1;
8661
8661
  };
8662
8662
  const name$2 = 'katex';
@@ -8696,19 +8696,19 @@ function transform$2(transformHooks) {
8696
8696
  };
8697
8697
  });
8698
8698
  return {
8699
- styles: options$1.styles,
8700
- scripts: options$1.scripts
8699
+ styles: config$1.styles,
8700
+ scripts: config$1.scripts
8701
8701
  };
8702
8702
  }
8703
8703
 
8704
8704
  var katex = /*#__PURE__*/Object.freeze({
8705
8705
  __proto__: null,
8706
- options: options$1,
8706
+ config: config$1,
8707
8707
  name: name$2,
8708
8708
  transform: transform$2
8709
8709
  });
8710
8710
 
8711
- var options = {
8711
+ var config = {
8712
8712
  preloadScripts: [{
8713
8713
  type: 'script',
8714
8714
  data: {
@@ -8731,7 +8731,7 @@ var options = {
8731
8731
  let loading;
8732
8732
 
8733
8733
  const autoload = () => {
8734
- loading || (loading = loadJS(options.preloadScripts));
8734
+ loading || (loading = loadJS(config.preloadScripts));
8735
8735
  return loading;
8736
8736
  };
8737
8737
 
@@ -8772,13 +8772,13 @@ function transform$1(transformHooks) {
8772
8772
  };
8773
8773
  });
8774
8774
  return {
8775
- styles: options.styles
8775
+ styles: config.styles
8776
8776
  };
8777
8777
  }
8778
8778
 
8779
8779
  var prism = /*#__PURE__*/Object.freeze({
8780
8780
  __proto__: null,
8781
- options: options,
8781
+ config: config,
8782
8782
  name: name$1,
8783
8783
  transform: transform$1
8784
8784
  });
@@ -12681,7 +12681,7 @@ function createTransformHooks() {
12681
12681
 
12682
12682
  const plugins = [katex, prism, frontmatter];
12683
12683
 
12684
- function cleanNode(node, depth = 0) {
12684
+ function cleanNode(node) {
12685
12685
  if (node.type === 'heading') {
12686
12686
  // drop all paragraphs
12687
12687
  node.children = node.children.filter(item => item.type !== 'paragraph');
@@ -12722,14 +12722,21 @@ function cleanNode(node, depth = 0) {
12722
12722
  if (node.children.length === 0) {
12723
12723
  delete node.children;
12724
12724
  } else {
12725
- node.children.forEach(child => cleanNode(child, depth + 1));
12725
+ node.children.forEach(child => cleanNode(child));
12726
12726
 
12727
12727
  if (node.children.length === 1 && !node.children[0].content) {
12728
12728
  node.children = node.children[0].children;
12729
12729
  }
12730
12730
  }
12731
+ }
12732
+
12733
+ function resetDepth(node, depth = 0) {
12734
+ var _node$children;
12731
12735
 
12732
12736
  node.depth = depth;
12737
+ (_node$children = node.children) == null ? void 0 : _node$children.forEach(child => {
12738
+ resetDepth(child, depth + 1);
12739
+ });
12733
12740
  }
12734
12741
 
12735
12742
  class Transformer {
@@ -12825,10 +12832,10 @@ class Transformer {
12825
12832
  } else if (token.type === 'inline') {
12826
12833
  const revoke = this.hooks.htmltag.tap(ctx => {
12827
12834
  const comment = ctx.result.match(/^<!--([\s\S]*?)-->$/);
12828
- const data = comment == null ? void 0 : comment[1].trim();
12835
+ const data = comment == null ? void 0 : comment[1].trim().split(' ');
12829
12836
 
12830
- if (data === 'fold') {
12831
- current.payload.fold = true;
12837
+ if (data[0] === 'fold') {
12838
+ current.payload.fold = ['all', 'recursively'].includes(data[1]) ? 2 : 1;
12832
12839
  ctx.result = '';
12833
12840
  }
12834
12841
  });
@@ -12863,6 +12870,7 @@ class Transformer {
12863
12870
  let root = this.buildTree(tokens);
12864
12871
  cleanNode(root);
12865
12872
  if (((_root$children = root.children) == null ? void 0 : _root$children.length) === 1) root = root.children[0];
12873
+ resetDepth(root);
12866
12874
  return _extends$1({}, context, {
12867
12875
  root
12868
12876
  });