markmap-view 0.18.5 → 0.18.8-alpha.2

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