mind-elixir 5.12.1 → 5.12.2-beta.1

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 = {
@@ -383,7 +383,8 @@ function Zt(t) {
383
383
  summaries: t.summaries,
384
384
  direction: t.direction,
385
385
  theme: t.theme,
386
- compact: t.compact
386
+ compact: t.compact,
387
+ meta: t.meta
387
388
  };
388
389
  }
389
390
  const Qt = function(t, e = !1) {
@@ -498,7 +499,7 @@ const Qt = function(t, e = !1) {
498
499
  }, c = s.x - r.x, l = s.y - r.y;
499
500
  this.move(c, l);
500
501
  }, be = function(t) {
501
- 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();
502
503
  }, xe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
503
504
  __proto__: null,
504
505
  cancelFocus: pe,
@@ -645,7 +646,7 @@ function Me(t) {
645
646
  }, d = (h) => {
646
647
  if (!t.editable) return;
647
648
  const m = h.target;
648
- if (J(m)) {
649
+ if (Z(m)) {
649
650
  t.selectNode(m), t.beginEdit(m);
650
651
  return;
651
652
  }
@@ -662,7 +663,7 @@ function Me(t) {
662
663
  return;
663
664
  }
664
665
  if (e.handlePointerDown(h), e.mousedown && (t.ptState = i.Pan), h.button === 0 || h.pointerType === "touch")
665
- if (J(m)) {
666
+ if (Z(m)) {
666
667
  t.selection?.cancel();
667
668
  const E = t.currentNodes || [];
668
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;
@@ -707,7 +708,7 @@ function Me(t) {
707
708
  h.preventDefault(), h.button === 2 && t.editable && setTimeout(() => {
708
709
  if (t.panHelper.moved || t.ptState !== i.Idle && t.ptState !== i.Pan) return;
709
710
  const m = h.target;
710
- 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);
711
712
  }, 200);
712
713
  }, b = (h) => {
713
714
  if (h.stopPropagation(), h.preventDefault(), h.ctrlKey || h.metaKey) return Le(t, h);
@@ -755,11 +756,11 @@ function Pe() {
755
756
  }
756
757
  };
757
758
  }
758
- const k = "http://www.w3.org/2000/svg", U = function(t) {
759
+ const k = "http://www.w3.org/2000/svg", K = function(t) {
759
760
  const e = t.clientWidth, n = t.clientHeight, o = t.dataset, s = Number(o.x), i = Number(o.y), r = o.anchor;
760
761
  let c = s;
761
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";
762
- }, Q = function(t, e, n, o) {
763
+ }, tt = function(t, e, n, o) {
763
764
  const { anchor: s = "middle", color: i, dataType: r, svgId: c } = o, l = document.createElement("div");
764
765
  l.className = "svg-label", l.style.color = i || "#666";
765
766
  const a = "label-" + c;
@@ -829,7 +830,7 @@ const k = "http://www.w3.org/2000/svg", U = function(t) {
829
830
  }), s.addEventListener("blur", () => {
830
831
  if (!s) return;
831
832
  const i = s.innerText?.trim() || "";
832
- 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", {
833
834
  name: "finishEditSummary",
834
835
  obj: n
835
836
  }) : t.bus.fire("operation", {
@@ -916,10 +917,17 @@ function Ve(t) {
916
917
  t.container.append(Re(t)), t.container.append(Xe(t));
917
918
  }
918
919
  const ze = function(t, e = !0) {
919
- 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);
920
928
  const o = {
921
- ...(t.type === "dark" ? et : tt).cssVar,
922
- ...t.cssVar
929
+ ...(this.theme.type === "dark" ? et : Y).cssVar,
930
+ ...this.theme.cssVar
923
931
  };
924
932
  this.compact && (o["--node-gap-x"] = "15px", o["--node-gap-y"] = "2px", o["--main-gap-x"] = "30px", o["--main-gap-y"] = "6px");
925
933
  const s = Object.keys(o);
@@ -975,9 +983,9 @@ function kt(t, e, n, o, s, i, r, c) {
975
983
  };
976
984
  }
977
985
  function _e(t, e, n) {
978
- 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));
979
987
  }
980
- function V(t, e, n, o, s) {
988
+ function z(t, e, n, o, s) {
981
989
  D(t, {
982
990
  x1: e + "",
983
991
  y1: n + "",
@@ -993,7 +1001,7 @@ function mt(t, e, n, o, s, i, r, c, l, a) {
993
1001
  }
994
1002
  const d = t.querySelectorAll('path[stroke="transparent"]');
995
1003
  d.length > 0 && d[0].setAttribute("d", f);
996
- const p = _(i, r, c, l);
1004
+ const p = q(i, r, c, l);
997
1005
  if (p) {
998
1006
  const u = `M ${p.x1} ${p.y1} L ${c} ${l} L ${p.x2} ${p.y2}`;
999
1007
  if (t.arrow1.setAttribute("d", u), d.length > 1 && d[1].setAttribute("d", u), a.style) {
@@ -1002,7 +1010,7 @@ function mt(t, e, n, o, s, i, r, c, l, a) {
1002
1010
  }
1003
1011
  }
1004
1012
  if (a.bidirectional) {
1005
- const u = _(o, s, e, n);
1013
+ const u = q(o, s, e, n);
1006
1014
  if (u) {
1007
1015
  const g = `M ${u.x1} ${u.y1} L ${e} ${n} L ${u.x2} ${u.y2}`;
1008
1016
  if (t.arrow2.setAttribute("d", g), d.length > 2 && d[2].setAttribute("d", g), a.style) {
@@ -1018,7 +1026,7 @@ function mt(t, e, n, o, s, i, r, c, l, a) {
1018
1026
  }
1019
1027
  tn(t);
1020
1028
  }
1021
- function q(t, e, n) {
1029
+ function j(t, e, n) {
1022
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;
1023
1031
  return {
1024
1032
  w: i,
@@ -1064,27 +1072,27 @@ const qe = function(t, e, n) {
1064
1072
  const S = qe(t, e, n);
1065
1073
  o.delta1 = S.delta1, o.delta2 = S.delta2;
1066
1074
  }
1067
- 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);
1068
1076
  if (!u) return;
1069
1077
  const g = `M ${u.x1} ${u.y1} L ${w} ${y} L ${u.x2} ${u.y2}`;
1070
1078
  let b = "";
1071
1079
  if (o.bidirectional) {
1072
- const S = _(a, f, c, l);
1080
+ const S = q(a, f, c, l);
1073
1081
  if (!S) return;
1074
1082
  b = `M ${S.x1} ${S.y1} L ${c} ${l} L ${S.x2} ${S.y2}`;
1075
1083
  }
1076
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;
1077
1085
  v.id = m;
1078
- 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, {
1079
1087
  anchor: "middle",
1080
1088
  color: h,
1081
1089
  dataType: "arrow",
1082
1090
  svgId: m
1083
1091
  });
1084
- 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));
1085
1093
  }, je = function(t, e, n = {}) {
1086
1094
  const o = {
1087
- id: Y(),
1095
+ id: R(),
1088
1096
  label: "Custom Link",
1089
1097
  from: t.nodeObj.id,
1090
1098
  to: e.nodeObj.id,
@@ -1095,8 +1103,8 @@ const qe = function(t, e, n) {
1095
1103
  obj: o
1096
1104
  });
1097
1105
  }, Ue = function(t) {
1098
- K(this);
1099
- const e = { ...t, id: Y() };
1106
+ J(this);
1107
+ const e = { ...t, id: R() };
1100
1108
  it(this, this.findEle(e.from), this.findEle(e.to), e), this.bus.fire("operation", {
1101
1109
  name: "createArrow",
1102
1110
  obj: e
@@ -1104,7 +1112,7 @@ const qe = function(t, e, n) {
1104
1112
  }, Ke = function(t) {
1105
1113
  let e;
1106
1114
  if (t ? e = t : e = this.currentArrow, !e) return;
1107
- K(this);
1115
+ J(this);
1108
1116
  const n = e.arrowObj.id;
1109
1117
  this.arrows = this.arrows.filter((o) => o.id !== n), e.labelEl?.remove(), e.remove(), this.bus.fire("operation", {
1110
1118
  name: "removeArrow",
@@ -1114,11 +1122,11 @@ const qe = function(t, e, n) {
1114
1122
  });
1115
1123
  }, Je = function(t) {
1116
1124
  this.currentArrow = t;
1117
- 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);
1118
1126
  this.editable ? At(this, e, s, i) : Nt(t, Pt), this.bus.fire("selectArrow", e);
1119
1127
  }, Ze = function() {
1120
- K(this), this.currentArrow = null, this.bus.fire("unselectArrow");
1121
- }, Z = function(t, e) {
1128
+ J(this), this.currentArrow = null, this.bus.fire("unselectArrow");
1129
+ }, Q = function(t, e) {
1122
1130
  const n = document.createElementNS(k, "path");
1123
1131
  return D(n, {
1124
1132
  d: t,
@@ -1131,11 +1139,11 @@ const qe = function(t, e, n) {
1131
1139
  }, Nt = function(t, e) {
1132
1140
  const n = document.createElementNS(k, "g");
1133
1141
  n.setAttribute("class", "arrow-highlight"), n.setAttribute("opacity", "0.45");
1134
- const o = Z(t.line.getAttribute("d"), e);
1142
+ const o = Q(t.line.getAttribute("d"), e);
1135
1143
  n.appendChild(o);
1136
- const s = Z(t.arrow1.getAttribute("d"), e);
1144
+ const s = Q(t.arrow1.getAttribute("d"), e);
1137
1145
  if (n.appendChild(s), t.arrow2.getAttribute("d")) {
1138
- const i = Z(t.arrow2.getAttribute("d"), e);
1146
+ const i = Q(t.arrow2.getAttribute("d"), e);
1139
1147
  n.appendChild(i);
1140
1148
  }
1141
1149
  t.insertBefore(n, t.firstChild);
@@ -1147,21 +1155,21 @@ const qe = function(t, e, n) {
1147
1155
  if (!e) return;
1148
1156
  const n = e.querySelectorAll("path");
1149
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"));
1150
- }, K = function(t) {
1158
+ }, J = function(t) {
1151
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);
1152
1160
  }, At = function(t, e, n, o) {
1153
1161
  const { linkController: s, P2: i, P3: r, line1: c, line2: l, nodes: a, map: f, currentArrow: d, bus: p } = t;
1154
1162
  if (!d) return;
1155
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);
1156
1164
  let { x: w, y } = I(n), { ctrlX: u, ctrlY: g } = n, { ctrlX: b, ctrlY: v } = o, { x: C, y: T } = I(o);
1157
- 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) => {
1158
1166
  u = u + h / t.scaleVal, g = g + m / t.scaleVal;
1159
1167
  const x = I({ ...n, ctrlX: u, ctrlY: g });
1160
- 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);
1161
1169
  }), t.helper2.init(f, (h, m) => {
1162
1170
  b = b + h / t.scaleVal, v = v + m / t.scaleVal;
1163
1171
  const x = I({ ...o, ctrlX: b, ctrlY: v });
1164
- 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);
1165
1173
  });
1166
1174
  };
1167
1175
  function en() {
@@ -1176,10 +1184,10 @@ function en() {
1176
1184
  this.nodes.appendChild(this.arrowSvg);
1177
1185
  }
1178
1186
  function nn(t) {
1179
- K(this), t && t.labelEl && Lt(this, t.labelEl, t.arrowObj);
1187
+ J(this), t && t.labelEl && Lt(this, t.labelEl, t.arrowObj);
1180
1188
  }
1181
1189
  function on() {
1182
- 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));
1183
1191
  }
1184
1192
  const sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1185
1193
  __proto__: null,
@@ -1251,23 +1259,23 @@ const sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1251
1259
  const ct = p.children?.[B];
1252
1260
  if (!ct)
1253
1261
  return t.removeSummary(n), null;
1254
- const R = ln(t.findEle(ct.id)), { offsetLeft: X, offsetTop: lt } = P(l, R), at = i === r ? 10 : 20;
1255
- 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);
1256
1264
  }
1257
1265
  let v, C;
1258
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;
1259
- 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 }));
1260
1268
  const $ = cn(M);
1261
- 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($), $;
1262
1270
  }, hn = function(t = {}) {
1263
1271
  if (!this.currentNodes) return;
1264
- 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);
1265
1273
  n.push(c), this.editSummary(l), o.fire("operation", {
1266
1274
  name: "createSummary",
1267
1275
  obj: c
1268
1276
  });
1269
1277
  }, dn = function(t) {
1270
- const e = Y(), n = { ...t, id: e };
1278
+ const e = R(), n = { ...t, id: e };
1271
1279
  rt(this, n), this.summaries.push(n), this.bus.fire("operation", {
1272
1280
  name: "createSummary",
1273
1281
  obj: n
@@ -1361,7 +1369,7 @@ function Cn(t, e) {
1361
1369
  "stroke-width": n.borderWidth
1362
1370
  }), i;
1363
1371
  }
1364
- function z(t, e, n = !1) {
1372
+ function F(t, e, n = !1) {
1365
1373
  const o = getComputedStyle(e), { offsetLeft: s, offsetTop: i } = P(t.nodes, e), r = document.createElementNS(L, "rect");
1366
1374
  D(r, {
1367
1375
  x: s + "",
@@ -1401,8 +1409,8 @@ function En(t, e) {
1401
1409
  href: e.src
1402
1410
  }), i;
1403
1411
  }
1404
- 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) => {
1405
- 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");
1406
1414
  D(c, {
1407
1415
  x: "0",
1408
1416
  y: "0",
@@ -1419,18 +1427,18 @@ const F = 100, Tn = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "
1419
1427
  a && r.appendChild(a);
1420
1428
  const f = n.querySelector(".summary")?.cloneNode(!0);
1421
1429
  return f && r.appendChild(f), n.querySelectorAll("me-tpc").forEach((d) => {
1422
- 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)));
1423
1431
  }), n.querySelectorAll(".tags > span").forEach((d) => {
1424
- r.appendChild(z(t, d));
1432
+ r.appendChild(F(t, d));
1425
1433
  }), n.querySelectorAll(".icons > span").forEach((d) => {
1426
- r.appendChild(z(t, d));
1434
+ r.appendChild(F(t, d));
1427
1435
  }), n.querySelectorAll(".hyper-link").forEach((d) => {
1428
1436
  r.appendChild(Sn(t, d));
1429
1437
  }), n.querySelectorAll("img").forEach((d) => {
1430
1438
  r.appendChild(En(t, d));
1431
1439
  }), D(r, {
1432
- x: F + "",
1433
- y: F + "",
1440
+ x: G + "",
1441
+ y: G + "",
1434
1442
  overflow: "visible"
1435
1443
  }), i.appendChild(r), i;
1436
1444
  }, Ln = (t, e) => (e && t.insertAdjacentHTML("afterbegin", "<style>" + e + "</style>"), Tn + t.outerHTML);
@@ -1461,7 +1469,7 @@ const Pn = function(t = !1, e) {
1461
1469
  exportPng: kn,
1462
1470
  exportSvg: Pn
1463
1471
  }, Symbol.toStringTag, { value: "Module" })), An = {}, $n = {
1464
- getObjById: G,
1472
+ getObjById: _,
1465
1473
  generateNewObj: Ht,
1466
1474
  layout: Vt,
1467
1475
  linkDiv: Ne,
@@ -1480,7 +1488,7 @@ const Pn = function(t = !1, e) {
1480
1488
  ...Nn,
1481
1489
  init(t) {
1482
1490
  if (t = JSON.parse(JSON.stringify(t)), !t || !t.nodeData) return new Error("MindElixir: `data` is required");
1483
- t.direction !== void 0 && (this.direction = t.direction), t.compact !== void 0 && (this.compact = t.compact), 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();
1484
1492
  },
1485
1493
  destroy() {
1486
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;
@@ -1510,7 +1518,7 @@ function In({ pT: t, pL: e, pW: n, pH: o, cT: s, cL: i, cW: r, cH: c, direction:
1510
1518
  const b = Math.abs(d - w) / 300 * f;
1511
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}`);
1512
1520
  }
1513
- const On = "5.12.1";
1521
+ const On = "5.12.2-beta.1";
1514
1522
  function Bn(t) {
1515
1523
  return {
1516
1524
  x: 0,
@@ -1570,7 +1578,7 @@ function A({
1570
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");
1571
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";
1572
1580
  const N = window.matchMedia("(prefers-color-scheme: dark)");
1573
- this.theme = u || (N.matches ? et : tt);
1581
+ this.theme = u || (N.matches ? et : Y);
1574
1582
  const $ = document.createElement("div");
1575
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);
1576
1584
  }
@@ -1584,7 +1592,7 @@ Object.defineProperty(A.prototype, "currentNode", {
1584
1592
  A.LEFT = 0;
1585
1593
  A.RIGHT = 1;
1586
1594
  A.SIDE = 2;
1587
- A.THEME = tt;
1595
+ A.THEME = Y;
1588
1596
  A.DARK_THEME = et;
1589
1597
  A.version = On;
1590
1598
  A.E = Ct;
@@ -1593,6 +1601,6 @@ export {
1593
1601
  Wn as LEFT,
1594
1602
  Yn as RIGHT,
1595
1603
  Rn as SIDE,
1596
- tt as THEME,
1604
+ Y as THEME,
1597
1605
  A as default
1598
1606
  };
package/dist/example.js CHANGED
@@ -1,5 +1,4 @@
1
1
  const e = {
2
- compact: !0,
3
2
  nodeData: {
4
3
  id: "me-root",
5
4
  topic: "Mind Elixir",
@@ -311,6 +310,7 @@ const e = {
311
310
  children: [
312
311
  {
313
312
  topic: `Drag a node to another node
313
+
314
314
  and the former one will become a child node of latter one`,
315
315
  id: "bd1f07c598e729dc"
316
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';
@@ -50,8 +50,7 @@ declare namespace MindElixir {
50
50
  getDataString: (this: MindElixirInstance) => string;
51
51
  getData: (this: MindElixirInstance) => MindElixirData;
52
52
  enableEdit: (this: MindElixirInstance) => void;
53
- disableEdit: (// summary container
54
- this: MindElixirInstance) => void;
53
+ disableEdit: (this: MindElixirInstance) => void;
55
54
  scale: (this: MindElixirInstance, scaleVal: number, offset?: {
56
55
  x: number;
57
56
  y: number;
@@ -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;
@@ -93,7 +93,7 @@ declare const methods: {
93
93
  createChildren: (this: MindElixirInstance, wrappers: import("./docs").Wrapper[]) => import("./docs").Children;
94
94
  createTopic: (this: MindElixirInstance, nodeObj: import("./types").NodeObj) => import("./docs").Topic;
95
95
  findEle: (this: MindElixirInstance, id: string, el?: HTMLElement) => import("./docs").Topic;
96
- changeTheme: (this: MindElixirInstance, theme: import("./types").Theme, shouldRefresh?: boolean) => void;
96
+ changeTheme: (this: MindElixirInstance, theme: Partial<import("./types").Theme>, shouldRefresh?: boolean) => void;
97
97
  changeCompact: (this: MindElixirInstance, compact: boolean) => void;
98
98
  };
99
99
  export default methods;
@@ -9,6 +9,7 @@ import type { ContextMenuOption } from '../plugin/contextMenu';
9
9
  import type { createPanHelper } from '../utils/panHelper';
10
10
  import type SelectionArea from '../viselect/src';
11
11
  export { type MindElixirMethods } from '../methods';
12
+ export type { MainLineParams, SubLineParams } from '../utils/generateBranch';
12
13
  export declare const DirectionClass: {
13
14
  readonly LHS: "lhs";
14
15
  readonly RHS: "rhs";
@@ -17,6 +18,35 @@ export type DirectionClass = (typeof DirectionClass)[keyof typeof DirectionClass
17
18
  type Before = Partial<{
18
19
  [K in Operations]: (...args: Parameters<OperationMap[K]>) => Promise<boolean> | boolean;
19
20
  }>;
21
+ /**
22
+ * MindElixir Theme
23
+ *
24
+ * @public
25
+ */
26
+ export type ThemeCssVar = {
27
+ '--node-gap-x': string;
28
+ '--node-gap-y': string;
29
+ '--main-gap-x': string;
30
+ '--main-gap-y': string;
31
+ '--main-color': string;
32
+ '--main-bgcolor': string;
33
+ '--main-bgcolor-transparent': string;
34
+ '--main-border'?: string;
35
+ '--color': string;
36
+ '--bgcolor': string;
37
+ '--selected': string;
38
+ '--accent-color': string;
39
+ '--root-color': string;
40
+ '--root-bgcolor': string;
41
+ '--root-border-color': string;
42
+ '--root-radius': string;
43
+ '--main-radius': string;
44
+ '--topic-padding': string;
45
+ '--panel-color': string;
46
+ '--panel-bgcolor': string;
47
+ '--panel-border-color': string;
48
+ '--map-padding': string;
49
+ };
20
50
  /**
21
51
  * MindElixir Theme
22
52
  *
@@ -32,29 +62,9 @@ export type Theme = {
32
62
  * Color palette for main branches
33
63
  */
34
64
  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
- };
65
+ cssVar?: Partial<ThemeCssVar>;
66
+ generateMainBranch?: (this: MindElixirInstance, params: MainLineParams) => string;
67
+ generateSubBranch?: (this: MindElixirInstance, params: SubLineParams) => string;
58
68
  };
59
69
  export type Alignment = 'root' | 'nodes';
60
70
  export interface KeypressOptions {
@@ -65,7 +75,10 @@ export interface KeypressOptions {
65
75
  *
66
76
  * @public
67
77
  */
68
- export interface MindElixirInstance extends Omit<Required<Options>, 'markdown' | 'imageProxy'>, MindElixirMethods {
78
+ export interface MindElixirInstance extends Omit<Required<Options>, 'markdown' | 'imageProxy' | 'theme'>, MindElixirMethods {
79
+ theme: Omit<Theme, 'cssVar'> & {
80
+ cssVar: ThemeCssVar;
81
+ };
69
82
  markdown?: (markdown: string, obj: NodeObj | Arrow | Summary) => string;
70
83
  imageProxy?: (url: string) => string;
71
84
  dragged: Topic[] | null;
@@ -83,6 +96,7 @@ export interface MindElixirInstance extends Omit<Required<Options>, 'markdown' |
83
96
  currentArrow: ArrowSvg | null;
84
97
  scaleVal: number;
85
98
  tempDirection: 0 | 1 | 2 | null;
99
+ meta?: Record<string, any>;
86
100
  container: HTMLElement;
87
101
  map: HTMLElement;
88
102
  root: HTMLElement;
@@ -265,4 +279,8 @@ export type MindElixirData = {
265
279
  direction?: 0 | 1 | 2;
266
280
  theme?: Theme;
267
281
  compact?: boolean;
282
+ /**
283
+ * Extension fields to store arbitrary metadata for the map.
284
+ */
285
+ meta?: Record<string, any>;
268
286
  };
@@ -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.1",
3
+ "version": "5.12.2-beta.1",
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
+ }