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