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