markmap-view 0.18.3 → 0.18.4-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 +140 -367
- package/dist/index.d.ts +0 -1
- package/dist/index.js +356 -344
- package/dist/types.d.ts +2 -3
- package/dist/util.d.ts +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const I = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), gt = W(ct), K = {
|
|
1
|
+
import { scaleOrdinal as G, schemeCategory10 as at, linkHorizontal as lt, zoomTransform as w, select as ct, zoom as ht, min as P, max as W, zoomIdentity as dt, minIndex as pt } from "d3";
|
|
2
|
+
import { Hook as ut, getId as mt, debounce as gt, addClass as ft, walkTree as C, childSelector as v, noop as S } from "markmap-common";
|
|
3
|
+
const V = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), xt = G(at), U = {
|
|
5
4
|
autoFit: !1,
|
|
6
5
|
color: (e) => {
|
|
7
6
|
var t;
|
|
8
|
-
return
|
|
7
|
+
return xt(`${((t = e.state) == null ? void 0 : t.path) || ""}`);
|
|
9
8
|
},
|
|
10
9
|
duration: 500,
|
|
11
10
|
embedGlobalCSS: !0,
|
|
@@ -14,7 +13,7 @@ const I = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), g
|
|
|
14
13
|
maxWidth: 0,
|
|
15
14
|
nodeMinHeight: 16,
|
|
16
15
|
paddingX: 8,
|
|
17
|
-
scrollForPan:
|
|
16
|
+
scrollForPan: V,
|
|
18
17
|
spacingHorizontal: 80,
|
|
19
18
|
spacingVertical: 5,
|
|
20
19
|
initialExpandLevel: -1,
|
|
@@ -22,24 +21,24 @@ const I = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), g
|
|
|
22
21
|
pan: !0,
|
|
23
22
|
toggleRecursively: !1
|
|
24
23
|
};
|
|
25
|
-
function
|
|
26
|
-
const t = {}, s = { ...e }, { color: n, colorFreezeLevel:
|
|
24
|
+
function ue(e) {
|
|
25
|
+
const t = {}, s = { ...e }, { color: n, colorFreezeLevel: o } = s;
|
|
27
26
|
if ((n == null ? void 0 : n.length) === 1) {
|
|
28
27
|
const r = n[0];
|
|
29
28
|
t.color = () => r;
|
|
30
29
|
} else if (n != null && n.length) {
|
|
31
|
-
const r =
|
|
32
|
-
t.color = (
|
|
30
|
+
const r = G(n);
|
|
31
|
+
t.color = (c) => r(`${c.state.path}`);
|
|
33
32
|
}
|
|
34
|
-
if (
|
|
35
|
-
const r = t.color ||
|
|
36
|
-
t.color = (
|
|
37
|
-
...
|
|
33
|
+
if (o) {
|
|
34
|
+
const r = t.color || U.color;
|
|
35
|
+
t.color = (c) => (c = {
|
|
36
|
+
...c,
|
|
38
37
|
state: {
|
|
39
|
-
...
|
|
40
|
-
path:
|
|
38
|
+
...c.state,
|
|
39
|
+
path: c.state.path.split(".").slice(0, o).join(".")
|
|
41
40
|
}
|
|
42
|
-
}, r(
|
|
41
|
+
}, r(c));
|
|
43
42
|
}
|
|
44
43
|
return [
|
|
45
44
|
"duration",
|
|
@@ -52,185 +51,185 @@ function he(e) {
|
|
|
52
51
|
"spacingHorizontal",
|
|
53
52
|
"spacingVertical"
|
|
54
53
|
].forEach((r) => {
|
|
55
|
-
const
|
|
56
|
-
typeof
|
|
54
|
+
const c = s[r];
|
|
55
|
+
typeof c == "number" && (t[r] = c);
|
|
57
56
|
}), ["zoom", "pan"].forEach((r) => {
|
|
58
|
-
const
|
|
59
|
-
|
|
57
|
+
const c = s[r];
|
|
58
|
+
c != null && (t[r] = !!c);
|
|
60
59
|
}), t;
|
|
61
60
|
}
|
|
62
|
-
function
|
|
61
|
+
function yt(e) {
|
|
63
62
|
let t = 0;
|
|
64
63
|
for (let s = 0; s < e.length; s++)
|
|
65
64
|
t = (t << 5) - t + e.charCodeAt(s) | 0;
|
|
66
65
|
return (t >>> 0).toString(36);
|
|
67
66
|
}
|
|
68
|
-
function
|
|
67
|
+
function kt(e) {
|
|
69
68
|
var t = 0, s = e.children, n = s && s.length;
|
|
70
69
|
if (!n) t = 1;
|
|
71
70
|
else for (; --n >= 0; ) t += s[n].value;
|
|
72
71
|
e.value = t;
|
|
73
72
|
}
|
|
74
|
-
function
|
|
75
|
-
return this.eachAfter(
|
|
73
|
+
function vt() {
|
|
74
|
+
return this.eachAfter(kt);
|
|
76
75
|
}
|
|
77
|
-
function
|
|
78
|
-
var t = this, s, n = [t],
|
|
76
|
+
function bt(e) {
|
|
77
|
+
var t = this, s, n = [t], o, a, l;
|
|
79
78
|
do
|
|
80
79
|
for (s = n.reverse(), n = []; t = s.pop(); )
|
|
81
|
-
if (e(t),
|
|
82
|
-
n.push(
|
|
80
|
+
if (e(t), o = t.children, o) for (a = 0, l = o.length; a < l; ++a)
|
|
81
|
+
n.push(o[a]);
|
|
83
82
|
while (n.length);
|
|
84
83
|
return this;
|
|
85
84
|
}
|
|
86
|
-
function
|
|
87
|
-
for (var t = this, s = [t], n,
|
|
88
|
-
if (e(t), n = t.children, n) for (
|
|
89
|
-
s.push(n[
|
|
85
|
+
function zt(e) {
|
|
86
|
+
for (var t = this, s = [t], n, o; t = s.pop(); )
|
|
87
|
+
if (e(t), n = t.children, n) for (o = n.length - 1; o >= 0; --o)
|
|
88
|
+
s.push(n[o]);
|
|
90
89
|
return this;
|
|
91
90
|
}
|
|
92
|
-
function
|
|
93
|
-
for (var t = this, s = [t], n = [],
|
|
94
|
-
if (n.push(t),
|
|
95
|
-
s.push(
|
|
91
|
+
function Et(e) {
|
|
92
|
+
for (var t = this, s = [t], n = [], o, a, l; t = s.pop(); )
|
|
93
|
+
if (n.push(t), o = t.children, o) for (a = 0, l = o.length; a < l; ++a)
|
|
94
|
+
s.push(o[a]);
|
|
96
95
|
for (; t = n.pop(); )
|
|
97
96
|
e(t);
|
|
98
97
|
return this;
|
|
99
98
|
}
|
|
100
|
-
function
|
|
99
|
+
function wt(e) {
|
|
101
100
|
return this.eachAfter(function(t) {
|
|
102
|
-
for (var s = +e(t.data) || 0, n = t.children,
|
|
101
|
+
for (var s = +e(t.data) || 0, n = t.children, o = n && n.length; --o >= 0; ) s += n[o].value;
|
|
103
102
|
t.value = s;
|
|
104
103
|
});
|
|
105
104
|
}
|
|
106
|
-
function
|
|
105
|
+
function Ct(e) {
|
|
107
106
|
return this.eachBefore(function(t) {
|
|
108
107
|
t.children && t.children.sort(e);
|
|
109
108
|
});
|
|
110
109
|
}
|
|
111
|
-
function
|
|
112
|
-
for (var t = this, s =
|
|
110
|
+
function St(e) {
|
|
111
|
+
for (var t = this, s = Rt(t, e), n = [t]; t !== s; )
|
|
113
112
|
t = t.parent, n.push(t);
|
|
114
|
-
for (var
|
|
115
|
-
n.splice(
|
|
113
|
+
for (var o = n.length; e !== s; )
|
|
114
|
+
n.splice(o, 0, e), e = e.parent;
|
|
116
115
|
return n;
|
|
117
116
|
}
|
|
118
|
-
function
|
|
117
|
+
function Rt(e, t) {
|
|
119
118
|
if (e === t) return e;
|
|
120
|
-
var s = e.ancestors(), n = t.ancestors(),
|
|
119
|
+
var s = e.ancestors(), n = t.ancestors(), o = null;
|
|
121
120
|
for (e = s.pop(), t = n.pop(); e === t; )
|
|
122
|
-
|
|
123
|
-
return
|
|
121
|
+
o = e, e = s.pop(), t = n.pop();
|
|
122
|
+
return o;
|
|
124
123
|
}
|
|
125
|
-
function
|
|
124
|
+
function Xt() {
|
|
126
125
|
for (var e = this, t = [e]; e = e.parent; )
|
|
127
126
|
t.push(e);
|
|
128
127
|
return t;
|
|
129
128
|
}
|
|
130
|
-
function
|
|
129
|
+
function Mt() {
|
|
131
130
|
var e = [];
|
|
132
131
|
return this.each(function(t) {
|
|
133
132
|
e.push(t);
|
|
134
133
|
}), e;
|
|
135
134
|
}
|
|
136
|
-
function
|
|
135
|
+
function jt() {
|
|
137
136
|
var e = [];
|
|
138
137
|
return this.eachBefore(function(t) {
|
|
139
138
|
t.children || e.push(t);
|
|
140
139
|
}), e;
|
|
141
140
|
}
|
|
142
|
-
function
|
|
141
|
+
function Ot() {
|
|
143
142
|
var e = this, t = [];
|
|
144
143
|
return e.each(function(s) {
|
|
145
144
|
s !== e && t.push({ source: s.parent, target: s });
|
|
146
145
|
}), t;
|
|
147
146
|
}
|
|
148
|
-
function
|
|
149
|
-
var s = new
|
|
150
|
-
for (t == null && (t =
|
|
151
|
-
if (n && (
|
|
152
|
-
for (
|
|
153
|
-
a.push(
|
|
154
|
-
return s.eachBefore(
|
|
147
|
+
function B(e, t) {
|
|
148
|
+
var s = new R(e), n = +e.value && (s.value = e.value), o, a = [s], l, r, c, p;
|
|
149
|
+
for (t == null && (t = At); o = a.pop(); )
|
|
150
|
+
if (n && (o.value = +o.data.value), (r = t(o.data)) && (p = r.length))
|
|
151
|
+
for (o.children = new Array(p), c = p - 1; c >= 0; --c)
|
|
152
|
+
a.push(l = o.children[c] = new R(r[c])), l.parent = o, l.depth = o.depth + 1;
|
|
153
|
+
return s.eachBefore(Ft);
|
|
155
154
|
}
|
|
156
|
-
function
|
|
157
|
-
return
|
|
155
|
+
function Bt() {
|
|
156
|
+
return B(this).eachBefore($t);
|
|
158
157
|
}
|
|
159
|
-
function
|
|
158
|
+
function At(e) {
|
|
160
159
|
return e.children;
|
|
161
160
|
}
|
|
162
|
-
function
|
|
161
|
+
function $t(e) {
|
|
163
162
|
e.data = e.data.data;
|
|
164
163
|
}
|
|
165
|
-
function
|
|
164
|
+
function Ft(e) {
|
|
166
165
|
var t = 0;
|
|
167
166
|
do
|
|
168
167
|
e.height = t;
|
|
169
168
|
while ((e = e.parent) && e.height < ++t);
|
|
170
169
|
}
|
|
171
|
-
function
|
|
170
|
+
function R(e) {
|
|
172
171
|
this.data = e, this.depth = this.height = 0, this.parent = null;
|
|
173
172
|
}
|
|
174
|
-
|
|
175
|
-
constructor:
|
|
176
|
-
count:
|
|
177
|
-
each:
|
|
178
|
-
eachAfter:
|
|
179
|
-
eachBefore:
|
|
180
|
-
sum:
|
|
181
|
-
sort:
|
|
182
|
-
path:
|
|
183
|
-
ancestors:
|
|
184
|
-
descendants:
|
|
185
|
-
leaves:
|
|
186
|
-
links:
|
|
187
|
-
copy:
|
|
173
|
+
R.prototype = B.prototype = {
|
|
174
|
+
constructor: R,
|
|
175
|
+
count: vt,
|
|
176
|
+
each: bt,
|
|
177
|
+
eachAfter: Et,
|
|
178
|
+
eachBefore: zt,
|
|
179
|
+
sum: wt,
|
|
180
|
+
sort: Ct,
|
|
181
|
+
path: St,
|
|
182
|
+
ancestors: Xt,
|
|
183
|
+
descendants: Mt,
|
|
184
|
+
leaves: jt,
|
|
185
|
+
links: Ot,
|
|
186
|
+
copy: Bt
|
|
188
187
|
};
|
|
189
|
-
const
|
|
190
|
-
name:
|
|
188
|
+
const Tt = "d3-flextree", Dt = "2.1.2", _t = "build/d3-flextree.js", Ht = "index", Nt = { name: "Chris Maloney", url: "http://chrismaloney.org" }, Lt = "Flexible tree layout algorithm that allows for variable node sizes.", Pt = ["d3", "d3-module", "layout", "tree", "hierarchy", "d3-hierarchy", "plugin", "d3-plugin", "infovis", "visualization", "2d"], Wt = "https://github.com/klortho/d3-flextree", It = "WTFPL", Kt = { type: "git", url: "https://github.com/klortho/d3-flextree.git" }, Gt = { clean: "rm -rf build demo test", "build:demo": "rollup -c --environment BUILD:demo", "build:dev": "rollup -c --environment BUILD:dev", "build:prod": "rollup -c --environment BUILD:prod", "build:test": "rollup -c --environment BUILD:test", build: "rollup -c", lint: "eslint index.js src", "test:main": "node test/bundle.js", "test:browser": "node test/browser-tests.js", test: "npm-run-all test:*", prepare: "npm-run-all clean build lint test" }, Vt = { "d3-hierarchy": "^1.1.5" }, Ut = { "babel-plugin-external-helpers": "^6.22.0", "babel-preset-es2015-rollup": "^3.0.0", d3: "^4.13.0", "d3-selection-multi": "^1.0.1", eslint: "^4.19.1", jsdom: "^11.6.2", "npm-run-all": "^4.1.2", rollup: "^0.55.3", "rollup-plugin-babel": "^2.7.1", "rollup-plugin-commonjs": "^8.0.2", "rollup-plugin-copy": "^0.2.3", "rollup-plugin-json": "^2.3.0", "rollup-plugin-node-resolve": "^3.0.2", "rollup-plugin-uglify": "^3.0.0", "uglify-es": "^3.3.9" }, Yt = {
|
|
189
|
+
name: Tt,
|
|
191
190
|
version: Dt,
|
|
192
|
-
main:
|
|
193
|
-
module:
|
|
191
|
+
main: _t,
|
|
192
|
+
module: Ht,
|
|
194
193
|
"jsnext:main": "index",
|
|
195
|
-
author:
|
|
196
|
-
description:
|
|
197
|
-
keywords:
|
|
198
|
-
homepage:
|
|
199
|
-
license:
|
|
200
|
-
repository:
|
|
201
|
-
scripts:
|
|
202
|
-
dependencies:
|
|
203
|
-
devDependencies:
|
|
204
|
-
}, { version:
|
|
194
|
+
author: Nt,
|
|
195
|
+
description: Lt,
|
|
196
|
+
keywords: Pt,
|
|
197
|
+
homepage: Wt,
|
|
198
|
+
license: It,
|
|
199
|
+
repository: Kt,
|
|
200
|
+
scripts: Gt,
|
|
201
|
+
dependencies: Vt,
|
|
202
|
+
devDependencies: Ut
|
|
203
|
+
}, { version: Zt } = Yt, qt = Object.freeze({
|
|
205
204
|
children: (e) => e.children,
|
|
206
205
|
nodeSize: (e) => e.data.size,
|
|
207
206
|
spacing: 0
|
|
208
207
|
});
|
|
209
|
-
function
|
|
210
|
-
const t = Object.assign({},
|
|
208
|
+
function Z(e) {
|
|
209
|
+
const t = Object.assign({}, qt, e);
|
|
211
210
|
function s(r) {
|
|
212
|
-
const
|
|
213
|
-
return typeof
|
|
211
|
+
const c = t[r];
|
|
212
|
+
return typeof c == "function" ? c : () => c;
|
|
214
213
|
}
|
|
215
214
|
function n(r) {
|
|
216
|
-
const
|
|
217
|
-
return
|
|
215
|
+
const c = l(a(), r, (p) => p.children);
|
|
216
|
+
return c.update(), c.data;
|
|
218
217
|
}
|
|
219
|
-
function
|
|
220
|
-
const r = s("nodeSize"),
|
|
221
|
-
return class
|
|
218
|
+
function o() {
|
|
219
|
+
const r = s("nodeSize"), c = s("spacing");
|
|
220
|
+
return class Y extends B.prototype.constructor {
|
|
222
221
|
constructor(h) {
|
|
223
222
|
super(h);
|
|
224
223
|
}
|
|
225
224
|
copy() {
|
|
226
|
-
const h =
|
|
227
|
-
return h.each((
|
|
225
|
+
const h = l(this.constructor, this, (u) => u.children);
|
|
226
|
+
return h.each((u) => u.data = u.data.data), h;
|
|
228
227
|
}
|
|
229
228
|
get size() {
|
|
230
229
|
return r(this);
|
|
231
230
|
}
|
|
232
231
|
spacing(h) {
|
|
233
|
-
return
|
|
232
|
+
return c(this, h);
|
|
234
233
|
}
|
|
235
234
|
get nodes() {
|
|
236
235
|
return this.descendants();
|
|
@@ -274,7 +273,7 @@ function V(e) {
|
|
|
274
273
|
}
|
|
275
274
|
get extents() {
|
|
276
275
|
return (this.children || []).reduce(
|
|
277
|
-
(h,
|
|
276
|
+
(h, u) => Y.maxExtents(h, u.extents),
|
|
278
277
|
this.nodeExtents
|
|
279
278
|
);
|
|
280
279
|
}
|
|
@@ -286,18 +285,18 @@ function V(e) {
|
|
|
286
285
|
right: this.right
|
|
287
286
|
};
|
|
288
287
|
}
|
|
289
|
-
static maxExtents(h,
|
|
288
|
+
static maxExtents(h, u) {
|
|
290
289
|
return {
|
|
291
|
-
top: Math.min(h.top,
|
|
292
|
-
bottom: Math.max(h.bottom,
|
|
293
|
-
left: Math.min(h.left,
|
|
294
|
-
right: Math.max(h.right,
|
|
290
|
+
top: Math.min(h.top, u.top),
|
|
291
|
+
bottom: Math.max(h.bottom, u.bottom),
|
|
292
|
+
left: Math.min(h.left, u.left),
|
|
293
|
+
right: Math.max(h.right, u.right)
|
|
295
294
|
};
|
|
296
295
|
}
|
|
297
296
|
};
|
|
298
297
|
}
|
|
299
298
|
function a() {
|
|
300
|
-
const r =
|
|
299
|
+
const r = o(), c = s("nodeSize"), p = s("spacing");
|
|
301
300
|
return class extends r {
|
|
302
301
|
constructor(h) {
|
|
303
302
|
super(h), Object.assign(this, {
|
|
@@ -316,10 +315,10 @@ function V(e) {
|
|
|
316
315
|
});
|
|
317
316
|
}
|
|
318
317
|
get size() {
|
|
319
|
-
return
|
|
318
|
+
return c(this.data);
|
|
320
319
|
}
|
|
321
320
|
spacing(h) {
|
|
322
|
-
return
|
|
321
|
+
return p(this.data, h.data);
|
|
323
322
|
}
|
|
324
323
|
get x() {
|
|
325
324
|
return this.data.x;
|
|
@@ -334,29 +333,29 @@ function V(e) {
|
|
|
334
333
|
this.data.y = h;
|
|
335
334
|
}
|
|
336
335
|
update() {
|
|
337
|
-
return
|
|
336
|
+
return q(this), J(this), this;
|
|
338
337
|
}
|
|
339
338
|
};
|
|
340
339
|
}
|
|
341
|
-
function
|
|
342
|
-
const h = (
|
|
343
|
-
const g = new r(
|
|
340
|
+
function l(r, c, p) {
|
|
341
|
+
const h = (u, m) => {
|
|
342
|
+
const g = new r(u);
|
|
344
343
|
Object.assign(g, {
|
|
345
|
-
parent:
|
|
346
|
-
depth:
|
|
344
|
+
parent: m,
|
|
345
|
+
depth: m === null ? 0 : m.depth + 1,
|
|
347
346
|
height: 0,
|
|
348
347
|
length: 1
|
|
349
348
|
});
|
|
350
|
-
const
|
|
351
|
-
return g.children =
|
|
352
|
-
(x,
|
|
353
|
-
height: Math.max(x.height,
|
|
354
|
-
length: x.length +
|
|
349
|
+
const y = p(u) || [];
|
|
350
|
+
return g.children = y.length === 0 ? null : y.map((x) => h(x, g)), g.children && Object.assign(g, g.children.reduce(
|
|
351
|
+
(x, b) => ({
|
|
352
|
+
height: Math.max(x.height, b.height + 1),
|
|
353
|
+
length: x.length + b.length
|
|
355
354
|
}),
|
|
356
355
|
g
|
|
357
356
|
)), g;
|
|
358
357
|
};
|
|
359
|
-
return h(
|
|
358
|
+
return h(c, null);
|
|
360
359
|
}
|
|
361
360
|
return Object.assign(n, {
|
|
362
361
|
nodeSize(r) {
|
|
@@ -368,67 +367,67 @@ function V(e) {
|
|
|
368
367
|
children(r) {
|
|
369
368
|
return arguments.length ? (t.children = r, n) : t.children;
|
|
370
369
|
},
|
|
371
|
-
hierarchy(r,
|
|
372
|
-
const
|
|
373
|
-
return
|
|
370
|
+
hierarchy(r, c) {
|
|
371
|
+
const p = typeof c > "u" ? t.children : c;
|
|
372
|
+
return l(o(), r, p);
|
|
374
373
|
},
|
|
375
374
|
dump(r) {
|
|
376
|
-
const
|
|
377
|
-
const
|
|
378
|
-
return `{ size: [${
|
|
375
|
+
const c = s("nodeSize"), p = (h) => (u) => {
|
|
376
|
+
const m = h + " ", g = h + " ", { x: y, y: x } = u, b = c(u), k = u.children || [], z = k.length === 0 ? " " : `,${m}children: [${g}${k.map(p(g)).join(g)}${m}],${h}`;
|
|
377
|
+
return `{ size: [${b.join(", ")}],${m}x: ${y}, y: ${x}${z}},`;
|
|
379
378
|
};
|
|
380
|
-
return
|
|
379
|
+
return p(`
|
|
381
380
|
`)(r);
|
|
382
381
|
}
|
|
383
382
|
}), n;
|
|
384
383
|
}
|
|
385
|
-
|
|
386
|
-
const
|
|
387
|
-
const [
|
|
388
|
-
|
|
389
|
-
const
|
|
390
|
-
|
|
391
|
-
const r =
|
|
392
|
-
return [
|
|
393
|
-
}, [0, null]),
|
|
384
|
+
Z.version = Zt;
|
|
385
|
+
const q = (e, t = 0) => (e.y = t, (e.children || []).reduce((s, n) => {
|
|
386
|
+
const [o, a] = s;
|
|
387
|
+
q(n, e.y + e.ySize);
|
|
388
|
+
const l = (o === 0 ? n.lExt : n.rExt).bottom;
|
|
389
|
+
o !== 0 && Qt(e, o, a);
|
|
390
|
+
const r = ae(l, o, a);
|
|
391
|
+
return [o + 1, r];
|
|
392
|
+
}, [0, null]), Jt(e), oe(e), e), J = (e, t, s) => {
|
|
394
393
|
typeof t > "u" && (t = -e.relX - e.prelim, s = 0);
|
|
395
394
|
const n = t + e.relX;
|
|
396
|
-
return e.relX = n + e.prelim - s, e.prelim = 0, e.x = s + e.relX, (e.children || []).forEach((
|
|
397
|
-
},
|
|
395
|
+
return e.relX = n + e.prelim - s, e.prelim = 0, e.x = s + e.relX, (e.children || []).forEach((o) => J(o, n, e.x)), e;
|
|
396
|
+
}, Jt = (e) => {
|
|
398
397
|
(e.children || []).reduce((t, s) => {
|
|
399
|
-
const [n,
|
|
400
|
-
return s.relX +=
|
|
398
|
+
const [n, o] = t, a = n + s.shift, l = o + a + s.change;
|
|
399
|
+
return s.relX += l, [a, l];
|
|
401
400
|
}, [0, 0]);
|
|
402
|
-
},
|
|
403
|
-
const n = e.children[t - 1],
|
|
404
|
-
let a = n,
|
|
401
|
+
}, Qt = (e, t, s) => {
|
|
402
|
+
const n = e.children[t - 1], o = e.children[t];
|
|
403
|
+
let a = n, l = n.relX, r = o, c = o.relX, p = !0;
|
|
405
404
|
for (; a && r; ) {
|
|
406
405
|
a.bottom > s.lowY && (s = s.next);
|
|
407
|
-
const h =
|
|
408
|
-
(h > 0 || h < 0 &&
|
|
409
|
-
const
|
|
410
|
-
|
|
406
|
+
const h = l + a.prelim - (c + r.prelim) + a.xSize / 2 + r.xSize / 2 + a.spacing(r);
|
|
407
|
+
(h > 0 || h < 0 && p) && (c += h, te(o, h), ee(e, t, s.index, h)), p = !1;
|
|
408
|
+
const u = a.bottom, m = r.bottom;
|
|
409
|
+
u <= m && (a = ne(a), a && (l += a.relX)), u >= m && (r = re(r), r && (c += r.relX));
|
|
411
410
|
}
|
|
412
|
-
!a && r ?
|
|
413
|
-
},
|
|
411
|
+
!a && r ? se(e, t, r, c) : a && !r && ie(e, t, a, l);
|
|
412
|
+
}, te = (e, t) => {
|
|
414
413
|
e.relX += t, e.lExtRelX += t, e.rExtRelX += t;
|
|
415
|
-
},
|
|
416
|
-
const
|
|
414
|
+
}, ee = (e, t, s, n) => {
|
|
415
|
+
const o = e.children[t], a = t - s;
|
|
417
416
|
if (a > 1) {
|
|
418
|
-
const
|
|
419
|
-
e.children[s + 1].shift +=
|
|
417
|
+
const l = n / a;
|
|
418
|
+
e.children[s + 1].shift += l, o.shift -= l, o.change -= n - l;
|
|
420
419
|
}
|
|
421
|
-
},
|
|
422
|
-
const
|
|
420
|
+
}, re = (e) => e.hasChildren ? e.firstChild : e.lThr, ne = (e) => e.hasChildren ? e.lastChild : e.rThr, se = (e, t, s, n) => {
|
|
421
|
+
const o = e.firstChild, a = o.lExt, l = e.children[t];
|
|
423
422
|
a.lThr = s;
|
|
424
|
-
const r = n - s.relX -
|
|
425
|
-
a.relX += r, a.prelim -= r,
|
|
426
|
-
},
|
|
427
|
-
const
|
|
423
|
+
const r = n - s.relX - o.lExtRelX;
|
|
424
|
+
a.relX += r, a.prelim -= r, o.lExt = l.lExt, o.lExtRelX = l.lExtRelX;
|
|
425
|
+
}, ie = (e, t, s, n) => {
|
|
426
|
+
const o = e.children[t], a = o.rExt, l = e.children[t - 1];
|
|
428
427
|
a.rThr = s;
|
|
429
|
-
const r = n - s.relX -
|
|
430
|
-
a.relX += r, a.prelim -= r,
|
|
431
|
-
},
|
|
428
|
+
const r = n - s.relX - o.rExtRelX;
|
|
429
|
+
a.relX += r, a.prelim -= r, o.rExt = l.rExt, o.rExtRelX = l.rExtRelX;
|
|
430
|
+
}, oe = (e) => {
|
|
432
431
|
if (e.hasChildren) {
|
|
433
432
|
const t = e.firstChild, s = e.lastChild, n = (t.prelim + t.relX - t.xSize / 2 + s.relX + s.prelim + s.xSize / 2) / 2;
|
|
434
433
|
Object.assign(e, {
|
|
@@ -439,7 +438,7 @@ const U = (e, t = 0) => (e.y = t, (e.children || []).reduce((s, n) => {
|
|
|
439
438
|
rExtRelX: s.rExtRelX
|
|
440
439
|
});
|
|
441
440
|
}
|
|
442
|
-
},
|
|
441
|
+
}, ae = (e, t, s) => {
|
|
443
442
|
for (; s !== null && e >= s.lowY; )
|
|
444
443
|
s = s.next;
|
|
445
444
|
return {
|
|
@@ -447,65 +446,66 @@ const U = (e, t = 0) => (e.y = t, (e.children || []).reduce((s, n) => {
|
|
|
447
446
|
index: t,
|
|
448
447
|
next: s
|
|
449
448
|
};
|
|
450
|
-
},
|
|
451
|
-
function
|
|
449
|
+
}, Q = ".markmap{--markmap-max-width: 9999px;--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;--markmap-circle-open-bg: #fff;--markmap-text-color: #333;font:var(--markmap-font);color:var(--markmap-text-color)}.markmap-link{fill:none}.markmap-node>circle{cursor:pointer}.markmap-foreign{display:inline-block}.markmap-foreign p{margin:0}.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 svg{fill:currentColor}.markmap-foreign>div{width:var(--markmap-max-width);text-align:left}.markmap-foreign>div>div{display:inline-block}.markmap-dark .markmap{--markmap-code-bg: #1a1b26;--markmap-code-color: #ddd;--markmap-circle-open-bg: #444;--markmap-text-color: #eee}", me = Q, j = lt();
|
|
450
|
+
function I(e) {
|
|
452
451
|
return Math.max(4 - 2 * e.state.depth, 1.5);
|
|
453
452
|
}
|
|
454
|
-
function
|
|
455
|
-
const s =
|
|
453
|
+
function K(e, t) {
|
|
454
|
+
const s = pt(e, t);
|
|
456
455
|
return e[s];
|
|
457
456
|
}
|
|
458
|
-
function
|
|
457
|
+
function O(e) {
|
|
459
458
|
e.stopPropagation();
|
|
460
459
|
}
|
|
461
|
-
const
|
|
462
|
-
class
|
|
460
|
+
const le = new ut();
|
|
461
|
+
class tt {
|
|
463
462
|
constructor(t, s) {
|
|
464
|
-
this.options =
|
|
465
|
-
const { transform:
|
|
466
|
-
this.g.attr("transform",
|
|
463
|
+
this.options = U, this.revokers = [], this.handleZoom = (n) => {
|
|
464
|
+
const { transform: o } = n;
|
|
465
|
+
this.g.attr("transform", o);
|
|
467
466
|
}, this.handlePan = (n) => {
|
|
468
467
|
n.preventDefault();
|
|
469
|
-
const
|
|
470
|
-
-n.deltaX /
|
|
471
|
-
-n.deltaY /
|
|
468
|
+
const o = w(this.svg.node()), a = o.translate(
|
|
469
|
+
-n.deltaX / o.k,
|
|
470
|
+
-n.deltaY / o.k
|
|
472
471
|
);
|
|
473
472
|
this.svg.call(this.zoom.transform, a);
|
|
474
|
-
}, this.handleClick = (n,
|
|
473
|
+
}, this.handleClick = (n, o) => {
|
|
475
474
|
let a = this.options.toggleRecursively;
|
|
476
|
-
(
|
|
477
|
-
}, this.ensureView = this.ensureVisible, this.svg = t.datum ? t :
|
|
478
|
-
id: this.options.id || this.svg.attr("id") ||
|
|
475
|
+
(V ? n.metaKey : n.ctrlKey) && (a = !a), this.toggleNode(o, a);
|
|
476
|
+
}, this.ensureView = this.ensureVisible, this.svg = t.datum ? t : ct(t), this.styleNode = this.svg.append("style"), this.zoom = ht().filter((n) => this.options.scrollForPan && n.type === "wheel" ? n.ctrlKey && !n.button : (!n.ctrlKey || n.type === "wheel") && !n.button).on("zoom", this.handleZoom), this.setOptions(s), this.state = {
|
|
477
|
+
id: this.options.id || this.svg.attr("id") || mt(),
|
|
479
478
|
rect: { x1: 0, y1: 0, x2: 0, y2: 0 }
|
|
480
479
|
}, this.g = this.svg.append("g"), this.observer = new ResizeObserver(
|
|
481
|
-
|
|
480
|
+
gt(() => {
|
|
482
481
|
this.renderData();
|
|
483
482
|
}, 100)
|
|
484
483
|
), this.revokers.push(
|
|
485
|
-
|
|
484
|
+
le.tap(() => {
|
|
486
485
|
this.setData();
|
|
487
|
-
})
|
|
486
|
+
}),
|
|
487
|
+
() => this.observer.disconnect()
|
|
488
488
|
);
|
|
489
489
|
}
|
|
490
490
|
getStyleContent() {
|
|
491
491
|
const { style: t } = this.options, { id: s } = this.state, n = typeof t == "function" ? t(s) : "";
|
|
492
|
-
return [this.options.embedGlobalCSS &&
|
|
492
|
+
return [this.options.embedGlobalCSS && Q, n].filter(Boolean).join(`
|
|
493
493
|
`);
|
|
494
494
|
}
|
|
495
495
|
updateStyle() {
|
|
496
496
|
this.svg.attr(
|
|
497
497
|
"class",
|
|
498
|
-
|
|
498
|
+
ft(this.svg.attr("class"), "markmap", this.state.id)
|
|
499
499
|
);
|
|
500
500
|
const t = this.getStyleContent();
|
|
501
501
|
this.styleNode.text(t);
|
|
502
502
|
}
|
|
503
503
|
async toggleNode(t, s = !1) {
|
|
504
|
-
var
|
|
505
|
-
const n = (
|
|
506
|
-
s ?
|
|
507
|
-
|
|
508
|
-
...
|
|
504
|
+
var o, a;
|
|
505
|
+
const n = (o = t.payload) != null && o.fold ? 0 : 1;
|
|
506
|
+
s ? C(t, (l, r) => {
|
|
507
|
+
l.payload = {
|
|
508
|
+
...l.payload,
|
|
509
509
|
fold: n
|
|
510
510
|
}, r();
|
|
511
511
|
}) : t.payload = {
|
|
@@ -515,13 +515,13 @@ class q {
|
|
|
515
515
|
}
|
|
516
516
|
_initializeData(t) {
|
|
517
517
|
let s = 0;
|
|
518
|
-
const { color: n, initialExpandLevel:
|
|
519
|
-
let a = 0,
|
|
520
|
-
|
|
521
|
-
var
|
|
522
|
-
|
|
518
|
+
const { color: n, initialExpandLevel: o } = this.options;
|
|
519
|
+
let a = 0, l = 0;
|
|
520
|
+
C(t, (r, c, p) => {
|
|
521
|
+
var u, m, g, y;
|
|
522
|
+
l += 1, r.children = (u = r.children) == null ? void 0 : u.map((x) => ({ ...x })), s += 1, r.state = {
|
|
523
523
|
...r.state,
|
|
524
|
-
depth:
|
|
524
|
+
depth: l,
|
|
525
525
|
id: s,
|
|
526
526
|
rect: {
|
|
527
527
|
x: 0,
|
|
@@ -530,46 +530,46 @@ class q {
|
|
|
530
530
|
height: 0
|
|
531
531
|
},
|
|
532
532
|
size: [0, 0]
|
|
533
|
-
}, r.state.key = [(
|
|
534
|
-
const h = ((
|
|
535
|
-
h ? a += 1 : (a ||
|
|
533
|
+
}, r.state.key = [(m = p == null ? void 0 : p.state) == null ? void 0 : m.id, r.state.id].filter(Boolean).join(".") + yt(r.content), r.state.path = [(g = p == null ? void 0 : p.state) == null ? void 0 : g.path, r.state.id].filter(Boolean).join("."), n(r);
|
|
534
|
+
const h = ((y = r.payload) == null ? void 0 : y.fold) === 2;
|
|
535
|
+
h ? a += 1 : (a || o >= 0 && r.state.depth >= o) && (r.payload = { ...r.payload, fold: 1 }), c(), h && (a -= 1), l -= 1;
|
|
536
536
|
});
|
|
537
537
|
}
|
|
538
538
|
_relayout() {
|
|
539
539
|
if (!this.state.data) return;
|
|
540
|
-
this.g.selectAll(
|
|
541
|
-
|
|
540
|
+
this.g.selectAll(v("g")).selectAll(
|
|
541
|
+
v("foreignObject")
|
|
542
542
|
).each(function(r) {
|
|
543
543
|
var h;
|
|
544
|
-
const
|
|
545
|
-
r.state.size =
|
|
544
|
+
const c = (h = this.firstChild) == null ? void 0 : h.firstChild, p = [c.scrollWidth, c.scrollHeight];
|
|
545
|
+
r.state.size = p;
|
|
546
546
|
});
|
|
547
|
-
const { spacingHorizontal: t, paddingX: s, spacingVertical: n } = this.options,
|
|
548
|
-
var
|
|
549
|
-
if (!((
|
|
547
|
+
const { spacingHorizontal: t, paddingX: s, spacingVertical: n } = this.options, o = Z({}).children((r) => {
|
|
548
|
+
var c;
|
|
549
|
+
if (!((c = r.payload) != null && c.fold)) return r.children;
|
|
550
550
|
}).nodeSize((r) => {
|
|
551
|
-
const [
|
|
552
|
-
return [
|
|
553
|
-
}).spacing((r,
|
|
554
|
-
|
|
555
|
-
const
|
|
556
|
-
|
|
557
|
-
const
|
|
558
|
-
|
|
551
|
+
const [c, p] = r.data.state.size;
|
|
552
|
+
return [p, c + (c ? s * 2 : 0) + t];
|
|
553
|
+
}).spacing((r, c) => r.parent === c.parent ? n : n * 2), a = o.hierarchy(this.state.data);
|
|
554
|
+
o(a);
|
|
555
|
+
const l = a.descendants();
|
|
556
|
+
l.forEach((r) => {
|
|
557
|
+
const c = r.data;
|
|
558
|
+
c.state.rect = {
|
|
559
559
|
x: r.y,
|
|
560
560
|
y: r.x - r.xSize / 2,
|
|
561
561
|
width: r.ySize - t,
|
|
562
562
|
height: r.xSize
|
|
563
563
|
};
|
|
564
564
|
}), this.state.rect = {
|
|
565
|
-
x1:
|
|
566
|
-
y1:
|
|
567
|
-
x2:
|
|
568
|
-
|
|
565
|
+
x1: P(l, (r) => r.data.state.rect.x) || 0,
|
|
566
|
+
y1: P(l, (r) => r.data.state.rect.y) || 0,
|
|
567
|
+
x2: W(
|
|
568
|
+
l,
|
|
569
569
|
(r) => r.data.state.rect.x + r.data.state.rect.width
|
|
570
570
|
) || 0,
|
|
571
|
-
y2:
|
|
572
|
-
|
|
571
|
+
y2: W(
|
|
572
|
+
l,
|
|
573
573
|
(r) => r.data.state.rect.y + r.data.state.rect.height
|
|
574
574
|
) || 0
|
|
575
575
|
};
|
|
@@ -584,96 +584,110 @@ class q {
|
|
|
584
584
|
s && this.setOptions(s), t && (this.state.data = t), this.state.data && (this._initializeData(this.state.data), this.updateStyle(), await this.renderData());
|
|
585
585
|
}
|
|
586
586
|
async renderData(t) {
|
|
587
|
-
const { paddingX: s, autoFit: n, color:
|
|
588
|
-
if (!
|
|
589
|
-
const c = [];
|
|
590
|
-
|
|
591
|
-
var
|
|
592
|
-
(
|
|
587
|
+
const { paddingX: s, autoFit: n, color: o, maxWidth: a } = this.options, l = this.state.data;
|
|
588
|
+
if (!l) return;
|
|
589
|
+
const r = {}, c = {}, p = [];
|
|
590
|
+
C(l, (i, d, f) => {
|
|
591
|
+
var E;
|
|
592
|
+
(E = i.payload) != null && E.fold || d(), r[i.state.id] = i, f && (c[i.state.id] = f.state.id), p.push(i);
|
|
593
593
|
});
|
|
594
|
-
const
|
|
594
|
+
const h = {}, u = {}, m = (i) => {
|
|
595
|
+
!i || h[i.state.id] || C(i, (d, f) => {
|
|
596
|
+
h[d.state.id] = i.state.id, f();
|
|
597
|
+
});
|
|
598
|
+
}, g = (i) => u[h[i.state.id]] || l.state.rect, y = (i) => (r[h[i.state.id]] || l).state.rect;
|
|
599
|
+
u[l.state.id] = l.state.rect, t && m(t);
|
|
600
|
+
const x = this.g.selectAll(v("g")).each((i) => {
|
|
601
|
+
u[i.state.id] = i.state.rect;
|
|
602
|
+
}).data(p, (i) => i.state.key), b = x.enter().append("g").attr("data-depth", (i) => i.state.depth).attr("data-path", (i) => i.state.path).each((i) => {
|
|
603
|
+
m(r[c[i.state.id]]);
|
|
604
|
+
}), k = x.exit().each((i) => {
|
|
605
|
+
m(r[c[i.state.id]]);
|
|
606
|
+
}), z = x.merge(b).attr(
|
|
595
607
|
"class",
|
|
596
|
-
(
|
|
597
|
-
var
|
|
598
|
-
return ["markmap-node", ((
|
|
599
|
-
}
|
|
600
|
-
),
|
|
601
|
-
(
|
|
602
|
-
(
|
|
603
|
-
),
|
|
604
|
-
(
|
|
605
|
-
var
|
|
606
|
-
return (
|
|
608
|
+
(i) => {
|
|
609
|
+
var d;
|
|
610
|
+
return ["markmap-node", ((d = i.payload) == null ? void 0 : d.fold) && "markmap-fold"].filter(Boolean).join(" ");
|
|
611
|
+
}
|
|
612
|
+
), A = z.selectAll(v("line")).data(
|
|
613
|
+
(i) => [i],
|
|
614
|
+
(i) => i.state.key
|
|
615
|
+
), $ = A.enter().append("line").attr("stroke", (i) => o(i)).attr("stroke-width", 0), F = A.merge($), T = z.selectAll(v("circle")).data(
|
|
616
|
+
(i) => {
|
|
617
|
+
var d;
|
|
618
|
+
return (d = i.children) != null && d.length ? [i] : [];
|
|
607
619
|
},
|
|
608
|
-
(
|
|
609
|
-
),
|
|
620
|
+
(i) => i.state.key
|
|
621
|
+
), D = T.enter().append("circle").attr("stroke-width", 0).attr("r", 0).on("click", (i, d) => this.handleClick(i, d)).on("mousedown", O).merge(T).attr("stroke", (i) => o(i)).attr(
|
|
610
622
|
"fill",
|
|
611
|
-
(
|
|
612
|
-
var
|
|
613
|
-
return (
|
|
614
|
-
}
|
|
615
|
-
),
|
|
616
|
-
(
|
|
617
|
-
(
|
|
618
|
-
), X =
|
|
619
|
-
X.append("xhtml:div").append("xhtml:div").html((
|
|
620
|
-
var
|
|
621
|
-
const
|
|
622
|
-
|
|
623
|
+
(i) => {
|
|
624
|
+
var d;
|
|
625
|
+
return (d = i.payload) != null && d.fold && i.children ? o(i) : "var(--markmap-circle-open-bg)";
|
|
626
|
+
}
|
|
627
|
+
), _ = this.observer, H = z.selectAll(v("foreignObject")).data(
|
|
628
|
+
(i) => [i],
|
|
629
|
+
(i) => i.state.key
|
|
630
|
+
), X = H.enter().append("foreignObject").attr("class", "markmap-foreign").attr("x", s).attr("y", 0).style("opacity", 0).on("mousedown", O).on("dblclick", O);
|
|
631
|
+
X.append("xhtml:div").append("xhtml:div").html((i) => i.content).attr("xmlns", "http://www.w3.org/1999/xhtml"), X.each(function() {
|
|
632
|
+
var d;
|
|
633
|
+
const i = (d = this.firstChild) == null ? void 0 : d.firstChild;
|
|
634
|
+
_.observe(i);
|
|
623
635
|
});
|
|
624
|
-
const
|
|
625
|
-
|
|
636
|
+
const N = k.selectAll(
|
|
637
|
+
v("foreignObject")
|
|
626
638
|
);
|
|
627
|
-
|
|
628
|
-
var
|
|
629
|
-
const
|
|
630
|
-
|
|
639
|
+
N.each(function() {
|
|
640
|
+
var d;
|
|
641
|
+
const i = (d = this.firstChild) == null ? void 0 : d.firstChild;
|
|
642
|
+
_.unobserve(i);
|
|
631
643
|
});
|
|
632
|
-
const
|
|
633
|
-
(
|
|
634
|
-
var
|
|
635
|
-
return (
|
|
636
|
-
}
|
|
637
|
-
),
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
644
|
+
const L = X.merge(H), et = p.flatMap(
|
|
645
|
+
(i) => {
|
|
646
|
+
var d;
|
|
647
|
+
return (d = i.payload) != null && d.fold ? [] : i.children.map((f) => ({ source: i, target: f }));
|
|
648
|
+
}
|
|
649
|
+
), M = this.g.selectAll(v("path")).data(et, (i) => i.target.state.key), rt = M.exit(), nt = M.enter().insert("path", "g").attr("class", "markmap-link").attr("data-depth", (i) => i.target.state.depth).attr("data-path", (i) => i.target.state.path).attr("d", (i) => {
|
|
650
|
+
const d = g(i.target), f = [
|
|
651
|
+
d.x + d.width,
|
|
652
|
+
d.y + d.height
|
|
653
|
+
];
|
|
654
|
+
return j({ source: f, target: f });
|
|
655
|
+
}).attr("stroke-width", 0).merge(M);
|
|
641
656
|
this.svg.style(
|
|
642
657
|
"--markmap-max-width",
|
|
643
658
|
a ? `${a}px` : null
|
|
644
|
-
), await new Promise(requestAnimationFrame), this._relayout()
|
|
645
|
-
|
|
646
|
-
|
|
659
|
+
), await new Promise(requestAnimationFrame), this._relayout(), b.attr("transform", (i) => {
|
|
660
|
+
const d = g(i);
|
|
661
|
+
return `translate(${d.x + d.width - i.state.rect.width},${d.y + d.height - i.state.rect.height})`;
|
|
662
|
+
}), this.transition(k).attr("transform", (i) => {
|
|
663
|
+
const d = y(i), f = d.x + d.width - i.state.rect.width, E = d.y + d.height - i.state.rect.height;
|
|
664
|
+
return `translate(${f},${E})`;
|
|
665
|
+
}).remove(), this.transition(z).attr(
|
|
647
666
|
"transform",
|
|
648
|
-
(
|
|
649
|
-
), this.transition(p).attr("transform", (o) => {
|
|
650
|
-
const m = z.x + z.width - o.state.rect.width, v = z.y + z.height - o.state.rect.height;
|
|
651
|
-
return `translate(${m},${v})`;
|
|
652
|
-
}).remove(), this.transition(u).attr(
|
|
653
|
-
"transform",
|
|
654
|
-
(o) => `translate(${o.state.rect.x},${o.state.rect.y})`
|
|
667
|
+
(i) => `translate(${i.state.rect.x},${i.state.rect.y})`
|
|
655
668
|
);
|
|
656
|
-
const
|
|
657
|
-
|
|
669
|
+
const st = k.selectAll(
|
|
670
|
+
v("line")
|
|
658
671
|
);
|
|
659
|
-
this.transition(
|
|
660
|
-
const
|
|
661
|
-
|
|
672
|
+
this.transition(st).attr("x1", (i) => i.state.rect.width).attr("stroke-width", 0), $.attr("x1", (i) => i.state.rect.width).attr("x2", (i) => i.state.rect.width), F.attr("y1", (i) => i.state.rect.height).attr("y2", (i) => i.state.rect.height), this.transition(F).attr("x1", -1).attr("x2", (i) => i.state.rect.width + 2).attr("stroke", (i) => o(i)).attr("stroke-width", I);
|
|
673
|
+
const it = k.selectAll(
|
|
674
|
+
v("circle")
|
|
662
675
|
);
|
|
663
|
-
this.transition(
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
676
|
+
this.transition(it).attr("r", 0).attr("stroke-width", 0), D.attr("cx", (i) => i.state.rect.width).attr("cy", (i) => i.state.rect.height), this.transition(D).attr("r", 6).attr("stroke-width", "1.5"), this.transition(N).style("opacity", 0), L.attr("width", (i) => Math.max(0, i.state.rect.width - s * 2)).attr("height", (i) => i.state.rect.height), this.transition(L).style("opacity", 1), this.transition(rt).attr("d", (i) => {
|
|
677
|
+
const d = y(i.target), f = [
|
|
678
|
+
d.x + d.width,
|
|
679
|
+
d.y + d.height
|
|
680
|
+
];
|
|
681
|
+
return j({ source: f, target: f });
|
|
682
|
+
}).attr("stroke-width", 0).remove(), this.transition(nt).attr("stroke", (i) => o(i.target)).attr("stroke-width", (i) => I(i.target)).attr("d", (i) => {
|
|
683
|
+
const d = i.source, f = i.target, E = [
|
|
684
|
+
d.state.rect.x + d.state.rect.width,
|
|
685
|
+
d.state.rect.y + d.state.rect.height
|
|
686
|
+
], ot = [
|
|
687
|
+
f.state.rect.x,
|
|
688
|
+
f.state.rect.y + f.state.rect.height
|
|
675
689
|
];
|
|
676
|
-
return
|
|
690
|
+
return j({ source: E, target: ot });
|
|
677
691
|
}), n && this.fit();
|
|
678
692
|
}
|
|
679
693
|
transition(t) {
|
|
@@ -684,21 +698,21 @@ class q {
|
|
|
684
698
|
* Fit the content to the viewport.
|
|
685
699
|
*/
|
|
686
700
|
async fit(t = this.options.maxInitialScale) {
|
|
687
|
-
const s = this.svg.node(), { width: n, height:
|
|
701
|
+
const s = this.svg.node(), { width: n, height: o } = s.getBoundingClientRect(), { fitRatio: a } = this.options, { x1: l, y1: r, x2: c, y2: p } = this.state.rect, h = c - l, u = p - r, m = Math.min(
|
|
688
702
|
n / h * a,
|
|
689
|
-
|
|
703
|
+
o / u * a,
|
|
690
704
|
t
|
|
691
|
-
), g =
|
|
692
|
-
(n - h *
|
|
693
|
-
(
|
|
694
|
-
).scale(
|
|
695
|
-
return this.transition(this.svg).call(this.zoom.transform, g).end().catch(
|
|
705
|
+
), g = dt.translate(
|
|
706
|
+
(n - h * m) / 2 - l * m,
|
|
707
|
+
(o - u * m) / 2 - r * m
|
|
708
|
+
).scale(m);
|
|
709
|
+
return this.transition(this.svg).call(this.zoom.transform, g).end().catch(S);
|
|
696
710
|
}
|
|
697
711
|
findElement(t) {
|
|
698
712
|
let s;
|
|
699
|
-
return this.g.selectAll(
|
|
700
|
-
|
|
701
|
-
data:
|
|
713
|
+
return this.g.selectAll(v("g")).each(function(o) {
|
|
714
|
+
o === t && (s = {
|
|
715
|
+
data: o,
|
|
702
716
|
g: this
|
|
703
717
|
});
|
|
704
718
|
}), s;
|
|
@@ -707,52 +721,52 @@ class q {
|
|
|
707
721
|
* Pan the content to make the provided node visible in the viewport.
|
|
708
722
|
*/
|
|
709
723
|
async ensureVisible(t, s) {
|
|
710
|
-
var
|
|
711
|
-
const n = (
|
|
724
|
+
var b;
|
|
725
|
+
const n = (b = this.findElement(t)) == null ? void 0 : b.data;
|
|
712
726
|
if (!n) return;
|
|
713
|
-
const
|
|
727
|
+
const o = this.svg.node(), a = o.getBoundingClientRect(), l = w(o), [r, c] = [
|
|
714
728
|
n.state.rect.x,
|
|
715
729
|
n.state.rect.x + n.state.rect.width + 2
|
|
716
|
-
].map((
|
|
730
|
+
].map((k) => k * l.k + l.x), [p, h] = [
|
|
717
731
|
n.state.rect.y,
|
|
718
732
|
n.state.rect.y + n.state.rect.height
|
|
719
|
-
].map((
|
|
733
|
+
].map((k) => k * l.k + l.y), u = {
|
|
720
734
|
left: 0,
|
|
721
735
|
right: 0,
|
|
722
736
|
top: 0,
|
|
723
737
|
bottom: 0,
|
|
724
738
|
...s
|
|
725
|
-
},
|
|
726
|
-
if (
|
|
727
|
-
const
|
|
728
|
-
return this.transition(this.svg).call(this.zoom.transform,
|
|
739
|
+
}, m = [u.left - r, a.width - u.right - c], g = [u.top - p, a.height - u.bottom - h], y = m[0] * m[1] > 0 ? K(m, Math.abs) / l.k : 0, x = g[0] * g[1] > 0 ? K(g, Math.abs) / l.k : 0;
|
|
740
|
+
if (y || x) {
|
|
741
|
+
const k = l.translate(y, x);
|
|
742
|
+
return this.transition(this.svg).call(this.zoom.transform, k).end().catch(S);
|
|
729
743
|
}
|
|
730
744
|
}
|
|
731
745
|
async centerNode(t, s) {
|
|
732
|
-
var
|
|
733
|
-
const n = (
|
|
746
|
+
var y;
|
|
747
|
+
const n = (y = this.findElement(t)) == null ? void 0 : y.data;
|
|
734
748
|
if (!n) return;
|
|
735
|
-
const
|
|
749
|
+
const o = this.svg.node(), a = o.getBoundingClientRect(), l = w(o), r = (n.state.rect.x + n.state.rect.width / 2) * l.k + l.x, c = (n.state.rect.y + n.state.rect.height / 2) * l.k + l.y, p = {
|
|
736
750
|
left: 0,
|
|
737
751
|
right: 0,
|
|
738
752
|
top: 0,
|
|
739
753
|
bottom: 0,
|
|
740
754
|
...s
|
|
741
|
-
}, h = (
|
|
742
|
-
if (
|
|
743
|
-
const x =
|
|
744
|
-
return this.transition(this.svg).call(this.zoom.transform, x).end().catch(
|
|
755
|
+
}, h = (p.left + a.width - p.right) / 2, u = (p.top + a.height - p.bottom) / 2, m = (h - r) / l.k, g = (u - c) / l.k;
|
|
756
|
+
if (m || g) {
|
|
757
|
+
const x = l.translate(m, g);
|
|
758
|
+
return this.transition(this.svg).call(this.zoom.transform, x).end().catch(S);
|
|
745
759
|
}
|
|
746
760
|
}
|
|
747
761
|
/**
|
|
748
762
|
* Scale content with it pinned at the center of the viewport.
|
|
749
763
|
*/
|
|
750
764
|
async rescale(t) {
|
|
751
|
-
const s = this.svg.node(), { width: n, height:
|
|
765
|
+
const s = this.svg.node(), { width: n, height: o } = s.getBoundingClientRect(), a = n / 2, l = o / 2, r = w(s), c = r.translate(
|
|
752
766
|
(a - r.x) * (1 - t) / r.k,
|
|
753
|
-
(
|
|
767
|
+
(l - r.y) * (1 - t) / r.k
|
|
754
768
|
).scale(t);
|
|
755
|
-
return this.transition(this.svg).call(this.zoom.transform,
|
|
769
|
+
return this.transition(this.svg).call(this.zoom.transform, c).end().catch(S);
|
|
756
770
|
}
|
|
757
771
|
destroy() {
|
|
758
772
|
this.svg.on(".zoom", null), this.svg.html(null), this.revokers.forEach((t) => {
|
|
@@ -760,21 +774,19 @@ class q {
|
|
|
760
774
|
});
|
|
761
775
|
}
|
|
762
776
|
static create(t, s, n = null) {
|
|
763
|
-
const
|
|
764
|
-
return n &&
|
|
765
|
-
|
|
766
|
-
}),
|
|
777
|
+
const o = new tt(t, s);
|
|
778
|
+
return n && o.setData(n).then(() => {
|
|
779
|
+
o.fit();
|
|
780
|
+
}), o;
|
|
767
781
|
}
|
|
768
782
|
}
|
|
769
783
|
export {
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
oe as refreshHook,
|
|
779
|
-
ft as simpleHash
|
|
784
|
+
tt as Markmap,
|
|
785
|
+
xt as defaultColorFn,
|
|
786
|
+
U as defaultOptions,
|
|
787
|
+
ue as deriveOptions,
|
|
788
|
+
me as globalCSS,
|
|
789
|
+
V as isMacintosh,
|
|
790
|
+
le as refreshHook,
|
|
791
|
+
yt as simpleHash
|
|
780
792
|
};
|