markmap-view 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/browser/index.js +60 -117
- package/dist/index.js +20 -40
- package/package.json +2 -2
package/dist/browser/index.js
CHANGED
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
}
|
|
11
11
|
revoke(fn) {
|
|
12
12
|
const i = this.listeners.indexOf(fn);
|
|
13
|
-
if (i >= 0)
|
|
14
|
-
this.listeners.splice(i, 1);
|
|
13
|
+
if (i >= 0) this.listeners.splice(i, 1);
|
|
15
14
|
}
|
|
16
15
|
revokeAll() {
|
|
17
16
|
this.listeners.splice(0);
|
|
@@ -44,8 +43,7 @@
|
|
|
44
43
|
function addClass(className, ...rest) {
|
|
45
44
|
const classList = (className || "").split(" ").filter(Boolean);
|
|
46
45
|
rest.forEach((item) => {
|
|
47
|
-
if (item && classList.indexOf(item) < 0)
|
|
48
|
-
classList.push(item);
|
|
46
|
+
if (item && classList.indexOf(item) < 0) classList.push(item);
|
|
49
47
|
});
|
|
50
48
|
return classList.join(" ");
|
|
51
49
|
}
|
|
@@ -57,8 +55,7 @@
|
|
|
57
55
|
const filterFn = filter;
|
|
58
56
|
return function selector() {
|
|
59
57
|
let nodes = Array.from(this.childNodes);
|
|
60
|
-
if (filterFn)
|
|
61
|
-
nodes = nodes.filter((node) => filterFn(node));
|
|
58
|
+
if (filterFn) nodes = nodes.filter((node) => filterFn(node));
|
|
62
59
|
return nodes;
|
|
63
60
|
};
|
|
64
61
|
}
|
|
@@ -96,8 +93,7 @@
|
|
|
96
93
|
}
|
|
97
94
|
function run() {
|
|
98
95
|
reset();
|
|
99
|
-
if (state.args)
|
|
100
|
-
state.result = fn(...state.args);
|
|
96
|
+
if (state.args) state.result = fn(...state.args);
|
|
101
97
|
}
|
|
102
98
|
return function debounced(...args) {
|
|
103
99
|
reset();
|
|
@@ -127,12 +123,9 @@
|
|
|
127
123
|
}
|
|
128
124
|
function jsx$1(type, props) {
|
|
129
125
|
let vtype;
|
|
130
|
-
if (typeof type === "string")
|
|
131
|
-
|
|
132
|
-
else
|
|
133
|
-
vtype = VTYPE_FUNCTION$1;
|
|
134
|
-
else
|
|
135
|
-
throw new Error("Invalid VNode type");
|
|
126
|
+
if (typeof type === "string") vtype = VTYPE_ELEMENT$1;
|
|
127
|
+
else if (typeof type === "function") vtype = VTYPE_FUNCTION$1;
|
|
128
|
+
else throw new Error("Invalid VNode type");
|
|
136
129
|
return {
|
|
137
130
|
vtype,
|
|
138
131
|
type,
|
|
@@ -146,22 +139,18 @@
|
|
|
146
139
|
isSvg: false
|
|
147
140
|
};
|
|
148
141
|
function insertDom$1(parent, nodes) {
|
|
149
|
-
if (!Array.isArray(nodes))
|
|
150
|
-
nodes = [nodes];
|
|
142
|
+
if (!Array.isArray(nodes)) nodes = [nodes];
|
|
151
143
|
nodes = nodes.filter(Boolean);
|
|
152
|
-
if (nodes.length)
|
|
153
|
-
parent.append(...nodes);
|
|
144
|
+
if (nodes.length) parent.append(...nodes);
|
|
154
145
|
}
|
|
155
146
|
function mountAttributes$1(domElement, props, env) {
|
|
156
147
|
for (const key in props) {
|
|
157
|
-
if (key === "key" || key === "children" || key === "ref")
|
|
158
|
-
continue;
|
|
148
|
+
if (key === "key" || key === "children" || key === "ref") continue;
|
|
159
149
|
if (key === "dangerouslySetInnerHTML") {
|
|
160
150
|
domElement.innerHTML = props[key].__html;
|
|
161
151
|
} else if (key === "innerHTML" || key === "textContent" || key === "innerText" || key === "value" && ["textarea", "select"].includes(domElement.tagName)) {
|
|
162
152
|
const value = props[key];
|
|
163
|
-
if (value != null)
|
|
164
|
-
domElement[key] = value;
|
|
153
|
+
if (value != null) domElement[key] = value;
|
|
165
154
|
} else if (key.startsWith("on")) {
|
|
166
155
|
domElement[key.toLowerCase()] = props[key];
|
|
167
156
|
} else {
|
|
@@ -245,14 +234,12 @@
|
|
|
245
234
|
});
|
|
246
235
|
}
|
|
247
236
|
const children = mountChildren$1(props.children, childEnv);
|
|
248
|
-
if (children != null)
|
|
249
|
-
insertDom$1(node, children);
|
|
237
|
+
if (children != null) insertDom$1(node, children);
|
|
250
238
|
}
|
|
251
239
|
const {
|
|
252
240
|
ref
|
|
253
241
|
} = props;
|
|
254
|
-
if (typeof ref === "function")
|
|
255
|
-
ref(node);
|
|
242
|
+
if (typeof ref === "function") ref(node);
|
|
256
243
|
return node;
|
|
257
244
|
}
|
|
258
245
|
throw new Error("mount: Invalid Vnode!");
|
|
@@ -309,8 +296,7 @@
|
|
|
309
296
|
if (!item.loaded) {
|
|
310
297
|
const deferred = defer();
|
|
311
298
|
item.loaded = deferred.promise;
|
|
312
|
-
if (url)
|
|
313
|
-
cssCache[url] = item.loaded;
|
|
299
|
+
if (url) cssCache[url] = item.loaded;
|
|
314
300
|
if (item.type === "style") {
|
|
315
301
|
document.head.append(
|
|
316
302
|
hm("style", {
|
|
@@ -326,8 +312,7 @@
|
|
|
326
312
|
})
|
|
327
313
|
);
|
|
328
314
|
fetch(url).then((res) => {
|
|
329
|
-
if (res.ok)
|
|
330
|
-
return res.text();
|
|
315
|
+
if (res.ok) return res.text();
|
|
331
316
|
throw res;
|
|
332
317
|
}).then(() => deferred.resolve(), deferred.reject);
|
|
333
318
|
}
|
|
@@ -412,14 +397,12 @@
|
|
|
412
397
|
];
|
|
413
398
|
numberKeys.forEach((key) => {
|
|
414
399
|
const value = options[key];
|
|
415
|
-
if (typeof value === "number")
|
|
416
|
-
derivedOptions[key] = value;
|
|
400
|
+
if (typeof value === "number") derivedOptions[key] = value;
|
|
417
401
|
});
|
|
418
402
|
const booleanKeys = ["zoom", "pan"];
|
|
419
403
|
booleanKeys.forEach((key) => {
|
|
420
404
|
const value = options[key];
|
|
421
|
-
if (value != null)
|
|
422
|
-
derivedOptions[key] = !!value;
|
|
405
|
+
if (value != null) derivedOptions[key] = !!value;
|
|
423
406
|
});
|
|
424
407
|
return derivedOptions;
|
|
425
408
|
}
|
|
@@ -438,12 +421,9 @@
|
|
|
438
421
|
const isRenderFunction = (c) => (c == null ? void 0 : c.vtype) === VTYPE_FUNCTION;
|
|
439
422
|
function jsx(type, props) {
|
|
440
423
|
let vtype;
|
|
441
|
-
if (typeof type === "string")
|
|
442
|
-
|
|
443
|
-
else
|
|
444
|
-
vtype = VTYPE_FUNCTION;
|
|
445
|
-
else
|
|
446
|
-
throw new Error("Invalid VNode type");
|
|
424
|
+
if (typeof type === "string") vtype = VTYPE_ELEMENT;
|
|
425
|
+
else if (typeof type === "function") vtype = VTYPE_FUNCTION;
|
|
426
|
+
else throw new Error("Invalid VNode type");
|
|
447
427
|
return {
|
|
448
428
|
vtype,
|
|
449
429
|
type,
|
|
@@ -457,22 +437,18 @@
|
|
|
457
437
|
isSvg: false
|
|
458
438
|
};
|
|
459
439
|
function insertDom(parent, nodes) {
|
|
460
|
-
if (!Array.isArray(nodes))
|
|
461
|
-
nodes = [nodes];
|
|
440
|
+
if (!Array.isArray(nodes)) nodes = [nodes];
|
|
462
441
|
nodes = nodes.filter(Boolean);
|
|
463
|
-
if (nodes.length)
|
|
464
|
-
parent.append(...nodes);
|
|
442
|
+
if (nodes.length) parent.append(...nodes);
|
|
465
443
|
}
|
|
466
444
|
function mountAttributes(domElement, props, env) {
|
|
467
445
|
for (const key in props) {
|
|
468
|
-
if (key === "key" || key === "children" || key === "ref")
|
|
469
|
-
continue;
|
|
446
|
+
if (key === "key" || key === "children" || key === "ref") continue;
|
|
470
447
|
if (key === "dangerouslySetInnerHTML") {
|
|
471
448
|
domElement.innerHTML = props[key].__html;
|
|
472
449
|
} else if (key === "innerHTML" || key === "textContent" || key === "innerText" || key === "value" && ["textarea", "select"].includes(domElement.tagName)) {
|
|
473
450
|
const value = props[key];
|
|
474
|
-
if (value != null)
|
|
475
|
-
domElement[key] = value;
|
|
451
|
+
if (value != null) domElement[key] = value;
|
|
476
452
|
} else if (key.startsWith("on")) {
|
|
477
453
|
domElement[key.toLowerCase()] = props[key];
|
|
478
454
|
} else {
|
|
@@ -556,14 +532,12 @@
|
|
|
556
532
|
});
|
|
557
533
|
}
|
|
558
534
|
const children = mountChildren(props.children, childEnv);
|
|
559
|
-
if (children != null)
|
|
560
|
-
insertDom(node, children);
|
|
535
|
+
if (children != null) insertDom(node, children);
|
|
561
536
|
}
|
|
562
537
|
const {
|
|
563
538
|
ref
|
|
564
539
|
} = props;
|
|
565
|
-
if (typeof ref === "function")
|
|
566
|
-
ref(node);
|
|
540
|
+
if (typeof ref === "function") ref(node);
|
|
567
541
|
return node;
|
|
568
542
|
}
|
|
569
543
|
throw new Error("mount: Invalid Vnode!");
|
|
@@ -573,11 +547,8 @@
|
|
|
573
547
|
}
|
|
574
548
|
function count(node) {
|
|
575
549
|
var sum = 0, children = node.children, i = children && children.length;
|
|
576
|
-
if (!i)
|
|
577
|
-
|
|
578
|
-
else
|
|
579
|
-
while (--i >= 0)
|
|
580
|
-
sum += children[i].value;
|
|
550
|
+
if (!i) sum = 1;
|
|
551
|
+
else while (--i >= 0) sum += children[i].value;
|
|
581
552
|
node.value = sum;
|
|
582
553
|
}
|
|
583
554
|
function node_count() {
|
|
@@ -589,10 +560,9 @@
|
|
|
589
560
|
current = next.reverse(), next = [];
|
|
590
561
|
while (node = current.pop()) {
|
|
591
562
|
callback(node), children = node.children;
|
|
592
|
-
if (children)
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
}
|
|
563
|
+
if (children) for (i = 0, n = children.length; i < n; ++i) {
|
|
564
|
+
next.push(children[i]);
|
|
565
|
+
}
|
|
596
566
|
}
|
|
597
567
|
} while (next.length);
|
|
598
568
|
return this;
|
|
@@ -601,10 +571,9 @@
|
|
|
601
571
|
var node = this, nodes = [node], children, i;
|
|
602
572
|
while (node = nodes.pop()) {
|
|
603
573
|
callback(node), children = node.children;
|
|
604
|
-
if (children)
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
}
|
|
574
|
+
if (children) for (i = children.length - 1; i >= 0; --i) {
|
|
575
|
+
nodes.push(children[i]);
|
|
576
|
+
}
|
|
608
577
|
}
|
|
609
578
|
return this;
|
|
610
579
|
}
|
|
@@ -612,10 +581,9 @@
|
|
|
612
581
|
var node = this, nodes = [node], next = [], children, i, n;
|
|
613
582
|
while (node = nodes.pop()) {
|
|
614
583
|
next.push(node), children = node.children;
|
|
615
|
-
if (children)
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
}
|
|
584
|
+
if (children) for (i = 0, n = children.length; i < n; ++i) {
|
|
585
|
+
nodes.push(children[i]);
|
|
586
|
+
}
|
|
619
587
|
}
|
|
620
588
|
while (node = next.pop()) {
|
|
621
589
|
callback(node);
|
|
@@ -625,8 +593,7 @@
|
|
|
625
593
|
function node_sum(value) {
|
|
626
594
|
return this.eachAfter(function(node) {
|
|
627
595
|
var sum = +value(node.data) || 0, children = node.children, i = children && children.length;
|
|
628
|
-
while (--i >= 0)
|
|
629
|
-
sum += children[i].value;
|
|
596
|
+
while (--i >= 0) sum += children[i].value;
|
|
630
597
|
node.value = sum;
|
|
631
598
|
});
|
|
632
599
|
}
|
|
@@ -651,8 +618,7 @@
|
|
|
651
618
|
return nodes;
|
|
652
619
|
}
|
|
653
620
|
function leastCommonAncestor(a, b) {
|
|
654
|
-
if (a === b)
|
|
655
|
-
return a;
|
|
621
|
+
if (a === b) return a;
|
|
656
622
|
var aNodes = a.ancestors(), bNodes = b.ancestors(), c = null;
|
|
657
623
|
a = aNodes.pop();
|
|
658
624
|
b = bNodes.pop();
|
|
@@ -697,11 +663,9 @@
|
|
|
697
663
|
}
|
|
698
664
|
function hierarchy(data, children) {
|
|
699
665
|
var root = new Node$1(data), valued = +data.value && (root.value = data.value), node, nodes = [root], child, childs, i, n;
|
|
700
|
-
if (children == null)
|
|
701
|
-
children = defaultChildren;
|
|
666
|
+
if (children == null) children = defaultChildren;
|
|
702
667
|
while (node = nodes.pop()) {
|
|
703
|
-
if (valued)
|
|
704
|
-
node.value = +node.data.value;
|
|
668
|
+
if (valued) node.value = +node.data.value;
|
|
705
669
|
if ((childs = children(node.data)) && (n = childs.length)) {
|
|
706
670
|
node.children = new Array(n);
|
|
707
671
|
for (i = n - 1; i >= 0; --i) {
|
|
@@ -1032,8 +996,7 @@
|
|
|
1032
996
|
const [i, lastLows] = acc;
|
|
1033
997
|
layoutChildren(kid, w.y + w.ySize);
|
|
1034
998
|
const lowY = (i === 0 ? kid.lExt : kid.rExt).bottom;
|
|
1035
|
-
if (i !== 0)
|
|
1036
|
-
separate(w, i, lastLows);
|
|
999
|
+
if (i !== 0) separate(w, i, lastLows);
|
|
1037
1000
|
const lows = updateLows(lowY, i, lastLows);
|
|
1038
1001
|
return [i + 1, lows];
|
|
1039
1002
|
}, [0, null]);
|
|
@@ -1071,8 +1034,7 @@
|
|
|
1071
1034
|
let lSumMods = curSubtree.relX;
|
|
1072
1035
|
let isFirst = true;
|
|
1073
1036
|
while (rContour && lContour) {
|
|
1074
|
-
if (rContour.bottom > lows.lowY)
|
|
1075
|
-
lows = lows.next;
|
|
1037
|
+
if (rContour.bottom > lows.lowY) lows = lows.next;
|
|
1076
1038
|
const dist = rSumMods + rContour.prelim - (lSumMods + lContour.prelim) + rContour.xSize / 2 + lContour.xSize / 2 + rContour.spacing(lContour);
|
|
1077
1039
|
if (dist > 0 || dist < 0 && isFirst) {
|
|
1078
1040
|
lSumMods += dist;
|
|
@@ -1084,19 +1046,15 @@
|
|
|
1084
1046
|
const leftBottom = lContour.bottom;
|
|
1085
1047
|
if (rightBottom <= leftBottom) {
|
|
1086
1048
|
rContour = nextRContour(rContour);
|
|
1087
|
-
if (rContour)
|
|
1088
|
-
rSumMods += rContour.relX;
|
|
1049
|
+
if (rContour) rSumMods += rContour.relX;
|
|
1089
1050
|
}
|
|
1090
1051
|
if (rightBottom >= leftBottom) {
|
|
1091
1052
|
lContour = nextLContour(lContour);
|
|
1092
|
-
if (lContour)
|
|
1093
|
-
lSumMods += lContour.relX;
|
|
1053
|
+
if (lContour) lSumMods += lContour.relX;
|
|
1094
1054
|
}
|
|
1095
1055
|
}
|
|
1096
|
-
if (!rContour && lContour)
|
|
1097
|
-
|
|
1098
|
-
else if (rContour && !lContour)
|
|
1099
|
-
setRThr(w, i, rContour, rSumMods);
|
|
1056
|
+
if (!rContour && lContour) setLThr(w, i, lContour, lSumMods);
|
|
1057
|
+
else if (rContour && !lContour) setRThr(w, i, rContour, rSumMods);
|
|
1100
1058
|
};
|
|
1101
1059
|
const moveSubtree = (subtree, distance) => {
|
|
1102
1060
|
subtree.relX += distance;
|
|
@@ -1199,16 +1157,14 @@
|
|
|
1199
1157
|
};
|
|
1200
1158
|
this.handleClick = (e, d) => {
|
|
1201
1159
|
let recursive = this.options.toggleRecursively;
|
|
1202
|
-
if (isMacintosh ? e.metaKey : e.ctrlKey)
|
|
1203
|
-
recursive = !recursive;
|
|
1160
|
+
if (isMacintosh ? e.metaKey : e.ctrlKey) recursive = !recursive;
|
|
1204
1161
|
this.toggleNode(d.data, recursive);
|
|
1205
1162
|
};
|
|
1206
1163
|
this.svg = svg.datum ? svg : d32.select(svg);
|
|
1207
1164
|
this.styleNode = this.svg.append("style");
|
|
1208
1165
|
this.zoom = d32.zoom().filter((event) => {
|
|
1209
1166
|
if (this.options.scrollForPan) {
|
|
1210
|
-
if (event.type === "wheel")
|
|
1211
|
-
return event.ctrlKey && !event.button;
|
|
1167
|
+
if (event.type === "wheel") return event.ctrlKey && !event.button;
|
|
1212
1168
|
}
|
|
1213
1169
|
return (!event.ctrlKey || event.type === "wheel") && !event.button;
|
|
1214
1170
|
}).on("zoom", this.handleZoom);
|
|
@@ -1306,8 +1262,7 @@
|
|
|
1306
1262
|
item.payload = { ...item.payload, fold: 1 };
|
|
1307
1263
|
}
|
|
1308
1264
|
next();
|
|
1309
|
-
if (isFoldRecursively)
|
|
1310
|
-
foldRecursively -= 1;
|
|
1265
|
+
if (isFoldRecursively) foldRecursively -= 1;
|
|
1311
1266
|
depth -= 1;
|
|
1312
1267
|
});
|
|
1313
1268
|
const nodes = Array.from(container.childNodes).map(
|
|
@@ -1336,8 +1291,7 @@
|
|
|
1336
1291
|
}
|
|
1337
1292
|
_checkImages(container) {
|
|
1338
1293
|
container.querySelectorAll("img").forEach((img) => {
|
|
1339
|
-
if (img.width)
|
|
1340
|
-
return;
|
|
1294
|
+
if (img.width) return;
|
|
1341
1295
|
const size = this.imgCache[img.src];
|
|
1342
1296
|
if (size == null ? void 0 : size[0]) {
|
|
1343
1297
|
[img.width, img.height] = size;
|
|
@@ -1372,24 +1326,19 @@
|
|
|
1372
1326
|
}
|
|
1373
1327
|
}
|
|
1374
1328
|
setData(data, opts) {
|
|
1375
|
-
if (opts)
|
|
1376
|
-
|
|
1377
|
-
if (data)
|
|
1378
|
-
this.state.data = data;
|
|
1379
|
-
if (!this.state.data)
|
|
1380
|
-
return;
|
|
1329
|
+
if (opts) this.setOptions(opts);
|
|
1330
|
+
if (data) this.state.data = data;
|
|
1331
|
+
if (!this.state.data) return;
|
|
1381
1332
|
this.initializeData(this.state.data);
|
|
1382
1333
|
this.updateStyle();
|
|
1383
1334
|
this.renderData();
|
|
1384
1335
|
}
|
|
1385
1336
|
renderData(originData) {
|
|
1386
|
-
if (!this.state.data)
|
|
1387
|
-
return;
|
|
1337
|
+
if (!this.state.data) return;
|
|
1388
1338
|
const { spacingHorizontal, paddingX, spacingVertical, autoFit, color } = this.options;
|
|
1389
1339
|
const layout = flextree({}).children((d) => {
|
|
1390
1340
|
var _a;
|
|
1391
|
-
if (!((_a = d.payload) == null ? void 0 : _a.fold))
|
|
1392
|
-
return d.children;
|
|
1341
|
+
if (!((_a = d.payload) == null ? void 0 : _a.fold)) return d.children;
|
|
1393
1342
|
}).nodeSize((node2) => {
|
|
1394
1343
|
const [width, height] = node2.data.state.size;
|
|
1395
1344
|
return [height, width + (width ? paddingX * 2 : 0) + spacingHorizontal];
|
|
@@ -1411,14 +1360,11 @@
|
|
|
1411
1360
|
minY,
|
|
1412
1361
|
maxY
|
|
1413
1362
|
});
|
|
1414
|
-
if (autoFit)
|
|
1415
|
-
this.fit();
|
|
1363
|
+
if (autoFit) this.fit();
|
|
1416
1364
|
const origin = originData && descendants.find((item) => item.data === originData) || tree;
|
|
1417
1365
|
const x0 = origin.data.state.x0 ?? origin.x;
|
|
1418
1366
|
const y0 = origin.data.state.y0 ?? origin.y;
|
|
1419
|
-
const node = this.g.selectAll(
|
|
1420
|
-
childSelector("g")
|
|
1421
|
-
).data(descendants, (d) => d.data.state.key);
|
|
1367
|
+
const node = this.g.selectAll(childSelector("g")).data(descendants, (d) => d.data.state.key);
|
|
1422
1368
|
const nodeEnter = node.enter().append("g").attr("data-depth", (d) => d.data.state.depth).attr("data-path", (d) => d.data.state.path).attr(
|
|
1423
1369
|
"transform",
|
|
1424
1370
|
(d) => `translate(${y0 + origin.ySize - d.ySize},${x0 + origin.xSize / 2 - d.xSize})`
|
|
@@ -1562,9 +1508,7 @@
|
|
|
1562
1508
|
}
|
|
1563
1509
|
findElement(node) {
|
|
1564
1510
|
let result;
|
|
1565
|
-
this.g.selectAll(
|
|
1566
|
-
childSelector("g")
|
|
1567
|
-
).each(function walk(d) {
|
|
1511
|
+
this.g.selectAll(childSelector("g")).each(function walk(d) {
|
|
1568
1512
|
if (d.data === node) {
|
|
1569
1513
|
result = {
|
|
1570
1514
|
data: d,
|
|
@@ -1580,8 +1524,7 @@
|
|
|
1580
1524
|
async ensureView(node, padding) {
|
|
1581
1525
|
var _a;
|
|
1582
1526
|
const itemData = (_a = this.findElement(node)) == null ? void 0 : _a.data;
|
|
1583
|
-
if (!itemData)
|
|
1584
|
-
return;
|
|
1527
|
+
if (!itemData) return;
|
|
1585
1528
|
const svgNode = this.svg.node();
|
|
1586
1529
|
const { spacingHorizontal } = this.options;
|
|
1587
1530
|
const relRect = svgNode.getBoundingClientRect();
|
package/dist/index.js
CHANGED
|
@@ -67,12 +67,9 @@ const U = 1, G = 2, xt = "http://www.w3.org/2000/svg", _ = "http://www.w3.org/19
|
|
|
67
67
|
}, kt = (e) => typeof e == "string" || typeof e == "number", vt = (e) => (e == null ? void 0 : e.vtype) === U, St = (e) => (e == null ? void 0 : e.vtype) === G;
|
|
68
68
|
function j(e, t) {
|
|
69
69
|
let n;
|
|
70
|
-
if (typeof e == "string")
|
|
71
|
-
|
|
72
|
-
else
|
|
73
|
-
n = G;
|
|
74
|
-
else
|
|
75
|
-
throw new Error("Invalid VNode type");
|
|
70
|
+
if (typeof e == "string") n = U;
|
|
71
|
+
else if (typeof e == "function") n = G;
|
|
72
|
+
else throw new Error("Invalid VNode type");
|
|
76
73
|
return {
|
|
77
74
|
vtype: n,
|
|
78
75
|
type: e,
|
|
@@ -96,8 +93,7 @@ function Et(e, t, n) {
|
|
|
96
93
|
else if (i === "innerHTML" || i === "textContent" || i === "innerText" || i === "value" && ["textarea", "select"].includes(e.tagName)) {
|
|
97
94
|
const o = t[i];
|
|
98
95
|
o != null && (e[i] = o);
|
|
99
|
-
} else
|
|
100
|
-
i.startsWith("on") ? e[i.toLowerCase()] = t[i] : wt(e, i, t[i], n.isSvg);
|
|
96
|
+
} else i.startsWith("on") ? e[i.toLowerCase()] = t[i] : wt(e, i, t[i], n.isSvg);
|
|
101
97
|
}
|
|
102
98
|
const Ct = {
|
|
103
99
|
className: "class",
|
|
@@ -170,11 +166,8 @@ function O(e) {
|
|
|
170
166
|
}
|
|
171
167
|
function jt(e) {
|
|
172
168
|
var t = 0, n = e.children, i = n && n.length;
|
|
173
|
-
if (!i)
|
|
174
|
-
|
|
175
|
-
else
|
|
176
|
-
for (; --i >= 0; )
|
|
177
|
-
t += n[i].value;
|
|
169
|
+
if (!i) t = 1;
|
|
170
|
+
else for (; --i >= 0; ) t += n[i].value;
|
|
178
171
|
e.value = t;
|
|
179
172
|
}
|
|
180
173
|
function Nt() {
|
|
@@ -184,32 +177,28 @@ function Rt(e) {
|
|
|
184
177
|
var t = this, n, i = [t], o, a, c;
|
|
185
178
|
do
|
|
186
179
|
for (n = i.reverse(), i = []; t = n.pop(); )
|
|
187
|
-
if (e(t), o = t.children, o)
|
|
188
|
-
|
|
189
|
-
i.push(o[a]);
|
|
180
|
+
if (e(t), o = t.children, o) for (a = 0, c = o.length; a < c; ++a)
|
|
181
|
+
i.push(o[a]);
|
|
190
182
|
while (i.length);
|
|
191
183
|
return this;
|
|
192
184
|
}
|
|
193
185
|
function Mt(e) {
|
|
194
186
|
for (var t = this, n = [t], i, o; t = n.pop(); )
|
|
195
|
-
if (e(t), i = t.children, i)
|
|
196
|
-
|
|
197
|
-
n.push(i[o]);
|
|
187
|
+
if (e(t), i = t.children, i) for (o = i.length - 1; o >= 0; --o)
|
|
188
|
+
n.push(i[o]);
|
|
198
189
|
return this;
|
|
199
190
|
}
|
|
200
191
|
function Tt(e) {
|
|
201
192
|
for (var t = this, n = [t], i = [], o, a, c; t = n.pop(); )
|
|
202
|
-
if (i.push(t), o = t.children, o)
|
|
203
|
-
|
|
204
|
-
n.push(o[a]);
|
|
193
|
+
if (i.push(t), o = t.children, o) for (a = 0, c = o.length; a < c; ++a)
|
|
194
|
+
n.push(o[a]);
|
|
205
195
|
for (; t = i.pop(); )
|
|
206
196
|
e(t);
|
|
207
197
|
return this;
|
|
208
198
|
}
|
|
209
199
|
function At(e) {
|
|
210
200
|
return this.eachAfter(function(t) {
|
|
211
|
-
for (var n = +e(t.data) || 0, i = t.children, o = i && i.length; --o >= 0; )
|
|
212
|
-
n += i[o].value;
|
|
201
|
+
for (var n = +e(t.data) || 0, i = t.children, o = i && i.length; --o >= 0; ) n += i[o].value;
|
|
213
202
|
t.value = n;
|
|
214
203
|
});
|
|
215
204
|
}
|
|
@@ -226,8 +215,7 @@ function Ot(e) {
|
|
|
226
215
|
return i;
|
|
227
216
|
}
|
|
228
217
|
function Dt(e, t) {
|
|
229
|
-
if (e === t)
|
|
230
|
-
return e;
|
|
218
|
+
if (e === t) return e;
|
|
231
219
|
var n = e.ancestors(), i = t.ancestors(), o = null;
|
|
232
220
|
for (e = n.pop(), t = i.pop(); e === t; )
|
|
233
221
|
o = e, e = n.pop(), t = i.pop();
|
|
@@ -723,8 +711,7 @@ class et {
|
|
|
723
711
|
}
|
|
724
712
|
_checkImages(t) {
|
|
725
713
|
t.querySelectorAll("img").forEach((n) => {
|
|
726
|
-
if (n.width)
|
|
727
|
-
return;
|
|
714
|
+
if (n.width) return;
|
|
728
715
|
const i = this.imgCache[n.src];
|
|
729
716
|
i != null && i[0] ? [n.width, n.height] = i : i || this._loadImage(n.src);
|
|
730
717
|
});
|
|
@@ -746,12 +733,10 @@ class et {
|
|
|
746
733
|
n && this.setOptions(n), t && (this.state.data = t), this.state.data && (this.initializeData(this.state.data), this.updateStyle(), this.renderData());
|
|
747
734
|
}
|
|
748
735
|
renderData(t) {
|
|
749
|
-
if (!this.state.data)
|
|
750
|
-
return;
|
|
736
|
+
if (!this.state.data) return;
|
|
751
737
|
const { spacingHorizontal: n, paddingX: i, spacingVertical: o, autoFit: a, color: c } = this.options, s = q({}).children((r) => {
|
|
752
738
|
var d;
|
|
753
|
-
if (!((d = r.payload) != null && d.fold))
|
|
754
|
-
return r.children;
|
|
739
|
+
if (!((d = r.payload) != null && d.fold)) return r.children;
|
|
755
740
|
}).nodeSize((r) => {
|
|
756
741
|
const [d, S] = r.data.state.size;
|
|
757
742
|
return [S, d + (d ? i * 2 : 0) + n];
|
|
@@ -764,9 +749,7 @@ class et {
|
|
|
764
749
|
minY: m,
|
|
765
750
|
maxY: y
|
|
766
751
|
}), a && this.fit();
|
|
767
|
-
const f = t && p.find((r) => r.data === t) || l, k = f.data.state.x0 ?? f.x, v = f.data.state.y0 ?? f.y, b = this.g.selectAll(
|
|
768
|
-
C("g")
|
|
769
|
-
).data(p, (r) => r.data.state.key), w = b.enter().append("g").attr("data-depth", (r) => r.data.state.depth).attr("data-path", (r) => r.data.state.path).attr(
|
|
752
|
+
const f = t && p.find((r) => r.data === t) || l, k = f.data.state.x0 ?? f.x, v = f.data.state.y0 ?? f.y, b = this.g.selectAll(C("g")).data(p, (r) => r.data.state.key), w = b.enter().append("g").attr("data-depth", (r) => r.data.state.depth).attr("data-path", (r) => r.data.state.path).attr(
|
|
770
753
|
"transform",
|
|
771
754
|
(r) => `translate(${v + f.ySize - r.ySize},${k + f.xSize / 2 - r.xSize})`
|
|
772
755
|
), z = this.transition(b.exit());
|
|
@@ -888,9 +871,7 @@ class et {
|
|
|
888
871
|
}
|
|
889
872
|
findElement(t) {
|
|
890
873
|
let n;
|
|
891
|
-
return this.g.selectAll(
|
|
892
|
-
C("g")
|
|
893
|
-
).each(function(o) {
|
|
874
|
+
return this.g.selectAll(C("g")).each(function(o) {
|
|
894
875
|
o.data === t && (n = {
|
|
895
876
|
data: o,
|
|
896
877
|
g: this
|
|
@@ -903,8 +884,7 @@ class et {
|
|
|
903
884
|
async ensureView(t, n) {
|
|
904
885
|
var k;
|
|
905
886
|
const i = (k = this.findElement(t)) == null ? void 0 : k.data;
|
|
906
|
-
if (!i)
|
|
907
|
-
return;
|
|
887
|
+
if (!i) return;
|
|
908
888
|
const o = this.svg.node(), { spacingHorizontal: a } = this.options, c = o.getBoundingClientRect(), s = A(o), [l, p] = [
|
|
909
889
|
i.y,
|
|
910
890
|
i.y + i.ySize - a + 2
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markmap-view",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.3-alpha.1+4942a37",
|
|
4
4
|
"description": "View markmaps in browser",
|
|
5
5
|
"author": "Gerald <gera2ld@live.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"markmap-common": "*"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "4942a3759db08bbbc179034c0b08c5c2112566dc"
|
|
55
55
|
}
|