markmap-view 0.15.8 → 0.15.9-alpha.0
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 +130 -81
- package/dist/constants.d.ts +4 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +427 -407
- package/dist/types.d.ts +11 -0
- package/dist/util.d.ts +3 -0
- package/dist/view.d.ts +5 -8
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,18 +1,65 @@
|
|
|
1
|
-
import { Hook as
|
|
2
|
-
import { loadCSS as
|
|
3
|
-
import { scaleOrdinal as
|
|
1
|
+
import { Hook as st, getId as at, debounce as lt, addClass as ct, walkTree as T, childSelector as E, noop as M } from "markmap-common";
|
|
2
|
+
import { loadCSS as Ee, loadJS as we } from "markmap-common";
|
|
3
|
+
import { scaleOrdinal as V, schemeCategory10 as ht, zoomTransform as A, select as dt, zoom as ut, linkHorizontal as pt, min as H, max as L, zoomIdentity as ft, minIndex as mt } from "d3";
|
|
4
|
+
const K = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), gt = V(ht), P = {
|
|
5
|
+
autoFit: !1,
|
|
6
|
+
color: (e) => {
|
|
7
|
+
var t;
|
|
8
|
+
return gt(`${((t = e.state) == null ? void 0 : t.path) || ""}`);
|
|
9
|
+
},
|
|
10
|
+
duration: 500,
|
|
11
|
+
embedGlobalCSS: !0,
|
|
12
|
+
fitRatio: 0.95,
|
|
13
|
+
maxWidth: 0,
|
|
14
|
+
nodeMinHeight: 16,
|
|
15
|
+
paddingX: 8,
|
|
16
|
+
scrollForPan: K,
|
|
17
|
+
spacingHorizontal: 80,
|
|
18
|
+
spacingVertical: 5,
|
|
19
|
+
initialExpandLevel: -1,
|
|
20
|
+
zoom: !0,
|
|
21
|
+
pan: !0,
|
|
22
|
+
toggleRecursively: !1
|
|
23
|
+
};
|
|
24
|
+
function Se(e) {
|
|
25
|
+
const t = {}, n = { ...e }, { color: i, colorFreezeLevel: o } = n;
|
|
26
|
+
if ((i == null ? void 0 : i.length) === 1) {
|
|
27
|
+
const s = i[0];
|
|
28
|
+
t.color = () => s;
|
|
29
|
+
} else if (i != null && i.length) {
|
|
30
|
+
const s = V(i);
|
|
31
|
+
t.color = (l) => s(`${l.state.path}`);
|
|
32
|
+
}
|
|
33
|
+
if (o) {
|
|
34
|
+
const s = t.color || P.color;
|
|
35
|
+
t.color = (l) => (l = {
|
|
36
|
+
...l,
|
|
37
|
+
state: {
|
|
38
|
+
...l.state,
|
|
39
|
+
path: l.state.path.split(".").slice(0, o).join(".")
|
|
40
|
+
}
|
|
41
|
+
}, s(l));
|
|
42
|
+
}
|
|
43
|
+
return ["duration", "maxWidth", "initialExpandLevel"].forEach((s) => {
|
|
44
|
+
const l = n[s];
|
|
45
|
+
typeof l == "number" && (t[s] = l);
|
|
46
|
+
}), ["zoom", "pan"].forEach((s) => {
|
|
47
|
+
const l = n[s];
|
|
48
|
+
l != null && (t[s] = !!l);
|
|
49
|
+
}), t;
|
|
50
|
+
}
|
|
4
51
|
/*! @gera2ld/jsx-dom v2.2.2 | ISC License */
|
|
5
|
-
const
|
|
6
|
-
show:
|
|
7
|
-
actuate:
|
|
8
|
-
href:
|
|
9
|
-
},
|
|
10
|
-
function
|
|
52
|
+
const U = 1, G = 2, xt = "http://www.w3.org/2000/svg", _ = "http://www.w3.org/1999/xlink", yt = {
|
|
53
|
+
show: _,
|
|
54
|
+
actuate: _,
|
|
55
|
+
href: _
|
|
56
|
+
}, 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;
|
|
57
|
+
function j(e, t) {
|
|
11
58
|
let n;
|
|
12
59
|
if (typeof e == "string")
|
|
13
|
-
n =
|
|
60
|
+
n = U;
|
|
14
61
|
else if (typeof e == "function")
|
|
15
|
-
n =
|
|
62
|
+
n = G;
|
|
16
63
|
else
|
|
17
64
|
throw new Error("Invalid VNode type");
|
|
18
65
|
return {
|
|
@@ -21,47 +68,47 @@ function N(e, t) {
|
|
|
21
68
|
props: t
|
|
22
69
|
};
|
|
23
70
|
}
|
|
24
|
-
function
|
|
71
|
+
function bt(e) {
|
|
25
72
|
return e.children;
|
|
26
73
|
}
|
|
27
74
|
const zt = {
|
|
28
75
|
isSvg: !1
|
|
29
76
|
};
|
|
30
|
-
function
|
|
77
|
+
function I(e, t) {
|
|
31
78
|
Array.isArray(t) || (t = [t]), t = t.filter(Boolean), t.length && e.append(...t);
|
|
32
79
|
}
|
|
33
|
-
function
|
|
80
|
+
function Ct(e, t, n) {
|
|
34
81
|
for (const i in t)
|
|
35
82
|
if (!(i === "key" || i === "children" || i === "ref"))
|
|
36
83
|
if (i === "dangerouslySetInnerHTML")
|
|
37
84
|
e.innerHTML = t[i].__html;
|
|
38
85
|
else if (i === "innerHTML" || i === "textContent" || i === "innerText" || i === "value" && ["textarea", "select"].includes(e.tagName)) {
|
|
39
|
-
const
|
|
40
|
-
|
|
86
|
+
const o = t[i];
|
|
87
|
+
o != null && (e[i] = o);
|
|
41
88
|
} else
|
|
42
|
-
i.startsWith("on") ? e[i.toLowerCase()] = t[i] :
|
|
89
|
+
i.startsWith("on") ? e[i.toLowerCase()] = t[i] : wt(e, i, t[i], n.isSvg);
|
|
43
90
|
}
|
|
44
|
-
const
|
|
91
|
+
const Et = {
|
|
45
92
|
className: "class",
|
|
46
93
|
labelFor: "for"
|
|
47
94
|
};
|
|
48
|
-
function
|
|
49
|
-
if (t =
|
|
95
|
+
function wt(e, t, n, i) {
|
|
96
|
+
if (t = Et[t] || t, n === !0)
|
|
50
97
|
e.setAttribute(t, "");
|
|
51
98
|
else if (n === !1)
|
|
52
99
|
e.removeAttribute(t);
|
|
53
100
|
else {
|
|
54
|
-
const
|
|
55
|
-
|
|
101
|
+
const o = i ? yt[t] : void 0;
|
|
102
|
+
o !== void 0 ? e.setAttributeNS(o, t, n) : e.setAttribute(t, n);
|
|
56
103
|
}
|
|
57
104
|
}
|
|
58
|
-
function
|
|
105
|
+
function Xt(e) {
|
|
59
106
|
return e.reduce((t, n) => t.concat(n), []);
|
|
60
107
|
}
|
|
61
|
-
function
|
|
62
|
-
return Array.isArray(e) ?
|
|
108
|
+
function $(e, t) {
|
|
109
|
+
return Array.isArray(e) ? Xt(e.map((n) => $(n, t))) : B(e, t);
|
|
63
110
|
}
|
|
64
|
-
function
|
|
111
|
+
function B(e, t = zt) {
|
|
65
112
|
if (e == null || typeof e == "boolean")
|
|
66
113
|
return null;
|
|
67
114
|
if (e instanceof Node)
|
|
@@ -71,46 +118,46 @@ function _(e, t = zt) {
|
|
|
71
118
|
type: n,
|
|
72
119
|
props: i
|
|
73
120
|
} = e;
|
|
74
|
-
if (n ===
|
|
121
|
+
if (n === bt) {
|
|
75
122
|
const a = document.createDocumentFragment();
|
|
76
123
|
if (i.children) {
|
|
77
|
-
const c =
|
|
78
|
-
|
|
124
|
+
const c = $(i.children, t);
|
|
125
|
+
I(a, c);
|
|
79
126
|
}
|
|
80
127
|
return a;
|
|
81
128
|
}
|
|
82
|
-
const
|
|
83
|
-
return
|
|
129
|
+
const o = n(i);
|
|
130
|
+
return B(o, t);
|
|
84
131
|
}
|
|
85
|
-
if (
|
|
132
|
+
if (kt(e))
|
|
86
133
|
return document.createTextNode(`${e}`);
|
|
87
|
-
if (
|
|
134
|
+
if (vt(e)) {
|
|
88
135
|
let n;
|
|
89
136
|
const {
|
|
90
137
|
type: i,
|
|
91
|
-
props:
|
|
138
|
+
props: o
|
|
92
139
|
} = e;
|
|
93
140
|
if (!t.isSvg && i === "svg" && (t = Object.assign({}, t, {
|
|
94
141
|
isSvg: !0
|
|
95
|
-
})), t.isSvg ? n = document.createElementNS(
|
|
142
|
+
})), t.isSvg ? n = document.createElementNS(xt, i) : n = document.createElement(i), Ct(n, o, t), o.children) {
|
|
96
143
|
let c = t;
|
|
97
144
|
t.isSvg && i === "foreignObject" && (c = Object.assign({}, c, {
|
|
98
145
|
isSvg: !1
|
|
99
146
|
}));
|
|
100
|
-
const s =
|
|
101
|
-
s != null &&
|
|
147
|
+
const s = $(o.children, c);
|
|
148
|
+
s != null && I(n, s);
|
|
102
149
|
}
|
|
103
150
|
const {
|
|
104
151
|
ref: a
|
|
105
|
-
} =
|
|
152
|
+
} = o;
|
|
106
153
|
return typeof a == "function" && a(n), n;
|
|
107
154
|
}
|
|
108
155
|
throw new Error("mount: Invalid Vnode!");
|
|
109
156
|
}
|
|
110
|
-
function
|
|
111
|
-
return
|
|
157
|
+
function O(e) {
|
|
158
|
+
return B(e);
|
|
112
159
|
}
|
|
113
|
-
function
|
|
160
|
+
function jt(e) {
|
|
114
161
|
var t = 0, n = e.children, i = n && n.length;
|
|
115
162
|
if (!i)
|
|
116
163
|
t = 1;
|
|
@@ -119,130 +166,130 @@ function wt(e) {
|
|
|
119
166
|
t += n[i].value;
|
|
120
167
|
e.value = t;
|
|
121
168
|
}
|
|
122
|
-
function
|
|
123
|
-
return this.eachAfter(
|
|
169
|
+
function Nt() {
|
|
170
|
+
return this.eachAfter(jt);
|
|
124
171
|
}
|
|
125
|
-
function
|
|
126
|
-
var t = this, n, i = [t],
|
|
172
|
+
function Rt(e) {
|
|
173
|
+
var t = this, n, i = [t], o, a, c;
|
|
127
174
|
do
|
|
128
175
|
for (n = i.reverse(), i = []; t = n.pop(); )
|
|
129
|
-
if (e(t),
|
|
130
|
-
for (a = 0, c =
|
|
131
|
-
i.push(
|
|
176
|
+
if (e(t), o = t.children, o)
|
|
177
|
+
for (a = 0, c = o.length; a < c; ++a)
|
|
178
|
+
i.push(o[a]);
|
|
132
179
|
while (i.length);
|
|
133
180
|
return this;
|
|
134
181
|
}
|
|
135
|
-
function
|
|
136
|
-
for (var t = this, n = [t], i,
|
|
182
|
+
function Tt(e) {
|
|
183
|
+
for (var t = this, n = [t], i, o; t = n.pop(); )
|
|
137
184
|
if (e(t), i = t.children, i)
|
|
138
|
-
for (
|
|
139
|
-
n.push(i[
|
|
185
|
+
for (o = i.length - 1; o >= 0; --o)
|
|
186
|
+
n.push(i[o]);
|
|
140
187
|
return this;
|
|
141
188
|
}
|
|
142
|
-
function
|
|
143
|
-
for (var t = this, n = [t], i = [],
|
|
144
|
-
if (i.push(t),
|
|
145
|
-
for (a = 0, c =
|
|
146
|
-
n.push(
|
|
189
|
+
function Mt(e) {
|
|
190
|
+
for (var t = this, n = [t], i = [], o, a, c; t = n.pop(); )
|
|
191
|
+
if (i.push(t), o = t.children, o)
|
|
192
|
+
for (a = 0, c = o.length; a < c; ++a)
|
|
193
|
+
n.push(o[a]);
|
|
147
194
|
for (; t = i.pop(); )
|
|
148
195
|
e(t);
|
|
149
196
|
return this;
|
|
150
197
|
}
|
|
151
|
-
function
|
|
198
|
+
function At(e) {
|
|
152
199
|
return this.eachAfter(function(t) {
|
|
153
|
-
for (var n = +e(t.data) || 0, i = t.children,
|
|
154
|
-
n += i[
|
|
200
|
+
for (var n = +e(t.data) || 0, i = t.children, o = i && i.length; --o >= 0; )
|
|
201
|
+
n += i[o].value;
|
|
155
202
|
t.value = n;
|
|
156
203
|
});
|
|
157
204
|
}
|
|
158
|
-
function
|
|
205
|
+
function _t(e) {
|
|
159
206
|
return this.eachBefore(function(t) {
|
|
160
207
|
t.children && t.children.sort(e);
|
|
161
208
|
});
|
|
162
209
|
}
|
|
163
|
-
function
|
|
164
|
-
for (var t = this, n =
|
|
210
|
+
function Ot(e) {
|
|
211
|
+
for (var t = this, n = Dt(t, e), i = [t]; t !== n; )
|
|
165
212
|
t = t.parent, i.push(t);
|
|
166
|
-
for (var
|
|
167
|
-
i.splice(
|
|
213
|
+
for (var o = i.length; e !== n; )
|
|
214
|
+
i.splice(o, 0, e), e = e.parent;
|
|
168
215
|
return i;
|
|
169
216
|
}
|
|
170
|
-
function
|
|
217
|
+
function Dt(e, t) {
|
|
171
218
|
if (e === t)
|
|
172
219
|
return e;
|
|
173
|
-
var n = e.ancestors(), i = t.ancestors(),
|
|
220
|
+
var n = e.ancestors(), i = t.ancestors(), o = null;
|
|
174
221
|
for (e = n.pop(), t = i.pop(); e === t; )
|
|
175
|
-
|
|
176
|
-
return
|
|
222
|
+
o = e, e = n.pop(), t = i.pop();
|
|
223
|
+
return o;
|
|
177
224
|
}
|
|
178
|
-
function
|
|
225
|
+
function $t() {
|
|
179
226
|
for (var e = this, t = [e]; e = e.parent; )
|
|
180
227
|
t.push(e);
|
|
181
228
|
return t;
|
|
182
229
|
}
|
|
183
|
-
function
|
|
230
|
+
function Bt() {
|
|
184
231
|
var e = [];
|
|
185
232
|
return this.each(function(t) {
|
|
186
233
|
e.push(t);
|
|
187
234
|
}), e;
|
|
188
235
|
}
|
|
189
|
-
function
|
|
236
|
+
function Ft() {
|
|
190
237
|
var e = [];
|
|
191
238
|
return this.eachBefore(function(t) {
|
|
192
239
|
t.children || e.push(t);
|
|
193
240
|
}), e;
|
|
194
241
|
}
|
|
195
|
-
function
|
|
242
|
+
function Ht() {
|
|
196
243
|
var e = this, t = [];
|
|
197
244
|
return e.each(function(n) {
|
|
198
245
|
n !== e && t.push({ source: n.parent, target: n });
|
|
199
246
|
}), t;
|
|
200
247
|
}
|
|
201
|
-
function
|
|
202
|
-
var n = new
|
|
203
|
-
for (t == null && (t =
|
|
204
|
-
if (i && (
|
|
205
|
-
for (
|
|
206
|
-
a.push(c =
|
|
207
|
-
return n.eachBefore(
|
|
248
|
+
function F(e, t) {
|
|
249
|
+
var n = new N(e), i = +e.value && (n.value = e.value), o, a = [n], c, s, l, p;
|
|
250
|
+
for (t == null && (t = It); o = a.pop(); )
|
|
251
|
+
if (i && (o.value = +o.data.value), (s = t(o.data)) && (p = s.length))
|
|
252
|
+
for (o.children = new Array(p), l = p - 1; l >= 0; --l)
|
|
253
|
+
a.push(c = o.children[l] = new N(s[l])), c.parent = o, c.depth = o.depth + 1;
|
|
254
|
+
return n.eachBefore(Yt);
|
|
208
255
|
}
|
|
209
|
-
function
|
|
210
|
-
return
|
|
256
|
+
function Lt() {
|
|
257
|
+
return F(this).eachBefore(Wt);
|
|
211
258
|
}
|
|
212
|
-
function
|
|
259
|
+
function It(e) {
|
|
213
260
|
return e.children;
|
|
214
261
|
}
|
|
215
|
-
function
|
|
262
|
+
function Wt(e) {
|
|
216
263
|
e.data = e.data.data;
|
|
217
264
|
}
|
|
218
|
-
function
|
|
265
|
+
function Yt(e) {
|
|
219
266
|
var t = 0;
|
|
220
267
|
do
|
|
221
268
|
e.height = t;
|
|
222
269
|
while ((e = e.parent) && e.height < ++t);
|
|
223
270
|
}
|
|
224
|
-
function
|
|
271
|
+
function N(e) {
|
|
225
272
|
this.data = e, this.depth = this.height = 0, this.parent = null;
|
|
226
273
|
}
|
|
227
|
-
|
|
228
|
-
constructor:
|
|
229
|
-
count:
|
|
230
|
-
each:
|
|
231
|
-
eachAfter:
|
|
232
|
-
eachBefore:
|
|
233
|
-
sum:
|
|
234
|
-
sort:
|
|
235
|
-
path:
|
|
236
|
-
ancestors:
|
|
237
|
-
descendants:
|
|
238
|
-
leaves:
|
|
239
|
-
links:
|
|
240
|
-
copy:
|
|
274
|
+
N.prototype = F.prototype = {
|
|
275
|
+
constructor: N,
|
|
276
|
+
count: Nt,
|
|
277
|
+
each: Rt,
|
|
278
|
+
eachAfter: Mt,
|
|
279
|
+
eachBefore: Tt,
|
|
280
|
+
sum: At,
|
|
281
|
+
sort: _t,
|
|
282
|
+
path: Ot,
|
|
283
|
+
ancestors: $t,
|
|
284
|
+
descendants: Bt,
|
|
285
|
+
leaves: Ft,
|
|
286
|
+
links: Ht,
|
|
287
|
+
copy: Lt
|
|
241
288
|
};
|
|
242
|
-
const
|
|
289
|
+
const Vt = "d3-flextree", Kt = "2.1.2", Pt = "build/d3-flextree.js", Ut = "index", Gt = {
|
|
243
290
|
name: "Chris Maloney",
|
|
244
291
|
url: "http://chrismaloney.org"
|
|
245
|
-
},
|
|
292
|
+
}, Zt = "Flexible tree layout algorithm that allows for variable node sizes.", qt = [
|
|
246
293
|
"d3",
|
|
247
294
|
"d3-module",
|
|
248
295
|
"layout",
|
|
@@ -254,10 +301,10 @@ const Wt = "d3-flextree", Vt = "2.1.2", Yt = "build/d3-flextree.js", Kt = "index
|
|
|
254
301
|
"infovis",
|
|
255
302
|
"visualization",
|
|
256
303
|
"2d"
|
|
257
|
-
],
|
|
304
|
+
], Jt = "https://github.com/klortho/d3-flextree", Qt = "WTFPL", te = {
|
|
258
305
|
type: "git",
|
|
259
306
|
url: "https://github.com/klortho/d3-flextree.git"
|
|
260
|
-
},
|
|
307
|
+
}, ee = {
|
|
261
308
|
clean: "rm -rf build demo test",
|
|
262
309
|
"build:demo": "rollup -c --environment BUILD:demo",
|
|
263
310
|
"build:dev": "rollup -c --environment BUILD:dev",
|
|
@@ -269,9 +316,9 @@ const Wt = "d3-flextree", Vt = "2.1.2", Yt = "build/d3-flextree.js", Kt = "index
|
|
|
269
316
|
"test:browser": "node test/browser-tests.js",
|
|
270
317
|
test: "npm-run-all test:*",
|
|
271
318
|
prepare: "npm-run-all clean build lint test"
|
|
272
|
-
},
|
|
319
|
+
}, ne = {
|
|
273
320
|
"d3-hierarchy": "^1.1.5"
|
|
274
|
-
},
|
|
321
|
+
}, ie = {
|
|
275
322
|
"babel-plugin-external-helpers": "^6.22.0",
|
|
276
323
|
"babel-preset-es2015-rollup": "^3.0.0",
|
|
277
324
|
d3: "^4.13.0",
|
|
@@ -287,45 +334,45 @@ const Wt = "d3-flextree", Vt = "2.1.2", Yt = "build/d3-flextree.js", Kt = "index
|
|
|
287
334
|
"rollup-plugin-node-resolve": "^3.0.2",
|
|
288
335
|
"rollup-plugin-uglify": "^3.0.0",
|
|
289
336
|
"uglify-es": "^3.3.9"
|
|
290
|
-
},
|
|
291
|
-
name:
|
|
292
|
-
version:
|
|
293
|
-
main:
|
|
294
|
-
module:
|
|
337
|
+
}, re = {
|
|
338
|
+
name: Vt,
|
|
339
|
+
version: Kt,
|
|
340
|
+
main: Pt,
|
|
341
|
+
module: Ut,
|
|
295
342
|
"jsnext:main": "index",
|
|
296
|
-
author:
|
|
297
|
-
description:
|
|
298
|
-
keywords:
|
|
299
|
-
homepage:
|
|
300
|
-
license:
|
|
301
|
-
repository:
|
|
302
|
-
scripts:
|
|
303
|
-
dependencies:
|
|
304
|
-
devDependencies:
|
|
305
|
-
}, { version:
|
|
343
|
+
author: Gt,
|
|
344
|
+
description: Zt,
|
|
345
|
+
keywords: qt,
|
|
346
|
+
homepage: Jt,
|
|
347
|
+
license: Qt,
|
|
348
|
+
repository: te,
|
|
349
|
+
scripts: ee,
|
|
350
|
+
dependencies: ne,
|
|
351
|
+
devDependencies: ie
|
|
352
|
+
}, { version: oe } = re, se = Object.freeze({
|
|
306
353
|
children: (e) => e.children,
|
|
307
354
|
nodeSize: (e) => e.data.size,
|
|
308
355
|
spacing: 0
|
|
309
356
|
});
|
|
310
|
-
function
|
|
311
|
-
const t = Object.assign({},
|
|
357
|
+
function q(e) {
|
|
358
|
+
const t = Object.assign({}, se, e);
|
|
312
359
|
function n(s) {
|
|
313
360
|
const l = t[s];
|
|
314
361
|
return typeof l == "function" ? l : () => l;
|
|
315
362
|
}
|
|
316
363
|
function i(s) {
|
|
317
|
-
const l = c(a(), s, (
|
|
364
|
+
const l = c(a(), s, (p) => p.children);
|
|
318
365
|
return l.update(), l.data;
|
|
319
366
|
}
|
|
320
|
-
function
|
|
367
|
+
function o() {
|
|
321
368
|
const s = n("nodeSize"), l = n("spacing");
|
|
322
|
-
return class
|
|
369
|
+
return class Z extends F.prototype.constructor {
|
|
323
370
|
constructor(h) {
|
|
324
371
|
super(h);
|
|
325
372
|
}
|
|
326
373
|
copy() {
|
|
327
|
-
const h = c(this.constructor, this, (
|
|
328
|
-
return h.each((
|
|
374
|
+
const h = c(this.constructor, this, (u) => u.children);
|
|
375
|
+
return h.each((u) => u.data = u.data.data), h;
|
|
329
376
|
}
|
|
330
377
|
get size() {
|
|
331
378
|
return s(this);
|
|
@@ -375,7 +422,7 @@ function Q(e) {
|
|
|
375
422
|
}
|
|
376
423
|
get extents() {
|
|
377
424
|
return (this.children || []).reduce(
|
|
378
|
-
(h,
|
|
425
|
+
(h, u) => Z.maxExtents(h, u.extents),
|
|
379
426
|
this.nodeExtents
|
|
380
427
|
);
|
|
381
428
|
}
|
|
@@ -387,18 +434,18 @@ function Q(e) {
|
|
|
387
434
|
right: this.right
|
|
388
435
|
};
|
|
389
436
|
}
|
|
390
|
-
static maxExtents(h,
|
|
437
|
+
static maxExtents(h, u) {
|
|
391
438
|
return {
|
|
392
|
-
top: Math.min(h.top,
|
|
393
|
-
bottom: Math.max(h.bottom,
|
|
394
|
-
left: Math.min(h.left,
|
|
395
|
-
right: Math.max(h.right,
|
|
439
|
+
top: Math.min(h.top, u.top),
|
|
440
|
+
bottom: Math.max(h.bottom, u.bottom),
|
|
441
|
+
left: Math.min(h.left, u.left),
|
|
442
|
+
right: Math.max(h.right, u.right)
|
|
396
443
|
};
|
|
397
444
|
}
|
|
398
445
|
};
|
|
399
446
|
}
|
|
400
447
|
function a() {
|
|
401
|
-
const s =
|
|
448
|
+
const s = o(), l = n("nodeSize"), p = n("spacing");
|
|
402
449
|
return class extends s {
|
|
403
450
|
constructor(h) {
|
|
404
451
|
super(h), Object.assign(this, {
|
|
@@ -420,7 +467,7 @@ function Q(e) {
|
|
|
420
467
|
return l(this.data);
|
|
421
468
|
}
|
|
422
469
|
spacing(h) {
|
|
423
|
-
return
|
|
470
|
+
return p(this.data, h.data);
|
|
424
471
|
}
|
|
425
472
|
get x() {
|
|
426
473
|
return this.data.x;
|
|
@@ -435,27 +482,27 @@ function Q(e) {
|
|
|
435
482
|
this.data.y = h;
|
|
436
483
|
}
|
|
437
484
|
update() {
|
|
438
|
-
return
|
|
485
|
+
return J(this), Q(this), this;
|
|
439
486
|
}
|
|
440
487
|
};
|
|
441
488
|
}
|
|
442
|
-
function c(s, l,
|
|
443
|
-
const h = (
|
|
444
|
-
const
|
|
445
|
-
Object.assign(
|
|
446
|
-
parent:
|
|
447
|
-
depth:
|
|
489
|
+
function c(s, l, p) {
|
|
490
|
+
const h = (u, g) => {
|
|
491
|
+
const y = new s(u);
|
|
492
|
+
Object.assign(y, {
|
|
493
|
+
parent: g,
|
|
494
|
+
depth: g === null ? 0 : g.depth + 1,
|
|
448
495
|
height: 0,
|
|
449
496
|
length: 1
|
|
450
497
|
});
|
|
451
|
-
const
|
|
452
|
-
return
|
|
453
|
-
(
|
|
454
|
-
height: Math.max(
|
|
455
|
-
length:
|
|
498
|
+
const f = p(u) || [];
|
|
499
|
+
return y.children = f.length === 0 ? null : f.map((k) => h(k, y)), y.children && Object.assign(y, y.children.reduce(
|
|
500
|
+
(k, m) => ({
|
|
501
|
+
height: Math.max(k.height, m.height + 1),
|
|
502
|
+
length: k.length + m.length
|
|
456
503
|
}),
|
|
457
|
-
|
|
458
|
-
)),
|
|
504
|
+
y
|
|
505
|
+
)), y;
|
|
459
506
|
};
|
|
460
507
|
return h(l, null);
|
|
461
508
|
}
|
|
@@ -470,66 +517,66 @@ function Q(e) {
|
|
|
470
517
|
return arguments.length ? (t.children = s, i) : t.children;
|
|
471
518
|
},
|
|
472
519
|
hierarchy(s, l) {
|
|
473
|
-
const
|
|
474
|
-
return c(
|
|
520
|
+
const p = typeof l > "u" ? t.children : l;
|
|
521
|
+
return c(o(), s, p);
|
|
475
522
|
},
|
|
476
523
|
dump(s) {
|
|
477
|
-
const l = n("nodeSize"),
|
|
478
|
-
const
|
|
479
|
-
return `{ size: [${
|
|
524
|
+
const l = n("nodeSize"), p = (h) => (u) => {
|
|
525
|
+
const g = h + " ", y = h + " ", { x: f, y: k } = u, m = l(u), x = u.children || [], v = x.length === 0 ? " " : `,${g}children: [${y}${x.map(p(y)).join(y)}${g}],${h}`;
|
|
526
|
+
return `{ size: [${m.join(", ")}],${g}x: ${f}, y: ${k}${v}},`;
|
|
480
527
|
};
|
|
481
|
-
return
|
|
528
|
+
return p(`
|
|
482
529
|
`)(s);
|
|
483
530
|
}
|
|
484
531
|
}), i;
|
|
485
532
|
}
|
|
486
|
-
|
|
487
|
-
const
|
|
488
|
-
const [
|
|
489
|
-
|
|
490
|
-
const c = (
|
|
491
|
-
|
|
492
|
-
const s =
|
|
493
|
-
return [
|
|
494
|
-
}, [0, null]),
|
|
533
|
+
q.version = oe;
|
|
534
|
+
const J = (e, t = 0) => (e.y = t, (e.children || []).reduce((n, i) => {
|
|
535
|
+
const [o, a] = n;
|
|
536
|
+
J(i, e.y + e.ySize);
|
|
537
|
+
const c = (o === 0 ? i.lExt : i.rExt).bottom;
|
|
538
|
+
o !== 0 && le(e, o, a);
|
|
539
|
+
const s = ge(c, o, a);
|
|
540
|
+
return [o + 1, s];
|
|
541
|
+
}, [0, null]), ae(e), me(e), e), Q = (e, t, n) => {
|
|
495
542
|
typeof t > "u" && (t = -e.relX - e.prelim, n = 0);
|
|
496
543
|
const i = t + e.relX;
|
|
497
|
-
return e.relX = i + e.prelim - n, e.prelim = 0, e.x = n + e.relX, (e.children || []).forEach((
|
|
498
|
-
},
|
|
544
|
+
return e.relX = i + e.prelim - n, e.prelim = 0, e.x = n + e.relX, (e.children || []).forEach((o) => Q(o, i, e.x)), e;
|
|
545
|
+
}, ae = (e) => {
|
|
499
546
|
(e.children || []).reduce((t, n) => {
|
|
500
|
-
const [i,
|
|
547
|
+
const [i, o] = t, a = i + n.shift, c = o + a + n.change;
|
|
501
548
|
return n.relX += c, [a, c];
|
|
502
549
|
}, [0, 0]);
|
|
503
|
-
},
|
|
504
|
-
const i = e.children[t - 1],
|
|
505
|
-
let a = i, c = i.relX, s =
|
|
550
|
+
}, le = (e, t, n) => {
|
|
551
|
+
const i = e.children[t - 1], o = e.children[t];
|
|
552
|
+
let a = i, c = i.relX, s = o, l = o.relX, p = !0;
|
|
506
553
|
for (; a && s; ) {
|
|
507
554
|
a.bottom > n.lowY && (n = n.next);
|
|
508
555
|
const h = c + a.prelim - (l + s.prelim) + a.xSize / 2 + s.xSize / 2 + a.spacing(s);
|
|
509
|
-
(h > 0 || h < 0 &&
|
|
510
|
-
const
|
|
511
|
-
|
|
556
|
+
(h > 0 || h < 0 && p) && (l += h, ce(o, h), he(e, t, n.index, h)), p = !1;
|
|
557
|
+
const u = a.bottom, g = s.bottom;
|
|
558
|
+
u <= g && (a = ue(a), a && (c += a.relX)), u >= g && (s = de(s), s && (l += s.relX));
|
|
512
559
|
}
|
|
513
|
-
!a && s ?
|
|
514
|
-
},
|
|
560
|
+
!a && s ? pe(e, t, s, l) : a && !s && fe(e, t, a, c);
|
|
561
|
+
}, ce = (e, t) => {
|
|
515
562
|
e.relX += t, e.lExtRelX += t, e.rExtRelX += t;
|
|
516
|
-
},
|
|
517
|
-
const
|
|
563
|
+
}, he = (e, t, n, i) => {
|
|
564
|
+
const o = e.children[t], a = t - n;
|
|
518
565
|
if (a > 1) {
|
|
519
566
|
const c = i / a;
|
|
520
|
-
e.children[n + 1].shift += c,
|
|
567
|
+
e.children[n + 1].shift += c, o.shift -= c, o.change -= i - c;
|
|
521
568
|
}
|
|
522
|
-
},
|
|
523
|
-
const
|
|
569
|
+
}, de = (e) => e.hasChildren ? e.firstChild : e.lThr, ue = (e) => e.hasChildren ? e.lastChild : e.rThr, pe = (e, t, n, i) => {
|
|
570
|
+
const o = e.firstChild, a = o.lExt, c = e.children[t];
|
|
524
571
|
a.lThr = n;
|
|
525
|
-
const s = i - n.relX -
|
|
526
|
-
a.relX += s, a.prelim -= s,
|
|
527
|
-
},
|
|
528
|
-
const
|
|
572
|
+
const s = i - n.relX - o.lExtRelX;
|
|
573
|
+
a.relX += s, a.prelim -= s, o.lExt = c.lExt, o.lExtRelX = c.lExtRelX;
|
|
574
|
+
}, fe = (e, t, n, i) => {
|
|
575
|
+
const o = e.children[t], a = o.rExt, c = e.children[t - 1];
|
|
529
576
|
a.rThr = n;
|
|
530
|
-
const s = i - n.relX -
|
|
531
|
-
a.relX += s, a.prelim -= s,
|
|
532
|
-
},
|
|
577
|
+
const s = i - n.relX - o.rExtRelX;
|
|
578
|
+
a.relX += s, a.prelim -= s, o.rExt = c.rExt, o.rExtRelX = c.rExtRelX;
|
|
579
|
+
}, me = (e) => {
|
|
533
580
|
if (e.hasChildren) {
|
|
534
581
|
const t = e.firstChild, n = e.lastChild, i = (t.prelim + t.relX - t.xSize / 2 + n.relX + n.prelim + n.xSize / 2) / 2;
|
|
535
582
|
Object.assign(e, {
|
|
@@ -540,7 +587,7 @@ const tt = (e, t = 0) => (e.y = t, (e.children || []).reduce((n, i) => {
|
|
|
540
587
|
rExtRelX: n.rExtRelX
|
|
541
588
|
});
|
|
542
589
|
}
|
|
543
|
-
},
|
|
590
|
+
}, ge = (e, t, n) => {
|
|
544
591
|
for (; n !== null && e >= n.lowY; )
|
|
545
592
|
n = n.next;
|
|
546
593
|
return {
|
|
@@ -548,67 +595,63 @@ const tt = (e, t = 0) => (e.y = t, (e.children || []).reduce((n, i) => {
|
|
|
548
595
|
index: t,
|
|
549
596
|
next: n
|
|
550
597
|
};
|
|
551
|
-
},
|
|
552
|
-
function
|
|
598
|
+
}, xe = ".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}", tt = ".markmap{--markmap-a-color: #0097e6;--markmap-a-hover-color: #00a8ff;--markmap-code-bg: #f0f0f0;--markmap-code-color: #555;--markmap-highlight-bg: #ffeaa7;--markmap-table-border: 1px solid currentColor;--markmap-font: 300 16px/20px sans-serif;font:var(--markmap-font)}.markmap-link{fill:none}.markmap-node>circle{cursor:pointer}.markmap-foreign{display:inline-block}.markmap-foreign a{color:var(--markmap-a-color)}.markmap-foreign a:hover{color:var(--markmap-a-hover-color)}.markmap-foreign code{padding:.25em;font-size:calc(1em - 2px);color:var(--markmap-code-color);background-color:var(--markmap-code-bg);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:var(--markmap-highlight-bg)}.markmap-foreign table,.markmap-foreign th,.markmap-foreign td{border-collapse:collapse;border:var(--markmap-table-border)}.markmap-foreign img{display:inline-block}.markmap-foreign-testing-max img{max-width:none;max-height:none}", be = tt;
|
|
599
|
+
function W(e) {
|
|
553
600
|
const t = e.data;
|
|
554
|
-
return Math.max(4 - 2 * t.depth, 1.5);
|
|
601
|
+
return Math.max(4 - 2 * t.state.depth, 1.5);
|
|
555
602
|
}
|
|
556
|
-
function
|
|
557
|
-
const n =
|
|
603
|
+
function Y(e, t) {
|
|
604
|
+
const n = mt(e, t);
|
|
558
605
|
return e[n];
|
|
559
606
|
}
|
|
560
|
-
function
|
|
607
|
+
function D(e) {
|
|
561
608
|
e.stopPropagation();
|
|
562
609
|
}
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
transformHtml: new U()
|
|
566
|
-
};
|
|
567
|
-
}
|
|
568
|
-
const xe = new U(), ye = G(ct), P = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), C = class C {
|
|
610
|
+
const ye = new st();
|
|
611
|
+
class et {
|
|
569
612
|
constructor(t, n) {
|
|
570
|
-
this.options =
|
|
571
|
-
const { transform:
|
|
572
|
-
this.g.attr("transform",
|
|
613
|
+
this.options = P, this.revokers = [], this.imgCache = {}, this.handleZoom = (i) => {
|
|
614
|
+
const { transform: o } = i;
|
|
615
|
+
this.g.attr("transform", o);
|
|
573
616
|
}, this.handlePan = (i) => {
|
|
574
617
|
i.preventDefault();
|
|
575
|
-
const
|
|
576
|
-
-i.deltaX /
|
|
577
|
-
-i.deltaY /
|
|
618
|
+
const o = A(this.svg.node()), a = o.translate(
|
|
619
|
+
-i.deltaX / o.k,
|
|
620
|
+
-i.deltaY / o.k
|
|
578
621
|
);
|
|
579
622
|
this.svg.call(this.zoom.transform, a);
|
|
580
|
-
}, this.handleClick = (i,
|
|
623
|
+
}, this.handleClick = (i, o) => {
|
|
581
624
|
let a = this.options.toggleRecursively;
|
|
582
|
-
(
|
|
583
|
-
}, this.
|
|
625
|
+
(K ? i.metaKey : i.ctrlKey) && (a = !a), this.toggleNode(o.data, a);
|
|
626
|
+
}, this.svg = t.datum ? t : dt(t), this.styleNode = this.svg.append("style"), this.zoom = ut().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
627
|
id: this.options.id || this.svg.attr("id") || at(),
|
|
585
628
|
minX: 0,
|
|
586
629
|
maxX: 0,
|
|
587
630
|
minY: 0,
|
|
588
631
|
maxY: 0
|
|
589
|
-
}, this.g = this.svg.append("g"), this.revokers.push(
|
|
590
|
-
|
|
632
|
+
}, this.g = this.svg.append("g"), this.debouncedRefresh = lt(() => this.setData(), 200), this.revokers.push(
|
|
633
|
+
ye.tap(() => {
|
|
591
634
|
this.setData();
|
|
592
635
|
})
|
|
593
636
|
);
|
|
594
637
|
}
|
|
595
638
|
getStyleContent() {
|
|
596
639
|
const { style: t } = this.options, { id: n } = this.state, i = typeof t == "function" ? t(n) : "";
|
|
597
|
-
return [this.options.embedGlobalCSS &&
|
|
640
|
+
return [this.options.embedGlobalCSS && tt, i].filter(Boolean).join(`
|
|
598
641
|
`);
|
|
599
642
|
}
|
|
600
643
|
updateStyle() {
|
|
601
644
|
this.svg.attr(
|
|
602
645
|
"class",
|
|
603
|
-
|
|
646
|
+
ct(this.svg.attr("class"), "markmap", this.state.id)
|
|
604
647
|
);
|
|
605
648
|
const t = this.getStyleContent();
|
|
606
649
|
this.styleNode.text(t);
|
|
607
650
|
}
|
|
608
651
|
toggleNode(t, n = !1) {
|
|
609
|
-
var
|
|
610
|
-
const i = (
|
|
611
|
-
n ?
|
|
652
|
+
var o, a;
|
|
653
|
+
const i = (o = t.payload) != null && o.fold ? 0 : 1;
|
|
654
|
+
n ? T(t, (c, s) => {
|
|
612
655
|
c.payload = {
|
|
613
656
|
...c.payload,
|
|
614
657
|
fold: i
|
|
@@ -620,44 +663,67 @@ const xe = new U(), ye = G(ct), P = typeof navigator < "u" && navigator.userAgen
|
|
|
620
663
|
}
|
|
621
664
|
initializeData(t) {
|
|
622
665
|
let n = 0;
|
|
623
|
-
const { color: i, nodeMinHeight:
|
|
624
|
-
/* @__PURE__ */
|
|
625
|
-
),
|
|
626
|
-
/* @__PURE__ */
|
|
666
|
+
const { color: i, nodeMinHeight: o, maxWidth: a, initialExpandLevel: c } = this.options, { id: s } = this.state, l = O(
|
|
667
|
+
/* @__PURE__ */ j("div", { className: `markmap-container markmap ${s}-g` })
|
|
668
|
+
), p = O(
|
|
669
|
+
/* @__PURE__ */ j("style", { children: [this.getStyleContent(), xe].join(`
|
|
627
670
|
`) })
|
|
628
671
|
);
|
|
629
|
-
document.body.append(l,
|
|
672
|
+
document.body.append(l, p);
|
|
630
673
|
const h = a ? `max-width: ${a}px` : "";
|
|
631
|
-
let
|
|
632
|
-
|
|
633
|
-
var
|
|
634
|
-
|
|
635
|
-
const
|
|
636
|
-
/* @__PURE__ */
|
|
674
|
+
let u = 0, g = 0;
|
|
675
|
+
T(t, (f, k, m) => {
|
|
676
|
+
var b, w, z;
|
|
677
|
+
g += 1, f.children = (b = f.children) == null ? void 0 : b.map((C) => ({ ...C })), n += 1;
|
|
678
|
+
const x = O(
|
|
679
|
+
/* @__PURE__ */ j(
|
|
680
|
+
"div",
|
|
681
|
+
{
|
|
682
|
+
className: "markmap-foreign markmap-foreign-testing-max",
|
|
683
|
+
style: h,
|
|
684
|
+
children: /* @__PURE__ */ j("div", { dangerouslySetInnerHTML: { __html: f.content } })
|
|
685
|
+
}
|
|
686
|
+
)
|
|
637
687
|
);
|
|
638
|
-
l.append(
|
|
639
|
-
...
|
|
688
|
+
l.append(x), f.state = {
|
|
689
|
+
...f.state,
|
|
690
|
+
depth: g,
|
|
640
691
|
id: n,
|
|
641
|
-
el:
|
|
642
|
-
},
|
|
643
|
-
const
|
|
644
|
-
|
|
692
|
+
el: x.firstChild
|
|
693
|
+
}, f.state.path = [(w = m == null ? void 0 : m.state) == null ? void 0 : w.path, f.state.id].filter(Boolean).join("."), i(f);
|
|
694
|
+
const v = ((z = f.payload) == null ? void 0 : z.fold) === 2;
|
|
695
|
+
v ? u += 1 : (u || c >= 0 && f.state.depth >= c) && (f.payload = { ...f.payload, fold: 1 }), k(), v && (u -= 1), g -= 1;
|
|
645
696
|
});
|
|
646
|
-
const
|
|
647
|
-
(
|
|
697
|
+
const y = Array.from(l.childNodes).map(
|
|
698
|
+
(f) => f.firstChild
|
|
648
699
|
);
|
|
649
|
-
this.
|
|
650
|
-
var
|
|
651
|
-
(
|
|
652
|
-
}),
|
|
653
|
-
var
|
|
654
|
-
const
|
|
655
|
-
|
|
656
|
-
Math.ceil(
|
|
657
|
-
Math.max(Math.ceil(
|
|
658
|
-
],
|
|
659
|
-
|
|
660
|
-
}), l.remove(),
|
|
700
|
+
this._checkImages(l), y.forEach((f) => {
|
|
701
|
+
var k;
|
|
702
|
+
(k = f.parentNode) == null || k.append(f.cloneNode(!0));
|
|
703
|
+
}), T(t, (f, k, m) => {
|
|
704
|
+
var b;
|
|
705
|
+
const x = f.state, v = x.el.getBoundingClientRect();
|
|
706
|
+
f.content = x.el.innerHTML, x.size = [
|
|
707
|
+
Math.ceil(v.width) + 1,
|
|
708
|
+
Math.max(Math.ceil(v.height), o)
|
|
709
|
+
], x.key = [(b = m == null ? void 0 : m.state) == null ? void 0 : b.id, x.id].filter(Boolean).join(".") + // FIXME: find a way to check content hash
|
|
710
|
+
f.content, k();
|
|
711
|
+
}), l.remove(), p.remove();
|
|
712
|
+
}
|
|
713
|
+
_checkImages(t) {
|
|
714
|
+
t.querySelectorAll("img").forEach((n) => {
|
|
715
|
+
if (n.width)
|
|
716
|
+
return;
|
|
717
|
+
const i = this.imgCache[n.src];
|
|
718
|
+
i != null && i[0] ? [n.width, n.height] = i : i || this._loadImage(n.src);
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
_loadImage(t) {
|
|
722
|
+
this.imgCache[t] = [0, 0];
|
|
723
|
+
const n = new Image();
|
|
724
|
+
n.src = t, n.onload = () => {
|
|
725
|
+
this.imgCache[t] = [n.naturalWidth, n.naturalHeight], this.debouncedRefresh();
|
|
726
|
+
};
|
|
661
727
|
}
|
|
662
728
|
setOptions(t) {
|
|
663
729
|
this.options = {
|
|
@@ -671,124 +737,124 @@ const xe = new U(), ye = G(ct), P = typeof navigator < "u" && navigator.userAgen
|
|
|
671
737
|
renderData(t) {
|
|
672
738
|
if (!this.state.data)
|
|
673
739
|
return;
|
|
674
|
-
const { spacingHorizontal: n, paddingX: i, spacingVertical:
|
|
675
|
-
var
|
|
676
|
-
if (!((
|
|
677
|
-
return
|
|
678
|
-
}).nodeSize((
|
|
679
|
-
const [
|
|
680
|
-
return [
|
|
681
|
-
}).spacing((
|
|
740
|
+
const { spacingHorizontal: n, paddingX: i, spacingVertical: o, autoFit: a, color: c } = this.options, s = q({}).children((r) => {
|
|
741
|
+
var d;
|
|
742
|
+
if (!((d = r.payload) != null && d.fold))
|
|
743
|
+
return r.children;
|
|
744
|
+
}).nodeSize((r) => {
|
|
745
|
+
const [d, S] = r.data.state.size;
|
|
746
|
+
return [S, d + (d ? i * 2 : 0) + n];
|
|
747
|
+
}).spacing((r, d) => r.parent === d.parent ? o : o * 2), l = s.hierarchy(this.state.data);
|
|
682
748
|
s(l);
|
|
683
|
-
const
|
|
749
|
+
const p = l.descendants().reverse(), h = l.links(), u = pt(), g = H(p, (r) => r.x - r.xSize / 2), y = L(p, (r) => r.x + r.xSize / 2), f = H(p, (r) => r.y), k = L(p, (r) => r.y + r.ySize - n);
|
|
684
750
|
Object.assign(this.state, {
|
|
685
|
-
minX:
|
|
686
|
-
maxX:
|
|
687
|
-
minY:
|
|
688
|
-
maxY:
|
|
751
|
+
minX: g,
|
|
752
|
+
maxX: y,
|
|
753
|
+
minY: f,
|
|
754
|
+
maxY: k
|
|
689
755
|
}), a && this.fit();
|
|
690
|
-
const
|
|
691
|
-
|
|
692
|
-
).data(
|
|
756
|
+
const m = t && p.find((r) => r.data === t) || l, x = m.data.state.x0 ?? m.x, v = m.data.state.y0 ?? m.y, b = this.g.selectAll(
|
|
757
|
+
E("g")
|
|
758
|
+
).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(
|
|
693
759
|
"transform",
|
|
694
|
-
(
|
|
695
|
-
),
|
|
696
|
-
|
|
760
|
+
(r) => `translate(${v + m.ySize - r.ySize},${x + m.xSize / 2 - r.xSize})`
|
|
761
|
+
), z = this.transition(b.exit());
|
|
762
|
+
z.select("line").attr("x1", (r) => r.ySize - n).attr("x2", (r) => r.ySize - n), z.select("foreignObject").style("opacity", 0), z.attr(
|
|
697
763
|
"transform",
|
|
698
|
-
(
|
|
764
|
+
(r) => `translate(${m.y + m.ySize - r.ySize},${m.x + m.xSize / 2 - r.xSize})`
|
|
699
765
|
).remove();
|
|
700
|
-
const
|
|
766
|
+
const C = b.merge(w).attr(
|
|
701
767
|
"class",
|
|
702
|
-
(
|
|
703
|
-
var
|
|
704
|
-
return ["markmap-node", ((
|
|
768
|
+
(r) => {
|
|
769
|
+
var d;
|
|
770
|
+
return ["markmap-node", ((d = r.data.payload) == null ? void 0 : d.fold) && "markmap-fold"].filter(Boolean).join(" ");
|
|
705
771
|
}
|
|
706
772
|
);
|
|
707
|
-
this.transition(
|
|
773
|
+
this.transition(C).attr(
|
|
708
774
|
"transform",
|
|
709
|
-
(
|
|
775
|
+
(r) => `translate(${r.y},${r.x - r.xSize / 2})`
|
|
710
776
|
);
|
|
711
|
-
const
|
|
712
|
-
|
|
777
|
+
const nt = C.selectAll(
|
|
778
|
+
E("line")
|
|
713
779
|
).data(
|
|
714
|
-
(
|
|
715
|
-
(
|
|
780
|
+
(r) => [r],
|
|
781
|
+
(r) => r.data.state.key
|
|
716
782
|
).join(
|
|
717
|
-
(
|
|
718
|
-
(
|
|
719
|
-
(
|
|
783
|
+
(r) => r.append("line").attr("x1", (d) => d.ySize - n).attr("x2", (d) => d.ySize - n),
|
|
784
|
+
(r) => r,
|
|
785
|
+
(r) => r.remove()
|
|
720
786
|
);
|
|
721
|
-
this.transition(
|
|
722
|
-
const
|
|
723
|
-
|
|
787
|
+
this.transition(nt).attr("x1", -1).attr("x2", (r) => r.ySize - n + 2).attr("y1", (r) => r.xSize).attr("y2", (r) => r.xSize).attr("stroke", (r) => c(r.data)).attr("stroke-width", W);
|
|
788
|
+
const it = C.selectAll(
|
|
789
|
+
E("circle")
|
|
724
790
|
).data(
|
|
725
|
-
(
|
|
726
|
-
var
|
|
727
|
-
return (
|
|
791
|
+
(r) => {
|
|
792
|
+
var d;
|
|
793
|
+
return (d = r.data.children) != null && d.length ? [r] : [];
|
|
728
794
|
},
|
|
729
|
-
(
|
|
795
|
+
(r) => r.data.state.key
|
|
730
796
|
).join(
|
|
731
|
-
(
|
|
732
|
-
(
|
|
733
|
-
(
|
|
797
|
+
(r) => r.append("circle").attr("stroke-width", "1.5").attr("cx", (d) => d.ySize - n).attr("cy", (d) => d.xSize).attr("r", 0).on("click", (d, S) => this.handleClick(d, S)).on("mousedown", D),
|
|
798
|
+
(r) => r,
|
|
799
|
+
(r) => r.remove()
|
|
734
800
|
);
|
|
735
|
-
this.transition(
|
|
801
|
+
this.transition(it).attr("r", 6).attr("cx", (r) => r.ySize - n).attr("cy", (r) => r.xSize).attr("stroke", (r) => c(r.data)).attr(
|
|
736
802
|
"fill",
|
|
737
|
-
(
|
|
738
|
-
var
|
|
739
|
-
return (
|
|
803
|
+
(r) => {
|
|
804
|
+
var d;
|
|
805
|
+
return (d = r.data.payload) != null && d.fold && r.data.children ? c(r.data) : "#fff";
|
|
740
806
|
}
|
|
741
807
|
);
|
|
742
|
-
const rt =
|
|
743
|
-
|
|
808
|
+
const rt = C.selectAll(
|
|
809
|
+
E("foreignObject")
|
|
744
810
|
).data(
|
|
745
|
-
(
|
|
746
|
-
(
|
|
811
|
+
(r) => [r],
|
|
812
|
+
(r) => r.data.state.key
|
|
747
813
|
).join(
|
|
748
|
-
(
|
|
749
|
-
const
|
|
750
|
-
return
|
|
751
|
-
const
|
|
752
|
-
return this.replaceWith(
|
|
753
|
-
}).attr("xmlns", "http://www.w3.org/1999/xhtml"),
|
|
814
|
+
(r) => {
|
|
815
|
+
const d = r.append("foreignObject").attr("class", "markmap-foreign").attr("x", i).attr("y", 0).style("opacity", 0).on("mousedown", D).on("dblclick", D);
|
|
816
|
+
return d.append("xhtml:div").select(function(R) {
|
|
817
|
+
const X = R.data.state.el.cloneNode(!0);
|
|
818
|
+
return this.replaceWith(X), X;
|
|
819
|
+
}).attr("xmlns", "http://www.w3.org/1999/xhtml"), d;
|
|
754
820
|
},
|
|
755
|
-
(
|
|
756
|
-
(
|
|
821
|
+
(r) => r,
|
|
822
|
+
(r) => r.remove()
|
|
757
823
|
).attr(
|
|
758
824
|
"width",
|
|
759
|
-
(
|
|
760
|
-
).attr("height", (
|
|
825
|
+
(r) => Math.max(0, r.ySize - n - i * 2)
|
|
826
|
+
).attr("height", (r) => r.xSize);
|
|
761
827
|
this.transition(rt).style("opacity", 1);
|
|
762
|
-
const
|
|
763
|
-
|
|
764
|
-
).data(h, (
|
|
765
|
-
(
|
|
766
|
-
const
|
|
767
|
-
v +
|
|
768
|
-
|
|
828
|
+
const ot = this.g.selectAll(
|
|
829
|
+
E("path")
|
|
830
|
+
).data(h, (r) => r.target.data.state.key).join(
|
|
831
|
+
(r) => {
|
|
832
|
+
const d = [
|
|
833
|
+
v + m.ySize - n,
|
|
834
|
+
x + m.xSize / 2
|
|
769
835
|
];
|
|
770
|
-
return
|
|
836
|
+
return r.insert("path", "g").attr("class", "markmap-link").attr("data-depth", (S) => S.target.data.state.depth).attr("data-path", (S) => S.target.data.state.path).attr("d", u({ source: d, target: d }));
|
|
771
837
|
},
|
|
772
|
-
(
|
|
773
|
-
(
|
|
774
|
-
const
|
|
775
|
-
|
|
776
|
-
|
|
838
|
+
(r) => r,
|
|
839
|
+
(r) => {
|
|
840
|
+
const d = [
|
|
841
|
+
m.y + m.ySize - n,
|
|
842
|
+
m.x + m.xSize / 2
|
|
777
843
|
];
|
|
778
|
-
return this.transition(
|
|
844
|
+
return this.transition(r).attr("d", u({ source: d, target: d })).remove();
|
|
779
845
|
}
|
|
780
846
|
);
|
|
781
|
-
this.transition(
|
|
782
|
-
const
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
],
|
|
786
|
-
|
|
787
|
-
|
|
847
|
+
this.transition(ot).attr("stroke", (r) => c(r.target.data)).attr("stroke-width", (r) => W(r.target)).attr("d", (r) => {
|
|
848
|
+
const d = r.source, S = r.target, R = [
|
|
849
|
+
d.y + d.ySize - n,
|
|
850
|
+
d.x + d.xSize / 2
|
|
851
|
+
], X = [
|
|
852
|
+
S.y,
|
|
853
|
+
S.x + S.xSize / 2
|
|
788
854
|
];
|
|
789
|
-
return
|
|
790
|
-
}),
|
|
791
|
-
|
|
855
|
+
return u({ source: R, target: X });
|
|
856
|
+
}), p.forEach((r) => {
|
|
857
|
+
r.data.state.x0 = r.x, r.data.state.y0 = r.y;
|
|
792
858
|
});
|
|
793
859
|
}
|
|
794
860
|
transition(t) {
|
|
@@ -799,15 +865,15 @@ const xe = new U(), ye = G(ct), P = typeof navigator < "u" && navigator.userAgen
|
|
|
799
865
|
* Fit the content to the viewport.
|
|
800
866
|
*/
|
|
801
867
|
async fit() {
|
|
802
|
-
const t = this.svg.node(), { width: n, height: i } = t.getBoundingClientRect(), { fitRatio:
|
|
803
|
-
n /
|
|
804
|
-
i / h *
|
|
868
|
+
const t = this.svg.node(), { width: n, height: i } = t.getBoundingClientRect(), { fitRatio: o } = this.options, { minX: a, maxX: c, minY: s, maxY: l } = this.state, p = l - s, h = c - a, u = Math.min(
|
|
869
|
+
n / p * o,
|
|
870
|
+
i / h * o,
|
|
805
871
|
2
|
|
806
|
-
),
|
|
807
|
-
(n -
|
|
808
|
-
(i - h *
|
|
809
|
-
).scale(
|
|
810
|
-
return this.transition(this.svg).call(this.zoom.transform,
|
|
872
|
+
), g = ft.translate(
|
|
873
|
+
(n - p * u) / 2 - s * u,
|
|
874
|
+
(i - h * u) / 2 - a * u
|
|
875
|
+
).scale(u);
|
|
876
|
+
return this.transition(this.svg).call(this.zoom.transform, g).end().catch(M);
|
|
811
877
|
}
|
|
812
878
|
/**
|
|
813
879
|
* Pan the content to make the provided node visible in the viewport.
|
|
@@ -815,38 +881,38 @@ const xe = new U(), ye = G(ct), P = typeof navigator < "u" && navigator.userAgen
|
|
|
815
881
|
async ensureView(t, n) {
|
|
816
882
|
let i;
|
|
817
883
|
if (this.g.selectAll(
|
|
818
|
-
|
|
884
|
+
E("g")
|
|
819
885
|
).each(function(v) {
|
|
820
886
|
v.data === t && (i = v);
|
|
821
887
|
}), !i)
|
|
822
888
|
return;
|
|
823
|
-
const
|
|
889
|
+
const o = this.svg.node(), { spacingHorizontal: a } = this.options, c = o.getBoundingClientRect(), s = A(o), [l, p] = [
|
|
824
890
|
i.y,
|
|
825
891
|
i.y + i.ySize - a + 2
|
|
826
|
-
].map((
|
|
892
|
+
].map((x) => x * s.k + s.x), [h, u] = [
|
|
827
893
|
i.x - i.xSize / 2,
|
|
828
894
|
i.x + i.xSize / 2
|
|
829
|
-
].map((
|
|
895
|
+
].map((x) => x * s.k + s.y), g = {
|
|
830
896
|
left: 0,
|
|
831
897
|
right: 0,
|
|
832
898
|
top: 0,
|
|
833
899
|
bottom: 0,
|
|
834
900
|
...n
|
|
835
|
-
},
|
|
836
|
-
if (
|
|
837
|
-
const
|
|
838
|
-
return this.transition(this.svg).call(this.zoom.transform,
|
|
901
|
+
}, y = [g.left - l, c.width - g.right - p], f = [g.top - h, c.height - g.bottom - u], k = y[0] * y[1] > 0 ? Y(y, Math.abs) / s.k : 0, m = f[0] * f[1] > 0 ? Y(f, Math.abs) / s.k : 0;
|
|
902
|
+
if (k || m) {
|
|
903
|
+
const x = s.translate(k, m);
|
|
904
|
+
return this.transition(this.svg).call(this.zoom.transform, x).end().catch(M);
|
|
839
905
|
}
|
|
840
906
|
}
|
|
841
907
|
/**
|
|
842
908
|
* Scale content with it pinned at the center of the viewport.
|
|
843
909
|
*/
|
|
844
910
|
async rescale(t) {
|
|
845
|
-
const n = this.svg.node(), { width: i, height:
|
|
911
|
+
const n = this.svg.node(), { width: i, height: o } = n.getBoundingClientRect(), a = i / 2, c = o / 2, s = A(n), l = s.translate(
|
|
846
912
|
(a - s.x) * (1 - t) / s.k,
|
|
847
913
|
(c - s.y) * (1 - t) / s.k
|
|
848
914
|
).scale(t);
|
|
849
|
-
return this.transition(this.svg).call(this.zoom.transform, l).end().catch(
|
|
915
|
+
return this.transition(this.svg).call(this.zoom.transform, l).end().catch(M);
|
|
850
916
|
}
|
|
851
917
|
destroy() {
|
|
852
918
|
this.svg.on(".zoom", null), this.svg.html(null), this.revokers.forEach((t) => {
|
|
@@ -854,64 +920,18 @@ const xe = new U(), ye = G(ct), P = typeof navigator < "u" && navigator.userAgen
|
|
|
854
920
|
});
|
|
855
921
|
}
|
|
856
922
|
static create(t, n, i = null) {
|
|
857
|
-
const
|
|
858
|
-
return i && (
|
|
859
|
-
}
|
|
860
|
-
};
|
|
861
|
-
C.defaultOptions = {
|
|
862
|
-
autoFit: !1,
|
|
863
|
-
color: (t) => {
|
|
864
|
-
var n;
|
|
865
|
-
return ye(`${((n = t.state) == null ? void 0 : n.path) || ""}`);
|
|
866
|
-
},
|
|
867
|
-
duration: 500,
|
|
868
|
-
embedGlobalCSS: !0,
|
|
869
|
-
fitRatio: 0.95,
|
|
870
|
-
maxWidth: 0,
|
|
871
|
-
nodeMinHeight: 16,
|
|
872
|
-
paddingX: 8,
|
|
873
|
-
scrollForPan: P,
|
|
874
|
-
spacingHorizontal: 80,
|
|
875
|
-
spacingVertical: 5,
|
|
876
|
-
initialExpandLevel: -1,
|
|
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));
|
|
923
|
+
const o = new et(t, n);
|
|
924
|
+
return i && (o.setData(i), o.fit()), o;
|
|
900
925
|
}
|
|
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
926
|
}
|
|
909
927
|
export {
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
928
|
+
et as Markmap,
|
|
929
|
+
gt as defaultColorFn,
|
|
930
|
+
P as defaultOptions,
|
|
931
|
+
Se as deriveOptions,
|
|
932
|
+
be as globalCSS,
|
|
933
|
+
K as isMacintosh,
|
|
934
|
+
Ee as loadCSS,
|
|
915
935
|
we as loadJS,
|
|
916
|
-
|
|
936
|
+
ye as refreshHook
|
|
917
937
|
};
|