markmap-autoloader 0.17.2 → 0.17.3-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.
- package/dist/index.js +20 -35
- package/package.json +5 -5
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
|
-
|
|
121
|
-
else
|
|
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,12 +349,12 @@ this.markmap = this.markmap || {};
|
|
|
360
349
|
const enabled = {};
|
|
361
350
|
const autoLoaderOptions = {
|
|
362
351
|
baseJs: [
|
|
363
|
-
`d3@${"7.
|
|
364
|
-
`markmap-lib@${"0.17.
|
|
365
|
-
`markmap-view@${"0.17.
|
|
366
|
-
`markmap-toolbar@${"0.17.
|
|
352
|
+
`d3@${"7.9.0"}`,
|
|
353
|
+
`markmap-lib@${"0.17.3-alpha.1"}`,
|
|
354
|
+
`markmap-view@${"0.17.3-alpha.1"}`,
|
|
355
|
+
`markmap-toolbar@${"0.17.3-alpha.1"}`
|
|
367
356
|
],
|
|
368
|
-
baseCss: [`markmap-toolbar@${"0.17.
|
|
357
|
+
baseCss: [`markmap-toolbar@${"0.17.3-alpha.1"}/dist/style.css`],
|
|
369
358
|
manual: false,
|
|
370
359
|
toolbar: false,
|
|
371
360
|
...(_a = window.markmap) == null ? void 0 : _a.autoLoader
|
|
@@ -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
|
-
|
|
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.
|
|
3
|
+
"version": "0.17.3-alpha.1+4942a37",
|
|
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.
|
|
43
|
-
"markmap-toolbar": "0.17.
|
|
44
|
-
"markmap-view": "0.17.
|
|
42
|
+
"markmap-lib": "0.17.3-alpha.1+4942a37",
|
|
43
|
+
"markmap-toolbar": "0.17.3-alpha.1+4942a37",
|
|
44
|
+
"markmap-view": "0.17.3-alpha.1+4942a37"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "4942a3759db08bbbc179034c0b08c5c2112566dc"
|
|
47
47
|
}
|