markmap-view 0.16.3-web.2 → 0.17.1-alpha.4

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.
@@ -363,6 +363,7 @@
363
363
  duration: 500,
364
364
  embedGlobalCSS: true,
365
365
  fitRatio: 0.95,
366
+ maxInitialScale: 2,
366
367
  maxWidth: 0,
367
368
  nodeMinHeight: 16,
368
369
  paddingX: 8,
@@ -398,7 +399,13 @@
398
399
  return color2(node);
399
400
  };
400
401
  }
401
- const numberKeys = ["duration", "maxWidth", "initialExpandLevel"];
402
+ const numberKeys = [
403
+ "duration",
404
+ "maxWidth",
405
+ "initialExpandLevel",
406
+ "fitRatio",
407
+ "maxInitialScale"
408
+ ];
402
409
  numberKeys.forEach((key) => {
403
410
  const value = options[key];
404
411
  if (typeof value === "number")
@@ -1154,7 +1161,7 @@
1154
1161
  };
1155
1162
  };
1156
1163
  const containerCSS = "/* used for pre-rendering to get the size of each node */\n.markmap-container {\n position: absolute;\n width: 0;\n height: 0;\n top: -100px;\n left: -100px;\n overflow: hidden;\n}\n.markmap-container > .markmap-foreign {\n display: inline-block;\n }\n/* first-child for line wrapping, last-child for max-width detection */\n.markmap-container > .markmap-foreign > div:last-child,\n \n .markmap-container > .markmap-foreign > div:last-child :not(pre) {\n white-space: nowrap;\n }\n.markmap-container > .markmap-foreign > div:last-child code {\n white-space: inherit;\n }\n";
1157
- const css = ".markmap {\n --markmap-max-width: none;\n --markmap-a-color: #0097e6;\n --markmap-a-hover-color: #00a8ff;\n --markmap-code-bg: #f0f0f0;\n --markmap-code-color: #555;\n --markmap-highlight-bg: #ffeaa7;\n --markmap-table-border: 1px solid currentColor;\n --markmap-font: 300 16px/20px sans-serif;\n --markmap-circle-open-bg: #fff;\n --markmap-text-color: #333;\n\n font: var(--markmap-font);\n color: var(--markmap-text-color);\n}\n\n .markmap-link {\n fill: none;\n }\n\n .markmap-node > circle {\n cursor: pointer;\n }\n\n .markmap-foreign {\n display: inline-block;\n }\n\n .markmap-foreign p {\n margin: 0;\n }\n\n .markmap-foreign a {\n color: var(--markmap-a-color);\n }\n\n .markmap-foreign a:hover {\n color: var(--markmap-a-hover-color);\n }\n\n .markmap-foreign code {\n padding: 0.25em;\n font-size: calc(1em - 2px);\n color: var(--markmap-code-color);\n background-color: var(--markmap-code-bg);\n border-radius: 2px;\n }\n\n .markmap-foreign pre {\n margin: 0;\n }\n\n .markmap-foreign pre > code {\n display: block;\n }\n\n .markmap-foreign del {\n text-decoration: line-through;\n }\n\n .markmap-foreign em {\n font-style: italic;\n }\n\n .markmap-foreign strong {\n font-weight: bold;\n }\n\n .markmap-foreign mark {\n background: var(--markmap-highlight-bg);\n }\n\n .markmap-foreign table,\n .markmap-foreign th,\n .markmap-foreign td {\n border-collapse: collapse;\n border: var(--markmap-table-border);\n }\n\n .markmap-foreign img {\n display: inline-block;\n }\n\n .markmap-foreign svg {\n fill: currentColor;\n }\n\n .markmap-foreign-testing-max {\n max-width: var(--markmap-max-width);\n }\n\n .markmap-foreign-testing-max img {\n max-width: var(--markmap-max-width);\n max-height: none;\n }\n\n.markmap-dark .markmap {\n --markmap-circle-open-bg: #444;\n --markmap-text-color: #eee;\n}\n";
1164
+ const css = ".markmap {\n --markmap-max-width: none;\n --markmap-a-color: #0097e6;\n --markmap-a-hover-color: #00a8ff;\n --markmap-code-bg: #f0f0f0;\n --markmap-code-color: #555;\n --markmap-highlight-bg: #ffeaa7;\n --markmap-table-border: 1px solid currentColor;\n --markmap-font: 300 16px/20px sans-serif;\n --markmap-circle-open-bg: #fff;\n --markmap-text-color: #333;\n\n font: var(--markmap-font);\n color: var(--markmap-text-color);\n}\n\n .markmap-link {\n fill: none;\n }\n\n .markmap-node > circle {\n cursor: pointer;\n }\n\n .markmap-foreign {\n display: inline-block;\n }\n\n .markmap-foreign p {\n margin: 0;\n }\n\n .markmap-foreign a {\n color: var(--markmap-a-color);\n }\n\n .markmap-foreign a:hover {\n color: var(--markmap-a-hover-color);\n }\n\n .markmap-foreign code {\n padding: 0.25em;\n font-size: calc(1em - 2px);\n color: var(--markmap-code-color);\n background-color: var(--markmap-code-bg);\n border-radius: 2px;\n }\n\n .markmap-foreign pre {\n margin: 0;\n }\n\n .markmap-foreign pre > code {\n display: block;\n }\n\n .markmap-foreign del {\n text-decoration: line-through;\n }\n\n .markmap-foreign em {\n font-style: italic;\n }\n\n .markmap-foreign strong {\n font-weight: bold;\n }\n\n .markmap-foreign mark {\n background: var(--markmap-highlight-bg);\n }\n\n .markmap-foreign table,\n .markmap-foreign th,\n .markmap-foreign td {\n border-collapse: collapse;\n border: var(--markmap-table-border);\n }\n\n .markmap-foreign img {\n display: inline-block;\n }\n\n .markmap-foreign svg {\n fill: currentColor;\n }\n\n .markmap-foreign-testing-max {\n max-width: var(--markmap-max-width);\n }\n\n .markmap-foreign-testing-max img {\n max-width: var(--markmap-max-width);\n max-height: none;\n }\n\n.markmap-dark .markmap {\n --markmap-code-bg: #1a1b26;\n --markmap-code-color: #ddd;\n --markmap-circle-open-bg: #444;\n --markmap-text-color: #eee;\n}\n";
1158
1165
  const globalCSS = css;
1159
1166
  function linkWidth(nodeData) {
1160
1167
  const data = nodeData.data;
@@ -1531,7 +1538,7 @@
1531
1538
  /**
1532
1539
  * Fit the content to the viewport.
1533
1540
  */
1534
- async fit() {
1541
+ async fit(maxScale = this.options.maxInitialScale) {
1535
1542
  const svgNode = this.svg.node();
1536
1543
  const { width: offsetWidth, height: offsetHeight } = svgNode.getBoundingClientRect();
1537
1544
  const { fitRatio } = this.options;
@@ -1541,7 +1548,7 @@
1541
1548
  const scale = Math.min(
1542
1549
  offsetWidth / naturalWidth * fitRatio,
1543
1550
  offsetHeight / naturalHeight * fitRatio,
1544
- 2
1551
+ maxScale
1545
1552
  );
1546
1553
  const initialZoom = d32.zoomIdentity.translate(
1547
1554
  (offsetWidth - naturalWidth * scale) / 2 - minY * scale,
@@ -1625,7 +1632,9 @@
1625
1632
  const mm = new Markmap(svg, opts);
1626
1633
  if (data) {
1627
1634
  mm.setData(data);
1628
- mm.fit();
1635
+ requestAnimationFrame(() => {
1636
+ mm.fit();
1637
+ });
1629
1638
  }
1630
1639
  return mm;
1631
1640
  }
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Hook as st, getId as at, debounce as lt, addClass as ct, walkTree as T, childSelector as C, noop as M } from "markmap-common";
2
2
  import { loadCSS as Ce, loadJS as we } from "markmap-common";
3
- import { scaleOrdinal as V, schemeCategory10 as ht, zoomTransform as A, select as dt, zoom as ut, linkHorizontal as pt, min as H, max as L, zoomIdentity as mt, minIndex as ft } from "d3";
3
+ import { scaleOrdinal as V, schemeCategory10 as ht, zoomTransform as A, select as dt, zoom as ut, linkHorizontal as pt, min as I, max as H, zoomIdentity as mt, minIndex as ft } from "d3";
4
4
  const K = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), gt = V(ht), P = {
5
5
  autoFit: !1,
6
6
  color: (e) => {
@@ -10,6 +10,7 @@ const K = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), g
10
10
  duration: 500,
11
11
  embedGlobalCSS: !0,
12
12
  fitRatio: 0.95,
13
+ maxInitialScale: 2,
13
14
  maxWidth: 0,
14
15
  nodeMinHeight: 16,
15
16
  paddingX: 8,
@@ -22,12 +23,12 @@ const K = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), g
22
23
  toggleRecursively: !1
23
24
  };
24
25
  function Se(e) {
25
- const t = {}, n = { ...e }, { color: r, colorFreezeLevel: o } = n;
26
- if ((r == null ? void 0 : r.length) === 1) {
27
- const s = r[0];
26
+ const t = {}, n = { ...e }, { color: i, colorFreezeLevel: o } = n;
27
+ if ((i == null ? void 0 : i.length) === 1) {
28
+ const s = i[0];
28
29
  t.color = () => s;
29
- } else if (r != null && r.length) {
30
- const s = V(r);
30
+ } else if (i != null && i.length) {
31
+ const s = V(i);
31
32
  t.color = (l) => s(`${l.state.path}`);
32
33
  }
33
34
  if (o) {
@@ -40,7 +41,13 @@ function Se(e) {
40
41
  }
41
42
  }, s(l));
42
43
  }
43
- return ["duration", "maxWidth", "initialExpandLevel"].forEach((s) => {
44
+ return [
45
+ "duration",
46
+ "maxWidth",
47
+ "initialExpandLevel",
48
+ "fitRatio",
49
+ "maxInitialScale"
50
+ ].forEach((s) => {
44
51
  const l = n[s];
45
52
  typeof l == "number" && (t[s] = l);
46
53
  }), ["zoom", "pan"].forEach((s) => {
@@ -74,31 +81,31 @@ function bt(e) {
74
81
  const zt = {
75
82
  isSvg: !1
76
83
  };
77
- function I(e, t) {
84
+ function L(e, t) {
78
85
  Array.isArray(t) || (t = [t]), t = t.filter(Boolean), t.length && e.append(...t);
79
86
  }
80
87
  function Et(e, t, n) {
81
- for (const r in t)
82
- if (!(r === "key" || r === "children" || r === "ref"))
83
- if (r === "dangerouslySetInnerHTML")
84
- e.innerHTML = t[r].__html;
85
- else if (r === "innerHTML" || r === "textContent" || r === "innerText" || r === "value" && ["textarea", "select"].includes(e.tagName)) {
86
- const o = t[r];
87
- o != null && (e[r] = o);
88
+ for (const i in t)
89
+ if (!(i === "key" || i === "children" || i === "ref"))
90
+ if (i === "dangerouslySetInnerHTML")
91
+ e.innerHTML = t[i].__html;
92
+ else if (i === "innerHTML" || i === "textContent" || i === "innerText" || i === "value" && ["textarea", "select"].includes(e.tagName)) {
93
+ const o = t[i];
94
+ o != null && (e[i] = o);
88
95
  } else
89
- r.startsWith("on") ? e[r.toLowerCase()] = t[r] : wt(e, r, t[r], n.isSvg);
96
+ i.startsWith("on") ? e[i.toLowerCase()] = t[i] : wt(e, i, t[i], n.isSvg);
90
97
  }
91
98
  const Ct = {
92
99
  className: "class",
93
100
  labelFor: "for"
94
101
  };
95
- function wt(e, t, n, r) {
102
+ function wt(e, t, n, i) {
96
103
  if (t = Ct[t] || t, n === !0)
97
104
  e.setAttribute(t, "");
98
105
  else if (n === !1)
99
106
  e.removeAttribute(t);
100
107
  else {
101
- const o = r ? yt[t] : void 0;
108
+ const o = i ? yt[t] : void 0;
102
109
  o !== void 0 ? e.setAttributeNS(o, t, n) : e.setAttribute(t, n);
103
110
  }
104
111
  }
@@ -116,17 +123,17 @@ function B(e, t = zt) {
116
123
  if (St(e)) {
117
124
  const {
118
125
  type: n,
119
- props: r
126
+ props: i
120
127
  } = e;
121
128
  if (n === bt) {
122
129
  const a = document.createDocumentFragment();
123
- if (r.children) {
124
- const c = $(r.children, t);
125
- I(a, c);
130
+ if (i.children) {
131
+ const c = $(i.children, t);
132
+ L(a, c);
126
133
  }
127
134
  return a;
128
135
  }
129
- const o = n(r);
136
+ const o = n(i);
130
137
  return B(o, t);
131
138
  }
132
139
  if (kt(e))
@@ -134,18 +141,18 @@ function B(e, t = zt) {
134
141
  if (vt(e)) {
135
142
  let n;
136
143
  const {
137
- type: r,
144
+ type: i,
138
145
  props: o
139
146
  } = e;
140
- if (!t.isSvg && r === "svg" && (t = Object.assign({}, t, {
147
+ if (!t.isSvg && i === "svg" && (t = Object.assign({}, t, {
141
148
  isSvg: !0
142
- })), t.isSvg ? n = document.createElementNS(xt, r) : n = document.createElement(r), Et(n, o, t), o.children) {
149
+ })), t.isSvg ? n = document.createElementNS(xt, i) : n = document.createElement(i), Et(n, o, t), o.children) {
143
150
  let c = t;
144
- t.isSvg && r === "foreignObject" && (c = Object.assign({}, c, {
151
+ t.isSvg && i === "foreignObject" && (c = Object.assign({}, c, {
145
152
  isSvg: !1
146
153
  }));
147
154
  const s = $(o.children, c);
148
- s != null && I(n, s);
155
+ s != null && L(n, s);
149
156
  }
150
157
  const {
151
158
  ref: a
@@ -158,47 +165,47 @@ function O(e) {
158
165
  return B(e);
159
166
  }
160
167
  function jt(e) {
161
- var t = 0, n = e.children, r = n && n.length;
162
- if (!r)
168
+ var t = 0, n = e.children, i = n && n.length;
169
+ if (!i)
163
170
  t = 1;
164
171
  else
165
- for (; --r >= 0; )
166
- t += n[r].value;
172
+ for (; --i >= 0; )
173
+ t += n[i].value;
167
174
  e.value = t;
168
175
  }
169
176
  function Nt() {
170
177
  return this.eachAfter(jt);
171
178
  }
172
179
  function Rt(e) {
173
- var t = this, n, r = [t], o, a, c;
180
+ var t = this, n, i = [t], o, a, c;
174
181
  do
175
- for (n = r.reverse(), r = []; t = n.pop(); )
182
+ for (n = i.reverse(), i = []; t = n.pop(); )
176
183
  if (e(t), o = t.children, o)
177
184
  for (a = 0, c = o.length; a < c; ++a)
178
- r.push(o[a]);
179
- while (r.length);
185
+ i.push(o[a]);
186
+ while (i.length);
180
187
  return this;
181
188
  }
182
189
  function Tt(e) {
183
- for (var t = this, n = [t], r, o; t = n.pop(); )
184
- if (e(t), r = t.children, r)
185
- for (o = r.length - 1; o >= 0; --o)
186
- n.push(r[o]);
190
+ for (var t = this, n = [t], i, o; t = n.pop(); )
191
+ if (e(t), i = t.children, i)
192
+ for (o = i.length - 1; o >= 0; --o)
193
+ n.push(i[o]);
187
194
  return this;
188
195
  }
189
196
  function Mt(e) {
190
- for (var t = this, n = [t], r = [], o, a, c; t = n.pop(); )
191
- if (r.push(t), o = t.children, o)
197
+ for (var t = this, n = [t], i = [], o, a, c; t = n.pop(); )
198
+ if (i.push(t), o = t.children, o)
192
199
  for (a = 0, c = o.length; a < c; ++a)
193
200
  n.push(o[a]);
194
- for (; t = r.pop(); )
201
+ for (; t = i.pop(); )
195
202
  e(t);
196
203
  return this;
197
204
  }
198
205
  function At(e) {
199
206
  return this.eachAfter(function(t) {
200
- for (var n = +e(t.data) || 0, r = t.children, o = r && r.length; --o >= 0; )
201
- n += r[o].value;
207
+ for (var n = +e(t.data) || 0, i = t.children, o = i && i.length; --o >= 0; )
208
+ n += i[o].value;
202
209
  t.value = n;
203
210
  });
204
211
  }
@@ -208,18 +215,18 @@ function _t(e) {
208
215
  });
209
216
  }
210
217
  function Ot(e) {
211
- for (var t = this, n = Dt(t, e), r = [t]; t !== n; )
212
- t = t.parent, r.push(t);
213
- for (var o = r.length; e !== n; )
214
- r.splice(o, 0, e), e = e.parent;
215
- return r;
218
+ for (var t = this, n = Dt(t, e), i = [t]; t !== n; )
219
+ t = t.parent, i.push(t);
220
+ for (var o = i.length; e !== n; )
221
+ i.splice(o, 0, e), e = e.parent;
222
+ return i;
216
223
  }
217
224
  function Dt(e, t) {
218
225
  if (e === t)
219
226
  return e;
220
- var n = e.ancestors(), r = t.ancestors(), o = null;
221
- for (e = n.pop(), t = r.pop(); e === t; )
222
- o = e, e = n.pop(), t = r.pop();
227
+ var n = e.ancestors(), i = t.ancestors(), o = null;
228
+ for (e = n.pop(), t = i.pop(); e === t; )
229
+ o = e, e = n.pop(), t = i.pop();
223
230
  return o;
224
231
  }
225
232
  function $t() {
@@ -239,24 +246,24 @@ function Ft() {
239
246
  t.children || e.push(t);
240
247
  }), e;
241
248
  }
242
- function Ht() {
249
+ function It() {
243
250
  var e = this, t = [];
244
251
  return e.each(function(n) {
245
252
  n !== e && t.push({ source: n.parent, target: n });
246
253
  }), t;
247
254
  }
248
255
  function F(e, t) {
249
- var n = new N(e), r = +e.value && (n.value = e.value), o, a = [n], c, s, l, p;
250
- for (t == null && (t = It); o = a.pop(); )
251
- if (r && (o.value = +o.data.value), (s = t(o.data)) && (p = s.length))
256
+ var n = new N(e), i = +e.value && (n.value = e.value), o, a = [n], c, s, l, p;
257
+ for (t == null && (t = Lt); o = a.pop(); )
258
+ if (i && (o.value = +o.data.value), (s = t(o.data)) && (p = s.length))
252
259
  for (o.children = new Array(p), l = p - 1; l >= 0; --l)
253
260
  a.push(c = o.children[l] = new N(s[l])), c.parent = o, c.depth = o.depth + 1;
254
261
  return n.eachBefore(Yt);
255
262
  }
256
- function Lt() {
263
+ function Ht() {
257
264
  return F(this).eachBefore(Wt);
258
265
  }
259
- function It(e) {
266
+ function Lt(e) {
260
267
  return e.children;
261
268
  }
262
269
  function Wt(e) {
@@ -283,8 +290,8 @@ N.prototype = F.prototype = {
283
290
  ancestors: $t,
284
291
  descendants: Bt,
285
292
  leaves: Ft,
286
- links: Ht,
287
- copy: Lt
293
+ links: It,
294
+ copy: Ht
288
295
  };
289
296
  const Vt = "d3-flextree", Kt = "2.1.2", Pt = "build/d3-flextree.js", Ut = "index", Gt = {
290
297
  name: "Chris Maloney",
@@ -318,7 +325,7 @@ const Vt = "d3-flextree", Kt = "2.1.2", Pt = "build/d3-flextree.js", Ut = "index
318
325
  prepare: "npm-run-all clean build lint test"
319
326
  }, ne = {
320
327
  "d3-hierarchy": "^1.1.5"
321
- }, re = {
328
+ }, ie = {
322
329
  "babel-plugin-external-helpers": "^6.22.0",
323
330
  "babel-preset-es2015-rollup": "^3.0.0",
324
331
  d3: "^4.13.0",
@@ -334,7 +341,7 @@ const Vt = "d3-flextree", Kt = "2.1.2", Pt = "build/d3-flextree.js", Ut = "index
334
341
  "rollup-plugin-node-resolve": "^3.0.2",
335
342
  "rollup-plugin-uglify": "^3.0.0",
336
343
  "uglify-es": "^3.3.9"
337
- }, ie = {
344
+ }, re = {
338
345
  name: Vt,
339
346
  version: Kt,
340
347
  main: Pt,
@@ -348,8 +355,8 @@ const Vt = "d3-flextree", Kt = "2.1.2", Pt = "build/d3-flextree.js", Ut = "index
348
355
  repository: te,
349
356
  scripts: ee,
350
357
  dependencies: ne,
351
- devDependencies: re
352
- }, { version: oe } = ie, se = Object.freeze({
358
+ devDependencies: ie
359
+ }, { version: oe } = re, se = Object.freeze({
353
360
  children: (e) => e.children,
354
361
  nodeSize: (e) => e.data.size,
355
362
  spacing: 0
@@ -360,7 +367,7 @@ function q(e) {
360
367
  const l = t[s];
361
368
  return typeof l == "function" ? l : () => l;
362
369
  }
363
- function r(s) {
370
+ function i(s) {
364
371
  const l = c(a(), s, (p) => p.children);
365
372
  return l.update(), l.data;
366
373
  }
@@ -506,15 +513,15 @@ function q(e) {
506
513
  };
507
514
  return h(l, null);
508
515
  }
509
- return Object.assign(r, {
516
+ return Object.assign(i, {
510
517
  nodeSize(s) {
511
- return arguments.length ? (t.nodeSize = s, r) : t.nodeSize;
518
+ return arguments.length ? (t.nodeSize = s, i) : t.nodeSize;
512
519
  },
513
520
  spacing(s) {
514
- return arguments.length ? (t.spacing = s, r) : t.spacing;
521
+ return arguments.length ? (t.spacing = s, i) : t.spacing;
515
522
  },
516
523
  children(s) {
517
- return arguments.length ? (t.children = s, r) : t.children;
524
+ return arguments.length ? (t.children = s, i) : t.children;
518
525
  },
519
526
  hierarchy(s, l) {
520
527
  const p = typeof l > "u" ? t.children : l;
@@ -528,28 +535,28 @@ function q(e) {
528
535
  return p(`
529
536
  `)(s);
530
537
  }
531
- }), r;
538
+ }), i;
532
539
  }
533
540
  q.version = oe;
534
- const J = (e, t = 0) => (e.y = t, (e.children || []).reduce((n, r) => {
541
+ const J = (e, t = 0) => (e.y = t, (e.children || []).reduce((n, i) => {
535
542
  const [o, a] = n;
536
- J(r, e.y + e.ySize);
537
- const c = (o === 0 ? r.lExt : r.rExt).bottom;
543
+ J(i, e.y + e.ySize);
544
+ const c = (o === 0 ? i.lExt : i.rExt).bottom;
538
545
  o !== 0 && le(e, o, a);
539
546
  const s = ge(c, o, a);
540
547
  return [o + 1, s];
541
548
  }, [0, null]), ae(e), fe(e), e), Q = (e, t, n) => {
542
549
  typeof t > "u" && (t = -e.relX - e.prelim, n = 0);
543
- const r = t + e.relX;
544
- return e.relX = r + e.prelim - n, e.prelim = 0, e.x = n + e.relX, (e.children || []).forEach((o) => Q(o, r, e.x)), e;
550
+ const i = t + e.relX;
551
+ return e.relX = i + e.prelim - n, e.prelim = 0, e.x = n + e.relX, (e.children || []).forEach((o) => Q(o, i, e.x)), e;
545
552
  }, ae = (e) => {
546
553
  (e.children || []).reduce((t, n) => {
547
- const [r, o] = t, a = r + n.shift, c = o + a + n.change;
554
+ const [i, o] = t, a = i + n.shift, c = o + a + n.change;
548
555
  return n.relX += c, [a, c];
549
556
  }, [0, 0]);
550
557
  }, le = (e, t, n) => {
551
- const r = e.children[t - 1], o = e.children[t];
552
- let a = r, c = r.relX, s = o, l = o.relX, p = !0;
558
+ const i = e.children[t - 1], o = e.children[t];
559
+ let a = i, c = i.relX, s = o, l = o.relX, p = !0;
553
560
  for (; a && s; ) {
554
561
  a.bottom > n.lowY && (n = n.next);
555
562
  const h = c + a.prelim - (l + s.prelim) + a.xSize / 2 + s.xSize / 2 + a.spacing(s);
@@ -560,27 +567,27 @@ const J = (e, t = 0) => (e.y = t, (e.children || []).reduce((n, r) => {
560
567
  !a && s ? pe(e, t, s, l) : a && !s && me(e, t, a, c);
561
568
  }, ce = (e, t) => {
562
569
  e.relX += t, e.lExtRelX += t, e.rExtRelX += t;
563
- }, he = (e, t, n, r) => {
570
+ }, he = (e, t, n, i) => {
564
571
  const o = e.children[t], a = t - n;
565
572
  if (a > 1) {
566
- const c = r / a;
567
- e.children[n + 1].shift += c, o.shift -= c, o.change -= r - c;
573
+ const c = i / a;
574
+ e.children[n + 1].shift += c, o.shift -= c, o.change -= i - c;
568
575
  }
569
- }, de = (e) => e.hasChildren ? e.firstChild : e.lThr, ue = (e) => e.hasChildren ? e.lastChild : e.rThr, pe = (e, t, n, r) => {
576
+ }, de = (e) => e.hasChildren ? e.firstChild : e.lThr, ue = (e) => e.hasChildren ? e.lastChild : e.rThr, pe = (e, t, n, i) => {
570
577
  const o = e.firstChild, a = o.lExt, c = e.children[t];
571
578
  a.lThr = n;
572
- const s = r - n.relX - o.lExtRelX;
579
+ const s = i - n.relX - o.lExtRelX;
573
580
  a.relX += s, a.prelim -= s, o.lExt = c.lExt, o.lExtRelX = c.lExtRelX;
574
- }, me = (e, t, n, r) => {
581
+ }, me = (e, t, n, i) => {
575
582
  const o = e.children[t], a = o.rExt, c = e.children[t - 1];
576
583
  a.rThr = n;
577
- const s = r - n.relX - o.rExtRelX;
584
+ const s = i - n.relX - o.rExtRelX;
578
585
  a.relX += s, a.prelim -= s, o.rExt = c.rExt, o.rExtRelX = c.rExtRelX;
579
586
  }, fe = (e) => {
580
587
  if (e.hasChildren) {
581
- const t = e.firstChild, n = e.lastChild, r = (t.prelim + t.relX - t.xSize / 2 + n.relX + n.prelim + n.xSize / 2) / 2;
588
+ const t = e.firstChild, n = e.lastChild, i = (t.prelim + t.relX - t.xSize / 2 + n.relX + n.prelim + n.xSize / 2) / 2;
582
589
  Object.assign(e, {
583
- prelim: r,
590
+ prelim: i,
584
591
  lExt: t.lExt,
585
592
  lExtRelX: t.lExtRelX,
586
593
  rExt: n.rExt,
@@ -595,7 +602,7 @@ const J = (e, t = 0) => (e.y = t, (e.children || []).reduce((n, r) => {
595
602
  index: t,
596
603
  next: n
597
604
  };
598
- }, xe = ".markmap-container{position:absolute;width:0;height:0;top:-100px;left:-100px;overflow:hidden}.markmap-container>.markmap-foreign{display:inline-block}.markmap-container>.markmap-foreign>div:last-child,.markmap-container>.markmap-foreign>div:last-child :not(pre){white-space:nowrap}.markmap-container>.markmap-foreign>div:last-child code{white-space:inherit}", tt = ".markmap{--markmap-max-width: none;--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-testing-max{max-width:var(--markmap-max-width)}.markmap-foreign-testing-max img{max-width:var(--markmap-max-width);max-height:none}.markmap-dark .markmap{--markmap-circle-open-bg: #444;--markmap-text-color: #eee}", be = tt;
605
+ }, xe = ".markmap-container{position:absolute;width:0;height:0;top:-100px;left:-100px;overflow:hidden}.markmap-container>.markmap-foreign{display:inline-block}.markmap-container>.markmap-foreign>div:last-child,.markmap-container>.markmap-foreign>div:last-child :not(pre){white-space:nowrap}.markmap-container>.markmap-foreign>div:last-child code{white-space:inherit}", tt = ".markmap{--markmap-max-width: none;--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-testing-max{max-width:var(--markmap-max-width)}.markmap-foreign-testing-max img{max-width:var(--markmap-max-width);max-height:none}.markmap-dark .markmap{--markmap-code-bg: #1a1b26;--markmap-code-color: #ddd;--markmap-circle-open-bg: #444;--markmap-text-color: #eee}", be = tt;
599
606
  function W(e) {
600
607
  const t = e.data;
601
608
  return Math.max(4 - 2 * t.state.depth, 1.5);
@@ -610,20 +617,20 @@ function D(e) {
610
617
  const ye = new st();
611
618
  class et {
612
619
  constructor(t, n) {
613
- this.options = P, this.revokers = [], this.imgCache = {}, this.handleZoom = (r) => {
614
- const { transform: o } = r;
620
+ this.options = P, this.revokers = [], this.imgCache = {}, this.handleZoom = (i) => {
621
+ const { transform: o } = i;
615
622
  this.g.attr("transform", o);
616
- }, this.handlePan = (r) => {
617
- r.preventDefault();
623
+ }, this.handlePan = (i) => {
624
+ i.preventDefault();
618
625
  const o = A(this.svg.node()), a = o.translate(
619
- -r.deltaX / o.k,
620
- -r.deltaY / o.k
626
+ -i.deltaX / o.k,
627
+ -i.deltaY / o.k
621
628
  );
622
629
  this.svg.call(this.zoom.transform, a);
623
- }, this.handleClick = (r, o) => {
630
+ }, this.handleClick = (i, o) => {
624
631
  let a = this.options.toggleRecursively;
625
- (K ? r.metaKey : r.ctrlKey) && (a = !a), this.toggleNode(o.data, a);
626
- }, this.svg = t.datum ? t : dt(t), this.styleNode = this.svg.append("style"), this.zoom = ut().filter((r) => this.options.scrollForPan && r.type === "wheel" ? r.ctrlKey && !r.button : (!r.ctrlKey || r.type === "wheel") && !r.button).on("zoom", this.handleZoom), this.setOptions(n), this.state = {
632
+ (K ? i.metaKey : i.ctrlKey) && (a = !a), this.toggleNode(o.data, a);
633
+ }, this.svg = t.datum ? t : dt(t), this.styleNode = this.svg.append("style"), this.zoom = ut().filter((i) => this.options.scrollForPan && i.type === "wheel" ? i.ctrlKey && !i.button : (!i.ctrlKey || i.type === "wheel") && !i.button).on("zoom", this.handleZoom), this.setOptions(n), this.state = {
627
634
  id: this.options.id || this.svg.attr("id") || at(),
628
635
  minX: 0,
629
636
  maxX: 0,
@@ -636,8 +643,8 @@ class et {
636
643
  );
637
644
  }
638
645
  getStyleContent() {
639
- const { style: t } = this.options, { id: n } = this.state, r = typeof t == "function" ? t(n) : "";
640
- return [this.options.embedGlobalCSS && tt, r].filter(Boolean).join(`
646
+ const { style: t } = this.options, { id: n } = this.state, i = typeof t == "function" ? t(n) : "";
647
+ return [this.options.embedGlobalCSS && tt, i].filter(Boolean).join(`
641
648
  `);
642
649
  }
643
650
  updateStyle() {
@@ -650,11 +657,11 @@ class et {
650
657
  }
651
658
  toggleNode(t, n = !1) {
652
659
  var o, a;
653
- const r = (o = t.payload) != null && o.fold ? 0 : 1;
660
+ const i = (o = t.payload) != null && o.fold ? 0 : 1;
654
661
  n ? T(t, (c, s) => {
655
662
  c.payload = {
656
663
  ...c.payload,
657
- fold: r
664
+ fold: i
658
665
  }, s();
659
666
  }) : t.payload = {
660
667
  ...t.payload,
@@ -663,7 +670,7 @@ class et {
663
670
  }
664
671
  initializeData(t) {
665
672
  let n = 0;
666
- const { color: r, nodeMinHeight: o, maxWidth: a, initialExpandLevel: c } = this.options, { id: s } = this.state, l = O(
673
+ const { color: i, nodeMinHeight: o, maxWidth: a, initialExpandLevel: c } = this.options, { id: s } = this.state, l = O(
667
674
  /* @__PURE__ */ j("div", { className: `markmap-container markmap ${s}-g` })
668
675
  ), p = O(
669
676
  /* @__PURE__ */ j("style", { children: [this.getStyleContent(), xe].join(`
@@ -690,7 +697,7 @@ class et {
690
697
  depth: g,
691
698
  id: n,
692
699
  el: k.firstChild
693
- }, m.state.path = [(w = f == null ? void 0 : f.state) == null ? void 0 : w.path, m.state.id].filter(Boolean).join("."), r(m);
700
+ }, m.state.path = [(w = f == null ? void 0 : f.state) == null ? void 0 : w.path, m.state.id].filter(Boolean).join("."), i(m);
694
701
  const v = ((z = m.payload) == null ? void 0 : z.fold) === 2;
695
702
  v ? u += 1 : (u || c >= 0 && m.state.depth >= c) && (m.payload = { ...m.payload, fold: 1 }), y(), v && (u -= 1), g -= 1;
696
703
  });
@@ -714,8 +721,8 @@ class et {
714
721
  t.querySelectorAll("img").forEach((n) => {
715
722
  if (n.width)
716
723
  return;
717
- const r = this.imgCache[n.src];
718
- r != null && r[0] ? [n.width, n.height] = r : r || this._loadImage(n.src);
724
+ const i = this.imgCache[n.src];
725
+ i != null && i[0] ? [n.width, n.height] = i : i || this._loadImage(n.src);
719
726
  });
720
727
  }
721
728
  _loadImage(t) {
@@ -737,115 +744,115 @@ class et {
737
744
  renderData(t) {
738
745
  if (!this.state.data)
739
746
  return;
740
- const { spacingHorizontal: n, paddingX: r, spacingVertical: o, autoFit: a, color: c } = this.options, s = q({}).children((i) => {
747
+ const { spacingHorizontal: n, paddingX: i, spacingVertical: o, autoFit: a, color: c } = this.options, s = q({}).children((r) => {
741
748
  var d;
742
- if (!((d = i.payload) != null && d.fold))
743
- return i.children;
744
- }).nodeSize((i) => {
745
- const [d, S] = i.data.state.size;
746
- return [S, d + (d ? r * 2 : 0) + n];
747
- }).spacing((i, d) => i.parent === d.parent ? o : o * 2), l = s.hierarchy(this.state.data);
749
+ if (!((d = r.payload) != null && d.fold))
750
+ return r.children;
751
+ }).nodeSize((r) => {
752
+ const [d, S] = r.data.state.size;
753
+ return [S, d + (d ? i * 2 : 0) + n];
754
+ }).spacing((r, d) => r.parent === d.parent ? o : o * 2), l = s.hierarchy(this.state.data);
748
755
  s(l);
749
- const p = l.descendants().reverse(), h = l.links(), u = pt(), g = H(p, (i) => i.x - i.xSize / 2), x = L(p, (i) => i.x + i.xSize / 2), m = H(p, (i) => i.y), y = L(p, (i) => i.y + i.ySize - n);
756
+ const p = l.descendants().reverse(), h = l.links(), u = pt(), g = I(p, (r) => r.x - r.xSize / 2), x = H(p, (r) => r.x + r.xSize / 2), m = I(p, (r) => r.y), y = H(p, (r) => r.y + r.ySize - n);
750
757
  Object.assign(this.state, {
751
758
  minX: g,
752
759
  maxX: x,
753
760
  minY: m,
754
761
  maxY: y
755
762
  }), a && this.fit();
756
- const f = t && p.find((i) => i.data === t) || l, k = f.data.state.x0 ?? f.x, v = f.data.state.y0 ?? f.y, b = this.g.selectAll(
763
+ const f = t && p.find((r) => r.data === t) || l, k = f.data.state.x0 ?? f.x, v = f.data.state.y0 ?? f.y, b = this.g.selectAll(
757
764
  C("g")
758
- ).data(p, (i) => i.data.state.key), w = b.enter().append("g").attr("data-depth", (i) => i.data.state.depth).attr("data-path", (i) => i.data.state.path).attr(
765
+ ).data(p, (r) => r.data.state.key), w = b.enter().append("g").attr("data-depth", (r) => r.data.state.depth).attr("data-path", (r) => r.data.state.path).attr(
759
766
  "transform",
760
- (i) => `translate(${v + f.ySize - i.ySize},${k + f.xSize / 2 - i.xSize})`
767
+ (r) => `translate(${v + f.ySize - r.ySize},${k + f.xSize / 2 - r.xSize})`
761
768
  ), z = this.transition(b.exit());
762
- z.select("line").attr("x1", (i) => i.ySize - n).attr("x2", (i) => i.ySize - n), z.select("foreignObject").style("opacity", 0), z.attr(
769
+ z.select("line").attr("x1", (r) => r.ySize - n).attr("x2", (r) => r.ySize - n), z.select("foreignObject").style("opacity", 0), z.attr(
763
770
  "transform",
764
- (i) => `translate(${f.y + f.ySize - i.ySize},${f.x + f.xSize / 2 - i.xSize})`
771
+ (r) => `translate(${f.y + f.ySize - r.ySize},${f.x + f.xSize / 2 - r.xSize})`
765
772
  ).remove();
766
773
  const E = b.merge(w).attr(
767
774
  "class",
768
- (i) => {
775
+ (r) => {
769
776
  var d;
770
- return ["markmap-node", ((d = i.data.payload) == null ? void 0 : d.fold) && "markmap-fold"].filter(Boolean).join(" ");
777
+ return ["markmap-node", ((d = r.data.payload) == null ? void 0 : d.fold) && "markmap-fold"].filter(Boolean).join(" ");
771
778
  }
772
779
  );
773
780
  this.transition(E).attr(
774
781
  "transform",
775
- (i) => `translate(${i.y},${i.x - i.xSize / 2})`
782
+ (r) => `translate(${r.y},${r.x - r.xSize / 2})`
776
783
  );
777
784
  const nt = E.selectAll(
778
785
  C("line")
779
786
  ).data(
780
- (i) => [i],
781
- (i) => i.data.state.key
787
+ (r) => [r],
788
+ (r) => r.data.state.key
782
789
  ).join(
783
- (i) => i.append("line").attr("x1", (d) => d.ySize - n).attr("x2", (d) => d.ySize - n),
784
- (i) => i,
785
- (i) => i.remove()
790
+ (r) => r.append("line").attr("x1", (d) => d.ySize - n).attr("x2", (d) => d.ySize - n),
791
+ (r) => r,
792
+ (r) => r.remove()
786
793
  );
787
- this.transition(nt).attr("x1", -1).attr("x2", (i) => i.ySize - n + 2).attr("y1", (i) => i.xSize).attr("y2", (i) => i.xSize).attr("stroke", (i) => c(i.data)).attr("stroke-width", W);
788
- const rt = E.selectAll(
794
+ this.transition(nt).attr("x1", -1).attr("x2", (r) => r.ySize - n + 2).attr("y1", (r) => r.xSize).attr("y2", (r) => r.xSize).attr("stroke", (r) => c(r.data)).attr("stroke-width", W);
795
+ const it = E.selectAll(
789
796
  C("circle")
790
797
  ).data(
791
- (i) => {
798
+ (r) => {
792
799
  var d;
793
- return (d = i.data.children) != null && d.length ? [i] : [];
800
+ return (d = r.data.children) != null && d.length ? [r] : [];
794
801
  },
795
- (i) => i.data.state.key
802
+ (r) => r.data.state.key
796
803
  ).join(
797
- (i) => i.append("circle").attr("stroke-width", "1.5").attr("cx", (d) => d.ySize - n).attr("cy", (d) => d.xSize).attr("r", 0).on("click", (d, S) => this.handleClick(d, S)).on("mousedown", D),
798
- (i) => i,
799
- (i) => i.remove()
804
+ (r) => r.append("circle").attr("stroke-width", "1.5").attr("cx", (d) => d.ySize - n).attr("cy", (d) => d.xSize).attr("r", 0).on("click", (d, S) => this.handleClick(d, S)).on("mousedown", D),
805
+ (r) => r,
806
+ (r) => r.remove()
800
807
  );
801
- this.transition(rt).attr("r", 6).attr("cx", (i) => i.ySize - n).attr("cy", (i) => i.xSize).attr("stroke", (i) => c(i.data)).attr(
808
+ this.transition(it).attr("r", 6).attr("cx", (r) => r.ySize - n).attr("cy", (r) => r.xSize).attr("stroke", (r) => c(r.data)).attr(
802
809
  "fill",
803
- (i) => {
810
+ (r) => {
804
811
  var d;
805
- return (d = i.data.payload) != null && d.fold && i.data.children ? c(i.data) : "var(--markmap-circle-open-bg)";
812
+ return (d = r.data.payload) != null && d.fold && r.data.children ? c(r.data) : "var(--markmap-circle-open-bg)";
806
813
  }
807
814
  );
808
- const it = E.selectAll(
815
+ const rt = E.selectAll(
809
816
  C("foreignObject")
810
817
  ).data(
811
- (i) => [i],
812
- (i) => i.data.state.key
818
+ (r) => [r],
819
+ (r) => r.data.state.key
813
820
  ).join(
814
- (i) => {
815
- const d = i.append("foreignObject").attr("class", "markmap-foreign").attr("x", r).attr("y", 0).style("opacity", 0).on("mousedown", D).on("dblclick", D);
821
+ (r) => {
822
+ const d = r.append("foreignObject").attr("class", "markmap-foreign").attr("x", i).attr("y", 0).style("opacity", 0).on("mousedown", D).on("dblclick", D);
816
823
  return d.append("xhtml:div").select(function(R) {
817
824
  const X = R.data.state.el.cloneNode(!0);
818
825
  return this.replaceWith(X), X;
819
826
  }).attr("xmlns", "http://www.w3.org/1999/xhtml"), d;
820
827
  },
821
- (i) => i,
822
- (i) => i.remove()
828
+ (r) => r,
829
+ (r) => r.remove()
823
830
  ).attr(
824
831
  "width",
825
- (i) => Math.max(0, i.ySize - n - r * 2)
826
- ).attr("height", (i) => i.xSize);
827
- this.transition(it).style("opacity", 1);
832
+ (r) => Math.max(0, r.ySize - n - i * 2)
833
+ ).attr("height", (r) => r.xSize);
834
+ this.transition(rt).style("opacity", 1);
828
835
  const ot = this.g.selectAll(
829
836
  C("path")
830
- ).data(h, (i) => i.target.data.state.key).join(
831
- (i) => {
837
+ ).data(h, (r) => r.target.data.state.key).join(
838
+ (r) => {
832
839
  const d = [
833
840
  v + f.ySize - n,
834
841
  k + f.xSize / 2
835
842
  ];
836
- return i.insert("path", "g").attr("class", "markmap-link").attr("data-depth", (S) => S.target.data.state.depth).attr("data-path", (S) => S.target.data.state.path).attr("d", u({ source: d, target: d }));
843
+ return r.insert("path", "g").attr("class", "markmap-link").attr("data-depth", (S) => S.target.data.state.depth).attr("data-path", (S) => S.target.data.state.path).attr("d", u({ source: d, target: d }));
837
844
  },
838
- (i) => i,
839
- (i) => {
845
+ (r) => r,
846
+ (r) => {
840
847
  const d = [
841
848
  f.y + f.ySize - n,
842
849
  f.x + f.xSize / 2
843
850
  ];
844
- return this.transition(i).attr("d", u({ source: d, target: d })).remove();
851
+ return this.transition(r).attr("d", u({ source: d, target: d })).remove();
845
852
  }
846
853
  );
847
- this.transition(ot).attr("stroke", (i) => c(i.target.data)).attr("stroke-width", (i) => W(i.target)).attr("d", (i) => {
848
- const d = i.source, S = i.target, R = [
854
+ this.transition(ot).attr("stroke", (r) => c(r.target.data)).attr("stroke-width", (r) => W(r.target)).attr("d", (r) => {
855
+ const d = r.source, S = r.target, R = [
849
856
  d.y + d.ySize - n,
850
857
  d.x + d.xSize / 2
851
858
  ], X = [
@@ -853,8 +860,8 @@ class et {
853
860
  S.x + S.xSize / 2
854
861
  ];
855
862
  return u({ source: R, target: X });
856
- }), p.forEach((i) => {
857
- i.data.state.x0 = i.x, i.data.state.y0 = i.y;
863
+ }), p.forEach((r) => {
864
+ r.data.state.x0 = r.x, r.data.state.y0 = r.y;
858
865
  });
859
866
  }
860
867
  transition(t) {
@@ -864,16 +871,16 @@ class et {
864
871
  /**
865
872
  * Fit the content to the viewport.
866
873
  */
867
- async fit() {
868
- const t = this.svg.node(), { width: n, height: r } = t.getBoundingClientRect(), { fitRatio: o } = this.options, { minX: a, maxX: c, minY: s, maxY: l } = this.state, p = l - s, h = c - a, u = Math.min(
869
- n / p * o,
870
- r / h * o,
871
- 2
872
- ), g = mt.translate(
873
- (n - p * u) / 2 - s * u,
874
- (r - h * u) / 2 - a * u
875
- ).scale(u);
876
- return this.transition(this.svg).call(this.zoom.transform, g).end().catch(M);
874
+ async fit(t = this.options.maxInitialScale) {
875
+ const n = this.svg.node(), { width: i, height: o } = n.getBoundingClientRect(), { fitRatio: a } = this.options, { minX: c, maxX: s, minY: l, maxY: p } = this.state, h = p - l, u = s - c, g = Math.min(
876
+ i / h * a,
877
+ o / u * a,
878
+ t
879
+ ), x = mt.translate(
880
+ (i - h * g) / 2 - l * g,
881
+ (o - u * g) / 2 - c * g
882
+ ).scale(g);
883
+ return this.transition(this.svg).call(this.zoom.transform, x).end().catch(M);
877
884
  }
878
885
  findElement(t) {
879
886
  let n;
@@ -891,15 +898,15 @@ class et {
891
898
  */
892
899
  async ensureView(t, n) {
893
900
  var k;
894
- const r = (k = this.findElement(t)) == null ? void 0 : k.data;
895
- if (!r)
901
+ const i = (k = this.findElement(t)) == null ? void 0 : k.data;
902
+ if (!i)
896
903
  return;
897
904
  const o = this.svg.node(), { spacingHorizontal: a } = this.options, c = o.getBoundingClientRect(), s = A(o), [l, p] = [
898
- r.y,
899
- r.y + r.ySize - a + 2
905
+ i.y,
906
+ i.y + i.ySize - a + 2
900
907
  ].map((v) => v * s.k + s.x), [h, u] = [
901
- r.x - r.xSize / 2,
902
- r.x + r.xSize / 2
908
+ i.x - i.xSize / 2,
909
+ i.x + i.xSize / 2
903
910
  ].map((v) => v * s.k + s.y), g = {
904
911
  left: 0,
905
912
  right: 0,
@@ -916,7 +923,7 @@ class et {
916
923
  * Scale content with it pinned at the center of the viewport.
917
924
  */
918
925
  async rescale(t) {
919
- const n = this.svg.node(), { width: r, height: o } = n.getBoundingClientRect(), a = r / 2, c = o / 2, s = A(n), l = s.translate(
926
+ const n = this.svg.node(), { width: i, height: o } = n.getBoundingClientRect(), a = i / 2, c = o / 2, s = A(n), l = s.translate(
920
927
  (a - s.x) * (1 - t) / s.k,
921
928
  (c - s.y) * (1 - t) / s.k
922
929
  ).scale(t);
@@ -927,9 +934,11 @@ class et {
927
934
  t();
928
935
  });
929
936
  }
930
- static create(t, n, r = null) {
937
+ static create(t, n, i = null) {
931
938
  const o = new et(t, n);
932
- return r && (o.setData(r), o.fit()), o;
939
+ return i && (o.setData(i), requestAnimationFrame(() => {
940
+ o.fit();
941
+ })), o;
933
942
  }
934
943
  }
935
944
  export {
package/dist/view.d.ts CHANGED
@@ -34,7 +34,7 @@ export declare class Markmap {
34
34
  /**
35
35
  * Fit the content to the viewport.
36
36
  */
37
- fit(): Promise<void>;
37
+ fit(maxScale?: number): Promise<void>;
38
38
  findElement(node: INode): {
39
39
  data: FlextreeNode<INode>;
40
40
  g: SVGGElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markmap-view",
3
- "version": "0.16.3-web.2+0f4c3f8",
3
+ "version": "0.17.1-alpha.4+12ca00a",
4
4
  "description": "View markmaps in browser",
5
5
  "author": "Gerald <gera2ld@live.com>",
6
6
  "license": "MIT",
@@ -22,7 +22,8 @@
22
22
  "clean": "del-cli dist",
23
23
  "build:types": "tsc",
24
24
  "build:js": "vite build && TARGET=es vite build",
25
- "build": "run-s clean build:*"
25
+ "build": "run-s clean build:*",
26
+ "prepublishOnly": "run-s build"
26
27
  },
27
28
  "bugs": {
28
29
  "url": "https://github.com/markmap/markmap/issues"
@@ -45,10 +46,10 @@
45
46
  },
46
47
  "devDependencies": {
47
48
  "@types/d3-flextree": "^2.1.1",
48
- "markmap-common": "0.16.3-web.2+0f4c3f8"
49
+ "markmap-common": "0.17.1-alpha.4+12ca00a"
49
50
  },
50
51
  "peerDependencies": {
51
52
  "markmap-common": "*"
52
53
  },
53
- "gitHead": "0f4c3f84ff21f0957ec3dbf338ed7a453f050638"
54
+ "gitHead": "12ca00a934bba8e5a6176539a54d389786e04730"
54
55
  }