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