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