markmap-autoloader 0.17.2 → 0.17.3-alpha.2

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 (2) hide show
  1. package/dist/index.js +17 -32
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -116,12 +116,9 @@ this.markmap = this.markmap || {};
116
116
  }
117
117
  function jsx(type, props) {
118
118
  let vtype;
119
- if (typeof type === "string")
120
- vtype = VTYPE_ELEMENT;
121
- else if (typeof type === "function")
122
- vtype = VTYPE_FUNCTION;
123
- else
124
- throw new Error("Invalid VNode type");
119
+ if (typeof type === "string") vtype = VTYPE_ELEMENT;
120
+ else if (typeof type === "function") vtype = VTYPE_FUNCTION;
121
+ else throw new Error("Invalid VNode type");
125
122
  return {
126
123
  vtype,
127
124
  type,
@@ -135,22 +132,18 @@ this.markmap = this.markmap || {};
135
132
  isSvg: false
136
133
  };
137
134
  function insertDom(parent, nodes) {
138
- if (!Array.isArray(nodes))
139
- nodes = [nodes];
135
+ if (!Array.isArray(nodes)) nodes = [nodes];
140
136
  nodes = nodes.filter(Boolean);
141
- if (nodes.length)
142
- parent.append(...nodes);
137
+ if (nodes.length) parent.append(...nodes);
143
138
  }
144
139
  function mountAttributes(domElement, props, env) {
145
140
  for (const key in props) {
146
- if (key === "key" || key === "children" || key === "ref")
147
- continue;
141
+ if (key === "key" || key === "children" || key === "ref") continue;
148
142
  if (key === "dangerouslySetInnerHTML") {
149
143
  domElement.innerHTML = props[key].__html;
150
144
  } else if (key === "innerHTML" || key === "textContent" || key === "innerText" || key === "value" && ["textarea", "select"].includes(domElement.tagName)) {
151
145
  const value = props[key];
152
- if (value != null)
153
- domElement[key] = value;
146
+ if (value != null) domElement[key] = value;
154
147
  } else if (key.startsWith("on")) {
155
148
  domElement[key.toLowerCase()] = props[key];
156
149
  } else {
@@ -234,14 +227,12 @@ this.markmap = this.markmap || {};
234
227
  });
235
228
  }
236
229
  const children = mountChildren(props.children, childEnv);
237
- if (children != null)
238
- insertDom(node, children);
230
+ if (children != null) insertDom(node, children);
239
231
  }
240
232
  const {
241
233
  ref
242
234
  } = props;
243
- if (typeof ref === "function")
244
- ref(node);
235
+ if (typeof ref === "function") ref(node);
245
236
  return node;
246
237
  }
247
238
  throw new Error("mount: Invalid Vnode!");
@@ -298,8 +289,7 @@ this.markmap = this.markmap || {};
298
289
  if (!item.loaded) {
299
290
  const deferred = defer();
300
291
  item.loaded = deferred.promise;
301
- if (url)
302
- cssCache[url] = item.loaded;
292
+ if (url) cssCache[url] = item.loaded;
303
293
  if (item.type === "style") {
304
294
  document.head.append(
305
295
  hm("style", {
@@ -315,8 +305,7 @@ this.markmap = this.markmap || {};
315
305
  })
316
306
  );
317
307
  fetch(url).then((res) => {
318
- if (res.ok)
319
- return res.text();
308
+ if (res.ok) return res.text();
320
309
  throw res;
321
310
  }).then(() => deferred.resolve(), deferred.reject);
322
311
  }
@@ -360,8 +349,8 @@ this.markmap = this.markmap || {};
360
349
  const enabled = {};
361
350
  const autoLoaderOptions = {
362
351
  baseJs: [
363
- `d3@${"7.8.5"}`,
364
- `markmap-lib@${"0.17.2"}`,
352
+ `d3@${"7.9.0"}`,
353
+ `markmap-lib@${"0.17.3-alpha.2"}`,
365
354
  `markmap-view@${"0.17.2"}`,
366
355
  `markmap-toolbar@${"0.17.2"}`
367
356
  ],
@@ -412,10 +401,8 @@ this.markmap = this.markmap || {};
412
401
  });
413
402
  const { styles, scripts } = transformer.getAssets(keys);
414
403
  const { markmap } = window;
415
- if (styles)
416
- markmap.loadCSS(styles);
417
- if (scripts)
418
- markmap.loadJS(scripts);
404
+ if (styles) markmap.loadCSS(styles);
405
+ if (scripts) markmap.loadJS(scripts);
419
406
  return result;
420
407
  }
421
408
  function render(el) {
@@ -426,8 +413,7 @@ this.markmap = this.markmap || {};
426
413
  lines.forEach((line) => {
427
414
  var _a3;
428
415
  const spaces = ((_a3 = line.match(/^\s*/)) == null ? void 0 : _a3[0].length) || 0;
429
- if (spaces < line.length)
430
- indent = Math.min(indent, spaces);
416
+ if (spaces < line.length) indent = Math.min(indent, spaces);
431
417
  });
432
418
  const content = lines.map((line) => line.slice(indent)).join("\n").trim();
433
419
  const transformer = new Transformer(autoLoaderOptions.transformPlugins);
@@ -466,8 +452,7 @@ this.markmap = this.markmap || {};
466
452
  document.addEventListener("DOMContentLoaded", () => {
467
453
  renderAll();
468
454
  });
469
- else
470
- renderAll();
455
+ else renderAll();
471
456
  }
472
457
  exports.ready = ready;
473
458
  exports.render = render;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markmap-autoloader",
3
- "version": "0.17.2",
3
+ "version": "0.17.3-alpha.2+9f2920f",
4
4
  "description": "Load markmaps automatically in HTML",
5
5
  "author": "Gerald <gera2ld@live.com>",
6
6
  "license": "MIT",
@@ -39,9 +39,9 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "markmap-common": "0.17.1",
42
- "markmap-lib": "0.17.2",
42
+ "markmap-lib": "0.17.3-alpha.2+9f2920f",
43
43
  "markmap-toolbar": "0.17.2",
44
44
  "markmap-view": "0.17.2"
45
45
  },
46
- "gitHead": "bbeec32d0efeea4e36755b1909a5993187264487"
46
+ "gitHead": "9f2920fcb10e39ca7bf714c8768539bf60357752"
47
47
  }