markmap-view 0.18.3 → 0.18.4-alpha.3
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 +55 -23
- package/dist/index.js +359 -344
- package/dist/types.d.ts +2 -3
- package/dist/util.d.ts +1 -1
- package/package.json +2 -2
package/dist/browser/index.js
CHANGED
|
@@ -1001,7 +1001,8 @@
|
|
|
1001
1001
|
this.revokers.push(
|
|
1002
1002
|
refreshHook.tap(() => {
|
|
1003
1003
|
this.setData();
|
|
1004
|
-
})
|
|
1004
|
+
}),
|
|
1005
|
+
() => this.observer.disconnect()
|
|
1005
1006
|
);
|
|
1006
1007
|
}
|
|
1007
1008
|
getStyleContent() {
|
|
@@ -1144,18 +1145,43 @@
|
|
|
1144
1145
|
}
|
|
1145
1146
|
async renderData(originData) {
|
|
1146
1147
|
const { paddingX, autoFit, color, maxWidth } = this.options;
|
|
1147
|
-
|
|
1148
|
+
const rootNode = this.state.data;
|
|
1149
|
+
if (!rootNode) return;
|
|
1150
|
+
const nodeMap = {};
|
|
1151
|
+
const parentMap = {};
|
|
1148
1152
|
const nodes = [];
|
|
1149
|
-
walkTree(
|
|
1153
|
+
walkTree(rootNode, (item, next, parent) => {
|
|
1150
1154
|
var _a;
|
|
1151
1155
|
if (!((_a = item.payload) == null ? void 0 : _a.fold)) next();
|
|
1156
|
+
nodeMap[item.state.id] = item;
|
|
1157
|
+
if (parent) parentMap[item.state.id] = parent.state.id;
|
|
1152
1158
|
nodes.push(item);
|
|
1153
1159
|
});
|
|
1154
|
-
const
|
|
1155
|
-
const
|
|
1156
|
-
const
|
|
1157
|
-
|
|
1158
|
-
|
|
1160
|
+
const originMap = {};
|
|
1161
|
+
const sourceRectMap = {};
|
|
1162
|
+
const setOriginNode = (originNode) => {
|
|
1163
|
+
if (!originNode || originMap[originNode.state.id]) return;
|
|
1164
|
+
walkTree(originNode, (item, next) => {
|
|
1165
|
+
originMap[item.state.id] = originNode.state.id;
|
|
1166
|
+
next();
|
|
1167
|
+
});
|
|
1168
|
+
};
|
|
1169
|
+
const getOriginSourceRect = (node) => {
|
|
1170
|
+
const rect = sourceRectMap[originMap[node.state.id]];
|
|
1171
|
+
return rect || rootNode.state.rect;
|
|
1172
|
+
};
|
|
1173
|
+
const getOriginTargetRect = (node) => (nodeMap[originMap[node.state.id]] || rootNode).state.rect;
|
|
1174
|
+
sourceRectMap[rootNode.state.id] = rootNode.state.rect;
|
|
1175
|
+
if (originData) setOriginNode(originData);
|
|
1176
|
+
const mmG = this.g.selectAll(childSelector("g")).each((d) => {
|
|
1177
|
+
sourceRectMap[d.state.id] = d.state.rect;
|
|
1178
|
+
}).data(nodes, (d) => d.state.key);
|
|
1179
|
+
const mmGEnter = mmG.enter().append("g").attr("data-depth", (d) => d.state.depth).attr("data-path", (d) => d.state.path).each((d) => {
|
|
1180
|
+
setOriginNode(nodeMap[parentMap[d.state.id]]);
|
|
1181
|
+
});
|
|
1182
|
+
const mmGExit = mmG.exit().each((d) => {
|
|
1183
|
+
setOriginNode(nodeMap[parentMap[d.state.id]]);
|
|
1184
|
+
});
|
|
1159
1185
|
const mmGMerge = mmG.merge(mmGEnter).attr(
|
|
1160
1186
|
"class",
|
|
1161
1187
|
(d) => {
|
|
@@ -1213,11 +1239,14 @@
|
|
|
1213
1239
|
);
|
|
1214
1240
|
const mmPath = this.g.selectAll(childSelector("path")).data(links, (d) => d.target.state.key);
|
|
1215
1241
|
const mmPathExit = mmPath.exit();
|
|
1216
|
-
const
|
|
1217
|
-
originRect
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1242
|
+
const mmPathEnter = mmPath.enter().insert("path", "g").attr("class", "markmap-link").attr("data-depth", (d) => d.target.state.depth).attr("data-path", (d) => d.target.state.path).attr("d", (d) => {
|
|
1243
|
+
const originRect = getOriginSourceRect(d.target);
|
|
1244
|
+
const pathOrigin = [
|
|
1245
|
+
originRect.x + originRect.width,
|
|
1246
|
+
originRect.y + originRect.height
|
|
1247
|
+
];
|
|
1248
|
+
return linkShape({ source: pathOrigin, target: pathOrigin });
|
|
1249
|
+
}).attr("stroke-width", 0);
|
|
1221
1250
|
const mmPathMerge = mmPathEnter.merge(mmPath);
|
|
1222
1251
|
this.svg.style(
|
|
1223
1252
|
"--markmap-max-width",
|
|
@@ -1225,12 +1254,12 @@
|
|
|
1225
1254
|
);
|
|
1226
1255
|
await new Promise(requestAnimationFrame);
|
|
1227
1256
|
this._relayout();
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
);
|
|
1257
|
+
mmGEnter.attr("transform", (d) => {
|
|
1258
|
+
const originRect = getOriginSourceRect(d);
|
|
1259
|
+
return `translate(${originRect.x + originRect.width - d.state.rect.width},${originRect.y + originRect.height - d.state.rect.height})`;
|
|
1260
|
+
});
|
|
1233
1261
|
this.transition(mmGExit).attr("transform", (d) => {
|
|
1262
|
+
const targetRect = getOriginTargetRect(d);
|
|
1234
1263
|
const targetX = targetRect.x + targetRect.width - d.state.rect.width;
|
|
1235
1264
|
const targetY = targetRect.y + targetRect.height - d.state.rect.height;
|
|
1236
1265
|
return `translate(${targetX},${targetY})`;
|
|
@@ -1255,11 +1284,14 @@
|
|
|
1255
1284
|
this.transition(mmFoExit).style("opacity", 0);
|
|
1256
1285
|
mmFoMerge.attr("width", (d) => Math.max(0, d.state.rect.width - paddingX * 2)).attr("height", (d) => d.state.rect.height);
|
|
1257
1286
|
this.transition(mmFoMerge).style("opacity", 1);
|
|
1258
|
-
|
|
1259
|
-
targetRect
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1287
|
+
this.transition(mmPathExit).attr("d", (d) => {
|
|
1288
|
+
const targetRect = getOriginTargetRect(d.target);
|
|
1289
|
+
const pathTarget = [
|
|
1290
|
+
targetRect.x + targetRect.width,
|
|
1291
|
+
targetRect.y + targetRect.height
|
|
1292
|
+
];
|
|
1293
|
+
return linkShape({ source: pathTarget, target: pathTarget });
|
|
1294
|
+
}).attr("stroke-width", 0).remove();
|
|
1263
1295
|
this.transition(mmPathMerge).attr("stroke", (d) => color(d.target)).attr("stroke-width", (d) => linkWidth(d.target)).attr("d", (d) => {
|
|
1264
1296
|
const origSource = d.source;
|
|
1265
1297
|
const origTarget = d.target;
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Hook as
|
|
2
|
-
import { loadCSS as
|
|
3
|
-
import { scaleOrdinal as
|
|
4
|
-
const
|
|
1
|
+
import { Hook as at, getId as lt, debounce as ct, addClass as ht, walkTree as C, childSelector as v, noop as w } from "markmap-common";
|
|
2
|
+
import { loadCSS as xe, loadJS as ye } from "markmap-common";
|
|
3
|
+
import { scaleOrdinal as G, schemeCategory10 as dt, linkHorizontal as pt, zoomTransform as S, select as ut, zoom as mt, min as P, max as W, zoomIdentity as gt, minIndex as ft } from "d3";
|
|
4
|
+
const V = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), xt = G(dt), U = {
|
|
5
5
|
autoFit: !1,
|
|
6
6
|
color: (e) => {
|
|
7
7
|
var t;
|
|
8
|
-
return
|
|
8
|
+
return xt(`${((t = e.state) == null ? void 0 : t.path) || ""}`);
|
|
9
9
|
},
|
|
10
10
|
duration: 500,
|
|
11
11
|
embedGlobalCSS: !0,
|
|
@@ -14,7 +14,7 @@ const I = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), g
|
|
|
14
14
|
maxWidth: 0,
|
|
15
15
|
nodeMinHeight: 16,
|
|
16
16
|
paddingX: 8,
|
|
17
|
-
scrollForPan:
|
|
17
|
+
scrollForPan: V,
|
|
18
18
|
spacingHorizontal: 80,
|
|
19
19
|
spacingVertical: 5,
|
|
20
20
|
initialExpandLevel: -1,
|
|
@@ -22,24 +22,24 @@ const I = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), g
|
|
|
22
22
|
pan: !0,
|
|
23
23
|
toggleRecursively: !1
|
|
24
24
|
};
|
|
25
|
-
function
|
|
26
|
-
const t = {}, s = { ...e }, { color: n, colorFreezeLevel:
|
|
25
|
+
function ue(e) {
|
|
26
|
+
const t = {}, s = { ...e }, { color: n, colorFreezeLevel: o } = s;
|
|
27
27
|
if ((n == null ? void 0 : n.length) === 1) {
|
|
28
28
|
const r = n[0];
|
|
29
29
|
t.color = () => r;
|
|
30
30
|
} else if (n != null && n.length) {
|
|
31
|
-
const r =
|
|
32
|
-
t.color = (
|
|
31
|
+
const r = G(n);
|
|
32
|
+
t.color = (c) => r(`${c.state.path}`);
|
|
33
33
|
}
|
|
34
|
-
if (
|
|
35
|
-
const r = t.color ||
|
|
36
|
-
t.color = (
|
|
37
|
-
...
|
|
34
|
+
if (o) {
|
|
35
|
+
const r = t.color || U.color;
|
|
36
|
+
t.color = (c) => (c = {
|
|
37
|
+
...c,
|
|
38
38
|
state: {
|
|
39
|
-
...
|
|
40
|
-
path:
|
|
39
|
+
...c.state,
|
|
40
|
+
path: c.state.path.split(".").slice(0, o).join(".")
|
|
41
41
|
}
|
|
42
|
-
}, r(
|
|
42
|
+
}, r(c));
|
|
43
43
|
}
|
|
44
44
|
return [
|
|
45
45
|
"duration",
|
|
@@ -52,185 +52,185 @@ function he(e) {
|
|
|
52
52
|
"spacingHorizontal",
|
|
53
53
|
"spacingVertical"
|
|
54
54
|
].forEach((r) => {
|
|
55
|
-
const
|
|
56
|
-
typeof
|
|
55
|
+
const c = s[r];
|
|
56
|
+
typeof c == "number" && (t[r] = c);
|
|
57
57
|
}), ["zoom", "pan"].forEach((r) => {
|
|
58
|
-
const
|
|
59
|
-
|
|
58
|
+
const c = s[r];
|
|
59
|
+
c != null && (t[r] = !!c);
|
|
60
60
|
}), t;
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function yt(e) {
|
|
63
63
|
let t = 0;
|
|
64
64
|
for (let s = 0; s < e.length; s++)
|
|
65
65
|
t = (t << 5) - t + e.charCodeAt(s) | 0;
|
|
66
66
|
return (t >>> 0).toString(36);
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function kt(e) {
|
|
69
69
|
var t = 0, s = e.children, n = s && s.length;
|
|
70
70
|
if (!n) t = 1;
|
|
71
71
|
else for (; --n >= 0; ) t += s[n].value;
|
|
72
72
|
e.value = t;
|
|
73
73
|
}
|
|
74
|
-
function
|
|
75
|
-
return this.eachAfter(
|
|
74
|
+
function vt() {
|
|
75
|
+
return this.eachAfter(kt);
|
|
76
76
|
}
|
|
77
|
-
function
|
|
78
|
-
var t = this, s, n = [t],
|
|
77
|
+
function bt(e) {
|
|
78
|
+
var t = this, s, n = [t], o, a, l;
|
|
79
79
|
do
|
|
80
80
|
for (s = n.reverse(), n = []; t = s.pop(); )
|
|
81
|
-
if (e(t),
|
|
82
|
-
n.push(
|
|
81
|
+
if (e(t), o = t.children, o) for (a = 0, l = o.length; a < l; ++a)
|
|
82
|
+
n.push(o[a]);
|
|
83
83
|
while (n.length);
|
|
84
84
|
return this;
|
|
85
85
|
}
|
|
86
|
-
function
|
|
87
|
-
for (var t = this, s = [t], n,
|
|
88
|
-
if (e(t), n = t.children, n) for (
|
|
89
|
-
s.push(n[
|
|
86
|
+
function zt(e) {
|
|
87
|
+
for (var t = this, s = [t], n, o; t = s.pop(); )
|
|
88
|
+
if (e(t), n = t.children, n) for (o = n.length - 1; o >= 0; --o)
|
|
89
|
+
s.push(n[o]);
|
|
90
90
|
return this;
|
|
91
91
|
}
|
|
92
|
-
function
|
|
93
|
-
for (var t = this, s = [t], n = [],
|
|
94
|
-
if (n.push(t),
|
|
95
|
-
s.push(
|
|
92
|
+
function Et(e) {
|
|
93
|
+
for (var t = this, s = [t], n = [], o, a, l; t = s.pop(); )
|
|
94
|
+
if (n.push(t), o = t.children, o) for (a = 0, l = o.length; a < l; ++a)
|
|
95
|
+
s.push(o[a]);
|
|
96
96
|
for (; t = n.pop(); )
|
|
97
97
|
e(t);
|
|
98
98
|
return this;
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function Ct(e) {
|
|
101
101
|
return this.eachAfter(function(t) {
|
|
102
|
-
for (var s = +e(t.data) || 0, n = t.children,
|
|
102
|
+
for (var s = +e(t.data) || 0, n = t.children, o = n && n.length; --o >= 0; ) s += n[o].value;
|
|
103
103
|
t.value = s;
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
|
-
function
|
|
106
|
+
function wt(e) {
|
|
107
107
|
return this.eachBefore(function(t) {
|
|
108
108
|
t.children && t.children.sort(e);
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
-
function
|
|
112
|
-
for (var t = this, s =
|
|
111
|
+
function St(e) {
|
|
112
|
+
for (var t = this, s = Rt(t, e), n = [t]; t !== s; )
|
|
113
113
|
t = t.parent, n.push(t);
|
|
114
|
-
for (var
|
|
115
|
-
n.splice(
|
|
114
|
+
for (var o = n.length; e !== s; )
|
|
115
|
+
n.splice(o, 0, e), e = e.parent;
|
|
116
116
|
return n;
|
|
117
117
|
}
|
|
118
|
-
function
|
|
118
|
+
function Rt(e, t) {
|
|
119
119
|
if (e === t) return e;
|
|
120
|
-
var s = e.ancestors(), n = t.ancestors(),
|
|
120
|
+
var s = e.ancestors(), n = t.ancestors(), o = null;
|
|
121
121
|
for (e = s.pop(), t = n.pop(); e === t; )
|
|
122
|
-
|
|
123
|
-
return
|
|
122
|
+
o = e, e = s.pop(), t = n.pop();
|
|
123
|
+
return o;
|
|
124
124
|
}
|
|
125
|
-
function
|
|
125
|
+
function Xt() {
|
|
126
126
|
for (var e = this, t = [e]; e = e.parent; )
|
|
127
127
|
t.push(e);
|
|
128
128
|
return t;
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function Mt() {
|
|
131
131
|
var e = [];
|
|
132
132
|
return this.each(function(t) {
|
|
133
133
|
e.push(t);
|
|
134
134
|
}), e;
|
|
135
135
|
}
|
|
136
|
-
function
|
|
136
|
+
function jt() {
|
|
137
137
|
var e = [];
|
|
138
138
|
return this.eachBefore(function(t) {
|
|
139
139
|
t.children || e.push(t);
|
|
140
140
|
}), e;
|
|
141
141
|
}
|
|
142
|
-
function
|
|
142
|
+
function Ot() {
|
|
143
143
|
var e = this, t = [];
|
|
144
144
|
return e.each(function(s) {
|
|
145
145
|
s !== e && t.push({ source: s.parent, target: s });
|
|
146
146
|
}), t;
|
|
147
147
|
}
|
|
148
|
-
function
|
|
149
|
-
var s = new
|
|
150
|
-
for (t == null && (t =
|
|
151
|
-
if (n && (
|
|
152
|
-
for (
|
|
153
|
-
a.push(
|
|
154
|
-
return s.eachBefore(
|
|
148
|
+
function B(e, t) {
|
|
149
|
+
var s = new R(e), n = +e.value && (s.value = e.value), o, a = [s], l, r, c, p;
|
|
150
|
+
for (t == null && (t = At); o = a.pop(); )
|
|
151
|
+
if (n && (o.value = +o.data.value), (r = t(o.data)) && (p = r.length))
|
|
152
|
+
for (o.children = new Array(p), c = p - 1; c >= 0; --c)
|
|
153
|
+
a.push(l = o.children[c] = new R(r[c])), l.parent = o, l.depth = o.depth + 1;
|
|
154
|
+
return s.eachBefore(Ft);
|
|
155
155
|
}
|
|
156
|
-
function
|
|
157
|
-
return
|
|
156
|
+
function Bt() {
|
|
157
|
+
return B(this).eachBefore($t);
|
|
158
158
|
}
|
|
159
|
-
function
|
|
159
|
+
function At(e) {
|
|
160
160
|
return e.children;
|
|
161
161
|
}
|
|
162
|
-
function
|
|
162
|
+
function $t(e) {
|
|
163
163
|
e.data = e.data.data;
|
|
164
164
|
}
|
|
165
|
-
function
|
|
165
|
+
function Ft(e) {
|
|
166
166
|
var t = 0;
|
|
167
167
|
do
|
|
168
168
|
e.height = t;
|
|
169
169
|
while ((e = e.parent) && e.height < ++t);
|
|
170
170
|
}
|
|
171
|
-
function
|
|
171
|
+
function R(e) {
|
|
172
172
|
this.data = e, this.depth = this.height = 0, this.parent = null;
|
|
173
173
|
}
|
|
174
|
-
|
|
175
|
-
constructor:
|
|
176
|
-
count:
|
|
177
|
-
each:
|
|
178
|
-
eachAfter:
|
|
179
|
-
eachBefore:
|
|
180
|
-
sum:
|
|
181
|
-
sort:
|
|
182
|
-
path:
|
|
183
|
-
ancestors:
|
|
184
|
-
descendants:
|
|
185
|
-
leaves:
|
|
186
|
-
links:
|
|
187
|
-
copy:
|
|
174
|
+
R.prototype = B.prototype = {
|
|
175
|
+
constructor: R,
|
|
176
|
+
count: vt,
|
|
177
|
+
each: bt,
|
|
178
|
+
eachAfter: Et,
|
|
179
|
+
eachBefore: zt,
|
|
180
|
+
sum: Ct,
|
|
181
|
+
sort: wt,
|
|
182
|
+
path: St,
|
|
183
|
+
ancestors: Xt,
|
|
184
|
+
descendants: Mt,
|
|
185
|
+
leaves: jt,
|
|
186
|
+
links: Ot,
|
|
187
|
+
copy: Bt
|
|
188
188
|
};
|
|
189
|
-
const
|
|
190
|
-
name:
|
|
189
|
+
const Tt = "d3-flextree", Dt = "2.1.2", _t = "build/d3-flextree.js", Ht = "index", Nt = { name: "Chris Maloney", url: "http://chrismaloney.org" }, Lt = "Flexible tree layout algorithm that allows for variable node sizes.", Pt = ["d3", "d3-module", "layout", "tree", "hierarchy", "d3-hierarchy", "plugin", "d3-plugin", "infovis", "visualization", "2d"], Wt = "https://github.com/klortho/d3-flextree", It = "WTFPL", Kt = { type: "git", url: "https://github.com/klortho/d3-flextree.git" }, Gt = { 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" }, Vt = { "d3-hierarchy": "^1.1.5" }, Ut = { "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" }, Yt = {
|
|
190
|
+
name: Tt,
|
|
191
191
|
version: Dt,
|
|
192
|
-
main:
|
|
193
|
-
module:
|
|
192
|
+
main: _t,
|
|
193
|
+
module: Ht,
|
|
194
194
|
"jsnext:main": "index",
|
|
195
|
-
author:
|
|
196
|
-
description:
|
|
197
|
-
keywords:
|
|
198
|
-
homepage:
|
|
199
|
-
license:
|
|
200
|
-
repository:
|
|
201
|
-
scripts:
|
|
202
|
-
dependencies:
|
|
203
|
-
devDependencies:
|
|
204
|
-
}, { version:
|
|
195
|
+
author: Nt,
|
|
196
|
+
description: Lt,
|
|
197
|
+
keywords: Pt,
|
|
198
|
+
homepage: Wt,
|
|
199
|
+
license: It,
|
|
200
|
+
repository: Kt,
|
|
201
|
+
scripts: Gt,
|
|
202
|
+
dependencies: Vt,
|
|
203
|
+
devDependencies: Ut
|
|
204
|
+
}, { version: Zt } = Yt, qt = Object.freeze({
|
|
205
205
|
children: (e) => e.children,
|
|
206
206
|
nodeSize: (e) => e.data.size,
|
|
207
207
|
spacing: 0
|
|
208
208
|
});
|
|
209
|
-
function
|
|
210
|
-
const t = Object.assign({},
|
|
209
|
+
function Z(e) {
|
|
210
|
+
const t = Object.assign({}, qt, e);
|
|
211
211
|
function s(r) {
|
|
212
|
-
const
|
|
213
|
-
return typeof
|
|
212
|
+
const c = t[r];
|
|
213
|
+
return typeof c == "function" ? c : () => c;
|
|
214
214
|
}
|
|
215
215
|
function n(r) {
|
|
216
|
-
const
|
|
217
|
-
return
|
|
216
|
+
const c = l(a(), r, (p) => p.children);
|
|
217
|
+
return c.update(), c.data;
|
|
218
218
|
}
|
|
219
|
-
function
|
|
220
|
-
const r = s("nodeSize"),
|
|
221
|
-
return class
|
|
219
|
+
function o() {
|
|
220
|
+
const r = s("nodeSize"), c = s("spacing");
|
|
221
|
+
return class Y extends B.prototype.constructor {
|
|
222
222
|
constructor(h) {
|
|
223
223
|
super(h);
|
|
224
224
|
}
|
|
225
225
|
copy() {
|
|
226
|
-
const h =
|
|
227
|
-
return h.each((
|
|
226
|
+
const h = l(this.constructor, this, (u) => u.children);
|
|
227
|
+
return h.each((u) => u.data = u.data.data), h;
|
|
228
228
|
}
|
|
229
229
|
get size() {
|
|
230
230
|
return r(this);
|
|
231
231
|
}
|
|
232
232
|
spacing(h) {
|
|
233
|
-
return
|
|
233
|
+
return c(this, h);
|
|
234
234
|
}
|
|
235
235
|
get nodes() {
|
|
236
236
|
return this.descendants();
|
|
@@ -274,7 +274,7 @@ function V(e) {
|
|
|
274
274
|
}
|
|
275
275
|
get extents() {
|
|
276
276
|
return (this.children || []).reduce(
|
|
277
|
-
(h,
|
|
277
|
+
(h, u) => Y.maxExtents(h, u.extents),
|
|
278
278
|
this.nodeExtents
|
|
279
279
|
);
|
|
280
280
|
}
|
|
@@ -286,18 +286,18 @@ function V(e) {
|
|
|
286
286
|
right: this.right
|
|
287
287
|
};
|
|
288
288
|
}
|
|
289
|
-
static maxExtents(h,
|
|
289
|
+
static maxExtents(h, u) {
|
|
290
290
|
return {
|
|
291
|
-
top: Math.min(h.top,
|
|
292
|
-
bottom: Math.max(h.bottom,
|
|
293
|
-
left: Math.min(h.left,
|
|
294
|
-
right: Math.max(h.right,
|
|
291
|
+
top: Math.min(h.top, u.top),
|
|
292
|
+
bottom: Math.max(h.bottom, u.bottom),
|
|
293
|
+
left: Math.min(h.left, u.left),
|
|
294
|
+
right: Math.max(h.right, u.right)
|
|
295
295
|
};
|
|
296
296
|
}
|
|
297
297
|
};
|
|
298
298
|
}
|
|
299
299
|
function a() {
|
|
300
|
-
const r =
|
|
300
|
+
const r = o(), c = s("nodeSize"), p = s("spacing");
|
|
301
301
|
return class extends r {
|
|
302
302
|
constructor(h) {
|
|
303
303
|
super(h), Object.assign(this, {
|
|
@@ -316,10 +316,10 @@ function V(e) {
|
|
|
316
316
|
});
|
|
317
317
|
}
|
|
318
318
|
get size() {
|
|
319
|
-
return
|
|
319
|
+
return c(this.data);
|
|
320
320
|
}
|
|
321
321
|
spacing(h) {
|
|
322
|
-
return
|
|
322
|
+
return p(this.data, h.data);
|
|
323
323
|
}
|
|
324
324
|
get x() {
|
|
325
325
|
return this.data.x;
|
|
@@ -334,29 +334,29 @@ function V(e) {
|
|
|
334
334
|
this.data.y = h;
|
|
335
335
|
}
|
|
336
336
|
update() {
|
|
337
|
-
return
|
|
337
|
+
return q(this), J(this), this;
|
|
338
338
|
}
|
|
339
339
|
};
|
|
340
340
|
}
|
|
341
|
-
function
|
|
342
|
-
const h = (
|
|
343
|
-
const g = new r(
|
|
341
|
+
function l(r, c, p) {
|
|
342
|
+
const h = (u, m) => {
|
|
343
|
+
const g = new r(u);
|
|
344
344
|
Object.assign(g, {
|
|
345
|
-
parent:
|
|
346
|
-
depth:
|
|
345
|
+
parent: m,
|
|
346
|
+
depth: m === null ? 0 : m.depth + 1,
|
|
347
347
|
height: 0,
|
|
348
348
|
length: 1
|
|
349
349
|
});
|
|
350
|
-
const
|
|
351
|
-
return g.children =
|
|
352
|
-
(x,
|
|
353
|
-
height: Math.max(x.height,
|
|
354
|
-
length: x.length +
|
|
350
|
+
const y = p(u) || [];
|
|
351
|
+
return g.children = y.length === 0 ? null : y.map((x) => h(x, g)), g.children && Object.assign(g, g.children.reduce(
|
|
352
|
+
(x, b) => ({
|
|
353
|
+
height: Math.max(x.height, b.height + 1),
|
|
354
|
+
length: x.length + b.length
|
|
355
355
|
}),
|
|
356
356
|
g
|
|
357
357
|
)), g;
|
|
358
358
|
};
|
|
359
|
-
return h(
|
|
359
|
+
return h(c, null);
|
|
360
360
|
}
|
|
361
361
|
return Object.assign(n, {
|
|
362
362
|
nodeSize(r) {
|
|
@@ -368,67 +368,67 @@ function V(e) {
|
|
|
368
368
|
children(r) {
|
|
369
369
|
return arguments.length ? (t.children = r, n) : t.children;
|
|
370
370
|
},
|
|
371
|
-
hierarchy(r,
|
|
372
|
-
const
|
|
373
|
-
return
|
|
371
|
+
hierarchy(r, c) {
|
|
372
|
+
const p = typeof c > "u" ? t.children : c;
|
|
373
|
+
return l(o(), r, p);
|
|
374
374
|
},
|
|
375
375
|
dump(r) {
|
|
376
|
-
const
|
|
377
|
-
const
|
|
378
|
-
return `{ size: [${
|
|
376
|
+
const c = s("nodeSize"), p = (h) => (u) => {
|
|
377
|
+
const m = h + " ", g = h + " ", { x: y, y: x } = u, b = c(u), k = u.children || [], z = k.length === 0 ? " " : `,${m}children: [${g}${k.map(p(g)).join(g)}${m}],${h}`;
|
|
378
|
+
return `{ size: [${b.join(", ")}],${m}x: ${y}, y: ${x}${z}},`;
|
|
379
379
|
};
|
|
380
|
-
return
|
|
380
|
+
return p(`
|
|
381
381
|
`)(r);
|
|
382
382
|
}
|
|
383
383
|
}), n;
|
|
384
384
|
}
|
|
385
|
-
|
|
386
|
-
const
|
|
387
|
-
const [
|
|
388
|
-
|
|
389
|
-
const
|
|
390
|
-
|
|
391
|
-
const r =
|
|
392
|
-
return [
|
|
393
|
-
}, [0, null]),
|
|
385
|
+
Z.version = Zt;
|
|
386
|
+
const q = (e, t = 0) => (e.y = t, (e.children || []).reduce((s, n) => {
|
|
387
|
+
const [o, a] = s;
|
|
388
|
+
q(n, e.y + e.ySize);
|
|
389
|
+
const l = (o === 0 ? n.lExt : n.rExt).bottom;
|
|
390
|
+
o !== 0 && Qt(e, o, a);
|
|
391
|
+
const r = ae(l, o, a);
|
|
392
|
+
return [o + 1, r];
|
|
393
|
+
}, [0, null]), Jt(e), oe(e), e), J = (e, t, s) => {
|
|
394
394
|
typeof t > "u" && (t = -e.relX - e.prelim, s = 0);
|
|
395
395
|
const n = t + e.relX;
|
|
396
|
-
return e.relX = n + e.prelim - s, e.prelim = 0, e.x = s + e.relX, (e.children || []).forEach((
|
|
397
|
-
},
|
|
396
|
+
return e.relX = n + e.prelim - s, e.prelim = 0, e.x = s + e.relX, (e.children || []).forEach((o) => J(o, n, e.x)), e;
|
|
397
|
+
}, Jt = (e) => {
|
|
398
398
|
(e.children || []).reduce((t, s) => {
|
|
399
|
-
const [n,
|
|
400
|
-
return s.relX +=
|
|
399
|
+
const [n, o] = t, a = n + s.shift, l = o + a + s.change;
|
|
400
|
+
return s.relX += l, [a, l];
|
|
401
401
|
}, [0, 0]);
|
|
402
|
-
},
|
|
403
|
-
const n = e.children[t - 1],
|
|
404
|
-
let a = n,
|
|
402
|
+
}, Qt = (e, t, s) => {
|
|
403
|
+
const n = e.children[t - 1], o = e.children[t];
|
|
404
|
+
let a = n, l = n.relX, r = o, c = o.relX, p = !0;
|
|
405
405
|
for (; a && r; ) {
|
|
406
406
|
a.bottom > s.lowY && (s = s.next);
|
|
407
|
-
const h =
|
|
408
|
-
(h > 0 || h < 0 &&
|
|
409
|
-
const
|
|
410
|
-
|
|
407
|
+
const h = l + a.prelim - (c + r.prelim) + a.xSize / 2 + r.xSize / 2 + a.spacing(r);
|
|
408
|
+
(h > 0 || h < 0 && p) && (c += h, te(o, h), ee(e, t, s.index, h)), p = !1;
|
|
409
|
+
const u = a.bottom, m = r.bottom;
|
|
410
|
+
u <= m && (a = ne(a), a && (l += a.relX)), u >= m && (r = re(r), r && (c += r.relX));
|
|
411
411
|
}
|
|
412
|
-
!a && r ?
|
|
413
|
-
},
|
|
412
|
+
!a && r ? se(e, t, r, c) : a && !r && ie(e, t, a, l);
|
|
413
|
+
}, te = (e, t) => {
|
|
414
414
|
e.relX += t, e.lExtRelX += t, e.rExtRelX += t;
|
|
415
|
-
},
|
|
416
|
-
const
|
|
415
|
+
}, ee = (e, t, s, n) => {
|
|
416
|
+
const o = e.children[t], a = t - s;
|
|
417
417
|
if (a > 1) {
|
|
418
|
-
const
|
|
419
|
-
e.children[s + 1].shift +=
|
|
418
|
+
const l = n / a;
|
|
419
|
+
e.children[s + 1].shift += l, o.shift -= l, o.change -= n - l;
|
|
420
420
|
}
|
|
421
|
-
},
|
|
422
|
-
const
|
|
421
|
+
}, re = (e) => e.hasChildren ? e.firstChild : e.lThr, ne = (e) => e.hasChildren ? e.lastChild : e.rThr, se = (e, t, s, n) => {
|
|
422
|
+
const o = e.firstChild, a = o.lExt, l = e.children[t];
|
|
423
423
|
a.lThr = s;
|
|
424
|
-
const r = n - s.relX -
|
|
425
|
-
a.relX += r, a.prelim -= r,
|
|
426
|
-
},
|
|
427
|
-
const
|
|
424
|
+
const r = n - s.relX - o.lExtRelX;
|
|
425
|
+
a.relX += r, a.prelim -= r, o.lExt = l.lExt, o.lExtRelX = l.lExtRelX;
|
|
426
|
+
}, ie = (e, t, s, n) => {
|
|
427
|
+
const o = e.children[t], a = o.rExt, l = e.children[t - 1];
|
|
428
428
|
a.rThr = s;
|
|
429
|
-
const r = n - s.relX -
|
|
430
|
-
a.relX += r, a.prelim -= r,
|
|
431
|
-
},
|
|
429
|
+
const r = n - s.relX - o.rExtRelX;
|
|
430
|
+
a.relX += r, a.prelim -= r, o.rExt = l.rExt, o.rExtRelX = l.rExtRelX;
|
|
431
|
+
}, oe = (e) => {
|
|
432
432
|
if (e.hasChildren) {
|
|
433
433
|
const t = e.firstChild, s = e.lastChild, n = (t.prelim + t.relX - t.xSize / 2 + s.relX + s.prelim + s.xSize / 2) / 2;
|
|
434
434
|
Object.assign(e, {
|
|
@@ -439,7 +439,7 @@ const U = (e, t = 0) => (e.y = t, (e.children || []).reduce((s, n) => {
|
|
|
439
439
|
rExtRelX: s.rExtRelX
|
|
440
440
|
});
|
|
441
441
|
}
|
|
442
|
-
},
|
|
442
|
+
}, ae = (e, t, s) => {
|
|
443
443
|
for (; s !== null && e >= s.lowY; )
|
|
444
444
|
s = s.next;
|
|
445
445
|
return {
|
|
@@ -447,65 +447,66 @@ const U = (e, t = 0) => (e.y = t, (e.children || []).reduce((s, n) => {
|
|
|
447
447
|
index: t,
|
|
448
448
|
next: s
|
|
449
449
|
};
|
|
450
|
-
},
|
|
451
|
-
function
|
|
450
|
+
}, Q = ".markmap{--markmap-max-width: 9999px;--markmap-a-color: #0097e6;--markmap-a-hover-color: #00a8ff;--markmap-code-bg: #f0f0f0;--markmap-code-color: #555;--markmap-highlight-bg: #ffeaa7;--markmap-table-border: 1px solid currentColor;--markmap-font: 300 16px/20px sans-serif;--markmap-circle-open-bg: #fff;--markmap-text-color: #333;font:var(--markmap-font);color:var(--markmap-text-color)}.markmap-link{fill:none}.markmap-node>circle{cursor:pointer}.markmap-foreign{display:inline-block}.markmap-foreign p{margin:0}.markmap-foreign a{color:var(--markmap-a-color)}.markmap-foreign a:hover{color:var(--markmap-a-hover-color)}.markmap-foreign code{padding:.25em;font-size:calc(1em - 2px);color:var(--markmap-code-color);background-color:var(--markmap-code-bg);border-radius:2px}.markmap-foreign pre{margin:0}.markmap-foreign pre>code{display:block}.markmap-foreign del{text-decoration:line-through}.markmap-foreign em{font-style:italic}.markmap-foreign strong{font-weight:700}.markmap-foreign mark{background:var(--markmap-highlight-bg)}.markmap-foreign table,.markmap-foreign th,.markmap-foreign td{border-collapse:collapse;border:var(--markmap-table-border)}.markmap-foreign img{display:inline-block}.markmap-foreign svg{fill:currentColor}.markmap-foreign>div{width:var(--markmap-max-width);text-align:left}.markmap-foreign>div>div{display:inline-block}.markmap-dark .markmap{--markmap-code-bg: #1a1b26;--markmap-code-color: #ddd;--markmap-circle-open-bg: #444;--markmap-text-color: #eee}", me = Q, j = pt();
|
|
451
|
+
function I(e) {
|
|
452
452
|
return Math.max(4 - 2 * e.state.depth, 1.5);
|
|
453
453
|
}
|
|
454
|
-
function
|
|
455
|
-
const s =
|
|
454
|
+
function K(e, t) {
|
|
455
|
+
const s = ft(e, t);
|
|
456
456
|
return e[s];
|
|
457
457
|
}
|
|
458
|
-
function
|
|
458
|
+
function O(e) {
|
|
459
459
|
e.stopPropagation();
|
|
460
460
|
}
|
|
461
|
-
const
|
|
462
|
-
class
|
|
461
|
+
const le = new at();
|
|
462
|
+
class tt {
|
|
463
463
|
constructor(t, s) {
|
|
464
|
-
this.options =
|
|
465
|
-
const { transform:
|
|
466
|
-
this.g.attr("transform",
|
|
464
|
+
this.options = U, this.revokers = [], this.handleZoom = (n) => {
|
|
465
|
+
const { transform: o } = n;
|
|
466
|
+
this.g.attr("transform", o);
|
|
467
467
|
}, this.handlePan = (n) => {
|
|
468
468
|
n.preventDefault();
|
|
469
|
-
const
|
|
470
|
-
-n.deltaX /
|
|
471
|
-
-n.deltaY /
|
|
469
|
+
const o = S(this.svg.node()), a = o.translate(
|
|
470
|
+
-n.deltaX / o.k,
|
|
471
|
+
-n.deltaY / o.k
|
|
472
472
|
);
|
|
473
473
|
this.svg.call(this.zoom.transform, a);
|
|
474
|
-
}, this.handleClick = (n,
|
|
474
|
+
}, this.handleClick = (n, o) => {
|
|
475
475
|
let a = this.options.toggleRecursively;
|
|
476
|
-
(
|
|
477
|
-
}, this.ensureView = this.ensureVisible, this.svg = t.datum ? t :
|
|
478
|
-
id: this.options.id || this.svg.attr("id") ||
|
|
476
|
+
(V ? n.metaKey : n.ctrlKey) && (a = !a), this.toggleNode(o, a);
|
|
477
|
+
}, this.ensureView = this.ensureVisible, this.svg = t.datum ? t : ut(t), this.styleNode = this.svg.append("style"), this.zoom = mt().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(s), this.state = {
|
|
478
|
+
id: this.options.id || this.svg.attr("id") || lt(),
|
|
479
479
|
rect: { x1: 0, y1: 0, x2: 0, y2: 0 }
|
|
480
480
|
}, this.g = this.svg.append("g"), this.observer = new ResizeObserver(
|
|
481
|
-
|
|
481
|
+
ct(() => {
|
|
482
482
|
this.renderData();
|
|
483
483
|
}, 100)
|
|
484
484
|
), this.revokers.push(
|
|
485
|
-
|
|
485
|
+
le.tap(() => {
|
|
486
486
|
this.setData();
|
|
487
|
-
})
|
|
487
|
+
}),
|
|
488
|
+
() => this.observer.disconnect()
|
|
488
489
|
);
|
|
489
490
|
}
|
|
490
491
|
getStyleContent() {
|
|
491
492
|
const { style: t } = this.options, { id: s } = this.state, n = typeof t == "function" ? t(s) : "";
|
|
492
|
-
return [this.options.embedGlobalCSS &&
|
|
493
|
+
return [this.options.embedGlobalCSS && Q, n].filter(Boolean).join(`
|
|
493
494
|
`);
|
|
494
495
|
}
|
|
495
496
|
updateStyle() {
|
|
496
497
|
this.svg.attr(
|
|
497
498
|
"class",
|
|
498
|
-
|
|
499
|
+
ht(this.svg.attr("class"), "markmap", this.state.id)
|
|
499
500
|
);
|
|
500
501
|
const t = this.getStyleContent();
|
|
501
502
|
this.styleNode.text(t);
|
|
502
503
|
}
|
|
503
504
|
async toggleNode(t, s = !1) {
|
|
504
|
-
var
|
|
505
|
-
const n = (
|
|
506
|
-
s ?
|
|
507
|
-
|
|
508
|
-
...
|
|
505
|
+
var o, a;
|
|
506
|
+
const n = (o = t.payload) != null && o.fold ? 0 : 1;
|
|
507
|
+
s ? C(t, (l, r) => {
|
|
508
|
+
l.payload = {
|
|
509
|
+
...l.payload,
|
|
509
510
|
fold: n
|
|
510
511
|
}, r();
|
|
511
512
|
}) : t.payload = {
|
|
@@ -515,13 +516,13 @@ class q {
|
|
|
515
516
|
}
|
|
516
517
|
_initializeData(t) {
|
|
517
518
|
let s = 0;
|
|
518
|
-
const { color: n, initialExpandLevel:
|
|
519
|
-
let a = 0,
|
|
520
|
-
|
|
521
|
-
var
|
|
522
|
-
|
|
519
|
+
const { color: n, initialExpandLevel: o } = this.options;
|
|
520
|
+
let a = 0, l = 0;
|
|
521
|
+
C(t, (r, c, p) => {
|
|
522
|
+
var u, m, g, y;
|
|
523
|
+
l += 1, r.children = (u = r.children) == null ? void 0 : u.map((x) => ({ ...x })), s += 1, r.state = {
|
|
523
524
|
...r.state,
|
|
524
|
-
depth:
|
|
525
|
+
depth: l,
|
|
525
526
|
id: s,
|
|
526
527
|
rect: {
|
|
527
528
|
x: 0,
|
|
@@ -530,46 +531,46 @@ class q {
|
|
|
530
531
|
height: 0
|
|
531
532
|
},
|
|
532
533
|
size: [0, 0]
|
|
533
|
-
}, r.state.key = [(
|
|
534
|
-
const h = ((
|
|
535
|
-
h ? a += 1 : (a ||
|
|
534
|
+
}, r.state.key = [(m = p == null ? void 0 : p.state) == null ? void 0 : m.id, r.state.id].filter(Boolean).join(".") + yt(r.content), r.state.path = [(g = p == null ? void 0 : p.state) == null ? void 0 : g.path, r.state.id].filter(Boolean).join("."), n(r);
|
|
535
|
+
const h = ((y = r.payload) == null ? void 0 : y.fold) === 2;
|
|
536
|
+
h ? a += 1 : (a || o >= 0 && r.state.depth >= o) && (r.payload = { ...r.payload, fold: 1 }), c(), h && (a -= 1), l -= 1;
|
|
536
537
|
});
|
|
537
538
|
}
|
|
538
539
|
_relayout() {
|
|
539
540
|
if (!this.state.data) return;
|
|
540
|
-
this.g.selectAll(
|
|
541
|
-
|
|
541
|
+
this.g.selectAll(v("g")).selectAll(
|
|
542
|
+
v("foreignObject")
|
|
542
543
|
).each(function(r) {
|
|
543
544
|
var h;
|
|
544
|
-
const
|
|
545
|
-
r.state.size =
|
|
545
|
+
const c = (h = this.firstChild) == null ? void 0 : h.firstChild, p = [c.scrollWidth, c.scrollHeight];
|
|
546
|
+
r.state.size = p;
|
|
546
547
|
});
|
|
547
|
-
const { spacingHorizontal: t, paddingX: s, spacingVertical: n } = this.options,
|
|
548
|
-
var
|
|
549
|
-
if (!((
|
|
548
|
+
const { spacingHorizontal: t, paddingX: s, spacingVertical: n } = this.options, o = Z({}).children((r) => {
|
|
549
|
+
var c;
|
|
550
|
+
if (!((c = r.payload) != null && c.fold)) return r.children;
|
|
550
551
|
}).nodeSize((r) => {
|
|
551
|
-
const [
|
|
552
|
-
return [
|
|
553
|
-
}).spacing((r,
|
|
554
|
-
|
|
555
|
-
const
|
|
556
|
-
|
|
557
|
-
const
|
|
558
|
-
|
|
552
|
+
const [c, p] = r.data.state.size;
|
|
553
|
+
return [p, c + (c ? s * 2 : 0) + t];
|
|
554
|
+
}).spacing((r, c) => r.parent === c.parent ? n : n * 2), a = o.hierarchy(this.state.data);
|
|
555
|
+
o(a);
|
|
556
|
+
const l = a.descendants();
|
|
557
|
+
l.forEach((r) => {
|
|
558
|
+
const c = r.data;
|
|
559
|
+
c.state.rect = {
|
|
559
560
|
x: r.y,
|
|
560
561
|
y: r.x - r.xSize / 2,
|
|
561
562
|
width: r.ySize - t,
|
|
562
563
|
height: r.xSize
|
|
563
564
|
};
|
|
564
565
|
}), this.state.rect = {
|
|
565
|
-
x1:
|
|
566
|
-
y1:
|
|
567
|
-
x2:
|
|
568
|
-
|
|
566
|
+
x1: P(l, (r) => r.data.state.rect.x) || 0,
|
|
567
|
+
y1: P(l, (r) => r.data.state.rect.y) || 0,
|
|
568
|
+
x2: W(
|
|
569
|
+
l,
|
|
569
570
|
(r) => r.data.state.rect.x + r.data.state.rect.width
|
|
570
571
|
) || 0,
|
|
571
|
-
y2:
|
|
572
|
-
|
|
572
|
+
y2: W(
|
|
573
|
+
l,
|
|
573
574
|
(r) => r.data.state.rect.y + r.data.state.rect.height
|
|
574
575
|
) || 0
|
|
575
576
|
};
|
|
@@ -584,96 +585,110 @@ class q {
|
|
|
584
585
|
s && this.setOptions(s), t && (this.state.data = t), this.state.data && (this._initializeData(this.state.data), this.updateStyle(), await this.renderData());
|
|
585
586
|
}
|
|
586
587
|
async renderData(t) {
|
|
587
|
-
const { paddingX: s, autoFit: n, color:
|
|
588
|
-
if (!
|
|
589
|
-
const c = [];
|
|
590
|
-
|
|
591
|
-
var
|
|
592
|
-
(
|
|
588
|
+
const { paddingX: s, autoFit: n, color: o, maxWidth: a } = this.options, l = this.state.data;
|
|
589
|
+
if (!l) return;
|
|
590
|
+
const r = {}, c = {}, p = [];
|
|
591
|
+
C(l, (i, d, f) => {
|
|
592
|
+
var E;
|
|
593
|
+
(E = i.payload) != null && E.fold || d(), r[i.state.id] = i, f && (c[i.state.id] = f.state.id), p.push(i);
|
|
593
594
|
});
|
|
594
|
-
const
|
|
595
|
+
const h = {}, u = {}, m = (i) => {
|
|
596
|
+
!i || h[i.state.id] || C(i, (d, f) => {
|
|
597
|
+
h[d.state.id] = i.state.id, f();
|
|
598
|
+
});
|
|
599
|
+
}, g = (i) => u[h[i.state.id]] || l.state.rect, y = (i) => (r[h[i.state.id]] || l).state.rect;
|
|
600
|
+
u[l.state.id] = l.state.rect, t && m(t);
|
|
601
|
+
const x = this.g.selectAll(v("g")).each((i) => {
|
|
602
|
+
u[i.state.id] = i.state.rect;
|
|
603
|
+
}).data(p, (i) => i.state.key), b = x.enter().append("g").attr("data-depth", (i) => i.state.depth).attr("data-path", (i) => i.state.path).each((i) => {
|
|
604
|
+
m(r[c[i.state.id]]);
|
|
605
|
+
}), k = x.exit().each((i) => {
|
|
606
|
+
m(r[c[i.state.id]]);
|
|
607
|
+
}), z = x.merge(b).attr(
|
|
595
608
|
"class",
|
|
596
|
-
(
|
|
597
|
-
var
|
|
598
|
-
return ["markmap-node", ((
|
|
599
|
-
}
|
|
600
|
-
),
|
|
601
|
-
(
|
|
602
|
-
(
|
|
603
|
-
),
|
|
604
|
-
(
|
|
605
|
-
var
|
|
606
|
-
return (
|
|
609
|
+
(i) => {
|
|
610
|
+
var d;
|
|
611
|
+
return ["markmap-node", ((d = i.payload) == null ? void 0 : d.fold) && "markmap-fold"].filter(Boolean).join(" ");
|
|
612
|
+
}
|
|
613
|
+
), A = z.selectAll(v("line")).data(
|
|
614
|
+
(i) => [i],
|
|
615
|
+
(i) => i.state.key
|
|
616
|
+
), $ = A.enter().append("line").attr("stroke", (i) => o(i)).attr("stroke-width", 0), F = A.merge($), T = z.selectAll(v("circle")).data(
|
|
617
|
+
(i) => {
|
|
618
|
+
var d;
|
|
619
|
+
return (d = i.children) != null && d.length ? [i] : [];
|
|
607
620
|
},
|
|
608
|
-
(
|
|
609
|
-
),
|
|
621
|
+
(i) => i.state.key
|
|
622
|
+
), D = T.enter().append("circle").attr("stroke-width", 0).attr("r", 0).on("click", (i, d) => this.handleClick(i, d)).on("mousedown", O).merge(T).attr("stroke", (i) => o(i)).attr(
|
|
610
623
|
"fill",
|
|
611
|
-
(
|
|
612
|
-
var
|
|
613
|
-
return (
|
|
614
|
-
}
|
|
615
|
-
),
|
|
616
|
-
(
|
|
617
|
-
(
|
|
618
|
-
), X =
|
|
619
|
-
X.append("xhtml:div").append("xhtml:div").html((
|
|
620
|
-
var
|
|
621
|
-
const
|
|
622
|
-
|
|
624
|
+
(i) => {
|
|
625
|
+
var d;
|
|
626
|
+
return (d = i.payload) != null && d.fold && i.children ? o(i) : "var(--markmap-circle-open-bg)";
|
|
627
|
+
}
|
|
628
|
+
), _ = this.observer, H = z.selectAll(v("foreignObject")).data(
|
|
629
|
+
(i) => [i],
|
|
630
|
+
(i) => i.state.key
|
|
631
|
+
), X = H.enter().append("foreignObject").attr("class", "markmap-foreign").attr("x", s).attr("y", 0).style("opacity", 0).on("mousedown", O).on("dblclick", O);
|
|
632
|
+
X.append("xhtml:div").append("xhtml:div").html((i) => i.content).attr("xmlns", "http://www.w3.org/1999/xhtml"), X.each(function() {
|
|
633
|
+
var d;
|
|
634
|
+
const i = (d = this.firstChild) == null ? void 0 : d.firstChild;
|
|
635
|
+
_.observe(i);
|
|
623
636
|
});
|
|
624
|
-
const
|
|
625
|
-
|
|
637
|
+
const N = k.selectAll(
|
|
638
|
+
v("foreignObject")
|
|
626
639
|
);
|
|
627
|
-
|
|
628
|
-
var
|
|
629
|
-
const
|
|
630
|
-
|
|
640
|
+
N.each(function() {
|
|
641
|
+
var d;
|
|
642
|
+
const i = (d = this.firstChild) == null ? void 0 : d.firstChild;
|
|
643
|
+
_.unobserve(i);
|
|
631
644
|
});
|
|
632
|
-
const
|
|
633
|
-
(
|
|
634
|
-
var
|
|
635
|
-
return (
|
|
636
|
-
}
|
|
637
|
-
),
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
645
|
+
const L = X.merge(H), et = p.flatMap(
|
|
646
|
+
(i) => {
|
|
647
|
+
var d;
|
|
648
|
+
return (d = i.payload) != null && d.fold ? [] : i.children.map((f) => ({ source: i, target: f }));
|
|
649
|
+
}
|
|
650
|
+
), M = this.g.selectAll(v("path")).data(et, (i) => i.target.state.key), rt = M.exit(), nt = M.enter().insert("path", "g").attr("class", "markmap-link").attr("data-depth", (i) => i.target.state.depth).attr("data-path", (i) => i.target.state.path).attr("d", (i) => {
|
|
651
|
+
const d = g(i.target), f = [
|
|
652
|
+
d.x + d.width,
|
|
653
|
+
d.y + d.height
|
|
654
|
+
];
|
|
655
|
+
return j({ source: f, target: f });
|
|
656
|
+
}).attr("stroke-width", 0).merge(M);
|
|
641
657
|
this.svg.style(
|
|
642
658
|
"--markmap-max-width",
|
|
643
659
|
a ? `${a}px` : null
|
|
644
|
-
), await new Promise(requestAnimationFrame), this._relayout()
|
|
645
|
-
|
|
646
|
-
|
|
660
|
+
), await new Promise(requestAnimationFrame), this._relayout(), b.attr("transform", (i) => {
|
|
661
|
+
const d = g(i);
|
|
662
|
+
return `translate(${d.x + d.width - i.state.rect.width},${d.y + d.height - i.state.rect.height})`;
|
|
663
|
+
}), this.transition(k).attr("transform", (i) => {
|
|
664
|
+
const d = y(i), f = d.x + d.width - i.state.rect.width, E = d.y + d.height - i.state.rect.height;
|
|
665
|
+
return `translate(${f},${E})`;
|
|
666
|
+
}).remove(), this.transition(z).attr(
|
|
647
667
|
"transform",
|
|
648
|
-
(
|
|
649
|
-
), this.transition(p).attr("transform", (o) => {
|
|
650
|
-
const m = z.x + z.width - o.state.rect.width, v = z.y + z.height - o.state.rect.height;
|
|
651
|
-
return `translate(${m},${v})`;
|
|
652
|
-
}).remove(), this.transition(u).attr(
|
|
653
|
-
"transform",
|
|
654
|
-
(o) => `translate(${o.state.rect.x},${o.state.rect.y})`
|
|
668
|
+
(i) => `translate(${i.state.rect.x},${i.state.rect.y})`
|
|
655
669
|
);
|
|
656
|
-
const
|
|
657
|
-
|
|
670
|
+
const st = k.selectAll(
|
|
671
|
+
v("line")
|
|
658
672
|
);
|
|
659
|
-
this.transition(
|
|
660
|
-
const
|
|
661
|
-
|
|
673
|
+
this.transition(st).attr("x1", (i) => i.state.rect.width).attr("stroke-width", 0), $.attr("x1", (i) => i.state.rect.width).attr("x2", (i) => i.state.rect.width), F.attr("y1", (i) => i.state.rect.height).attr("y2", (i) => i.state.rect.height), this.transition(F).attr("x1", -1).attr("x2", (i) => i.state.rect.width + 2).attr("stroke", (i) => o(i)).attr("stroke-width", I);
|
|
674
|
+
const it = k.selectAll(
|
|
675
|
+
v("circle")
|
|
662
676
|
);
|
|
663
|
-
this.transition(
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
677
|
+
this.transition(it).attr("r", 0).attr("stroke-width", 0), D.attr("cx", (i) => i.state.rect.width).attr("cy", (i) => i.state.rect.height), this.transition(D).attr("r", 6).attr("stroke-width", "1.5"), this.transition(N).style("opacity", 0), L.attr("width", (i) => Math.max(0, i.state.rect.width - s * 2)).attr("height", (i) => i.state.rect.height), this.transition(L).style("opacity", 1), this.transition(rt).attr("d", (i) => {
|
|
678
|
+
const d = y(i.target), f = [
|
|
679
|
+
d.x + d.width,
|
|
680
|
+
d.y + d.height
|
|
681
|
+
];
|
|
682
|
+
return j({ source: f, target: f });
|
|
683
|
+
}).attr("stroke-width", 0).remove(), this.transition(nt).attr("stroke", (i) => o(i.target)).attr("stroke-width", (i) => I(i.target)).attr("d", (i) => {
|
|
684
|
+
const d = i.source, f = i.target, E = [
|
|
685
|
+
d.state.rect.x + d.state.rect.width,
|
|
686
|
+
d.state.rect.y + d.state.rect.height
|
|
687
|
+
], ot = [
|
|
688
|
+
f.state.rect.x,
|
|
689
|
+
f.state.rect.y + f.state.rect.height
|
|
675
690
|
];
|
|
676
|
-
return
|
|
691
|
+
return j({ source: E, target: ot });
|
|
677
692
|
}), n && this.fit();
|
|
678
693
|
}
|
|
679
694
|
transition(t) {
|
|
@@ -684,21 +699,21 @@ class q {
|
|
|
684
699
|
* Fit the content to the viewport.
|
|
685
700
|
*/
|
|
686
701
|
async fit(t = this.options.maxInitialScale) {
|
|
687
|
-
const s = this.svg.node(), { width: n, height:
|
|
702
|
+
const s = this.svg.node(), { width: n, height: o } = s.getBoundingClientRect(), { fitRatio: a } = this.options, { x1: l, y1: r, x2: c, y2: p } = this.state.rect, h = c - l, u = p - r, m = Math.min(
|
|
688
703
|
n / h * a,
|
|
689
|
-
|
|
704
|
+
o / u * a,
|
|
690
705
|
t
|
|
691
|
-
), g =
|
|
692
|
-
(n - h *
|
|
693
|
-
(
|
|
694
|
-
).scale(
|
|
695
|
-
return this.transition(this.svg).call(this.zoom.transform, g).end().catch(
|
|
706
|
+
), g = gt.translate(
|
|
707
|
+
(n - h * m) / 2 - l * m,
|
|
708
|
+
(o - u * m) / 2 - r * m
|
|
709
|
+
).scale(m);
|
|
710
|
+
return this.transition(this.svg).call(this.zoom.transform, g).end().catch(w);
|
|
696
711
|
}
|
|
697
712
|
findElement(t) {
|
|
698
713
|
let s;
|
|
699
|
-
return this.g.selectAll(
|
|
700
|
-
|
|
701
|
-
data:
|
|
714
|
+
return this.g.selectAll(v("g")).each(function(o) {
|
|
715
|
+
o === t && (s = {
|
|
716
|
+
data: o,
|
|
702
717
|
g: this
|
|
703
718
|
});
|
|
704
719
|
}), s;
|
|
@@ -707,52 +722,52 @@ class q {
|
|
|
707
722
|
* Pan the content to make the provided node visible in the viewport.
|
|
708
723
|
*/
|
|
709
724
|
async ensureVisible(t, s) {
|
|
710
|
-
var
|
|
711
|
-
const n = (
|
|
725
|
+
var b;
|
|
726
|
+
const n = (b = this.findElement(t)) == null ? void 0 : b.data;
|
|
712
727
|
if (!n) return;
|
|
713
|
-
const
|
|
728
|
+
const o = this.svg.node(), a = o.getBoundingClientRect(), l = S(o), [r, c] = [
|
|
714
729
|
n.state.rect.x,
|
|
715
730
|
n.state.rect.x + n.state.rect.width + 2
|
|
716
|
-
].map((
|
|
731
|
+
].map((k) => k * l.k + l.x), [p, h] = [
|
|
717
732
|
n.state.rect.y,
|
|
718
733
|
n.state.rect.y + n.state.rect.height
|
|
719
|
-
].map((
|
|
734
|
+
].map((k) => k * l.k + l.y), u = {
|
|
720
735
|
left: 0,
|
|
721
736
|
right: 0,
|
|
722
737
|
top: 0,
|
|
723
738
|
bottom: 0,
|
|
724
739
|
...s
|
|
725
|
-
},
|
|
726
|
-
if (
|
|
727
|
-
const
|
|
728
|
-
return this.transition(this.svg).call(this.zoom.transform,
|
|
740
|
+
}, m = [u.left - r, a.width - u.right - c], g = [u.top - p, a.height - u.bottom - h], y = m[0] * m[1] > 0 ? K(m, Math.abs) / l.k : 0, x = g[0] * g[1] > 0 ? K(g, Math.abs) / l.k : 0;
|
|
741
|
+
if (y || x) {
|
|
742
|
+
const k = l.translate(y, x);
|
|
743
|
+
return this.transition(this.svg).call(this.zoom.transform, k).end().catch(w);
|
|
729
744
|
}
|
|
730
745
|
}
|
|
731
746
|
async centerNode(t, s) {
|
|
732
|
-
var
|
|
733
|
-
const n = (
|
|
747
|
+
var y;
|
|
748
|
+
const n = (y = this.findElement(t)) == null ? void 0 : y.data;
|
|
734
749
|
if (!n) return;
|
|
735
|
-
const
|
|
750
|
+
const o = this.svg.node(), a = o.getBoundingClientRect(), l = S(o), r = (n.state.rect.x + n.state.rect.width / 2) * l.k + l.x, c = (n.state.rect.y + n.state.rect.height / 2) * l.k + l.y, p = {
|
|
736
751
|
left: 0,
|
|
737
752
|
right: 0,
|
|
738
753
|
top: 0,
|
|
739
754
|
bottom: 0,
|
|
740
755
|
...s
|
|
741
|
-
}, h = (
|
|
742
|
-
if (
|
|
743
|
-
const x =
|
|
744
|
-
return this.transition(this.svg).call(this.zoom.transform, x).end().catch(
|
|
756
|
+
}, h = (p.left + a.width - p.right) / 2, u = (p.top + a.height - p.bottom) / 2, m = (h - r) / l.k, g = (u - c) / l.k;
|
|
757
|
+
if (m || g) {
|
|
758
|
+
const x = l.translate(m, g);
|
|
759
|
+
return this.transition(this.svg).call(this.zoom.transform, x).end().catch(w);
|
|
745
760
|
}
|
|
746
761
|
}
|
|
747
762
|
/**
|
|
748
763
|
* Scale content with it pinned at the center of the viewport.
|
|
749
764
|
*/
|
|
750
765
|
async rescale(t) {
|
|
751
|
-
const s = this.svg.node(), { width: n, height:
|
|
766
|
+
const s = this.svg.node(), { width: n, height: o } = s.getBoundingClientRect(), a = n / 2, l = o / 2, r = S(s), c = r.translate(
|
|
752
767
|
(a - r.x) * (1 - t) / r.k,
|
|
753
|
-
(
|
|
768
|
+
(l - r.y) * (1 - t) / r.k
|
|
754
769
|
).scale(t);
|
|
755
|
-
return this.transition(this.svg).call(this.zoom.transform,
|
|
770
|
+
return this.transition(this.svg).call(this.zoom.transform, c).end().catch(w);
|
|
756
771
|
}
|
|
757
772
|
destroy() {
|
|
758
773
|
this.svg.on(".zoom", null), this.svg.html(null), this.revokers.forEach((t) => {
|
|
@@ -760,21 +775,21 @@ class q {
|
|
|
760
775
|
});
|
|
761
776
|
}
|
|
762
777
|
static create(t, s, n = null) {
|
|
763
|
-
const
|
|
764
|
-
return n &&
|
|
765
|
-
|
|
766
|
-
}),
|
|
778
|
+
const o = new tt(t, s);
|
|
779
|
+
return n && o.setData(n).then(() => {
|
|
780
|
+
o.fit();
|
|
781
|
+
}), o;
|
|
767
782
|
}
|
|
768
783
|
}
|
|
769
784
|
export {
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
785
|
+
tt as Markmap,
|
|
786
|
+
xt as defaultColorFn,
|
|
787
|
+
U as defaultOptions,
|
|
788
|
+
ue as deriveOptions,
|
|
789
|
+
me as globalCSS,
|
|
790
|
+
V as isMacintosh,
|
|
791
|
+
xe as loadCSS,
|
|
792
|
+
ye as loadJS,
|
|
793
|
+
le as refreshHook,
|
|
794
|
+
yt as simpleHash
|
|
780
795
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export interface IMarkmapState {
|
|
|
9
9
|
y2: number;
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
export
|
|
12
|
+
export interface IMarkmapJSONOptions {
|
|
13
13
|
color: string[];
|
|
14
14
|
colorFreezeLevel: number;
|
|
15
15
|
duration: number;
|
|
@@ -25,8 +25,7 @@ export type IMarkmapJSONOptions = Partial<{
|
|
|
25
25
|
spacingHorizontal: number;
|
|
26
26
|
spacingVertical: number;
|
|
27
27
|
zoom: boolean;
|
|
28
|
-
|
|
29
|
-
}>;
|
|
28
|
+
}
|
|
30
29
|
export interface IPadding {
|
|
31
30
|
left: number;
|
|
32
31
|
right: number;
|
package/dist/util.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IMarkmapOptions } from 'markmap-common';
|
|
2
2
|
import { IMarkmapJSONOptions } from './types';
|
|
3
|
-
export declare function deriveOptions(jsonOptions?: IMarkmapJSONOptions): Partial<IMarkmapOptions>;
|
|
3
|
+
export declare function deriveOptions(jsonOptions?: Partial<IMarkmapJSONOptions>): Partial<IMarkmapOptions>;
|
|
4
4
|
/**
|
|
5
5
|
* Credit: https://gist.github.com/jlevy/c246006675becc446360a798e2b2d781?permalink_comment_id=4738050#gistcomment-4738050
|
|
6
6
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markmap-view",
|
|
3
|
-
"version": "0.18.3",
|
|
3
|
+
"version": "0.18.4-alpha.3+be73b69",
|
|
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": "be73b698cdf408b0a16aea2fe860fe92d8c458bc"
|
|
55
55
|
}
|