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