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