markmap-view 0.15.5 → 0.15.6-alpha.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.
- package/dist/browser/index.js +4 -1670
- package/dist/index.js +743 -1123
- package/package.json +7 -9
- /package/{types → dist}/index.d.ts +0 -0
- /package/{types → dist}/types.d.ts +0 -0
- /package/{types → dist}/view.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -1,352 +1,337 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { Hook as U, getId as at, addClass as lt, walkTree as M, childSelector as b, noop as A } from "markmap-common";
|
|
2
|
+
import { loadCSS as Ce, loadJS as we } from "markmap-common";
|
|
3
|
+
import { scaleOrdinal as G, schemeCategory10 as ct, zoomTransform as O, select as ht, zoom as dt, linkHorizontal as ut, min as I, max as W, zoomIdentity as pt, minIndex as ft } from "d3";
|
|
4
|
+
/*! @gera2ld/jsx-dom v2.2.2 | ISC License */
|
|
5
|
+
const Z = 1, J = 2, gt = "http://www.w3.org/2000/svg", H = "http://www.w3.org/1999/xlink", mt = {
|
|
6
|
+
show: H,
|
|
7
|
+
actuate: H,
|
|
8
|
+
href: H
|
|
9
|
+
}, xt = (e) => typeof e == "string" || typeof e == "number", yt = (e) => (e == null ? void 0 : e.vtype) === Z, St = (e) => (e == null ? void 0 : e.vtype) === J;
|
|
10
|
+
function N(e, t) {
|
|
11
|
+
let n;
|
|
12
|
+
if (typeof e == "string")
|
|
13
|
+
n = Z;
|
|
14
|
+
else if (typeof e == "function")
|
|
15
|
+
n = J;
|
|
16
|
+
else
|
|
17
|
+
throw new Error("Invalid VNode type");
|
|
18
|
+
return {
|
|
19
|
+
vtype: n,
|
|
20
|
+
type: e,
|
|
21
|
+
props: t
|
|
17
22
|
};
|
|
18
|
-
return _extends.apply(this, arguments);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function count(node) {
|
|
22
|
-
var sum = 0,
|
|
23
|
-
children = node.children,
|
|
24
|
-
i = children && children.length;
|
|
25
|
-
if (!i) sum = 1;else while (--i >= 0) sum += children[i].value;
|
|
26
|
-
node.value = sum;
|
|
27
23
|
}
|
|
28
|
-
function
|
|
29
|
-
return
|
|
24
|
+
function vt(e) {
|
|
25
|
+
return e.children;
|
|
30
26
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
27
|
+
const zt = {
|
|
28
|
+
isSvg: !1
|
|
29
|
+
};
|
|
30
|
+
function V(e, t) {
|
|
31
|
+
Array.isArray(t) || (t = [t]), t = t.filter(Boolean), t.length && e.append(...t);
|
|
32
|
+
}
|
|
33
|
+
function kt(e, t, n) {
|
|
34
|
+
for (const i in t)
|
|
35
|
+
if (!(i === "key" || i === "children" || i === "ref"))
|
|
36
|
+
if (i === "dangerouslySetInnerHTML")
|
|
37
|
+
e.innerHTML = t[i].__html;
|
|
38
|
+
else if (i === "innerHTML" || i === "textContent" || i === "innerText" || i === "value" && ["textarea", "select"].includes(e.tagName)) {
|
|
39
|
+
const r = t[i];
|
|
40
|
+
r != null && (e[i] = r);
|
|
41
|
+
} else
|
|
42
|
+
i.startsWith("on") ? e[i.toLowerCase()] = t[i] : Et(e, i, t[i], n.isSvg);
|
|
43
|
+
}
|
|
44
|
+
const bt = {
|
|
45
|
+
className: "class",
|
|
46
|
+
labelFor: "for"
|
|
47
|
+
};
|
|
48
|
+
function Et(e, t, n, i) {
|
|
49
|
+
if (t = bt[t] || t, n === !0)
|
|
50
|
+
e.setAttribute(t, "");
|
|
51
|
+
else if (n === !1)
|
|
52
|
+
e.removeAttribute(t);
|
|
53
|
+
else {
|
|
54
|
+
const r = i ? mt[t] : void 0;
|
|
55
|
+
r !== void 0 ? e.setAttributeNS(r, t, n) : e.setAttribute(t, n);
|
|
61
56
|
}
|
|
62
|
-
return this;
|
|
63
57
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
var node = this,
|
|
67
|
-
nodes = [node],
|
|
68
|
-
next = [],
|
|
69
|
-
children,
|
|
70
|
-
i,
|
|
71
|
-
n;
|
|
72
|
-
while (node = nodes.pop()) {
|
|
73
|
-
next.push(node), children = node.children;
|
|
74
|
-
if (children) for (i = 0, n = children.length; i < n; ++i) {
|
|
75
|
-
nodes.push(children[i]);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
while (node = next.pop()) {
|
|
79
|
-
callback(node);
|
|
80
|
-
}
|
|
81
|
-
return this;
|
|
58
|
+
function Ct(e) {
|
|
59
|
+
return e.reduce((t, n) => t.concat(n), []);
|
|
82
60
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return this.eachAfter(function (node) {
|
|
86
|
-
var sum = +value(node.data) || 0,
|
|
87
|
-
children = node.children,
|
|
88
|
-
i = children && children.length;
|
|
89
|
-
while (--i >= 0) sum += children[i].value;
|
|
90
|
-
node.value = sum;
|
|
91
|
-
});
|
|
61
|
+
function D(e, t) {
|
|
62
|
+
return Array.isArray(e) ? Ct(e.map((n) => D(n, t))) : _(e, t);
|
|
92
63
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
64
|
+
function _(e, t = zt) {
|
|
65
|
+
if (e == null || typeof e == "boolean")
|
|
66
|
+
return null;
|
|
67
|
+
if (e instanceof Node)
|
|
68
|
+
return e;
|
|
69
|
+
if (St(e)) {
|
|
70
|
+
const {
|
|
71
|
+
type: n,
|
|
72
|
+
props: i
|
|
73
|
+
} = e;
|
|
74
|
+
if (n === vt) {
|
|
75
|
+
const a = document.createDocumentFragment();
|
|
76
|
+
if (i.children) {
|
|
77
|
+
const c = D(i.children, t);
|
|
78
|
+
V(a, c);
|
|
79
|
+
}
|
|
80
|
+
return a;
|
|
98
81
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
function node_path (end) {
|
|
103
|
-
var start = this,
|
|
104
|
-
ancestor = leastCommonAncestor(start, end),
|
|
105
|
-
nodes = [start];
|
|
106
|
-
while (start !== ancestor) {
|
|
107
|
-
start = start.parent;
|
|
108
|
-
nodes.push(start);
|
|
109
|
-
}
|
|
110
|
-
var k = nodes.length;
|
|
111
|
-
while (end !== ancestor) {
|
|
112
|
-
nodes.splice(k, 0, end);
|
|
113
|
-
end = end.parent;
|
|
114
|
-
}
|
|
115
|
-
return nodes;
|
|
116
|
-
}
|
|
117
|
-
function leastCommonAncestor(a, b) {
|
|
118
|
-
if (a === b) return a;
|
|
119
|
-
var aNodes = a.ancestors(),
|
|
120
|
-
bNodes = b.ancestors(),
|
|
121
|
-
c = null;
|
|
122
|
-
a = aNodes.pop();
|
|
123
|
-
b = bNodes.pop();
|
|
124
|
-
while (a === b) {
|
|
125
|
-
c = a;
|
|
126
|
-
a = aNodes.pop();
|
|
127
|
-
b = bNodes.pop();
|
|
82
|
+
const r = n(i);
|
|
83
|
+
return _(r, t);
|
|
128
84
|
}
|
|
129
|
-
|
|
85
|
+
if (xt(e))
|
|
86
|
+
return document.createTextNode(`${e}`);
|
|
87
|
+
if (yt(e)) {
|
|
88
|
+
let n;
|
|
89
|
+
const {
|
|
90
|
+
type: i,
|
|
91
|
+
props: r
|
|
92
|
+
} = e;
|
|
93
|
+
if (!t.isSvg && i === "svg" && (t = Object.assign({}, t, {
|
|
94
|
+
isSvg: !0
|
|
95
|
+
})), t.isSvg ? n = document.createElementNS(gt, i) : n = document.createElement(i), kt(n, r, t), r.children) {
|
|
96
|
+
let c = t;
|
|
97
|
+
t.isSvg && i === "foreignObject" && (c = Object.assign({}, c, {
|
|
98
|
+
isSvg: !1
|
|
99
|
+
}));
|
|
100
|
+
const s = D(r.children, c);
|
|
101
|
+
s != null && V(n, s);
|
|
102
|
+
}
|
|
103
|
+
const {
|
|
104
|
+
ref: a
|
|
105
|
+
} = r;
|
|
106
|
+
return typeof a == "function" && a(n), n;
|
|
107
|
+
}
|
|
108
|
+
throw new Error("mount: Invalid Vnode!");
|
|
109
|
+
}
|
|
110
|
+
function $(e) {
|
|
111
|
+
return _(e);
|
|
112
|
+
}
|
|
113
|
+
function wt(e) {
|
|
114
|
+
var t = 0, n = e.children, i = n && n.length;
|
|
115
|
+
if (!i)
|
|
116
|
+
t = 1;
|
|
117
|
+
else
|
|
118
|
+
for (; --i >= 0; )
|
|
119
|
+
t += n[i].value;
|
|
120
|
+
e.value = t;
|
|
121
|
+
}
|
|
122
|
+
function Xt() {
|
|
123
|
+
return this.eachAfter(wt);
|
|
124
|
+
}
|
|
125
|
+
function jt(e) {
|
|
126
|
+
var t = this, n, i = [t], r, a, c;
|
|
127
|
+
do
|
|
128
|
+
for (n = i.reverse(), i = []; t = n.pop(); )
|
|
129
|
+
if (e(t), r = t.children, r)
|
|
130
|
+
for (a = 0, c = r.length; a < c; ++a)
|
|
131
|
+
i.push(r[a]);
|
|
132
|
+
while (i.length);
|
|
133
|
+
return this;
|
|
130
134
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
return nodes;
|
|
135
|
+
function Nt(e) {
|
|
136
|
+
for (var t = this, n = [t], i, r; t = n.pop(); )
|
|
137
|
+
if (e(t), i = t.children, i)
|
|
138
|
+
for (r = i.length - 1; r >= 0; --r)
|
|
139
|
+
n.push(i[r]);
|
|
140
|
+
return this;
|
|
139
141
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
function Rt(e) {
|
|
143
|
+
for (var t = this, n = [t], i = [], r, a, c; t = n.pop(); )
|
|
144
|
+
if (i.push(t), r = t.children, r)
|
|
145
|
+
for (a = 0, c = r.length; a < c; ++a)
|
|
146
|
+
n.push(r[a]);
|
|
147
|
+
for (; t = i.pop(); )
|
|
148
|
+
e(t);
|
|
149
|
+
return this;
|
|
147
150
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
leaves.push(node);
|
|
154
|
-
}
|
|
151
|
+
function Tt(e) {
|
|
152
|
+
return this.eachAfter(function(t) {
|
|
153
|
+
for (var n = +e(t.data) || 0, i = t.children, r = i && i.length; --r >= 0; )
|
|
154
|
+
n += i[r].value;
|
|
155
|
+
t.value = n;
|
|
155
156
|
});
|
|
156
|
-
return leaves;
|
|
157
157
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
links = [];
|
|
162
|
-
root.each(function (node) {
|
|
163
|
-
if (node !== root) {
|
|
164
|
-
// Don’t include the root’s parent, if any.
|
|
165
|
-
links.push({
|
|
166
|
-
source: node.parent,
|
|
167
|
-
target: node
|
|
168
|
-
});
|
|
169
|
-
}
|
|
158
|
+
function Mt(e) {
|
|
159
|
+
return this.eachBefore(function(t) {
|
|
160
|
+
t.children && t.children.sort(e);
|
|
170
161
|
});
|
|
171
|
-
return links;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
function hierarchy(data, children) {
|
|
175
|
-
var root = new Node$1(data),
|
|
176
|
-
valued = +data.value && (root.value = data.value),
|
|
177
|
-
node,
|
|
178
|
-
nodes = [root],
|
|
179
|
-
child,
|
|
180
|
-
childs,
|
|
181
|
-
i,
|
|
182
|
-
n;
|
|
183
|
-
if (children == null) children = defaultChildren;
|
|
184
|
-
while (node = nodes.pop()) {
|
|
185
|
-
if (valued) node.value = +node.data.value;
|
|
186
|
-
if ((childs = children(node.data)) && (n = childs.length)) {
|
|
187
|
-
node.children = new Array(n);
|
|
188
|
-
for (i = n - 1; i >= 0; --i) {
|
|
189
|
-
nodes.push(child = node.children[i] = new Node$1(childs[i]));
|
|
190
|
-
child.parent = node;
|
|
191
|
-
child.depth = node.depth + 1;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
return root.eachBefore(computeHeight);
|
|
196
|
-
}
|
|
197
|
-
function node_copy() {
|
|
198
|
-
return hierarchy(this).eachBefore(copyData);
|
|
199
162
|
}
|
|
200
|
-
function
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
var
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
var
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
163
|
+
function At(e) {
|
|
164
|
+
for (var t = this, n = Ot(t, e), i = [t]; t !== n; )
|
|
165
|
+
t = t.parent, i.push(t);
|
|
166
|
+
for (var r = i.length; e !== n; )
|
|
167
|
+
i.splice(r, 0, e), e = e.parent;
|
|
168
|
+
return i;
|
|
169
|
+
}
|
|
170
|
+
function Ot(e, t) {
|
|
171
|
+
if (e === t)
|
|
172
|
+
return e;
|
|
173
|
+
var n = e.ancestors(), i = t.ancestors(), r = null;
|
|
174
|
+
for (e = n.pop(), t = i.pop(); e === t; )
|
|
175
|
+
r = e, e = n.pop(), t = i.pop();
|
|
176
|
+
return r;
|
|
177
|
+
}
|
|
178
|
+
function Ht() {
|
|
179
|
+
for (var e = this, t = [e]; e = e.parent; )
|
|
180
|
+
t.push(e);
|
|
181
|
+
return t;
|
|
182
|
+
}
|
|
183
|
+
function $t() {
|
|
184
|
+
var e = [];
|
|
185
|
+
return this.each(function(t) {
|
|
186
|
+
e.push(t);
|
|
187
|
+
}), e;
|
|
188
|
+
}
|
|
189
|
+
function Bt() {
|
|
190
|
+
var e = [];
|
|
191
|
+
return this.eachBefore(function(t) {
|
|
192
|
+
t.children || e.push(t);
|
|
193
|
+
}), e;
|
|
194
|
+
}
|
|
195
|
+
function Dt() {
|
|
196
|
+
var e = this, t = [];
|
|
197
|
+
return e.each(function(n) {
|
|
198
|
+
n !== e && t.push({ source: n.parent, target: n });
|
|
199
|
+
}), t;
|
|
200
|
+
}
|
|
201
|
+
function L(e, t) {
|
|
202
|
+
var n = new R(e), i = +e.value && (n.value = e.value), r, a = [n], c, s, l, f;
|
|
203
|
+
for (t == null && (t = _t); r = a.pop(); )
|
|
204
|
+
if (i && (r.value = +r.data.value), (s = t(r.data)) && (f = s.length))
|
|
205
|
+
for (r.children = new Array(f), l = f - 1; l >= 0; --l)
|
|
206
|
+
a.push(c = r.children[l] = new R(s[l])), c.parent = r, c.depth = r.depth + 1;
|
|
207
|
+
return n.eachBefore(It);
|
|
208
|
+
}
|
|
209
|
+
function Ft() {
|
|
210
|
+
return L(this).eachBefore(Lt);
|
|
211
|
+
}
|
|
212
|
+
function _t(e) {
|
|
213
|
+
return e.children;
|
|
214
|
+
}
|
|
215
|
+
function Lt(e) {
|
|
216
|
+
e.data = e.data.data;
|
|
217
|
+
}
|
|
218
|
+
function It(e) {
|
|
219
|
+
var t = 0;
|
|
220
|
+
do
|
|
221
|
+
e.height = t;
|
|
222
|
+
while ((e = e.parent) && e.height < ++t);
|
|
223
|
+
}
|
|
224
|
+
function R(e) {
|
|
225
|
+
this.data = e, this.depth = this.height = 0, this.parent = null;
|
|
226
|
+
}
|
|
227
|
+
R.prototype = L.prototype = {
|
|
228
|
+
constructor: R,
|
|
229
|
+
count: Xt,
|
|
230
|
+
each: jt,
|
|
231
|
+
eachAfter: Rt,
|
|
232
|
+
eachBefore: Nt,
|
|
233
|
+
sum: Tt,
|
|
234
|
+
sort: Mt,
|
|
235
|
+
path: At,
|
|
236
|
+
ancestors: Ht,
|
|
237
|
+
descendants: $t,
|
|
238
|
+
leaves: Bt,
|
|
239
|
+
links: Dt,
|
|
240
|
+
copy: Ft
|
|
258
241
|
};
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
242
|
+
const Wt = "d3-flextree", Vt = "2.1.2", Yt = "build/d3-flextree.js", Kt = "index", Pt = {
|
|
243
|
+
name: "Chris Maloney",
|
|
244
|
+
url: "http://chrismaloney.org"
|
|
245
|
+
}, Ut = "Flexible tree layout algorithm that allows for variable node sizes.", Gt = [
|
|
246
|
+
"d3",
|
|
247
|
+
"d3-module",
|
|
248
|
+
"layout",
|
|
249
|
+
"tree",
|
|
250
|
+
"hierarchy",
|
|
251
|
+
"d3-hierarchy",
|
|
252
|
+
"plugin",
|
|
253
|
+
"d3-plugin",
|
|
254
|
+
"infovis",
|
|
255
|
+
"visualization",
|
|
256
|
+
"2d"
|
|
257
|
+
], Zt = "https://github.com/klortho/d3-flextree", Jt = "WTFPL", qt = {
|
|
258
|
+
type: "git",
|
|
259
|
+
url: "https://github.com/klortho/d3-flextree.git"
|
|
260
|
+
}, Qt = {
|
|
261
|
+
clean: "rm -rf build demo test",
|
|
262
|
+
"build:demo": "rollup -c --environment BUILD:demo",
|
|
263
|
+
"build:dev": "rollup -c --environment BUILD:dev",
|
|
264
|
+
"build:prod": "rollup -c --environment BUILD:prod",
|
|
265
|
+
"build:test": "rollup -c --environment BUILD:test",
|
|
266
|
+
build: "rollup -c",
|
|
267
|
+
lint: "eslint index.js src",
|
|
268
|
+
"test:main": "node test/bundle.js",
|
|
269
|
+
"test:browser": "node test/browser-tests.js",
|
|
270
|
+
test: "npm-run-all test:*",
|
|
271
|
+
prepare: "npm-run-all clean build lint test"
|
|
272
|
+
}, te = {
|
|
273
|
+
"d3-hierarchy": "^1.1.5"
|
|
274
|
+
}, ee = {
|
|
275
|
+
"babel-plugin-external-helpers": "^6.22.0",
|
|
276
|
+
"babel-preset-es2015-rollup": "^3.0.0",
|
|
277
|
+
d3: "^4.13.0",
|
|
278
|
+
"d3-selection-multi": "^1.0.1",
|
|
279
|
+
eslint: "^4.19.1",
|
|
280
|
+
jsdom: "^11.6.2",
|
|
281
|
+
"npm-run-all": "^4.1.2",
|
|
282
|
+
rollup: "^0.55.3",
|
|
283
|
+
"rollup-plugin-babel": "^2.7.1",
|
|
284
|
+
"rollup-plugin-commonjs": "^8.0.2",
|
|
285
|
+
"rollup-plugin-copy": "^0.2.3",
|
|
286
|
+
"rollup-plugin-json": "^2.3.0",
|
|
287
|
+
"rollup-plugin-node-resolve": "^3.0.2",
|
|
288
|
+
"rollup-plugin-uglify": "^3.0.0",
|
|
289
|
+
"uglify-es": "^3.3.9"
|
|
290
|
+
}, ne = {
|
|
291
|
+
name: Wt,
|
|
292
|
+
version: Vt,
|
|
293
|
+
main: Yt,
|
|
294
|
+
module: Kt,
|
|
295
|
+
"jsnext:main": "index",
|
|
296
|
+
author: Pt,
|
|
297
|
+
description: Ut,
|
|
298
|
+
keywords: Gt,
|
|
299
|
+
homepage: Zt,
|
|
300
|
+
license: Jt,
|
|
301
|
+
repository: qt,
|
|
302
|
+
scripts: Qt,
|
|
303
|
+
dependencies: te,
|
|
304
|
+
devDependencies: ee
|
|
305
|
+
}, { version: ie } = ne, oe = Object.freeze({
|
|
306
|
+
children: (e) => e.children,
|
|
307
|
+
nodeSize: (e) => e.data.size,
|
|
315
308
|
spacing: 0
|
|
316
309
|
});
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
}
|
|
333
|
-
function getFlexNode() {
|
|
334
|
-
const nodeSize = accessor('nodeSize');
|
|
335
|
-
const spacing = accessor('spacing');
|
|
336
|
-
return class FlexNode extends hierarchy.prototype.constructor {
|
|
337
|
-
constructor(data) {
|
|
338
|
-
super(data);
|
|
310
|
+
function Q(e) {
|
|
311
|
+
const t = Object.assign({}, oe, e);
|
|
312
|
+
function n(s) {
|
|
313
|
+
const l = t[s];
|
|
314
|
+
return typeof l == "function" ? l : () => l;
|
|
315
|
+
}
|
|
316
|
+
function i(s) {
|
|
317
|
+
const l = c(a(), s, (f) => f.children);
|
|
318
|
+
return l.update(), l.data;
|
|
319
|
+
}
|
|
320
|
+
function r() {
|
|
321
|
+
const s = n("nodeSize"), l = n("spacing");
|
|
322
|
+
return class q extends L.prototype.constructor {
|
|
323
|
+
constructor(h) {
|
|
324
|
+
super(h);
|
|
339
325
|
}
|
|
340
326
|
copy() {
|
|
341
|
-
const
|
|
342
|
-
|
|
343
|
-
return c;
|
|
327
|
+
const h = c(this.constructor, this, (p) => p.children);
|
|
328
|
+
return h.each((p) => p.data = p.data.data), h;
|
|
344
329
|
}
|
|
345
330
|
get size() {
|
|
346
|
-
return
|
|
331
|
+
return s(this);
|
|
347
332
|
}
|
|
348
|
-
spacing(
|
|
349
|
-
return
|
|
333
|
+
spacing(h) {
|
|
334
|
+
return l(this, h);
|
|
350
335
|
}
|
|
351
336
|
get nodes() {
|
|
352
337
|
return this.descendants();
|
|
@@ -370,8 +355,8 @@ function flextree(options) {
|
|
|
370
355
|
return this.x + this.xSize / 2;
|
|
371
356
|
}
|
|
372
357
|
get root() {
|
|
373
|
-
const
|
|
374
|
-
return
|
|
358
|
+
const h = this.ancestors();
|
|
359
|
+
return h[h.length - 1];
|
|
375
360
|
}
|
|
376
361
|
get numChildren() {
|
|
377
362
|
return this.hasChildren ? this.children.length : 0;
|
|
@@ -389,7 +374,10 @@ function flextree(options) {
|
|
|
389
374
|
return this.hasChildren ? this.children[this.numChildren - 1] : null;
|
|
390
375
|
}
|
|
391
376
|
get extents() {
|
|
392
|
-
return (this.children || []).reduce(
|
|
377
|
+
return (this.children || []).reduce(
|
|
378
|
+
(h, p) => q.maxExtents(h, p.extents),
|
|
379
|
+
this.nodeExtents
|
|
380
|
+
);
|
|
393
381
|
}
|
|
394
382
|
get nodeExtents() {
|
|
395
383
|
return {
|
|
@@ -399,24 +387,21 @@ function flextree(options) {
|
|
|
399
387
|
right: this.right
|
|
400
388
|
};
|
|
401
389
|
}
|
|
402
|
-
static maxExtents(
|
|
390
|
+
static maxExtents(h, p) {
|
|
403
391
|
return {
|
|
404
|
-
top: Math.min(
|
|
405
|
-
bottom: Math.max(
|
|
406
|
-
left: Math.min(
|
|
407
|
-
right: Math.max(
|
|
392
|
+
top: Math.min(h.top, p.top),
|
|
393
|
+
bottom: Math.max(h.bottom, p.bottom),
|
|
394
|
+
left: Math.min(h.left, p.left),
|
|
395
|
+
right: Math.max(h.right, p.right)
|
|
408
396
|
};
|
|
409
397
|
}
|
|
410
398
|
};
|
|
411
399
|
}
|
|
412
|
-
function
|
|
413
|
-
const
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
constructor(data) {
|
|
418
|
-
super(data);
|
|
419
|
-
Object.assign(this, {
|
|
400
|
+
function a() {
|
|
401
|
+
const s = r(), l = n("nodeSize"), f = n("spacing");
|
|
402
|
+
return class extends s {
|
|
403
|
+
constructor(h) {
|
|
404
|
+
super(h), Object.assign(this, {
|
|
420
405
|
x: 0,
|
|
421
406
|
y: 0,
|
|
422
407
|
relX: 0,
|
|
@@ -432,866 +417,501 @@ function flextree(options) {
|
|
|
432
417
|
});
|
|
433
418
|
}
|
|
434
419
|
get size() {
|
|
435
|
-
return
|
|
420
|
+
return l(this.data);
|
|
436
421
|
}
|
|
437
|
-
spacing(
|
|
438
|
-
return
|
|
422
|
+
spacing(h) {
|
|
423
|
+
return f(this.data, h.data);
|
|
439
424
|
}
|
|
440
425
|
get x() {
|
|
441
426
|
return this.data.x;
|
|
442
427
|
}
|
|
443
|
-
set x(
|
|
444
|
-
this.data.x =
|
|
428
|
+
set x(h) {
|
|
429
|
+
this.data.x = h;
|
|
445
430
|
}
|
|
446
431
|
get y() {
|
|
447
432
|
return this.data.y;
|
|
448
433
|
}
|
|
449
|
-
set y(
|
|
450
|
-
this.data.y =
|
|
434
|
+
set y(h) {
|
|
435
|
+
this.data.y = h;
|
|
451
436
|
}
|
|
452
437
|
update() {
|
|
453
|
-
|
|
454
|
-
resolveX(this);
|
|
455
|
-
return this;
|
|
438
|
+
return tt(this), et(this), this;
|
|
456
439
|
}
|
|
457
440
|
};
|
|
458
441
|
}
|
|
459
|
-
function
|
|
460
|
-
const
|
|
461
|
-
const
|
|
462
|
-
Object.assign(
|
|
463
|
-
parent,
|
|
464
|
-
depth:
|
|
442
|
+
function c(s, l, f) {
|
|
443
|
+
const h = (p, m) => {
|
|
444
|
+
const d = new s(p);
|
|
445
|
+
Object.assign(d, {
|
|
446
|
+
parent: m,
|
|
447
|
+
depth: m === null ? 0 : m.depth + 1,
|
|
465
448
|
height: 0,
|
|
466
449
|
length: 1
|
|
467
450
|
});
|
|
468
|
-
const
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
return node;
|
|
451
|
+
const S = f(p) || [];
|
|
452
|
+
return d.children = S.length === 0 ? null : S.map((x) => h(x, d)), d.children && Object.assign(d, d.children.reduce(
|
|
453
|
+
(x, g) => ({
|
|
454
|
+
height: Math.max(x.height, g.height + 1),
|
|
455
|
+
length: x.length + g.length
|
|
456
|
+
}),
|
|
457
|
+
d
|
|
458
|
+
)), d;
|
|
477
459
|
};
|
|
478
|
-
return
|
|
460
|
+
return h(l, null);
|
|
479
461
|
}
|
|
480
|
-
Object.assign(
|
|
481
|
-
nodeSize(
|
|
482
|
-
return arguments.length ? (
|
|
462
|
+
return Object.assign(i, {
|
|
463
|
+
nodeSize(s) {
|
|
464
|
+
return arguments.length ? (t.nodeSize = s, i) : t.nodeSize;
|
|
483
465
|
},
|
|
484
|
-
spacing(
|
|
485
|
-
return arguments.length ? (
|
|
466
|
+
spacing(s) {
|
|
467
|
+
return arguments.length ? (t.spacing = s, i) : t.spacing;
|
|
486
468
|
},
|
|
487
|
-
children(
|
|
488
|
-
return arguments.length ? (
|
|
469
|
+
children(s) {
|
|
470
|
+
return arguments.length ? (t.children = s, i) : t.children;
|
|
489
471
|
},
|
|
490
|
-
hierarchy(
|
|
491
|
-
const
|
|
492
|
-
return
|
|
472
|
+
hierarchy(s, l) {
|
|
473
|
+
const f = typeof l > "u" ? t.children : l;
|
|
474
|
+
return c(r(), s, f);
|
|
493
475
|
},
|
|
494
|
-
dump(
|
|
495
|
-
const
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
const i2 = i0 + ' ';
|
|
499
|
-
const {
|
|
500
|
-
x,
|
|
501
|
-
y
|
|
502
|
-
} = node;
|
|
503
|
-
const size = nodeSize(node);
|
|
504
|
-
const kids = node.children || [];
|
|
505
|
-
const kdumps = kids.length === 0 ? ' ' : `,${i1}children: [${i2}${kids.map(_dump(i2)).join(i2)}${i1}],${i0}`;
|
|
506
|
-
return `{ size: [${size.join(', ')}],${i1}x: ${x}, y: ${y}${kdumps}},`;
|
|
476
|
+
dump(s) {
|
|
477
|
+
const l = n("nodeSize"), f = (h) => (p) => {
|
|
478
|
+
const m = h + " ", d = h + " ", { x: S, y: x } = p, g = l(p), y = p.children || [], v = y.length === 0 ? " " : `,${m}children: [${d}${y.map(f(d)).join(d)}${m}],${h}`;
|
|
479
|
+
return `{ size: [${g.join(", ")}],${m}x: ${S}, y: ${x}${v}},`;
|
|
507
480
|
};
|
|
508
|
-
return
|
|
481
|
+
return f(`
|
|
482
|
+
`)(s);
|
|
509
483
|
}
|
|
510
|
-
});
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
const
|
|
515
|
-
|
|
516
|
-
(
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
return w;
|
|
529
|
-
};
|
|
530
|
-
|
|
531
|
-
// Resolves the relative coordinate properties - relX and prelim --
|
|
532
|
-
// to set the final, absolute x coordinate for each node. This also sets
|
|
533
|
-
// `prelim` to 0, so that `relX` for each node is its x-coordinate relative
|
|
534
|
-
// to its parent.
|
|
535
|
-
const resolveX = (w, prevSum, parentX) => {
|
|
536
|
-
// A call to resolveX without arguments is assumed to be for the root of
|
|
537
|
-
// the tree. This will set the root's x-coord to zero.
|
|
538
|
-
if (typeof prevSum === 'undefined') {
|
|
539
|
-
prevSum = -w.relX - w.prelim;
|
|
540
|
-
parentX = 0;
|
|
541
|
-
}
|
|
542
|
-
const sum = prevSum + w.relX;
|
|
543
|
-
w.relX = sum + w.prelim - parentX;
|
|
544
|
-
w.prelim = 0;
|
|
545
|
-
w.x = parentX + w.relX;
|
|
546
|
-
(w.children || []).forEach(k => resolveX(k, sum, w.x));
|
|
547
|
-
return w;
|
|
548
|
-
};
|
|
549
|
-
|
|
550
|
-
// Process shift and change for all children, to add intermediate spacing to
|
|
551
|
-
// each child's modifier.
|
|
552
|
-
const shiftChange = w => {
|
|
553
|
-
(w.children || []).reduce((acc, child) => {
|
|
554
|
-
const [lastShiftSum, lastChangeSum] = acc;
|
|
555
|
-
const shiftSum = lastShiftSum + child.shift;
|
|
556
|
-
const changeSum = lastChangeSum + shiftSum + child.change;
|
|
557
|
-
child.relX += changeSum;
|
|
558
|
-
return [shiftSum, changeSum];
|
|
484
|
+
}), i;
|
|
485
|
+
}
|
|
486
|
+
Q.version = ie;
|
|
487
|
+
const tt = (e, t = 0) => (e.y = t, (e.children || []).reduce((n, i) => {
|
|
488
|
+
const [r, a] = n;
|
|
489
|
+
tt(i, e.y + e.ySize);
|
|
490
|
+
const c = (r === 0 ? i.lExt : i.rExt).bottom;
|
|
491
|
+
r !== 0 && se(e, r, a);
|
|
492
|
+
const s = fe(c, r, a);
|
|
493
|
+
return [r + 1, s];
|
|
494
|
+
}, [0, null]), re(e), pe(e), e), et = (e, t, n) => {
|
|
495
|
+
typeof t > "u" && (t = -e.relX - e.prelim, n = 0);
|
|
496
|
+
const i = t + e.relX;
|
|
497
|
+
return e.relX = i + e.prelim - n, e.prelim = 0, e.x = n + e.relX, (e.children || []).forEach((r) => et(r, i, e.x)), e;
|
|
498
|
+
}, re = (e) => {
|
|
499
|
+
(e.children || []).reduce((t, n) => {
|
|
500
|
+
const [i, r] = t, a = i + n.shift, c = r + a + n.change;
|
|
501
|
+
return n.relX += c, [a, c];
|
|
559
502
|
}, [0, 0]);
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
// current subtree is taller than the left siblings.
|
|
599
|
-
if (!rContour && lContour) setLThr(w, i, lContour, lSumMods);
|
|
600
|
-
// In the next case, the left siblings are taller than the current subtree
|
|
601
|
-
else if (rContour && !lContour) setRThr(w, i, rContour, rSumMods);
|
|
602
|
-
};
|
|
603
|
-
/* eslint-enable complexity */
|
|
604
|
-
|
|
605
|
-
// Move subtree by changing relX.
|
|
606
|
-
const moveSubtree = (subtree, distance) => {
|
|
607
|
-
subtree.relX += distance;
|
|
608
|
-
subtree.lExtRelX += distance;
|
|
609
|
-
subtree.rExtRelX += distance;
|
|
610
|
-
};
|
|
611
|
-
const distributeExtra = (w, curSubtreeI, leftSibI, dist) => {
|
|
612
|
-
const curSubtree = w.children[curSubtreeI];
|
|
613
|
-
const n = curSubtreeI - leftSibI;
|
|
614
|
-
// Are there intermediate children?
|
|
615
|
-
if (n > 1) {
|
|
616
|
-
const delta = dist / n;
|
|
617
|
-
w.children[leftSibI + 1].shift += delta;
|
|
618
|
-
curSubtree.shift -= delta;
|
|
619
|
-
curSubtree.change -= dist - delta;
|
|
620
|
-
}
|
|
621
|
-
};
|
|
622
|
-
const nextLContour = w => {
|
|
623
|
-
return w.hasChildren ? w.firstChild : w.lThr;
|
|
624
|
-
};
|
|
625
|
-
const nextRContour = w => {
|
|
626
|
-
return w.hasChildren ? w.lastChild : w.rThr;
|
|
627
|
-
};
|
|
628
|
-
const setLThr = (w, i, lContour, lSumMods) => {
|
|
629
|
-
const firstChild = w.firstChild;
|
|
630
|
-
const lExt = firstChild.lExt;
|
|
631
|
-
const curSubtree = w.children[i];
|
|
632
|
-
lExt.lThr = lContour;
|
|
633
|
-
// Change relX so that the sum of modifier after following thread is correct.
|
|
634
|
-
const diff = lSumMods - lContour.relX - firstChild.lExtRelX;
|
|
635
|
-
lExt.relX += diff;
|
|
636
|
-
// Change preliminary x coordinate so that the node does not move.
|
|
637
|
-
lExt.prelim -= diff;
|
|
638
|
-
// Update extreme node and its sum of modifiers.
|
|
639
|
-
firstChild.lExt = curSubtree.lExt;
|
|
640
|
-
firstChild.lExtRelX = curSubtree.lExtRelX;
|
|
641
|
-
};
|
|
642
|
-
|
|
643
|
-
// Mirror image of setLThr.
|
|
644
|
-
const setRThr = (w, i, rContour, rSumMods) => {
|
|
645
|
-
const curSubtree = w.children[i];
|
|
646
|
-
const rExt = curSubtree.rExt;
|
|
647
|
-
const lSib = w.children[i - 1];
|
|
648
|
-
rExt.rThr = rContour;
|
|
649
|
-
const diff = rSumMods - rContour.relX - curSubtree.rExtRelX;
|
|
650
|
-
rExt.relX += diff;
|
|
651
|
-
rExt.prelim -= diff;
|
|
652
|
-
curSubtree.rExt = lSib.rExt;
|
|
653
|
-
curSubtree.rExtRelX = lSib.rExtRelX;
|
|
654
|
-
};
|
|
655
|
-
|
|
656
|
-
// Position root between children, taking into account their modifiers
|
|
657
|
-
const positionRoot = w => {
|
|
658
|
-
if (w.hasChildren) {
|
|
659
|
-
const k0 = w.firstChild;
|
|
660
|
-
const kf = w.lastChild;
|
|
661
|
-
const prelim = (k0.prelim + k0.relX - k0.xSize / 2 + kf.relX + kf.prelim + kf.xSize / 2) / 2;
|
|
662
|
-
Object.assign(w, {
|
|
663
|
-
prelim,
|
|
664
|
-
lExt: k0.lExt,
|
|
665
|
-
lExtRelX: k0.lExtRelX,
|
|
666
|
-
rExt: kf.rExt,
|
|
667
|
-
rExtRelX: kf.rExtRelX
|
|
503
|
+
}, se = (e, t, n) => {
|
|
504
|
+
const i = e.children[t - 1], r = e.children[t];
|
|
505
|
+
let a = i, c = i.relX, s = r, l = r.relX, f = !0;
|
|
506
|
+
for (; a && s; ) {
|
|
507
|
+
a.bottom > n.lowY && (n = n.next);
|
|
508
|
+
const h = c + a.prelim - (l + s.prelim) + a.xSize / 2 + s.xSize / 2 + a.spacing(s);
|
|
509
|
+
(h > 0 || h < 0 && f) && (l += h, ae(r, h), le(e, t, n.index, h)), f = !1;
|
|
510
|
+
const p = a.bottom, m = s.bottom;
|
|
511
|
+
p <= m && (a = he(a), a && (c += a.relX)), p >= m && (s = ce(s), s && (l += s.relX));
|
|
512
|
+
}
|
|
513
|
+
!a && s ? de(e, t, s, l) : a && !s && ue(e, t, a, c);
|
|
514
|
+
}, ae = (e, t) => {
|
|
515
|
+
e.relX += t, e.lExtRelX += t, e.rExtRelX += t;
|
|
516
|
+
}, le = (e, t, n, i) => {
|
|
517
|
+
const r = e.children[t], a = t - n;
|
|
518
|
+
if (a > 1) {
|
|
519
|
+
const c = i / a;
|
|
520
|
+
e.children[n + 1].shift += c, r.shift -= c, r.change -= i - c;
|
|
521
|
+
}
|
|
522
|
+
}, ce = (e) => e.hasChildren ? e.firstChild : e.lThr, he = (e) => e.hasChildren ? e.lastChild : e.rThr, de = (e, t, n, i) => {
|
|
523
|
+
const r = e.firstChild, a = r.lExt, c = e.children[t];
|
|
524
|
+
a.lThr = n;
|
|
525
|
+
const s = i - n.relX - r.lExtRelX;
|
|
526
|
+
a.relX += s, a.prelim -= s, r.lExt = c.lExt, r.lExtRelX = c.lExtRelX;
|
|
527
|
+
}, ue = (e, t, n, i) => {
|
|
528
|
+
const r = e.children[t], a = r.rExt, c = e.children[t - 1];
|
|
529
|
+
a.rThr = n;
|
|
530
|
+
const s = i - n.relX - r.rExtRelX;
|
|
531
|
+
a.relX += s, a.prelim -= s, r.rExt = c.rExt, r.rExtRelX = c.rExtRelX;
|
|
532
|
+
}, pe = (e) => {
|
|
533
|
+
if (e.hasChildren) {
|
|
534
|
+
const t = e.firstChild, n = e.lastChild, i = (t.prelim + t.relX - t.xSize / 2 + n.relX + n.prelim + n.xSize / 2) / 2;
|
|
535
|
+
Object.assign(e, {
|
|
536
|
+
prelim: i,
|
|
537
|
+
lExt: t.lExt,
|
|
538
|
+
lExtRelX: t.lExtRelX,
|
|
539
|
+
rExt: n.rExt,
|
|
540
|
+
rExtRelX: n.rExtRelX
|
|
668
541
|
});
|
|
669
542
|
}
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
// lowest vertical coordinate.
|
|
674
|
-
const updateLows = (lowY, index, lastLows) => {
|
|
675
|
-
// Remove siblings that are hidden by the new subtree.
|
|
676
|
-
while (lastLows !== null && lowY >= lastLows.lowY) lastLows = lastLows.next;
|
|
677
|
-
// Prepend the new subtree.
|
|
678
|
-
return {
|
|
679
|
-
lowY,
|
|
680
|
-
index,
|
|
681
|
-
next: lastLows
|
|
682
|
-
};
|
|
683
|
-
};
|
|
684
|
-
|
|
685
|
-
/*! @gera2ld/jsx-dom v2.2.2 | ISC License */
|
|
686
|
-
const VTYPE_ELEMENT = 1;
|
|
687
|
-
const VTYPE_FUNCTION = 2;
|
|
688
|
-
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
689
|
-
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
690
|
-
const NS_ATTRS = {
|
|
691
|
-
show: XLINK_NS,
|
|
692
|
-
actuate: XLINK_NS,
|
|
693
|
-
href: XLINK_NS
|
|
694
|
-
};
|
|
695
|
-
const isLeaf = c => typeof c === 'string' || typeof c === 'number';
|
|
696
|
-
const isElement = c => (c == null ? void 0 : c.vtype) === VTYPE_ELEMENT;
|
|
697
|
-
const isRenderFunction = c => (c == null ? void 0 : c.vtype) === VTYPE_FUNCTION;
|
|
698
|
-
function jsx(type, props) {
|
|
699
|
-
let vtype;
|
|
700
|
-
if (typeof type === 'string') vtype = VTYPE_ELEMENT;else if (typeof type === 'function') vtype = VTYPE_FUNCTION;else throw new Error('Invalid VNode type');
|
|
543
|
+
}, fe = (e, t, n) => {
|
|
544
|
+
for (; n !== null && e >= n.lowY; )
|
|
545
|
+
n = n.next;
|
|
701
546
|
return {
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
547
|
+
lowY: e,
|
|
548
|
+
index: t,
|
|
549
|
+
next: n
|
|
705
550
|
};
|
|
551
|
+
}, nt = ".markmap{font:300 16px/20px sans-serif}.markmap-link{fill:none}.markmap-node>circle{cursor:pointer}.markmap-foreign{display:inline-block}.markmap-foreign a{color:#0097e6}.markmap-foreign a:hover{color:#00a8ff}.markmap-foreign code{padding:.25em;font-size:calc(1em - 2px);color:#555;background-color:#f0f0f0;border-radius:2px}.markmap-foreign pre{margin:0}.markmap-foreign pre>code{display:block}.markmap-foreign del{text-decoration:line-through}.markmap-foreign em{font-style:italic}.markmap-foreign strong{font-weight:700}.markmap-foreign mark{background:#ffeaa7}", ge = ".markmap-container{position:absolute;width:0;height:0;top:-100px;left:-100px;overflow:hidden}.markmap-container>.markmap-foreign{display:inline-block}.markmap-container>.markmap-foreign>div:last-child,.markmap-container>.markmap-foreign>div:last-child :not(pre){white-space:nowrap}.markmap-container>.markmap-foreign>div:last-child code{white-space:inherit}", ze = nt;
|
|
552
|
+
function Y(e) {
|
|
553
|
+
const t = e.data;
|
|
554
|
+
return Math.max(4 - 2 * t.depth, 1.5);
|
|
706
555
|
}
|
|
707
|
-
function
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
const DEFAULT_ENV = {
|
|
711
|
-
isSvg: false
|
|
712
|
-
};
|
|
713
|
-
function insertDom(parent, nodes) {
|
|
714
|
-
if (!Array.isArray(nodes)) nodes = [nodes];
|
|
715
|
-
nodes = nodes.filter(Boolean);
|
|
716
|
-
if (nodes.length) parent.append(...nodes);
|
|
556
|
+
function K(e, t) {
|
|
557
|
+
const n = ft(e, t);
|
|
558
|
+
return e[n];
|
|
717
559
|
}
|
|
718
|
-
function
|
|
719
|
-
for (const key in props) {
|
|
720
|
-
if (key === 'key' || key === 'children' || key === 'ref') continue;
|
|
721
|
-
if (key === 'dangerouslySetInnerHTML') {
|
|
722
|
-
domElement.innerHTML = props[key].__html;
|
|
723
|
-
} else if (key === 'innerHTML' || key === 'textContent' || key === 'innerText' || key === 'value' && ['textarea', 'select'].includes(domElement.tagName)) {
|
|
724
|
-
const value = props[key];
|
|
725
|
-
if (value != null) domElement[key] = value;
|
|
726
|
-
} else if (key.startsWith('on')) {
|
|
727
|
-
domElement[key.toLowerCase()] = props[key];
|
|
728
|
-
} else {
|
|
729
|
-
setDOMAttribute(domElement, key, props[key], env.isSvg);
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
const attrMap = {
|
|
734
|
-
className: 'class',
|
|
735
|
-
labelFor: 'for'
|
|
736
|
-
};
|
|
737
|
-
function setDOMAttribute(el, attr, value, isSVG) {
|
|
738
|
-
attr = attrMap[attr] || attr;
|
|
739
|
-
if (value === true) {
|
|
740
|
-
el.setAttribute(attr, '');
|
|
741
|
-
} else if (value === false) {
|
|
742
|
-
el.removeAttribute(attr);
|
|
743
|
-
} else {
|
|
744
|
-
const namespace = isSVG ? NS_ATTRS[attr] : undefined;
|
|
745
|
-
if (namespace !== undefined) {
|
|
746
|
-
el.setAttributeNS(namespace, attr, value);
|
|
747
|
-
} else {
|
|
748
|
-
el.setAttribute(attr, value);
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
function flatten(arr) {
|
|
753
|
-
return arr.reduce((prev, item) => prev.concat(item), []);
|
|
754
|
-
}
|
|
755
|
-
function mountChildren(children, env) {
|
|
756
|
-
return Array.isArray(children) ? flatten(children.map(child => mountChildren(child, env))) : mount(children, env);
|
|
757
|
-
}
|
|
758
|
-
function mount(vnode, env = DEFAULT_ENV) {
|
|
759
|
-
if (vnode == null || typeof vnode === 'boolean') {
|
|
760
|
-
return null;
|
|
761
|
-
}
|
|
762
|
-
if (vnode instanceof Node) {
|
|
763
|
-
return vnode;
|
|
764
|
-
}
|
|
765
|
-
if (isRenderFunction(vnode)) {
|
|
766
|
-
const {
|
|
767
|
-
type,
|
|
768
|
-
props
|
|
769
|
-
} = vnode;
|
|
770
|
-
if (type === Fragment) {
|
|
771
|
-
const node = document.createDocumentFragment();
|
|
772
|
-
if (props.children) {
|
|
773
|
-
const children = mountChildren(props.children, env);
|
|
774
|
-
insertDom(node, children);
|
|
775
|
-
}
|
|
776
|
-
return node;
|
|
777
|
-
}
|
|
778
|
-
const childVNode = type(props);
|
|
779
|
-
return mount(childVNode, env);
|
|
780
|
-
}
|
|
781
|
-
if (isLeaf(vnode)) {
|
|
782
|
-
return document.createTextNode(`${vnode}`);
|
|
783
|
-
}
|
|
784
|
-
if (isElement(vnode)) {
|
|
785
|
-
let node;
|
|
786
|
-
const {
|
|
787
|
-
type,
|
|
788
|
-
props
|
|
789
|
-
} = vnode;
|
|
790
|
-
if (!env.isSvg && type === 'svg') {
|
|
791
|
-
env = Object.assign({}, env, {
|
|
792
|
-
isSvg: true
|
|
793
|
-
});
|
|
794
|
-
}
|
|
795
|
-
if (!env.isSvg) {
|
|
796
|
-
node = document.createElement(type);
|
|
797
|
-
} else {
|
|
798
|
-
node = document.createElementNS(SVG_NS, type);
|
|
799
|
-
}
|
|
800
|
-
mountAttributes(node, props, env);
|
|
801
|
-
if (props.children) {
|
|
802
|
-
let childEnv = env;
|
|
803
|
-
if (env.isSvg && type === 'foreignObject') {
|
|
804
|
-
childEnv = Object.assign({}, childEnv, {
|
|
805
|
-
isSvg: false
|
|
806
|
-
});
|
|
807
|
-
}
|
|
808
|
-
const children = mountChildren(props.children, childEnv);
|
|
809
|
-
if (children != null) insertDom(node, children);
|
|
810
|
-
}
|
|
811
|
-
const {
|
|
812
|
-
ref
|
|
813
|
-
} = props;
|
|
814
|
-
if (typeof ref === 'function') ref(node);
|
|
815
|
-
return node;
|
|
816
|
-
}
|
|
817
|
-
throw new Error('mount: Invalid Vnode!');
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
/**
|
|
821
|
-
* Mount vdom as real DOM nodes.
|
|
822
|
-
*/
|
|
823
|
-
function mountDom(vnode) {
|
|
824
|
-
return mount(vnode);
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
var css_248z$1 = ".markmap{font:300 16px/20px sans-serif}.markmap-link{fill:none}.markmap-node>circle{cursor:pointer}.markmap-foreign{display:inline-block}.markmap-foreign a{color:#0097e6}.markmap-foreign a:hover{color:#00a8ff}.markmap-foreign code{background-color:#f0f0f0;border-radius:2px;color:#555;font-size:calc(1em - 2px);padding:.25em}.markmap-foreign pre{margin:0}.markmap-foreign pre>code{display:block}.markmap-foreign del{text-decoration:line-through}.markmap-foreign em{font-style:italic}.markmap-foreign strong{font-weight:700}.markmap-foreign mark{background:#ffeaa7}";
|
|
828
|
-
|
|
829
|
-
var css_248z = ".markmap-container{height:0;left:-100px;overflow:hidden;position:absolute;top:-100px;width:0}.markmap-container>.markmap-foreign{display:inline-block}.markmap-container>.markmap-foreign>div:last-child,.markmap-container>.markmap-foreign>div:last-child *{white-space:nowrap}";
|
|
830
|
-
|
|
831
|
-
const globalCSS = css_248z$1;
|
|
832
|
-
function linkWidth(nodeData) {
|
|
833
|
-
const data = nodeData.data;
|
|
834
|
-
return Math.max(4 - 2 * data.depth, 1.5);
|
|
835
|
-
}
|
|
836
|
-
function minBy(numbers, by) {
|
|
837
|
-
const index = minIndex(numbers, by);
|
|
838
|
-
return numbers[index];
|
|
839
|
-
}
|
|
840
|
-
function stopPropagation(e) {
|
|
560
|
+
function B(e) {
|
|
841
561
|
e.stopPropagation();
|
|
842
562
|
}
|
|
843
|
-
function
|
|
563
|
+
function me() {
|
|
844
564
|
return {
|
|
845
|
-
transformHtml: new
|
|
565
|
+
transformHtml: new U()
|
|
846
566
|
};
|
|
847
567
|
}
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
this.handlePan = e => {
|
|
866
|
-
e.preventDefault();
|
|
867
|
-
const transform = zoomTransform(this.svg.node());
|
|
868
|
-
const newTransform = transform.translate(-e.deltaX / transform.k, -e.deltaY / transform.k);
|
|
869
|
-
this.svg.call(this.zoom.transform, newTransform);
|
|
870
|
-
};
|
|
871
|
-
this.handleClick = (e, d) => {
|
|
872
|
-
let recursive = this.options.toggleRecursively;
|
|
873
|
-
if (isMacintosh ? e.metaKey : e.ctrlKey) recursive = !recursive;
|
|
874
|
-
this.toggleNode(d.data, recursive);
|
|
875
|
-
};
|
|
876
|
-
this.viewHooks = createViewHooks();
|
|
877
|
-
this.svg = svg.datum ? svg : select(svg);
|
|
878
|
-
this.styleNode = this.svg.append('style');
|
|
879
|
-
this.zoom = zoom().filter(event => {
|
|
880
|
-
if (this.options.scrollForPan) {
|
|
881
|
-
// Pan with wheels, zoom with ctrl+wheels
|
|
882
|
-
if (event.type === 'wheel') return event.ctrlKey && !event.button;
|
|
883
|
-
}
|
|
884
|
-
return (!event.ctrlKey || event.type === 'wheel') && !event.button;
|
|
885
|
-
}).on('zoom', this.handleZoom);
|
|
886
|
-
this.setOptions(opts);
|
|
887
|
-
this.state = {
|
|
888
|
-
id: this.options.id || this.svg.attr('id') || getId(),
|
|
568
|
+
const xe = new U(), ye = G(ct), P = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), C = class C {
|
|
569
|
+
constructor(t, n) {
|
|
570
|
+
this.options = C.defaultOptions, this.revokers = [], this.handleZoom = (i) => {
|
|
571
|
+
const { transform: r } = i;
|
|
572
|
+
this.g.attr("transform", r);
|
|
573
|
+
}, this.handlePan = (i) => {
|
|
574
|
+
i.preventDefault();
|
|
575
|
+
const r = O(this.svg.node()), a = r.translate(
|
|
576
|
+
-i.deltaX / r.k,
|
|
577
|
+
-i.deltaY / r.k
|
|
578
|
+
);
|
|
579
|
+
this.svg.call(this.zoom.transform, a);
|
|
580
|
+
}, this.handleClick = (i, r) => {
|
|
581
|
+
let a = this.options.toggleRecursively;
|
|
582
|
+
(P ? i.metaKey : i.ctrlKey) && (a = !a), this.toggleNode(r.data, a);
|
|
583
|
+
}, this.viewHooks = me(), this.svg = t.datum ? t : ht(t), this.styleNode = this.svg.append("style"), this.zoom = dt().filter((i) => this.options.scrollForPan && i.type === "wheel" ? i.ctrlKey && !i.button : (!i.ctrlKey || i.type === "wheel") && !i.button).on("zoom", this.handleZoom), this.setOptions(n), this.state = {
|
|
584
|
+
id: this.options.id || this.svg.attr("id") || at(),
|
|
889
585
|
minX: 0,
|
|
890
586
|
maxX: 0,
|
|
891
587
|
minY: 0,
|
|
892
588
|
maxY: 0
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
589
|
+
}, this.g = this.svg.append("g"), this.revokers.push(
|
|
590
|
+
xe.tap(() => {
|
|
591
|
+
this.setData();
|
|
592
|
+
})
|
|
593
|
+
);
|
|
898
594
|
}
|
|
899
595
|
getStyleContent() {
|
|
900
|
-
const {
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
const {
|
|
904
|
-
id
|
|
905
|
-
} = this.state;
|
|
906
|
-
const styleText = typeof style === 'function' ? style(id) : '';
|
|
907
|
-
return [this.options.embedGlobalCSS && css_248z$1, styleText].filter(Boolean).join('\n');
|
|
596
|
+
const { style: t } = this.options, { id: n } = this.state, i = typeof t == "function" ? t(n) : "";
|
|
597
|
+
return [this.options.embedGlobalCSS && nt, i].filter(Boolean).join(`
|
|
598
|
+
`);
|
|
908
599
|
}
|
|
909
600
|
updateStyle() {
|
|
910
|
-
this.svg.attr(
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
});
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
var _item$children, _parent$state, _item$payload;
|
|
955
|
-
item.children = (_item$children = item.children) == null ? void 0 : _item$children.map(child => _extends({}, child));
|
|
956
|
-
nodeId += 1;
|
|
957
|
-
const group = mountDom(jsx("div", {
|
|
958
|
-
className: "markmap-foreign",
|
|
959
|
-
style: groupStyle,
|
|
960
|
-
children: jsx("div", {
|
|
961
|
-
dangerouslySetInnerHTML: {
|
|
962
|
-
__html: item.content
|
|
963
|
-
}
|
|
964
|
-
})
|
|
965
|
-
}));
|
|
966
|
-
container.append(group);
|
|
967
|
-
item.state = _extends({}, item.state, {
|
|
968
|
-
id: nodeId,
|
|
969
|
-
el: group.firstChild
|
|
970
|
-
});
|
|
971
|
-
item.state.path = [parent == null || (_parent$state = parent.state) == null ? void 0 : _parent$state.path, item.state.id].filter(Boolean).join('.');
|
|
972
|
-
color(item); // preload colors
|
|
973
|
-
|
|
974
|
-
const isFoldRecursively = ((_item$payload = item.payload) == null ? void 0 : _item$payload.fold) === 2;
|
|
975
|
-
if (isFoldRecursively) {
|
|
976
|
-
foldRecursively += 1;
|
|
977
|
-
} else if (foldRecursively || initialExpandLevel >= 0 && item.depth >= initialExpandLevel) {
|
|
978
|
-
item.payload = _extends({}, item.payload, {
|
|
979
|
-
fold: 1
|
|
980
|
-
});
|
|
981
|
-
}
|
|
982
|
-
next();
|
|
983
|
-
if (isFoldRecursively) foldRecursively -= 1;
|
|
601
|
+
this.svg.attr(
|
|
602
|
+
"class",
|
|
603
|
+
lt(this.svg.attr("class"), "markmap", this.state.id)
|
|
604
|
+
);
|
|
605
|
+
const t = this.getStyleContent();
|
|
606
|
+
this.styleNode.text(t);
|
|
607
|
+
}
|
|
608
|
+
toggleNode(t, n = !1) {
|
|
609
|
+
var r, a;
|
|
610
|
+
const i = (r = t.payload) != null && r.fold ? 0 : 1;
|
|
611
|
+
n ? M(t, (c, s) => {
|
|
612
|
+
c.payload = {
|
|
613
|
+
...c.payload,
|
|
614
|
+
fold: i
|
|
615
|
+
}, s();
|
|
616
|
+
}) : t.payload = {
|
|
617
|
+
...t.payload,
|
|
618
|
+
fold: (a = t.payload) != null && a.fold ? 0 : 1
|
|
619
|
+
}, this.renderData(t);
|
|
620
|
+
}
|
|
621
|
+
initializeData(t) {
|
|
622
|
+
let n = 0;
|
|
623
|
+
const { color: i, nodeMinHeight: r, maxWidth: a, initialExpandLevel: c } = this.options, { id: s } = this.state, l = $(
|
|
624
|
+
/* @__PURE__ */ N("div", { className: `markmap-container markmap ${s}-g` })
|
|
625
|
+
), f = $(
|
|
626
|
+
/* @__PURE__ */ N("style", { children: [this.getStyleContent(), ge].join(`
|
|
627
|
+
`) })
|
|
628
|
+
);
|
|
629
|
+
document.body.append(l, f);
|
|
630
|
+
const h = a ? `max-width: ${a}px` : "";
|
|
631
|
+
let p = 0;
|
|
632
|
+
M(t, (d, S, x) => {
|
|
633
|
+
var v, k, w;
|
|
634
|
+
d.children = (v = d.children) == null ? void 0 : v.map((E) => ({ ...E })), n += 1;
|
|
635
|
+
const g = $(
|
|
636
|
+
/* @__PURE__ */ N("div", { className: "markmap-foreign", style: h, children: /* @__PURE__ */ N("div", { dangerouslySetInnerHTML: { __html: d.content } }) })
|
|
637
|
+
);
|
|
638
|
+
l.append(g), d.state = {
|
|
639
|
+
...d.state,
|
|
640
|
+
id: n,
|
|
641
|
+
el: g.firstChild
|
|
642
|
+
}, d.state.path = [(k = x == null ? void 0 : x.state) == null ? void 0 : k.path, d.state.id].filter(Boolean).join("."), i(d);
|
|
643
|
+
const y = ((w = d.payload) == null ? void 0 : w.fold) === 2;
|
|
644
|
+
y ? p += 1 : (p || c >= 0 && d.depth >= c) && (d.payload = { ...d.payload, fold: 1 }), S(), y && (p -= 1);
|
|
984
645
|
});
|
|
985
|
-
const
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
var
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
});
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
if (this.
|
|
1012
|
-
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
if (opts) this.setOptions(opts);
|
|
1024
|
-
if (data) this.state.data = data;
|
|
1025
|
-
if (!this.state.data) return;
|
|
1026
|
-
this.initializeData(this.state.data);
|
|
1027
|
-
this.updateStyle();
|
|
1028
|
-
this.renderData();
|
|
1029
|
-
}
|
|
1030
|
-
renderData(originData) {
|
|
1031
|
-
var _origin$data$state$x, _origin$data$state$y;
|
|
1032
|
-
if (!this.state.data) return;
|
|
1033
|
-
const {
|
|
1034
|
-
spacingHorizontal,
|
|
1035
|
-
paddingX,
|
|
1036
|
-
spacingVertical,
|
|
1037
|
-
autoFit,
|
|
1038
|
-
color
|
|
1039
|
-
} = this.options;
|
|
1040
|
-
const layout = flextree({}).children(d => {
|
|
1041
|
-
var _d$payload;
|
|
1042
|
-
if (!((_d$payload = d.payload) != null && _d$payload.fold)) return d.children;
|
|
1043
|
-
}).nodeSize(node => {
|
|
1044
|
-
const [width, height] = node.data.state.size;
|
|
1045
|
-
return [height, width + (width ? paddingX * 2 : 0) + spacingHorizontal];
|
|
1046
|
-
}).spacing((a, b) => {
|
|
1047
|
-
return a.parent === b.parent ? spacingVertical : spacingVertical * 2;
|
|
1048
|
-
});
|
|
1049
|
-
const tree = layout.hierarchy(this.state.data);
|
|
1050
|
-
layout(tree);
|
|
1051
|
-
const descendants = tree.descendants().reverse();
|
|
1052
|
-
const links = tree.links();
|
|
1053
|
-
const linkShape = linkHorizontal();
|
|
1054
|
-
const minX = min(descendants, d => d.x - d.xSize / 2);
|
|
1055
|
-
const maxX = max(descendants, d => d.x + d.xSize / 2);
|
|
1056
|
-
const minY = min(descendants, d => d.y);
|
|
1057
|
-
const maxY = max(descendants, d => d.y + d.ySize - spacingHorizontal);
|
|
646
|
+
const m = Array.from(l.childNodes).map(
|
|
647
|
+
(d) => d.firstChild
|
|
648
|
+
);
|
|
649
|
+
this.viewHooks.transformHtml.call(this, m), m.forEach((d) => {
|
|
650
|
+
var S;
|
|
651
|
+
(S = d.parentNode) == null || S.append(d.cloneNode(!0));
|
|
652
|
+
}), M(t, (d, S, x) => {
|
|
653
|
+
var v;
|
|
654
|
+
const g = d.state, y = g.el.getBoundingClientRect();
|
|
655
|
+
d.content = g.el.innerHTML, g.size = [
|
|
656
|
+
Math.ceil(y.width) + 1,
|
|
657
|
+
Math.max(Math.ceil(y.height), r)
|
|
658
|
+
], g.key = [(v = x == null ? void 0 : x.state) == null ? void 0 : v.id, g.id].filter(Boolean).join(".") + // FIXME: find a way to check content hash
|
|
659
|
+
d.content, S();
|
|
660
|
+
}), l.remove(), f.remove();
|
|
661
|
+
}
|
|
662
|
+
setOptions(t) {
|
|
663
|
+
this.options = {
|
|
664
|
+
...this.options,
|
|
665
|
+
...t
|
|
666
|
+
}, this.options.zoom ? this.svg.call(this.zoom) : this.svg.on(".zoom", null), this.options.pan ? this.svg.on("wheel", this.handlePan) : this.svg.on("wheel", null);
|
|
667
|
+
}
|
|
668
|
+
setData(t, n) {
|
|
669
|
+
n && this.setOptions(n), t && (this.state.data = t), this.state.data && (this.initializeData(this.state.data), this.updateStyle(), this.renderData());
|
|
670
|
+
}
|
|
671
|
+
renderData(t) {
|
|
672
|
+
if (!this.state.data)
|
|
673
|
+
return;
|
|
674
|
+
const { spacingHorizontal: n, paddingX: i, spacingVertical: r, autoFit: a, color: c } = this.options, s = Q({}).children((o) => {
|
|
675
|
+
var u;
|
|
676
|
+
if (!((u = o.payload) != null && u.fold))
|
|
677
|
+
return o.children;
|
|
678
|
+
}).nodeSize((o) => {
|
|
679
|
+
const [u, z] = o.data.state.size;
|
|
680
|
+
return [z, u + (u ? i * 2 : 0) + n];
|
|
681
|
+
}).spacing((o, u) => o.parent === u.parent ? r : r * 2), l = s.hierarchy(this.state.data);
|
|
682
|
+
s(l);
|
|
683
|
+
const f = l.descendants().reverse(), h = l.links(), p = ut(), m = I(f, (o) => o.x - o.xSize / 2), d = W(f, (o) => o.x + o.xSize / 2), S = I(f, (o) => o.y), x = W(f, (o) => o.y + o.ySize - n);
|
|
1058
684
|
Object.assign(this.state, {
|
|
1059
|
-
minX,
|
|
1060
|
-
maxX,
|
|
1061
|
-
minY,
|
|
1062
|
-
maxY
|
|
1063
|
-
});
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
this.transition(
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
685
|
+
minX: m,
|
|
686
|
+
maxX: d,
|
|
687
|
+
minY: S,
|
|
688
|
+
maxY: x
|
|
689
|
+
}), a && this.fit();
|
|
690
|
+
const g = t && f.find((o) => o.data === t) || l, y = g.data.state.x0 ?? g.x, v = g.data.state.y0 ?? g.y, k = this.g.selectAll(
|
|
691
|
+
b("g")
|
|
692
|
+
).data(f, (o) => o.data.state.key), w = k.enter().append("g").attr("data-depth", (o) => o.data.depth).attr("data-path", (o) => o.data.state.path).attr(
|
|
693
|
+
"transform",
|
|
694
|
+
(o) => `translate(${v + g.ySize - o.ySize},${y + g.xSize / 2 - o.xSize})`
|
|
695
|
+
), E = this.transition(k.exit());
|
|
696
|
+
E.select("line").attr("x1", (o) => o.ySize - n).attr("x2", (o) => o.ySize - n), E.select("foreignObject").style("opacity", 0), E.attr(
|
|
697
|
+
"transform",
|
|
698
|
+
(o) => `translate(${g.y + g.ySize - o.ySize},${g.x + g.xSize / 2 - o.xSize})`
|
|
699
|
+
).remove();
|
|
700
|
+
const X = k.merge(w).attr(
|
|
701
|
+
"class",
|
|
702
|
+
(o) => {
|
|
703
|
+
var u;
|
|
704
|
+
return ["markmap-node", ((u = o.data.payload) == null ? void 0 : u.fold) && "markmap-fold"].filter(Boolean).join(" ");
|
|
705
|
+
}
|
|
706
|
+
);
|
|
707
|
+
this.transition(X).attr(
|
|
708
|
+
"transform",
|
|
709
|
+
(o) => `translate(${o.y},${o.x - o.xSize / 2})`
|
|
710
|
+
);
|
|
711
|
+
const it = X.selectAll(
|
|
712
|
+
b("line")
|
|
713
|
+
).data(
|
|
714
|
+
(o) => [o],
|
|
715
|
+
(o) => o.data.state.key
|
|
716
|
+
).join(
|
|
717
|
+
(o) => o.append("line").attr("x1", (u) => u.ySize - n).attr("x2", (u) => u.ySize - n),
|
|
718
|
+
(o) => o,
|
|
719
|
+
(o) => o.remove()
|
|
720
|
+
);
|
|
721
|
+
this.transition(it).attr("x1", -1).attr("x2", (o) => o.ySize - n + 2).attr("y1", (o) => o.xSize).attr("y2", (o) => o.xSize).attr("stroke", (o) => c(o.data)).attr("stroke-width", Y);
|
|
722
|
+
const ot = X.selectAll(
|
|
723
|
+
b("circle")
|
|
724
|
+
).data(
|
|
725
|
+
(o) => {
|
|
726
|
+
var u;
|
|
727
|
+
return (u = o.data.children) != null && u.length ? [o] : [];
|
|
728
|
+
},
|
|
729
|
+
(o) => o.data.state.key
|
|
730
|
+
).join(
|
|
731
|
+
(o) => o.append("circle").attr("stroke-width", "1.5").attr("cx", (u) => u.ySize - n).attr("cy", (u) => u.xSize).attr("r", 0).on("click", (u, z) => this.handleClick(u, z)).on("mousedown", B),
|
|
732
|
+
(o) => o,
|
|
733
|
+
(o) => o.remove()
|
|
734
|
+
);
|
|
735
|
+
this.transition(ot).attr("r", 6).attr("cx", (o) => o.ySize - n).attr("cy", (o) => o.xSize).attr("stroke", (o) => c(o.data)).attr(
|
|
736
|
+
"fill",
|
|
737
|
+
(o) => {
|
|
738
|
+
var u;
|
|
739
|
+
return (u = o.data.payload) != null && u.fold && o.data.children ? c(o.data) : "#fff";
|
|
740
|
+
}
|
|
741
|
+
);
|
|
742
|
+
const rt = X.selectAll(
|
|
743
|
+
b("foreignObject")
|
|
744
|
+
).data(
|
|
745
|
+
(o) => [o],
|
|
746
|
+
(o) => o.data.state.key
|
|
747
|
+
).join(
|
|
748
|
+
(o) => {
|
|
749
|
+
const u = o.append("foreignObject").attr("class", "markmap-foreign").attr("x", i).attr("y", 0).style("opacity", 0).on("mousedown", B).on("dblclick", B);
|
|
750
|
+
return u.append("xhtml:div").select(function(T) {
|
|
751
|
+
const j = T.data.state.el.cloneNode(!0);
|
|
752
|
+
return this.replaceWith(j), j;
|
|
753
|
+
}).attr("xmlns", "http://www.w3.org/1999/xhtml"), u;
|
|
754
|
+
},
|
|
755
|
+
(o) => o,
|
|
756
|
+
(o) => o.remove()
|
|
757
|
+
).attr(
|
|
758
|
+
"width",
|
|
759
|
+
(o) => Math.max(0, o.ySize - n - i * 2)
|
|
760
|
+
).attr("height", (o) => o.xSize);
|
|
761
|
+
this.transition(rt).style("opacity", 1);
|
|
762
|
+
const st = this.g.selectAll(
|
|
763
|
+
b("path")
|
|
764
|
+
).data(h, (o) => o.target.data.state.key).join(
|
|
765
|
+
(o) => {
|
|
766
|
+
const u = [
|
|
767
|
+
v + g.ySize - n,
|
|
768
|
+
y + g.xSize / 2
|
|
769
|
+
];
|
|
770
|
+
return o.insert("path", "g").attr("class", "markmap-link").attr("data-depth", (z) => z.target.data.depth).attr("data-path", (z) => z.target.data.state.path).attr("d", p({ source: u, target: u }));
|
|
771
|
+
},
|
|
772
|
+
(o) => o,
|
|
773
|
+
(o) => {
|
|
774
|
+
const u = [
|
|
775
|
+
g.y + g.ySize - n,
|
|
776
|
+
g.x + g.xSize / 2
|
|
777
|
+
];
|
|
778
|
+
return this.transition(o).attr("d", p({ source: u, target: u })).remove();
|
|
779
|
+
}
|
|
780
|
+
);
|
|
781
|
+
this.transition(st).attr("stroke", (o) => c(o.target.data)).attr("stroke-width", (o) => Y(o.target)).attr("d", (o) => {
|
|
782
|
+
const u = o.source, z = o.target, T = [
|
|
783
|
+
u.y + u.ySize - n,
|
|
784
|
+
u.x + u.xSize / 2
|
|
785
|
+
], j = [
|
|
786
|
+
z.y,
|
|
787
|
+
z.x + z.xSize / 2
|
|
788
|
+
];
|
|
789
|
+
return p({ source: T, target: j });
|
|
790
|
+
}), f.forEach((o) => {
|
|
791
|
+
o.data.state.x0 = o.x, o.data.state.y0 = o.y;
|
|
1137
792
|
});
|
|
1138
793
|
}
|
|
1139
|
-
transition(
|
|
1140
|
-
const {
|
|
1141
|
-
|
|
1142
|
-
} = this.options;
|
|
1143
|
-
return sel.transition().duration(duration);
|
|
794
|
+
transition(t) {
|
|
795
|
+
const { duration: n } = this.options;
|
|
796
|
+
return t.transition().duration(n);
|
|
1144
797
|
}
|
|
1145
|
-
|
|
1146
798
|
/**
|
|
1147
799
|
* Fit the content to the viewport.
|
|
1148
800
|
*/
|
|
1149
801
|
async fit() {
|
|
1150
|
-
const
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
minX,
|
|
1160
|
-
maxX,
|
|
1161
|
-
minY,
|
|
1162
|
-
maxY
|
|
1163
|
-
} = this.state;
|
|
1164
|
-
const naturalWidth = maxY - minY;
|
|
1165
|
-
const naturalHeight = maxX - minX;
|
|
1166
|
-
const scale = Math.min(offsetWidth / naturalWidth * fitRatio, offsetHeight / naturalHeight * fitRatio, 2);
|
|
1167
|
-
const initialZoom = zoomIdentity.translate((offsetWidth - naturalWidth * scale) / 2 - minY * scale, (offsetHeight - naturalHeight * scale) / 2 - minX * scale).scale(scale);
|
|
1168
|
-
return this.transition(this.svg).call(this.zoom.transform, initialZoom).end().catch(noop);
|
|
802
|
+
const t = this.svg.node(), { width: n, height: i } = t.getBoundingClientRect(), { fitRatio: r } = this.options, { minX: a, maxX: c, minY: s, maxY: l } = this.state, f = l - s, h = c - a, p = Math.min(
|
|
803
|
+
n / f * r,
|
|
804
|
+
i / h * r,
|
|
805
|
+
2
|
|
806
|
+
), m = pt.translate(
|
|
807
|
+
(n - f * p) / 2 - s * p,
|
|
808
|
+
(i - h * p) / 2 - a * p
|
|
809
|
+
).scale(p);
|
|
810
|
+
return this.transition(this.svg).call(this.zoom.transform, m).end().catch(A);
|
|
1169
811
|
}
|
|
1170
|
-
|
|
1171
812
|
/**
|
|
1172
813
|
* Pan the content to make the provided node visible in the viewport.
|
|
1173
814
|
*/
|
|
1174
|
-
async ensureView(
|
|
1175
|
-
let
|
|
1176
|
-
this.g.selectAll(
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
})
|
|
1181
|
-
|
|
1182
|
-
const
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
const [top, bottom] = [itemData.x - itemData.xSize / 2, itemData.x + itemData.xSize / 2].map(y => y * transform.k + transform.y);
|
|
1190
|
-
// Skip if the node includes or is included in the container.
|
|
1191
|
-
const pd = _extends({
|
|
815
|
+
async ensureView(t, n) {
|
|
816
|
+
let i;
|
|
817
|
+
if (this.g.selectAll(
|
|
818
|
+
b("g")
|
|
819
|
+
).each(function(v) {
|
|
820
|
+
v.data === t && (i = v);
|
|
821
|
+
}), !i)
|
|
822
|
+
return;
|
|
823
|
+
const r = this.svg.node(), { spacingHorizontal: a } = this.options, c = r.getBoundingClientRect(), s = O(r), [l, f] = [
|
|
824
|
+
i.y,
|
|
825
|
+
i.y + i.ySize - a + 2
|
|
826
|
+
].map((y) => y * s.k + s.x), [h, p] = [
|
|
827
|
+
i.x - i.xSize / 2,
|
|
828
|
+
i.x + i.xSize / 2
|
|
829
|
+
].map((y) => y * s.k + s.y), m = {
|
|
1192
830
|
left: 0,
|
|
1193
831
|
right: 0,
|
|
1194
832
|
top: 0,
|
|
1195
|
-
bottom: 0
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
if (dx || dy) {
|
|
1202
|
-
const newTransform = transform.translate(dx, dy);
|
|
1203
|
-
return this.transition(this.svg).call(this.zoom.transform, newTransform).end().catch(noop);
|
|
833
|
+
bottom: 0,
|
|
834
|
+
...n
|
|
835
|
+
}, d = [m.left - l, c.width - m.right - f], S = [m.top - h, c.height - m.bottom - p], x = d[0] * d[1] > 0 ? K(d, Math.abs) / s.k : 0, g = S[0] * S[1] > 0 ? K(S, Math.abs) / s.k : 0;
|
|
836
|
+
if (x || g) {
|
|
837
|
+
const y = s.translate(x, g);
|
|
838
|
+
return this.transition(this.svg).call(this.zoom.transform, y).end().catch(A);
|
|
1204
839
|
}
|
|
1205
840
|
}
|
|
1206
|
-
|
|
1207
841
|
/**
|
|
1208
842
|
* Scale content with it pinned at the center of the viewport.
|
|
1209
843
|
*/
|
|
1210
|
-
async rescale(
|
|
1211
|
-
const
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
const halfWidth = offsetWidth / 2;
|
|
1217
|
-
const halfHeight = offsetHeight / 2;
|
|
1218
|
-
const transform = zoomTransform(svgNode);
|
|
1219
|
-
const newTransform = transform.translate((halfWidth - transform.x) * (1 - scale) / transform.k, (halfHeight - transform.y) * (1 - scale) / transform.k).scale(scale);
|
|
1220
|
-
return this.transition(this.svg).call(this.zoom.transform, newTransform).end().catch(noop);
|
|
844
|
+
async rescale(t) {
|
|
845
|
+
const n = this.svg.node(), { width: i, height: r } = n.getBoundingClientRect(), a = i / 2, c = r / 2, s = O(n), l = s.translate(
|
|
846
|
+
(a - s.x) * (1 - t) / s.k,
|
|
847
|
+
(c - s.y) * (1 - t) / s.k
|
|
848
|
+
).scale(t);
|
|
849
|
+
return this.transition(this.svg).call(this.zoom.transform, l).end().catch(A);
|
|
1221
850
|
}
|
|
1222
851
|
destroy() {
|
|
1223
|
-
this.svg.on(
|
|
1224
|
-
|
|
1225
|
-
this.revokers.forEach(fn => {
|
|
1226
|
-
fn();
|
|
852
|
+
this.svg.on(".zoom", null), this.svg.html(null), this.revokers.forEach((t) => {
|
|
853
|
+
t();
|
|
1227
854
|
});
|
|
1228
855
|
}
|
|
1229
|
-
static create(
|
|
1230
|
-
const
|
|
1231
|
-
|
|
1232
|
-
mm.setData(data);
|
|
1233
|
-
mm.fit(); // always fit for the first render
|
|
1234
|
-
}
|
|
1235
|
-
|
|
1236
|
-
return mm;
|
|
856
|
+
static create(t, n, i = null) {
|
|
857
|
+
const r = new C(t, n);
|
|
858
|
+
return i && (r.setData(i), r.fit()), r;
|
|
1237
859
|
}
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1240
|
-
autoFit:
|
|
1241
|
-
color:
|
|
1242
|
-
var
|
|
1243
|
-
return
|
|
860
|
+
};
|
|
861
|
+
C.defaultOptions = {
|
|
862
|
+
autoFit: !1,
|
|
863
|
+
color: (t) => {
|
|
864
|
+
var n;
|
|
865
|
+
return ye(`${((n = t.state) == null ? void 0 : n.path) || ""}`);
|
|
1244
866
|
},
|
|
1245
867
|
duration: 500,
|
|
1246
|
-
embedGlobalCSS:
|
|
868
|
+
embedGlobalCSS: !0,
|
|
1247
869
|
fitRatio: 0.95,
|
|
1248
870
|
maxWidth: 0,
|
|
1249
871
|
nodeMinHeight: 16,
|
|
1250
872
|
paddingX: 8,
|
|
1251
|
-
scrollForPan:
|
|
873
|
+
scrollForPan: P,
|
|
1252
874
|
spacingHorizontal: 80,
|
|
1253
875
|
spacingVertical: 5,
|
|
1254
876
|
initialExpandLevel: -1,
|
|
1255
|
-
zoom:
|
|
1256
|
-
pan:
|
|
1257
|
-
toggleRecursively:
|
|
877
|
+
zoom: !0,
|
|
878
|
+
pan: !0,
|
|
879
|
+
toggleRecursively: !1
|
|
880
|
+
};
|
|
881
|
+
let F = C;
|
|
882
|
+
function ke(e) {
|
|
883
|
+
const t = {}, n = { ...e }, { color: i, colorFreezeLevel: r } = n;
|
|
884
|
+
if ((i == null ? void 0 : i.length) === 1) {
|
|
885
|
+
const s = i[0];
|
|
886
|
+
t.color = () => s;
|
|
887
|
+
} else if (i != null && i.length) {
|
|
888
|
+
const s = G(i);
|
|
889
|
+
t.color = (l) => s(`${l.state.path}`);
|
|
890
|
+
}
|
|
891
|
+
if (r) {
|
|
892
|
+
const s = t.color || F.defaultOptions.color;
|
|
893
|
+
t.color = (l) => (l = {
|
|
894
|
+
...l,
|
|
895
|
+
state: {
|
|
896
|
+
...l.state,
|
|
897
|
+
path: l.state.path.split(".").slice(0, r).join(".")
|
|
898
|
+
}
|
|
899
|
+
}, s(l));
|
|
900
|
+
}
|
|
901
|
+
return ["duration", "maxWidth", "initialExpandLevel"].forEach((s) => {
|
|
902
|
+
const l = n[s];
|
|
903
|
+
typeof l == "number" && (t[s] = l);
|
|
904
|
+
}), ["zoom", "pan"].forEach((s) => {
|
|
905
|
+
const l = n[s];
|
|
906
|
+
l != null && (t[s] = !!l);
|
|
907
|
+
}), t;
|
|
908
|
+
}
|
|
909
|
+
export {
|
|
910
|
+
F as Markmap,
|
|
911
|
+
ye as defaultColorFn,
|
|
912
|
+
ke as deriveOptions,
|
|
913
|
+
ze as globalCSS,
|
|
914
|
+
Ce as loadCSS,
|
|
915
|
+
we as loadJS,
|
|
916
|
+
xe as refreshHook
|
|
1258
917
|
};
|
|
1259
|
-
function deriveOptions(jsonOptions) {
|
|
1260
|
-
const derivedOptions = {};
|
|
1261
|
-
const options = _extends({}, jsonOptions);
|
|
1262
|
-
const {
|
|
1263
|
-
color,
|
|
1264
|
-
colorFreezeLevel
|
|
1265
|
-
} = options;
|
|
1266
|
-
if ((color == null ? void 0 : color.length) === 1) {
|
|
1267
|
-
const solidColor = color[0];
|
|
1268
|
-
derivedOptions.color = () => solidColor;
|
|
1269
|
-
} else if (color != null && color.length) {
|
|
1270
|
-
const colorFn = scaleOrdinal(color);
|
|
1271
|
-
derivedOptions.color = node => colorFn(`${node.state.path}`);
|
|
1272
|
-
}
|
|
1273
|
-
if (colorFreezeLevel) {
|
|
1274
|
-
const color = derivedOptions.color || Markmap.defaultOptions.color;
|
|
1275
|
-
derivedOptions.color = node => {
|
|
1276
|
-
node = _extends({}, node, {
|
|
1277
|
-
state: _extends({}, node.state, {
|
|
1278
|
-
path: node.state.path.split('.').slice(0, colorFreezeLevel).join('.')
|
|
1279
|
-
})
|
|
1280
|
-
});
|
|
1281
|
-
return color(node);
|
|
1282
|
-
};
|
|
1283
|
-
}
|
|
1284
|
-
const numberKeys = ['duration', 'maxWidth', 'initialExpandLevel'];
|
|
1285
|
-
numberKeys.forEach(key => {
|
|
1286
|
-
const value = options[key];
|
|
1287
|
-
if (typeof value === 'number') derivedOptions[key] = value;
|
|
1288
|
-
});
|
|
1289
|
-
const booleanKeys = ['zoom', 'pan'];
|
|
1290
|
-
booleanKeys.forEach(key => {
|
|
1291
|
-
const value = options[key];
|
|
1292
|
-
if (value != null) derivedOptions[key] = !!value;
|
|
1293
|
-
});
|
|
1294
|
-
return derivedOptions;
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
|
-
export { Markmap, defaultColorFn, deriveOptions, globalCSS, refreshHook };
|