markmap-view 0.18.10 → 0.18.13

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