mind-elixir 5.12.0 → 5.12.2-beta.0

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.
@@ -1,4 +1,4 @@
1
- const Wn = 0, Yn = 1, Rn = 2, tt = {
1
+ const Wn = 0, Yn = 1, Rn = 2, Y = {
2
2
  name: "Latte",
3
3
  type: "light",
4
4
  palette: ["#dd7878", "#ea76cb", "#8839ef", "#e64553", "#fe640b", "#df8e1d", "#40a02b", "#209fb5", "#1e66f5", "#7287fd"],
@@ -56,12 +56,12 @@ const Wn = 0, Yn = 1, Rn = 2, tt = {
56
56
  function $t(t) {
57
57
  return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/"/g, "&quot;");
58
58
  }
59
- const G = function(t, e) {
59
+ const _ = function(t, e) {
60
60
  if (e.id === t)
61
61
  return e;
62
62
  if (e.children && e.children.length) {
63
63
  for (let n = 0; n < e.children.length; n++) {
64
- const o = G(t, e.children[n]);
64
+ const o = _(t, e.children[n]);
65
65
  if (o) return o;
66
66
  }
67
67
  return null;
@@ -76,7 +76,7 @@ const G = function(t, e) {
76
76
  wt(o, e);
77
77
  });
78
78
  };
79
- function _(t, e, n, o) {
79
+ function q(t, e, n, o) {
80
80
  const s = n - t, i = o - e, c = Math.atan2(i, s) * 180 / Math.PI, l = 12, a = 30, f = (c + 180 - a) * Math.PI / 180, d = (c + 180 + a) * Math.PI / 180;
81
81
  return {
82
82
  x1: n + Math.cos(f) * l,
@@ -85,11 +85,11 @@ function _(t, e, n, o) {
85
85
  y2: o + Math.sin(d) * l
86
86
  };
87
87
  }
88
- function Y() {
88
+ function R() {
89
89
  return ((/* @__PURE__ */ new Date()).getTime().toString(16) + Math.random().toString(16).substring(2)).substring(2, 18);
90
90
  }
91
91
  const Ht = function() {
92
- const t = Y();
92
+ const t = R();
93
93
  return {
94
94
  topic: this.newTopicName,
95
95
  id: t
@@ -102,7 +102,7 @@ const Ht = function() {
102
102
  }, D = (t, e) => {
103
103
  for (const n in e)
104
104
  t.setAttribute(n, e[n]);
105
- }, J = (t) => t ? t.tagName === "ME-TPC" : !1, ot = (t) => {
105
+ }, Z = (t) => t ? t.tagName === "ME-TPC" : !1, ot = (t) => {
106
106
  const e = /translate3d\(([^,]+),\s*([^,]+)/, n = t.match(e);
107
107
  return n ? { x: parseFloat(n[1]), y: parseFloat(n[2]) } : { x: 0, y: 0 };
108
108
  }, vt = function(t) {
@@ -121,11 +121,11 @@ const Ht = function() {
121
121
  return Math.sqrt(n * n + o * o);
122
122
  }, It = function(t, e) {
123
123
  if (!e)
124
- return j(t), t;
124
+ return U(t), t;
125
125
  let n = t.querySelector(".insert-preview");
126
126
  const o = `insert-preview ${e} show`;
127
127
  return n || (n = document.createElement("div"), t.appendChild(n)), n.className = o, t;
128
- }, j = function(t) {
128
+ }, U = function(t) {
129
129
  if (!t) return;
130
130
  const e = t.querySelectorAll(".insert-preview");
131
131
  for (const n of e || [])
@@ -199,7 +199,7 @@ function Rt(t, e, n) {
199
199
  const s = n.clientX - e.startX, i = n.clientY - e.startY, r = Math.sqrt(s * s + i * i);
200
200
  if (!e.isDragging && r > Yt && xt(t, e), !e.isDragging) return;
201
201
  const c = t.container.getBoundingClientRect();
202
- bt(e.ghost, n.clientX - c.x, n.clientY - c.y), n.clientX < c.x + 50 ? e.edgeMoveController.move(1, 0) : n.clientX > c.x + c.width - 50 ? e.edgeMoveController.move(-1, 0) : n.clientY < c.y + 50 ? e.edgeMoveController.move(0, 1) : n.clientY > c.y + c.height - 50 ? e.edgeMoveController.move(0, -1) : e.edgeMoveController.stop(), j(e.meet);
202
+ bt(e.ghost, n.clientX - c.x, n.clientY - c.y), n.clientX < c.x + 50 ? e.edgeMoveController.move(1, 0) : n.clientX > c.x + c.width - 50 ? e.edgeMoveController.move(-1, 0) : n.clientY < c.y + 50 ? e.edgeMoveController.move(0, 1) : n.clientY > c.y + c.height - 50 ? e.edgeMoveController.move(0, -1) : e.edgeMoveController.stop(), U(e.meet);
203
203
  const l = 12 * t.scaleVal, a = document.elementFromPoint(n.clientX, n.clientY - l);
204
204
  if (dt(a, o)) {
205
205
  e.meet = a;
@@ -222,7 +222,7 @@ function Xt(t, e, n) {
222
222
  e.edgeMoveController.stop();
223
223
  for (const s of o)
224
224
  s.parentElement.parentElement.style.opacity = "1";
225
- e.ghost.style.display = "none", e.ghost.innerHTML = "", e.isDragging && e.meet && (j(e.meet), e.insertType === "before" ? t.moveNodeBefore(o, e.meet) : e.insertType === "after" ? t.moveNodeAfter(o, e.meet) : e.insertType === "in" && t.moveNodeIn(o, e.meet)), t.dragged = null, e.isDragging = !1, e.insertType = null, e.meet = null, e.pointerId = null;
225
+ e.ghost.style.display = "none", e.ghost.innerHTML = "", e.isDragging && e.meet && (U(e.meet), e.insertType === "before" ? t.moveNodeBefore(o, e.meet) : e.insertType === "after" ? t.moveNodeAfter(o, e.meet) : e.insertType === "in" && t.moveNodeIn(o, e.meet)), t.dragged = null, e.isDragging = !1, e.insertType = null, e.meet = null, e.pointerId = null;
226
226
  }
227
227
  }
228
228
  function ut(t, e) {
@@ -231,7 +231,7 @@ function ut(t, e) {
231
231
  e.edgeMoveController.stop();
232
232
  for (const o of n)
233
233
  o.parentElement.parentElement.style.opacity = "1";
234
- e.meet && j(e.meet), e.ghost.style.display = "none", e.ghost.innerHTML = "", t.dragged = null, e.isDragging = !1, e.insertType = null, e.meet = null, e.pointerId = null;
234
+ e.meet && U(e.meet), e.ghost.style.display = "none", e.ghost.innerHTML = "", t.dragged = null, e.isDragging = !1, e.insertType = null, e.meet = null, e.pointerId = null;
235
235
  }
236
236
  }
237
237
  const O = {
@@ -382,7 +382,9 @@ function Zt(t) {
382
382
  arrows: t.arrows,
383
383
  summaries: t.summaries,
384
384
  direction: t.direction,
385
- theme: t.theme
385
+ theme: t.theme,
386
+ compact: t.compact,
387
+ meta: t.meta
386
388
  };
387
389
  }
388
390
  const Qt = function(t, e = !1) {
@@ -497,7 +499,7 @@ const Qt = function(t, e = !1) {
497
499
  }, c = s.x - r.x, l = s.y - r.y;
498
500
  this.move(c, l);
499
501
  }, be = function(t) {
500
- this.clearSelection(), t && (t = JSON.parse(JSON.stringify(t)), this.nodeData = t.nodeData, this.arrows = t.arrows || [], this.summaries = t.summaries || [], t.theme && this.changeTheme(t.theme)), nt(this.nodeData), this.layout(), this.linkDiv();
502
+ this.clearSelection(), t && (t = JSON.parse(JSON.stringify(t)), this.nodeData = t.nodeData, this.arrows = t.arrows || [], this.summaries = t.summaries || [], t.meta && (this.meta = t.meta), t.theme && this.changeTheme(t.theme)), nt(this.nodeData), this.layout(), this.linkDiv();
501
503
  }, xe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
502
504
  __proto__: null,
503
505
  cancelFocus: pe,
@@ -644,7 +646,7 @@ function Me(t) {
644
646
  }, d = (h) => {
645
647
  if (!t.editable) return;
646
648
  const m = h.target;
647
- if (J(m)) {
649
+ if (Z(m)) {
648
650
  t.selectNode(m), t.beginEdit(m);
649
651
  return;
650
652
  }
@@ -661,7 +663,7 @@ function Me(t) {
661
663
  return;
662
664
  }
663
665
  if (e.handlePointerDown(h), e.mousedown && (t.ptState = i.Pan), h.button === 0 || h.pointerType === "touch")
664
- if (J(m)) {
666
+ if (Z(m)) {
665
667
  t.selection?.cancel();
666
668
  const E = t.currentNodes || [];
667
669
  if (h.ctrlKey || h.metaKey || t.mobileMultiSelect ? E.includes(m) ? o = m : ((t.currentArrow || t.currentSummary) && t.clearSelection(), t.selection?.select(m)) : E.includes(m) || t.selectNode(m), !t.editable) return;
@@ -706,7 +708,7 @@ function Me(t) {
706
708
  h.preventDefault(), h.button === 2 && t.editable && setTimeout(() => {
707
709
  if (t.panHelper.moved || t.ptState !== i.Idle && t.ptState !== i.Pan) return;
708
710
  const m = h.target;
709
- J(m) && !m.classList.contains("selected") && t.selectNode(m), t.bus.fire("showContextMenu", h);
711
+ Z(m) && !m.classList.contains("selected") && t.selectNode(m), t.bus.fire("showContextMenu", h);
710
712
  }, 200);
711
713
  }, b = (h) => {
712
714
  if (h.stopPropagation(), h.preventDefault(), h.ctrlKey || h.metaKey) return Le(t, h);
@@ -754,11 +756,11 @@ function Pe() {
754
756
  }
755
757
  };
756
758
  }
757
- const k = "http://www.w3.org/2000/svg", U = function(t) {
759
+ const k = "http://www.w3.org/2000/svg", K = function(t) {
758
760
  const e = t.clientWidth, n = t.clientHeight, o = t.dataset, s = Number(o.x), i = Number(o.y), r = o.anchor;
759
761
  let c = s;
760
762
  r === "middle" ? c = s - e / 2 : r === "end" && (c = s - e), t.style.left = `${c}px`, t.style.top = `${i - n / 2}px`, t.style.visibility = "visible";
761
- }, Q = function(t, e, n, o) {
763
+ }, tt = function(t, e, n, o) {
762
764
  const { anchor: s = "middle", color: i, dataType: r, svgId: c } = o, l = document.createElement("div");
763
765
  l.className = "svg-label", l.style.color = i || "#666";
764
766
  const a = "label-" + c;
@@ -828,7 +830,7 @@ const k = "http://www.w3.org/2000/svg", U = function(t) {
828
830
  }), s.addEventListener("blur", () => {
829
831
  if (!s) return;
830
832
  const i = s.innerText?.trim() || "";
831
- i === "" ? n.label = o : n.label = i, e.style.opacity = "1", s.remove(), i !== o && (t.markdown ? e.innerHTML = t.markdown(n.label, n) : e.textContent = n.label, U(e), "parent" in n ? t.bus.fire("operation", {
833
+ i === "" ? n.label = o : n.label = i, e.style.opacity = "1", s.remove(), i !== o && (t.markdown ? e.innerHTML = t.markdown(n.label, n) : e.textContent = n.label, K(e), "parent" in n ? t.bus.fire("operation", {
832
834
  name: "finishEditSummary",
833
835
  obj: n
834
836
  }) : t.bus.fire("operation", {
@@ -915,10 +917,17 @@ function Ve(t) {
915
917
  t.container.append(Re(t)), t.container.append(Xe(t));
916
918
  }
917
919
  const ze = function(t, e = !0) {
918
- this.theme = t;
920
+ this.theme = {
921
+ ...this.theme || Y,
922
+ ...t,
923
+ cssVar: {
924
+ ...this.theme?.cssVar || Y.cssVar,
925
+ ...t.cssVar || {}
926
+ }
927
+ }, this.theme.generateMainBranch !== void 0 && (this.generateMainBranch = this.theme.generateMainBranch), this.theme.generateSubBranch !== void 0 && (this.generateSubBranch = this.theme.generateSubBranch);
919
928
  const o = {
920
- ...(t.type === "dark" ? et : tt).cssVar,
921
- ...t.cssVar
929
+ ...(this.theme.type === "dark" ? et : Y).cssVar,
930
+ ...this.theme.cssVar
922
931
  };
923
932
  this.compact && (o["--node-gap-x"] = "15px", o["--node-gap-y"] = "2px", o["--main-gap-x"] = "30px", o["--main-gap-y"] = "6px");
924
933
  const s = Object.keys(o);
@@ -974,9 +983,9 @@ function kt(t, e, n, o, s, i, r, c) {
974
983
  };
975
984
  }
976
985
  function _e(t, e, n) {
977
- t && (t.dataset.x = e.toString(), t.dataset.y = n.toString(), U(t));
986
+ t && (t.dataset.x = e.toString(), t.dataset.y = n.toString(), K(t));
978
987
  }
979
- function V(t, e, n, o, s) {
988
+ function z(t, e, n, o, s) {
980
989
  D(t, {
981
990
  x1: e + "",
982
991
  y1: n + "",
@@ -992,7 +1001,7 @@ function mt(t, e, n, o, s, i, r, c, l, a) {
992
1001
  }
993
1002
  const d = t.querySelectorAll('path[stroke="transparent"]');
994
1003
  d.length > 0 && d[0].setAttribute("d", f);
995
- const p = _(i, r, c, l);
1004
+ const p = q(i, r, c, l);
996
1005
  if (p) {
997
1006
  const u = `M ${p.x1} ${p.y1} L ${c} ${l} L ${p.x2} ${p.y2}`;
998
1007
  if (t.arrow1.setAttribute("d", u), d.length > 1 && d[1].setAttribute("d", u), a.style) {
@@ -1001,7 +1010,7 @@ function mt(t, e, n, o, s, i, r, c, l, a) {
1001
1010
  }
1002
1011
  }
1003
1012
  if (a.bidirectional) {
1004
- const u = _(o, s, e, n);
1013
+ const u = q(o, s, e, n);
1005
1014
  if (u) {
1006
1015
  const g = `M ${u.x1} ${u.y1} L ${e} ${n} L ${u.x2} ${u.y2}`;
1007
1016
  if (t.arrow2.setAttribute("d", g), d.length > 2 && d[2].setAttribute("d", g), a.style) {
@@ -1017,7 +1026,7 @@ function mt(t, e, n, o, s, i, r, c, l, a) {
1017
1026
  }
1018
1027
  tn(t);
1019
1028
  }
1020
- function q(t, e, n) {
1029
+ function j(t, e, n) {
1021
1030
  const { offsetLeft: o, offsetTop: s } = P(t.nodes, e), i = e.offsetWidth, r = e.offsetHeight, c = o + i / 2, l = s + r / 2, a = c + n.x, f = l + n.y;
1022
1031
  return {
1023
1032
  w: i,
@@ -1063,27 +1072,27 @@ const qe = function(t, e, n) {
1063
1072
  const S = qe(t, e, n);
1064
1073
  o.delta1 = S.delta1, o.delta2 = S.delta2;
1065
1074
  }
1066
- const i = q(t, e, o.delta1), r = q(t, n, o.delta2), { x: c, y: l } = I(i), { ctrlX: a, ctrlY: f } = i, { ctrlX: d, ctrlY: p } = r, { x: w, y } = I(r), u = _(d, p, w, y);
1075
+ const i = j(t, e, o.delta1), r = j(t, n, o.delta2), { x: c, y: l } = I(i), { ctrlX: a, ctrlY: f } = i, { ctrlX: d, ctrlY: p } = r, { x: w, y } = I(r), u = q(d, p, w, y);
1067
1076
  if (!u) return;
1068
1077
  const g = `M ${u.x1} ${u.y1} L ${w} ${y} L ${u.x2} ${u.y2}`;
1069
1078
  let b = "";
1070
1079
  if (o.bidirectional) {
1071
- const S = _(a, f, c, l);
1080
+ const S = q(a, f, c, l);
1072
1081
  if (!S) return;
1073
1082
  b = `M ${S.x1} ${S.y1} L ${c} ${l} L ${S.x2} ${S.y2}`;
1074
1083
  }
1075
1084
  const v = ke(`M ${c} ${l} C ${a} ${f} ${d} ${p} ${w} ${y}`, g, b, o.style), { x: C, y: T } = kt(c, l, a, f, d, p, w, y), h = o.style?.labelColor || "rgb(235, 95, 82)", m = "a-" + o.id;
1076
1085
  v.id = m;
1077
- const x = t.markdown ? t.markdown(o.label, o) : o.label, E = Q(x, C, T, {
1086
+ const x = t.markdown ? t.markdown(o.label, o) : o.label, E = tt(x, C, T, {
1078
1087
  anchor: "middle",
1079
1088
  color: h,
1080
1089
  dataType: "arrow",
1081
1090
  svgId: m
1082
1091
  });
1083
- v.labelEl = E, v.arrowObj = o, v.dataset.linkid = o.id, t.labelContainer.appendChild(E), t.arrowSvg.appendChild(v), U(E), s || (t.arrows.push(o), t.currentArrow = v, At(t, o, i, r));
1092
+ v.labelEl = E, v.arrowObj = o, v.dataset.linkid = o.id, t.labelContainer.appendChild(E), t.arrowSvg.appendChild(v), K(E), s || (t.arrows.push(o), t.currentArrow = v, At(t, o, i, r));
1084
1093
  }, je = function(t, e, n = {}) {
1085
1094
  const o = {
1086
- id: Y(),
1095
+ id: R(),
1087
1096
  label: "Custom Link",
1088
1097
  from: t.nodeObj.id,
1089
1098
  to: e.nodeObj.id,
@@ -1094,8 +1103,8 @@ const qe = function(t, e, n) {
1094
1103
  obj: o
1095
1104
  });
1096
1105
  }, Ue = function(t) {
1097
- K(this);
1098
- const e = { ...t, id: Y() };
1106
+ J(this);
1107
+ const e = { ...t, id: R() };
1099
1108
  it(this, this.findEle(e.from), this.findEle(e.to), e), this.bus.fire("operation", {
1100
1109
  name: "createArrow",
1101
1110
  obj: e
@@ -1103,7 +1112,7 @@ const qe = function(t, e, n) {
1103
1112
  }, Ke = function(t) {
1104
1113
  let e;
1105
1114
  if (t ? e = t : e = this.currentArrow, !e) return;
1106
- K(this);
1115
+ J(this);
1107
1116
  const n = e.arrowObj.id;
1108
1117
  this.arrows = this.arrows.filter((o) => o.id !== n), e.labelEl?.remove(), e.remove(), this.bus.fire("operation", {
1109
1118
  name: "removeArrow",
@@ -1113,11 +1122,11 @@ const qe = function(t, e, n) {
1113
1122
  });
1114
1123
  }, Je = function(t) {
1115
1124
  this.currentArrow = t;
1116
- const e = t.arrowObj, n = this.findEle(e.from), o = this.findEle(e.to), s = q(this, n, e.delta1), i = q(this, o, e.delta2);
1125
+ const e = t.arrowObj, n = this.findEle(e.from), o = this.findEle(e.to), s = j(this, n, e.delta1), i = j(this, o, e.delta2);
1117
1126
  this.editable ? At(this, e, s, i) : Nt(t, Pt), this.bus.fire("selectArrow", e);
1118
1127
  }, Ze = function() {
1119
- K(this), this.currentArrow = null, this.bus.fire("unselectArrow");
1120
- }, Z = function(t, e) {
1128
+ J(this), this.currentArrow = null, this.bus.fire("unselectArrow");
1129
+ }, Q = function(t, e) {
1121
1130
  const n = document.createElementNS(k, "path");
1122
1131
  return D(n, {
1123
1132
  d: t,
@@ -1130,11 +1139,11 @@ const qe = function(t, e, n) {
1130
1139
  }, Nt = function(t, e) {
1131
1140
  const n = document.createElementNS(k, "g");
1132
1141
  n.setAttribute("class", "arrow-highlight"), n.setAttribute("opacity", "0.45");
1133
- const o = Z(t.line.getAttribute("d"), e);
1142
+ const o = Q(t.line.getAttribute("d"), e);
1134
1143
  n.appendChild(o);
1135
- const s = Z(t.arrow1.getAttribute("d"), e);
1144
+ const s = Q(t.arrow1.getAttribute("d"), e);
1136
1145
  if (n.appendChild(s), t.arrow2.getAttribute("d")) {
1137
- const i = Z(t.arrow2.getAttribute("d"), e);
1146
+ const i = Q(t.arrow2.getAttribute("d"), e);
1138
1147
  n.appendChild(i);
1139
1148
  }
1140
1149
  t.insertBefore(n, t.firstChild);
@@ -1146,21 +1155,21 @@ const qe = function(t, e, n) {
1146
1155
  if (!e) return;
1147
1156
  const n = e.querySelectorAll("path");
1148
1157
  n.length >= 1 && n[0].setAttribute("d", t.line.getAttribute("d")), n.length >= 2 && n[1].setAttribute("d", t.arrow1.getAttribute("d")), n.length >= 3 && t.arrow2.getAttribute("d") && n[2].setAttribute("d", t.arrow2.getAttribute("d"));
1149
- }, K = function(t) {
1158
+ }, J = function(t) {
1150
1159
  t.helper1?.destroy(), t.helper2?.destroy(), t.linkController.style.display = "none", t.P2.style.display = "none", t.P3.style.display = "none", t.currentArrow && Qe(t.currentArrow);
1151
1160
  }, At = function(t, e, n, o) {
1152
1161
  const { linkController: s, P2: i, P3: r, line1: c, line2: l, nodes: a, map: f, currentArrow: d, bus: p } = t;
1153
1162
  if (!d) return;
1154
1163
  s.style.display = "initial", i.style.display = "initial", r.style.display = "initial", a.appendChild(s), a.appendChild(i), a.appendChild(r), Nt(d, Pt);
1155
1164
  let { x: w, y } = I(n), { ctrlX: u, ctrlY: g } = n, { ctrlX: b, ctrlY: v } = o, { x: C, y: T } = I(o);
1156
- i.style.cssText = `top:${g}px;left:${u}px;`, r.style.cssText = `top:${v}px;left:${b}px;`, V(c, w, y, u, g), V(l, b, v, C, T), t.helper1 = gt.create(i), t.helper2 = gt.create(r), t.helper1.init(f, (h, m) => {
1165
+ i.style.cssText = `top:${g}px;left:${u}px;`, r.style.cssText = `top:${v}px;left:${b}px;`, z(c, w, y, u, g), z(l, b, v, C, T), t.helper1 = gt.create(i), t.helper2 = gt.create(r), t.helper1.init(f, (h, m) => {
1157
1166
  u = u + h / t.scaleVal, g = g + m / t.scaleVal;
1158
1167
  const x = I({ ...n, ctrlX: u, ctrlY: g });
1159
- w = x.x, y = x.y, i.style.top = g + "px", i.style.left = u + "px", mt(d, w, y, u, g, b, v, C, T, e), V(c, w, y, u, g), e.delta1.x = Math.round(u - n.cx), e.delta1.y = Math.round(g - n.cy), p.fire("updateArrowDelta", e);
1168
+ w = x.x, y = x.y, i.style.top = g + "px", i.style.left = u + "px", mt(d, w, y, u, g, b, v, C, T, e), z(c, w, y, u, g), e.delta1.x = Math.round(u - n.cx), e.delta1.y = Math.round(g - n.cy), p.fire("updateArrowDelta", e);
1160
1169
  }), t.helper2.init(f, (h, m) => {
1161
1170
  b = b + h / t.scaleVal, v = v + m / t.scaleVal;
1162
1171
  const x = I({ ...o, ctrlX: b, ctrlY: v });
1163
- C = x.x, T = x.y, r.style.top = v + "px", r.style.left = b + "px", mt(d, w, y, u, g, b, v, C, T, e), V(l, b, v, C, T), e.delta2.x = Math.round(b - o.cx), e.delta2.y = Math.round(v - o.cy), p.fire("updateArrowDelta", e);
1172
+ C = x.x, T = x.y, r.style.top = v + "px", r.style.left = b + "px", mt(d, w, y, u, g, b, v, C, T, e), z(l, b, v, C, T), e.delta2.x = Math.round(b - o.cx), e.delta2.y = Math.round(v - o.cy), p.fire("updateArrowDelta", e);
1164
1173
  });
1165
1174
  };
1166
1175
  function en() {
@@ -1175,10 +1184,10 @@ function en() {
1175
1184
  this.nodes.appendChild(this.arrowSvg);
1176
1185
  }
1177
1186
  function nn(t) {
1178
- K(this), t && t.labelEl && Lt(this, t.labelEl, t.arrowObj);
1187
+ J(this), t && t.labelEl && Lt(this, t.labelEl, t.arrowObj);
1179
1188
  }
1180
1189
  function on() {
1181
- this.arrows = this.arrows.filter((t) => G(t.from, this.nodeData) && G(t.to, this.nodeData));
1190
+ this.arrows = this.arrows.filter((t) => _(t.from, this.nodeData) && _(t.to, this.nodeData));
1182
1191
  }
1183
1192
  const sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1184
1193
  __proto__: null,
@@ -1250,23 +1259,23 @@ const sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1250
1259
  const ct = p.children?.[B];
1251
1260
  if (!ct)
1252
1261
  return t.removeSummary(n), null;
1253
- const R = ln(t.findEle(ct.id)), { offsetLeft: X, offsetTop: lt } = P(l, R), at = i === r ? 10 : 20;
1254
- B === i && (g = lt + at), B === r && (b = lt + R.offsetHeight - at), X < y && (y = X), R.offsetWidth + X > u && (u = R.offsetWidth + X);
1262
+ const X = ln(t.findEle(ct.id)), { offsetLeft: V, offsetTop: lt } = P(l, X), at = i === r ? 10 : 20;
1263
+ B === i && (g = lt + at), B === r && (b = lt + X.offsetHeight - at), V < y && (y = V), X.offsetWidth + V > u && (u = X.offsetWidth + V);
1255
1264
  }
1256
1265
  let v, C;
1257
1266
  const T = p.parent ? 10 : 0, h = g + T, m = b + T, x = (h + m) / 2, E = c?.stroke || a.cssVar["--color"], S = c?.labelColor || a.cssVar["--color"], M = "s-" + n, N = t.markdown ? t.markdown(o, e) : o;
1258
- w === O.LHS ? (v = yt(`M ${y + 10} ${h} c -5 0 -10 5 -10 10 L ${y} ${m - 10} c 0 5 5 10 10 10 M ${y} ${x} h -10`, E), C = Q(N, y - 20, x, { anchor: "end", color: S, dataType: "summary", svgId: M })) : (v = yt(`M ${u - 10} ${h} c 5 0 10 5 10 10 L ${u} ${m - 10} c 0 5 -5 10 -10 10 M ${u} ${x} h 10`, E), C = Q(N, u + 20, x, { anchor: "start", color: S, dataType: "summary", svgId: M }));
1267
+ w === O.LHS ? (v = yt(`M ${y + 10} ${h} c -5 0 -10 5 -10 10 L ${y} ${m - 10} c 0 5 5 10 10 10 M ${y} ${x} h -10`, E), C = tt(N, y - 20, x, { anchor: "end", color: S, dataType: "summary", svgId: M })) : (v = yt(`M ${u - 10} ${h} c 5 0 10 5 10 10 L ${u} ${m - 10} c 0 5 -5 10 -10 10 M ${u} ${x} h 10`, E), C = tt(N, u + 20, x, { anchor: "start", color: S, dataType: "summary", svgId: M }));
1259
1268
  const $ = cn(M);
1260
- return $.appendChild(v), t.labelContainer.appendChild(C), U(C), $.summaryObj = e, $.labelEl = C, f.appendChild($), $;
1269
+ return $.appendChild(v), t.labelContainer.appendChild(C), K(C), $.summaryObj = e, $.labelEl = C, f.appendChild($), $;
1261
1270
  }, hn = function(t = {}) {
1262
1271
  if (!this.currentNodes) return;
1263
- const { currentNodes: e, summaries: n, bus: o } = this, { parent: s, start: i, end: r } = rn(e), c = { id: Y(), parent: s, start: i, end: r, label: "summary", style: t.style }, l = rt(this, c);
1272
+ const { currentNodes: e, summaries: n, bus: o } = this, { parent: s, start: i, end: r } = rn(e), c = { id: R(), parent: s, start: i, end: r, label: "summary", style: t.style }, l = rt(this, c);
1264
1273
  n.push(c), this.editSummary(l), o.fire("operation", {
1265
1274
  name: "createSummary",
1266
1275
  obj: c
1267
1276
  });
1268
1277
  }, dn = function(t) {
1269
- const e = Y(), n = { ...t, id: e };
1278
+ const e = R(), n = { ...t, id: e };
1270
1279
  rt(this, n), this.summaries.push(n), this.bus.fire("operation", {
1271
1280
  name: "createSummary",
1272
1281
  obj: n
@@ -1360,7 +1369,7 @@ function Cn(t, e) {
1360
1369
  "stroke-width": n.borderWidth
1361
1370
  }), i;
1362
1371
  }
1363
- function z(t, e, n = !1) {
1372
+ function F(t, e, n = !1) {
1364
1373
  const o = getComputedStyle(e), { offsetLeft: s, offsetTop: i } = P(t.nodes, e), r = document.createElementNS(L, "rect");
1365
1374
  D(r, {
1366
1375
  x: s + "",
@@ -1400,8 +1409,8 @@ function En(t, e) {
1400
1409
  href: e.src
1401
1410
  }), i;
1402
1411
  }
1403
- const F = 100, Tn = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">', Dn = (t, e = !1) => {
1404
- const n = t.nodes, o = n.offsetHeight + F * 2, s = n.offsetWidth + F * 2, i = wn(o + "px", s + "px"), r = document.createElementNS(L, "svg"), c = document.createElementNS(L, "rect");
1412
+ const G = 100, Tn = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">', Dn = (t, e = !1) => {
1413
+ const n = t.nodes, o = n.offsetHeight + G * 2, s = n.offsetWidth + G * 2, i = wn(o + "px", s + "px"), r = document.createElementNS(L, "svg"), c = document.createElementNS(L, "rect");
1405
1414
  D(c, {
1406
1415
  x: "0",
1407
1416
  y: "0",
@@ -1418,18 +1427,18 @@ const F = 100, Tn = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "
1418
1427
  a && r.appendChild(a);
1419
1428
  const f = n.querySelector(".summary")?.cloneNode(!0);
1420
1429
  return f && r.appendChild(f), n.querySelectorAll("me-tpc").forEach((d) => {
1421
- d.nodeObj.dangerouslySetInnerHTML ? r.appendChild(z(t, d, !e)) : (r.appendChild(Cn(t, d)), r.appendChild(z(t, d.text, !e)));
1430
+ d.nodeObj.dangerouslySetInnerHTML ? r.appendChild(F(t, d, !e)) : (r.appendChild(Cn(t, d)), r.appendChild(F(t, d.text, !e)));
1422
1431
  }), n.querySelectorAll(".tags > span").forEach((d) => {
1423
- r.appendChild(z(t, d));
1432
+ r.appendChild(F(t, d));
1424
1433
  }), n.querySelectorAll(".icons > span").forEach((d) => {
1425
- r.appendChild(z(t, d));
1434
+ r.appendChild(F(t, d));
1426
1435
  }), n.querySelectorAll(".hyper-link").forEach((d) => {
1427
1436
  r.appendChild(Sn(t, d));
1428
1437
  }), n.querySelectorAll("img").forEach((d) => {
1429
1438
  r.appendChild(En(t, d));
1430
1439
  }), D(r, {
1431
- x: F + "",
1432
- y: F + "",
1440
+ x: G + "",
1441
+ y: G + "",
1433
1442
  overflow: "visible"
1434
1443
  }), i.appendChild(r), i;
1435
1444
  }, Ln = (t, e) => (e && t.insertAdjacentHTML("afterbegin", "<style>" + e + "</style>"), Tn + t.outerHTML);
@@ -1460,7 +1469,7 @@ const Pn = function(t = !1, e) {
1460
1469
  exportPng: kn,
1461
1470
  exportSvg: Pn
1462
1471
  }, Symbol.toStringTag, { value: "Module" })), An = {}, $n = {
1463
- getObjById: G,
1472
+ getObjById: _,
1464
1473
  generateNewObj: Ht,
1465
1474
  layout: Vt,
1466
1475
  linkDiv: Ne,
@@ -1479,7 +1488,7 @@ const Pn = function(t = !1, e) {
1479
1488
  ...Nn,
1480
1489
  init(t) {
1481
1490
  if (t = JSON.parse(JSON.stringify(t)), !t || !t.nodeData) return new Error("MindElixir: `data` is required");
1482
- t.direction !== void 0 && (this.direction = t.direction), this.changeTheme(t.theme || this.theme, !1), this.nodeData = t.nodeData, nt(this.nodeData), this.arrows = t.arrows || [], this.summaries = t.summaries || [], this.tidyArrow(), this.toolBar && Ve(this), this.layout(), this.linkDiv(), this.toCenter();
1491
+ t.direction !== void 0 && (this.direction = t.direction), t.compact !== void 0 && (this.compact = t.compact), this.changeTheme(t.theme || this.theme, !1), t.meta && (this.meta = t.meta), this.nodeData = t.nodeData, nt(this.nodeData), this.arrows = t.arrows || [], this.summaries = t.summaries || [], this.tidyArrow(), this.toolBar && Ve(this), this.layout(), this.linkDiv(), this.toCenter();
1483
1492
  },
1484
1493
  destroy() {
1485
1494
  this.disposable.forEach((t) => t()), this.el && (this.el.innerHTML = ""), this.el = void 0, this.nodeData = void 0, this.arrows = void 0, this.summaries = void 0, this.currentArrow = void 0, this.currentNodes = void 0, this.currentSummary = void 0, this.theme = void 0, this.direction = void 0, this.bus = void 0, this.container = void 0, this.map = void 0, this.lines = void 0, this.linkController = void 0, this.arrowSvg = void 0, this.P2 = void 0, this.P3 = void 0, this.line1 = void 0, this.line2 = void 0, this.nodes = void 0, this.selection?.destroy(), this.selection = void 0;
@@ -1509,7 +1518,7 @@ function In({ pT: t, pL: e, pW: n, pH: o, cT: s, cL: i, cW: r, cH: c, direction:
1509
1518
  const b = Math.abs(d - w) / 300 * f;
1510
1519
  return l === O.LHS ? (g = e, y = g + f, u = g - f, p = i + f, `M ${y} ${d} C ${g} ${d} ${g + b} ${w} ${u} ${w} H ${p}`) : (g = e + n, y = g - f, u = g + f, p = i + r - f, `M ${y} ${d} C ${g} ${d} ${g - b} ${w} ${u} ${w} H ${p}`);
1511
1520
  }
1512
- const On = "5.12.0";
1521
+ const On = "5.12.2-beta.0";
1513
1522
  function Bn(t) {
1514
1523
  return {
1515
1524
  x: 0,
@@ -1569,7 +1578,7 @@ function A({
1569
1578
  if (M === "[object HTMLDivElement]" ? S = t : M === "[object String]" && (S = document.querySelector(t)), !S) throw new Error("MindElixir: el is not a valid element");
1570
1579
  S.style.position = "relative", S.innerHTML = "", this.el = S, this.disposable = [], this.before = l || {}, this.newTopicName = a || "New Node", this.contextMenu = o ?? !0, this.toolBar = s ?? !0, this.keypress = i ?? !0, this.mouseSelectionButton = r ?? 0, this.direction = e ?? 1, this.editable = n ?? !0, this.allowUndo = f ?? !0, this.scaleSensitivity = b ?? 0.1, this.scaleMax = v ?? 1.4, this.scaleMin = C ?? 0.2, this.generateMainBranch = d || Hn, this.generateSubBranch = p || In, this.overflowHidden = w ?? !1, this.compact = y ?? !1, this.alignment = g ?? "root", this.handleWheel = T ?? !0, this.markdown = h || void 0, this.imageProxy = m || void 0, this.currentNodes = [], this.currentArrow = null, this.scaleVal = 1, this.tempDirection = null, this.mobileMultiSelect = E ?? !1, this.panHelper = Bn(this), this.bus = Pe(), this.container = document.createElement("div"), this.selectionContainer = c || this.container, this.container.className = "map-container";
1571
1580
  const N = window.matchMedia("(prefers-color-scheme: dark)");
1572
- this.theme = u || (N.matches ? et : tt);
1581
+ this.theme = u || (N.matches ? et : Y);
1573
1582
  const $ = document.createElement("div");
1574
1583
  $.className = "map-canvas", this.map = $, this.container.setAttribute("tabindex", "0"), this.container.appendChild(this.map), this.el.appendChild(this.container), this.nodes = document.createElement("me-nodes"), this.lines = W("lines"), this.summarySvg = W("summary"), this.linkController = W("linkcontroller"), this.P2 = document.createElement("div"), this.P3 = document.createElement("div"), this.P2.className = this.P3.className = "circle", this.P2.style.display = this.P3.style.display = "none", this.line1 = pt(), this.line2 = pt(), this.linkController.appendChild(this.line1), this.linkController.appendChild(this.line2), this.arrowSvg = W("topiclinks"), this.labelContainer = document.createElement("div"), this.labelContainer.className = "label-container", this.map.appendChild(this.nodes), this.overflowHidden ? this.container.style.overflow = "hidden" : this.disposable.push(Me(this)), x && (this.pasteHandler = x);
1575
1584
  }
@@ -1583,7 +1592,7 @@ Object.defineProperty(A.prototype, "currentNode", {
1583
1592
  A.LEFT = 0;
1584
1593
  A.RIGHT = 1;
1585
1594
  A.SIDE = 2;
1586
- A.THEME = tt;
1595
+ A.THEME = Y;
1587
1596
  A.DARK_THEME = et;
1588
1597
  A.version = On;
1589
1598
  A.E = Ct;
@@ -1592,6 +1601,6 @@ export {
1592
1601
  Wn as LEFT,
1593
1602
  Yn as RIGHT,
1594
1603
  Rn as SIDE,
1595
- tt as THEME,
1604
+ Y as THEME,
1596
1605
  A as default
1597
1606
  };
package/dist/example.js CHANGED
@@ -310,6 +310,7 @@ const e = {
310
310
  children: [
311
311
  {
312
312
  topic: `Drag a node to another node
313
+
313
314
  and the former one will become a child node of latter one`,
314
315
  id: "bd1f07c598e729dc"
315
316
  }
@@ -0,0 +1,8 @@
1
+ import type { MainLineParams, SubLineParams } from './utils/generateBranch';
2
+ import type { MindElixirInstance } from './types/index';
3
+ export declare function markmapMain({ pT, pL, pW, pH, cT, cL, cW, cH, direction }: MainLineParams): string;
4
+ export declare function markmapSub(this: MindElixirInstance, { pT, pL, pW, pH, cT, cL, cW, cH, direction }: SubLineParams): string;
5
+ export declare function straightMain({ pT, pL, pW, pH, cT, cL, cW, cH, direction }: MainLineParams): string;
6
+ export declare function straightSub(this: MindElixirInstance, { pT, pL, pW, pH, cT, cL, cW, cH, direction }: SubLineParams): string;
7
+ export declare function straightUnderlineMain({ pT, pL, pW, pH, cT, cL, cW, cH, direction }: MainLineParams): string;
8
+ export declare function straightUnderlineSub(this: MindElixirInstance, { pT, pL, pW, pH, cT, cL, cW, cH, direction }: SubLineParams): string;
@@ -1 +1,2 @@
1
1
  import 'katex/dist/katex.min.css';
2
+ import '../dev.css';
@@ -48,8 +48,7 @@ declare namespace MindElixir {
48
48
  clearSelection: (this: MindElixirInstance) => void;
49
49
  stringifyData: (data: object) => string;
50
50
  getDataString: (this: MindElixirInstance) => string;
51
- getData: (// infrastructure
52
- this: MindElixirInstance) => MindElixirData;
51
+ getData: (this: MindElixirInstance) => MindElixirData;
53
52
  enableEdit: (this: MindElixirInstance) => void;
54
53
  disableEdit: (this: MindElixirInstance) => void;
55
54
  scale: (this: MindElixirInstance, scaleVal: number, offset?: {
@@ -85,7 +84,7 @@ declare namespace MindElixir {
85
84
  createChildren: (this: MindElixirInstance, wrappers: import("./docs").Wrapper[]) => import("./docs").Children;
86
85
  createTopic: (this: MindElixirInstance, nodeObj: import("./docs").NodeObj) => Topic;
87
86
  findEle: (this: MindElixirInstance, id: string, el?: HTMLElement) => Topic;
88
- changeTheme: (this: MindElixirInstance, theme: import("./docs").Theme, shouldRefresh?: boolean) => void;
87
+ changeTheme: (this: MindElixirInstance, theme: Partial<import("./docs").Theme>, shouldRefresh?: boolean) => void;
89
88
  changeCompact: (this: MindElixirInstance, compact: boolean) => void;
90
89
  };
91
90
  export var LEFT: number;
@@ -60,12 +60,7 @@ declare const methods: {
60
60
  getData: (this: MindElixirInstance) => MindElixirData;
61
61
  enableEdit: (this: MindElixirInstance) => void;
62
62
  disableEdit: (this: MindElixirInstance) => void;
63
- scale: (this: MindElixirInstance,
64
- /**
65
- * @public
66
- * @param {boolean} enable
67
- */
68
- scaleVal: number, offset?: {
63
+ scale: (this: MindElixirInstance, scaleVal: number, offset?: {
69
64
  x: number;
70
65
  y: number;
71
66
  }) => void;
@@ -98,7 +93,7 @@ declare const methods: {
98
93
  createChildren: (this: MindElixirInstance, wrappers: import("./docs").Wrapper[]) => import("./docs").Children;
99
94
  createTopic: (this: MindElixirInstance, nodeObj: import("./types").NodeObj) => import("./docs").Topic;
100
95
  findEle: (this: MindElixirInstance, id: string, el?: HTMLElement) => import("./docs").Topic;
101
- changeTheme: (this: MindElixirInstance, theme: import("./types").Theme, shouldRefresh?: boolean) => void;
96
+ changeTheme: (this: MindElixirInstance, theme: Partial<import("./types").Theme>, shouldRefresh?: boolean) => void;
102
97
  changeCompact: (this: MindElixirInstance, compact: boolean) => void;
103
98
  };
104
99
  export default methods;
@@ -17,6 +17,35 @@ export type DirectionClass = (typeof DirectionClass)[keyof typeof DirectionClass
17
17
  type Before = Partial<{
18
18
  [K in Operations]: (...args: Parameters<OperationMap[K]>) => Promise<boolean> | boolean;
19
19
  }>;
20
+ /**
21
+ * MindElixir Theme
22
+ *
23
+ * @public
24
+ */
25
+ export type ThemeCssVar = {
26
+ '--node-gap-x': string;
27
+ '--node-gap-y': string;
28
+ '--main-gap-x': string;
29
+ '--main-gap-y': string;
30
+ '--main-color': string;
31
+ '--main-bgcolor': string;
32
+ '--main-bgcolor-transparent': string;
33
+ '--main-border'?: string;
34
+ '--color': string;
35
+ '--bgcolor': string;
36
+ '--selected': string;
37
+ '--accent-color': string;
38
+ '--root-color': string;
39
+ '--root-bgcolor': string;
40
+ '--root-border-color': string;
41
+ '--root-radius': string;
42
+ '--main-radius': string;
43
+ '--topic-padding': string;
44
+ '--panel-color': string;
45
+ '--panel-bgcolor': string;
46
+ '--panel-border-color': string;
47
+ '--map-padding': string;
48
+ };
20
49
  /**
21
50
  * MindElixir Theme
22
51
  *
@@ -32,29 +61,9 @@ export type Theme = {
32
61
  * Color palette for main branches
33
62
  */
34
63
  palette: string[];
35
- cssVar: {
36
- '--node-gap-x': string;
37
- '--node-gap-y': string;
38
- '--main-gap-x': string;
39
- '--main-gap-y': string;
40
- '--main-color': string;
41
- '--main-bgcolor': string;
42
- '--main-bgcolor-transparent': string;
43
- '--color': string;
44
- '--bgcolor': string;
45
- '--selected': string;
46
- '--accent-color': string;
47
- '--root-color': string;
48
- '--root-bgcolor': string;
49
- '--root-border-color': string;
50
- '--root-radius': string;
51
- '--main-radius': string;
52
- '--topic-padding': string;
53
- '--panel-color': string;
54
- '--panel-bgcolor': string;
55
- '--panel-border-color': string;
56
- '--map-padding': string;
57
- };
64
+ cssVar?: Partial<ThemeCssVar>;
65
+ generateMainBranch?: (this: MindElixirInstance, params: MainLineParams) => string;
66
+ generateSubBranch?: (this: MindElixirInstance, params: SubLineParams) => string;
58
67
  };
59
68
  export type Alignment = 'root' | 'nodes';
60
69
  export interface KeypressOptions {
@@ -65,7 +74,10 @@ export interface KeypressOptions {
65
74
  *
66
75
  * @public
67
76
  */
68
- export interface MindElixirInstance extends Omit<Required<Options>, 'markdown' | 'imageProxy'>, MindElixirMethods {
77
+ export interface MindElixirInstance extends Omit<Required<Options>, 'markdown' | 'imageProxy' | 'theme'>, MindElixirMethods {
78
+ theme: Omit<Theme, 'cssVar'> & {
79
+ cssVar: ThemeCssVar;
80
+ };
69
81
  markdown?: (markdown: string, obj: NodeObj | Arrow | Summary) => string;
70
82
  imageProxy?: (url: string) => string;
71
83
  dragged: Topic[] | null;
@@ -83,6 +95,7 @@ export interface MindElixirInstance extends Omit<Required<Options>, 'markdown' |
83
95
  currentArrow: ArrowSvg | null;
84
96
  scaleVal: number;
85
97
  tempDirection: 0 | 1 | 2 | null;
98
+ meta?: Record<string, any>;
86
99
  container: HTMLElement;
87
100
  map: HTMLElement;
88
101
  root: HTMLElement;
@@ -264,4 +277,9 @@ export type MindElixirData = {
264
277
  summaries?: Summary[];
265
278
  direction?: 0 | 1 | 2;
266
279
  theme?: Theme;
280
+ compact?: boolean;
281
+ /**
282
+ * Extension fields to store arbitrary metadata for the map.
283
+ */
284
+ meta?: Record<string, any>;
267
285
  };
@@ -1,4 +1,4 @@
1
1
  import type { MindElixirInstance } from '../types/index';
2
2
  import type { Theme } from '../types/index';
3
- export declare const changeTheme: (this: MindElixirInstance, theme: Theme, shouldRefresh?: boolean) => void;
3
+ export declare const changeTheme: (this: MindElixirInstance, theme: Partial<Theme>, shouldRefresh?: boolean) => void;
4
4
  export declare const changeCompact: (this: MindElixirInstance, compact: boolean) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mind-elixir",
3
- "version": "5.12.0",
3
+ "version": "5.12.2-beta.0",
4
4
  "type": "module",
5
5
  "description": "Mind elixir is a free open source mind map core.",
6
6
  "keywords": [
@@ -103,4 +103,4 @@
103
103
  "vite": "^7.1.7",
104
104
  "vite-plugin-istanbul": "^7.2.0"
105
105
  }
106
- }
106
+ }