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