mind-elixir 5.12.2-beta.2 → 5.12.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.
- package/dist/MindElixir.css +1 -1
- package/dist/MindElixir.iife.js +4 -4
- package/dist/MindElixir.js +101 -105
- package/dist/MindElixirLite.css +1 -1
- package/dist/MindElixirLite.iife.js +4 -4
- package/dist/MindElixirLite.js +67 -71
- package/dist/types/index.d.ts +1 -1
- package/dist/types/methods.d.ts +1 -1
- package/dist/types/utils/theme.d.ts +1 -1
- package/package.json +1 -1
package/dist/MindElixirLite.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const Wn = 0, Yn = 1, Rn = 2,
|
|
1
|
+
const Wn = 0, Yn = 1, Rn = 2, tt = {
|
|
2
2
|
name: "Latte",
|
|
3
3
|
type: "light",
|
|
4
4
|
palette: ["#dd7878", "#ea76cb", "#8839ef", "#e64553", "#fe640b", "#df8e1d", "#40a02b", "#209fb5", "#1e66f5", "#7287fd"],
|
|
@@ -12,6 +12,8 @@ const Wn = 0, Yn = 1, Rn = 2, Y = {
|
|
|
12
12
|
"--root-color": "#ffffff",
|
|
13
13
|
"--root-bgcolor": "#4c4f69",
|
|
14
14
|
"--root-border-color": "rgba(0, 0, 0, 0)",
|
|
15
|
+
"--main-border": "",
|
|
16
|
+
// you can customize, it will fallback to 2px solid main-color
|
|
15
17
|
"--main-color": "#444446",
|
|
16
18
|
"--main-bgcolor": "#ffffff",
|
|
17
19
|
"--main-bgcolor-transparent": "rgba(255, 255, 255, 0.8)",
|
|
@@ -39,6 +41,7 @@ const Wn = 0, Yn = 1, Rn = 2, Y = {
|
|
|
39
41
|
"--root-color": "#ffffff",
|
|
40
42
|
"--root-bgcolor": "#2d3748",
|
|
41
43
|
"--root-border-color": "rgba(255, 255, 255, 0.1)",
|
|
44
|
+
"--main-border": "",
|
|
42
45
|
"--main-color": "#ffffff",
|
|
43
46
|
"--main-bgcolor": "#4c4f69",
|
|
44
47
|
"--main-bgcolor-transparent": "rgba(76, 79, 105, 0.8)",
|
|
@@ -56,12 +59,12 @@ const Wn = 0, Yn = 1, Rn = 2, Y = {
|
|
|
56
59
|
function It(t) {
|
|
57
60
|
return t.replace(/&/g, "&").replace(/</g, "<").replace(/"/g, """);
|
|
58
61
|
}
|
|
59
|
-
const
|
|
62
|
+
const G = function(t, e) {
|
|
60
63
|
if (e.id === t)
|
|
61
64
|
return e;
|
|
62
65
|
if (e.children && e.children.length) {
|
|
63
66
|
for (let n = 0; n < e.children.length; n++) {
|
|
64
|
-
const o =
|
|
67
|
+
const o = G(t, e.children[n]);
|
|
65
68
|
if (o) return o;
|
|
66
69
|
}
|
|
67
70
|
return null;
|
|
@@ -76,7 +79,7 @@ const _ = function(t, e) {
|
|
|
76
79
|
wt(o, e);
|
|
77
80
|
});
|
|
78
81
|
};
|
|
79
|
-
function
|
|
82
|
+
function _(t, e, n, o) {
|
|
80
83
|
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
84
|
return {
|
|
82
85
|
x1: n + Math.cos(f) * l,
|
|
@@ -85,11 +88,11 @@ function q(t, e, n, o) {
|
|
|
85
88
|
y2: o + Math.sin(d) * l
|
|
86
89
|
};
|
|
87
90
|
}
|
|
88
|
-
function
|
|
91
|
+
function Y() {
|
|
89
92
|
return ((/* @__PURE__ */ new Date()).getTime().toString(16) + Math.random().toString(16).substring(2)).substring(2, 18);
|
|
90
93
|
}
|
|
91
94
|
const Ot = function() {
|
|
92
|
-
const t =
|
|
95
|
+
const t = Y();
|
|
93
96
|
return {
|
|
94
97
|
topic: this.newTopicName,
|
|
95
98
|
id: t
|
|
@@ -102,7 +105,7 @@ const Ot = function() {
|
|
|
102
105
|
}, D = (t, e) => {
|
|
103
106
|
for (const n in e)
|
|
104
107
|
t.setAttribute(n, e[n]);
|
|
105
|
-
},
|
|
108
|
+
}, J = (t) => t ? t.tagName === "ME-TPC" : !1, ot = (t) => {
|
|
106
109
|
const e = /translate3d\(([^,]+),\s*([^,]+)/, n = t.match(e);
|
|
107
110
|
return n ? { x: parseFloat(n[1]), y: parseFloat(n[2]) } : { x: 0, y: 0 };
|
|
108
111
|
}, bt = function(t) {
|
|
@@ -121,11 +124,11 @@ const Ot = function() {
|
|
|
121
124
|
return Math.sqrt(n * n + o * o);
|
|
122
125
|
}, Bt = function(t, e) {
|
|
123
126
|
if (!e)
|
|
124
|
-
return
|
|
127
|
+
return j(t), t;
|
|
125
128
|
let n = t.querySelector(".insert-preview");
|
|
126
129
|
const o = `insert-preview ${e} show`;
|
|
127
130
|
return n || (n = document.createElement("div"), t.appendChild(n)), n.className = o, t;
|
|
128
|
-
},
|
|
131
|
+
}, j = function(t) {
|
|
129
132
|
if (!t) return;
|
|
130
133
|
const e = t.querySelectorAll(".insert-preview");
|
|
131
134
|
for (const n of e || [])
|
|
@@ -199,7 +202,7 @@ function Vt(t, e, n) {
|
|
|
199
202
|
const s = n.clientX - e.startX, i = n.clientY - e.startY, r = Math.sqrt(s * s + i * i);
|
|
200
203
|
if (!e.isDragging && r > Xt && xt(t, e), !e.isDragging) return;
|
|
201
204
|
const c = t.container.getBoundingClientRect();
|
|
202
|
-
vt(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(),
|
|
205
|
+
vt(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);
|
|
203
206
|
const l = 12 * t.scaleVal, a = document.elementFromPoint(n.clientX, n.clientY - l);
|
|
204
207
|
if (dt(a, o)) {
|
|
205
208
|
e.meet = a;
|
|
@@ -222,7 +225,7 @@ function zt(t, e, n) {
|
|
|
222
225
|
e.edgeMoveController.stop();
|
|
223
226
|
for (const s of o)
|
|
224
227
|
s.parentElement.parentElement.style.opacity = "1";
|
|
225
|
-
e.ghost.style.display = "none", e.ghost.innerHTML = "", e.isDragging && e.meet && (
|
|
228
|
+
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;
|
|
226
229
|
}
|
|
227
230
|
}
|
|
228
231
|
function ut(t, e) {
|
|
@@ -231,7 +234,7 @@ function ut(t, e) {
|
|
|
231
234
|
e.edgeMoveController.stop();
|
|
232
235
|
for (const o of n)
|
|
233
236
|
o.parentElement.parentElement.style.opacity = "1";
|
|
234
|
-
e.meet &&
|
|
237
|
+
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;
|
|
235
238
|
}
|
|
236
239
|
}
|
|
237
240
|
const O = {
|
|
@@ -646,7 +649,7 @@ function ke(t) {
|
|
|
646
649
|
}, d = (h) => {
|
|
647
650
|
if (!t.editable) return;
|
|
648
651
|
const m = h.target;
|
|
649
|
-
if (
|
|
652
|
+
if (J(m)) {
|
|
650
653
|
t.selectNode(m), t.beginEdit(m);
|
|
651
654
|
return;
|
|
652
655
|
}
|
|
@@ -663,7 +666,7 @@ function ke(t) {
|
|
|
663
666
|
return;
|
|
664
667
|
}
|
|
665
668
|
if (e.handlePointerDown(h), e.mousedown && (t.ptState = i.Pan), h.button === 0 || h.pointerType === "touch")
|
|
666
|
-
if (
|
|
669
|
+
if (J(m)) {
|
|
667
670
|
t.selection?.cancel();
|
|
668
671
|
const E = t.currentNodes || [];
|
|
669
672
|
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;
|
|
@@ -708,7 +711,7 @@ function ke(t) {
|
|
|
708
711
|
h.preventDefault(), h.button === 2 && t.editable && setTimeout(() => {
|
|
709
712
|
if (t.panHelper.moved || t.ptState !== i.Idle && t.ptState !== i.Pan) return;
|
|
710
713
|
const m = h.target;
|
|
711
|
-
|
|
714
|
+
J(m) && !m.classList.contains("selected") && t.selectNode(m), t.bus.fire("showContextMenu", h);
|
|
712
715
|
}, 200);
|
|
713
716
|
}, v = (h) => {
|
|
714
717
|
if (h.stopPropagation(), h.preventDefault(), h.ctrlKey || h.metaKey) return Pe(t, h);
|
|
@@ -756,11 +759,11 @@ function Ne() {
|
|
|
756
759
|
}
|
|
757
760
|
};
|
|
758
761
|
}
|
|
759
|
-
const k = "http://www.w3.org/2000/svg",
|
|
762
|
+
const k = "http://www.w3.org/2000/svg", U = function(t) {
|
|
760
763
|
const e = t.clientWidth, n = t.clientHeight, o = t.dataset, s = Number(o.x), i = Number(o.y), r = o.anchor;
|
|
761
764
|
let c = s;
|
|
762
765
|
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";
|
|
763
|
-
},
|
|
766
|
+
}, Q = function(t, e, n, o) {
|
|
764
767
|
const { anchor: s = "middle", color: i, dataType: r, svgId: c } = o, l = document.createElement("div");
|
|
765
768
|
l.className = "svg-label", l.style.color = i || "#666";
|
|
766
769
|
const a = "label-" + c;
|
|
@@ -830,7 +833,7 @@ const k = "http://www.w3.org/2000/svg", K = function(t) {
|
|
|
830
833
|
}), s.addEventListener("blur", () => {
|
|
831
834
|
if (!s) return;
|
|
832
835
|
const i = s.innerText?.trim() || "";
|
|
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,
|
|
836
|
+
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", {
|
|
834
837
|
name: "finishEditSummary",
|
|
835
838
|
obj: n
|
|
836
839
|
}) : t.bus.fire("operation", {
|
|
@@ -934,16 +937,9 @@ function kt({ pT: t, pL: e, pW: n, pH: o, cT: s, cL: i, cW: r, cH: c, direction:
|
|
|
934
937
|
return l === O.LHS ? (g = e, y = g + f, u = g - f, p = i + f, `M ${y} ${d} C ${g} ${d} ${g + v} ${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 - v} ${w} ${u} ${w} H ${p}`);
|
|
935
938
|
}
|
|
936
939
|
const Ge = function(t, e = !0) {
|
|
937
|
-
this.theme =
|
|
938
|
-
...this.theme || Y,
|
|
939
|
-
...t,
|
|
940
|
-
cssVar: {
|
|
941
|
-
...this.theme?.cssVar || Y.cssVar,
|
|
942
|
-
...t.cssVar || {}
|
|
943
|
-
}
|
|
944
|
-
}, this.generateMainBranch = this.theme.generateMainBranch || Pt, this.generateSubBranch = this.theme.generateSubBranch || kt;
|
|
940
|
+
this.theme = t, this.generateMainBranch = this.theme.generateMainBranch || Pt, this.generateSubBranch = this.theme.generateSubBranch || kt;
|
|
945
941
|
const o = {
|
|
946
|
-
...(this.theme.type === "dark" ? et :
|
|
942
|
+
...(this.theme.type === "dark" ? et : tt).cssVar,
|
|
947
943
|
...this.theme.cssVar
|
|
948
944
|
};
|
|
949
945
|
this.compact && (o["--node-gap-x"] = "15px", o["--node-gap-y"] = "2px", o["--main-gap-x"] = "30px", o["--main-gap-y"] = "6px");
|
|
@@ -1000,9 +996,9 @@ function At(t, e, n, o, s, i, r, c) {
|
|
|
1000
996
|
};
|
|
1001
997
|
}
|
|
1002
998
|
function je(t, e, n) {
|
|
1003
|
-
t && (t.dataset.x = e.toString(), t.dataset.y = n.toString(),
|
|
999
|
+
t && (t.dataset.x = e.toString(), t.dataset.y = n.toString(), U(t));
|
|
1004
1000
|
}
|
|
1005
|
-
function
|
|
1001
|
+
function V(t, e, n, o, s) {
|
|
1006
1002
|
D(t, {
|
|
1007
1003
|
x1: e + "",
|
|
1008
1004
|
y1: n + "",
|
|
@@ -1018,7 +1014,7 @@ function mt(t, e, n, o, s, i, r, c, l, a) {
|
|
|
1018
1014
|
}
|
|
1019
1015
|
const d = t.querySelectorAll('path[stroke="transparent"]');
|
|
1020
1016
|
d.length > 0 && d[0].setAttribute("d", f);
|
|
1021
|
-
const p =
|
|
1017
|
+
const p = _(i, r, c, l);
|
|
1022
1018
|
if (p) {
|
|
1023
1019
|
const u = `M ${p.x1} ${p.y1} L ${c} ${l} L ${p.x2} ${p.y2}`;
|
|
1024
1020
|
if (t.arrow1.setAttribute("d", u), d.length > 1 && d[1].setAttribute("d", u), a.style) {
|
|
@@ -1027,7 +1023,7 @@ function mt(t, e, n, o, s, i, r, c, l, a) {
|
|
|
1027
1023
|
}
|
|
1028
1024
|
}
|
|
1029
1025
|
if (a.bidirectional) {
|
|
1030
|
-
const u =
|
|
1026
|
+
const u = _(o, s, e, n);
|
|
1031
1027
|
if (u) {
|
|
1032
1028
|
const g = `M ${u.x1} ${u.y1} L ${e} ${n} L ${u.x2} ${u.y2}`;
|
|
1033
1029
|
if (t.arrow2.setAttribute("d", g), d.length > 2 && d[2].setAttribute("d", g), a.style) {
|
|
@@ -1043,7 +1039,7 @@ function mt(t, e, n, o, s, i, r, c, l, a) {
|
|
|
1043
1039
|
}
|
|
1044
1040
|
nn(t);
|
|
1045
1041
|
}
|
|
1046
|
-
function
|
|
1042
|
+
function q(t, e, n) {
|
|
1047
1043
|
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;
|
|
1048
1044
|
return {
|
|
1049
1045
|
w: i,
|
|
@@ -1089,27 +1085,27 @@ const Ue = function(t, e, n) {
|
|
|
1089
1085
|
const S = Ue(t, e, n);
|
|
1090
1086
|
o.delta1 = S.delta1, o.delta2 = S.delta2;
|
|
1091
1087
|
}
|
|
1092
|
-
const i =
|
|
1088
|
+
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);
|
|
1093
1089
|
if (!u) return;
|
|
1094
1090
|
const g = `M ${u.x1} ${u.y1} L ${w} ${y} L ${u.x2} ${u.y2}`;
|
|
1095
1091
|
let v = "";
|
|
1096
1092
|
if (o.bidirectional) {
|
|
1097
|
-
const S =
|
|
1093
|
+
const S = _(a, f, c, l);
|
|
1098
1094
|
if (!S) return;
|
|
1099
1095
|
v = `M ${S.x1} ${S.y1} L ${c} ${l} L ${S.x2} ${S.y2}`;
|
|
1100
1096
|
}
|
|
1101
1097
|
const b = Ae(`M ${c} ${l} C ${a} ${f} ${d} ${p} ${w} ${y}`, g, v, o.style), { x: C, y: T } = At(c, l, a, f, d, p, w, y), h = o.style?.labelColor || "rgb(235, 95, 82)", m = "a-" + o.id;
|
|
1102
1098
|
b.id = m;
|
|
1103
|
-
const x = t.markdown ? t.markdown(o.label, o) : o.label, E =
|
|
1099
|
+
const x = t.markdown ? t.markdown(o.label, o) : o.label, E = Q(x, C, T, {
|
|
1104
1100
|
anchor: "middle",
|
|
1105
1101
|
color: h,
|
|
1106
1102
|
dataType: "arrow",
|
|
1107
1103
|
svgId: m
|
|
1108
1104
|
});
|
|
1109
|
-
b.labelEl = E, b.arrowObj = o, b.dataset.linkid = o.id, t.labelContainer.appendChild(E), t.arrowSvg.appendChild(b),
|
|
1105
|
+
b.labelEl = E, b.arrowObj = o, b.dataset.linkid = o.id, t.labelContainer.appendChild(E), t.arrowSvg.appendChild(b), U(E), s || (t.arrows.push(o), t.currentArrow = b, Ht(t, o, i, r));
|
|
1110
1106
|
}, Ke = function(t, e, n = {}) {
|
|
1111
1107
|
const o = {
|
|
1112
|
-
id:
|
|
1108
|
+
id: Y(),
|
|
1113
1109
|
label: "Custom Link",
|
|
1114
1110
|
from: t.nodeObj.id,
|
|
1115
1111
|
to: e.nodeObj.id,
|
|
@@ -1120,8 +1116,8 @@ const Ue = function(t, e, n) {
|
|
|
1120
1116
|
obj: o
|
|
1121
1117
|
});
|
|
1122
1118
|
}, Je = function(t) {
|
|
1123
|
-
|
|
1124
|
-
const e = { ...t, id:
|
|
1119
|
+
K(this);
|
|
1120
|
+
const e = { ...t, id: Y() };
|
|
1125
1121
|
it(this, this.findEle(e.from), this.findEle(e.to), e), this.bus.fire("operation", {
|
|
1126
1122
|
name: "createArrow",
|
|
1127
1123
|
obj: e
|
|
@@ -1129,7 +1125,7 @@ const Ue = function(t, e, n) {
|
|
|
1129
1125
|
}, Ze = function(t) {
|
|
1130
1126
|
let e;
|
|
1131
1127
|
if (t ? e = t : e = this.currentArrow, !e) return;
|
|
1132
|
-
|
|
1128
|
+
K(this);
|
|
1133
1129
|
const n = e.arrowObj.id;
|
|
1134
1130
|
this.arrows = this.arrows.filter((o) => o.id !== n), e.labelEl?.remove(), e.remove(), this.bus.fire("operation", {
|
|
1135
1131
|
name: "removeArrow",
|
|
@@ -1139,11 +1135,11 @@ const Ue = function(t, e, n) {
|
|
|
1139
1135
|
});
|
|
1140
1136
|
}, Qe = function(t) {
|
|
1141
1137
|
this.currentArrow = t;
|
|
1142
|
-
const e = t.arrowObj, n = this.findEle(e.from), o = this.findEle(e.to), s =
|
|
1138
|
+
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);
|
|
1143
1139
|
this.editable ? Ht(this, e, s, i) : $t(t, Nt), this.bus.fire("selectArrow", e);
|
|
1144
1140
|
}, tn = function() {
|
|
1145
|
-
|
|
1146
|
-
},
|
|
1141
|
+
K(this), this.currentArrow = null, this.bus.fire("unselectArrow");
|
|
1142
|
+
}, Z = function(t, e) {
|
|
1147
1143
|
const n = document.createElementNS(k, "path");
|
|
1148
1144
|
return D(n, {
|
|
1149
1145
|
d: t,
|
|
@@ -1156,11 +1152,11 @@ const Ue = function(t, e, n) {
|
|
|
1156
1152
|
}, $t = function(t, e) {
|
|
1157
1153
|
const n = document.createElementNS(k, "g");
|
|
1158
1154
|
n.setAttribute("class", "arrow-highlight"), n.setAttribute("opacity", "0.45");
|
|
1159
|
-
const o =
|
|
1155
|
+
const o = Z(t.line.getAttribute("d"), e);
|
|
1160
1156
|
n.appendChild(o);
|
|
1161
|
-
const s =
|
|
1157
|
+
const s = Z(t.arrow1.getAttribute("d"), e);
|
|
1162
1158
|
if (n.appendChild(s), t.arrow2.getAttribute("d")) {
|
|
1163
|
-
const i =
|
|
1159
|
+
const i = Z(t.arrow2.getAttribute("d"), e);
|
|
1164
1160
|
n.appendChild(i);
|
|
1165
1161
|
}
|
|
1166
1162
|
t.insertBefore(n, t.firstChild);
|
|
@@ -1172,21 +1168,21 @@ const Ue = function(t, e, n) {
|
|
|
1172
1168
|
if (!e) return;
|
|
1173
1169
|
const n = e.querySelectorAll("path");
|
|
1174
1170
|
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"));
|
|
1175
|
-
},
|
|
1171
|
+
}, K = function(t) {
|
|
1176
1172
|
t.helper1?.destroy(), t.helper2?.destroy(), t.linkController.style.display = "none", t.P2.style.display = "none", t.P3.style.display = "none", t.currentArrow && en(t.currentArrow);
|
|
1177
1173
|
}, Ht = function(t, e, n, o) {
|
|
1178
1174
|
const { linkController: s, P2: i, P3: r, line1: c, line2: l, nodes: a, map: f, currentArrow: d, bus: p } = t;
|
|
1179
1175
|
if (!d) return;
|
|
1180
1176
|
s.style.display = "initial", i.style.display = "initial", r.style.display = "initial", a.appendChild(s), a.appendChild(i), a.appendChild(r), $t(d, Nt);
|
|
1181
1177
|
let { x: w, y } = I(n), { ctrlX: u, ctrlY: g } = n, { ctrlX: v, ctrlY: b } = o, { x: C, y: T } = I(o);
|
|
1182
|
-
i.style.cssText = `top:${g}px;left:${u}px;`, r.style.cssText = `top:${b}px;left:${v}px;`,
|
|
1178
|
+
i.style.cssText = `top:${g}px;left:${u}px;`, r.style.cssText = `top:${b}px;left:${v}px;`, V(c, w, y, u, g), V(l, v, b, C, T), t.helper1 = gt.create(i), t.helper2 = gt.create(r), t.helper1.init(f, (h, m) => {
|
|
1183
1179
|
u = u + h / t.scaleVal, g = g + m / t.scaleVal;
|
|
1184
1180
|
const x = I({ ...n, ctrlX: u, ctrlY: g });
|
|
1185
|
-
w = x.x, y = x.y, i.style.top = g + "px", i.style.left = u + "px", mt(d, w, y, u, g, v, b, C, T, e),
|
|
1181
|
+
w = x.x, y = x.y, i.style.top = g + "px", i.style.left = u + "px", mt(d, w, y, u, g, v, b, 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);
|
|
1186
1182
|
}), t.helper2.init(f, (h, m) => {
|
|
1187
1183
|
v = v + h / t.scaleVal, b = b + m / t.scaleVal;
|
|
1188
1184
|
const x = I({ ...o, ctrlX: v, ctrlY: b });
|
|
1189
|
-
C = x.x, T = x.y, r.style.top = b + "px", r.style.left = v + "px", mt(d, w, y, u, g, v, b, C, T, e),
|
|
1185
|
+
C = x.x, T = x.y, r.style.top = b + "px", r.style.left = v + "px", mt(d, w, y, u, g, v, b, C, T, e), V(l, v, b, C, T), e.delta2.x = Math.round(v - o.cx), e.delta2.y = Math.round(b - o.cy), p.fire("updateArrowDelta", e);
|
|
1190
1186
|
});
|
|
1191
1187
|
};
|
|
1192
1188
|
function on() {
|
|
@@ -1201,10 +1197,10 @@ function on() {
|
|
|
1201
1197
|
this.nodes.appendChild(this.arrowSvg);
|
|
1202
1198
|
}
|
|
1203
1199
|
function sn(t) {
|
|
1204
|
-
|
|
1200
|
+
K(this), t && t.labelEl && Lt(this, t.labelEl, t.arrowObj);
|
|
1205
1201
|
}
|
|
1206
1202
|
function rn() {
|
|
1207
|
-
this.arrows = this.arrows.filter((t) =>
|
|
1203
|
+
this.arrows = this.arrows.filter((t) => G(t.from, this.nodeData) && G(t.to, this.nodeData));
|
|
1208
1204
|
}
|
|
1209
1205
|
const cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1210
1206
|
__proto__: null,
|
|
@@ -1276,23 +1272,23 @@ const cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
1276
1272
|
const ct = p.children?.[B];
|
|
1277
1273
|
if (!ct)
|
|
1278
1274
|
return t.removeSummary(n), null;
|
|
1279
|
-
const
|
|
1280
|
-
B === i && (g = lt + at), B === r && (v = lt +
|
|
1275
|
+
const R = hn(t.findEle(ct.id)), { offsetLeft: X, offsetTop: lt } = P(l, R), at = i === r ? 10 : 20;
|
|
1276
|
+
B === i && (g = lt + at), B === r && (v = lt + R.offsetHeight - at), X < y && (y = X), R.offsetWidth + X > u && (u = R.offsetWidth + X);
|
|
1281
1277
|
}
|
|
1282
1278
|
let b, C;
|
|
1283
1279
|
const T = p.parent ? 10 : 0, h = g + T, m = v + 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;
|
|
1284
|
-
w === O.LHS ? (b = 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 =
|
|
1280
|
+
w === O.LHS ? (b = 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 })) : (b = 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 }));
|
|
1285
1281
|
const $ = an(M);
|
|
1286
|
-
return $.appendChild(b), t.labelContainer.appendChild(C),
|
|
1282
|
+
return $.appendChild(b), t.labelContainer.appendChild(C), U(C), $.summaryObj = e, $.labelEl = C, f.appendChild($), $;
|
|
1287
1283
|
}, fn = function(t = {}) {
|
|
1288
1284
|
if (!this.currentNodes) return;
|
|
1289
|
-
const { currentNodes: e, summaries: n, bus: o } = this, { parent: s, start: i, end: r } = ln(e), c = { id:
|
|
1285
|
+
const { currentNodes: e, summaries: n, bus: o } = this, { parent: s, start: i, end: r } = ln(e), c = { id: Y(), parent: s, start: i, end: r, label: "summary", style: t.style }, l = rt(this, c);
|
|
1290
1286
|
n.push(c), this.editSummary(l), o.fire("operation", {
|
|
1291
1287
|
name: "createSummary",
|
|
1292
1288
|
obj: c
|
|
1293
1289
|
});
|
|
1294
1290
|
}, un = function(t) {
|
|
1295
|
-
const e =
|
|
1291
|
+
const e = Y(), n = { ...t, id: e };
|
|
1296
1292
|
rt(this, n), this.summaries.push(n), this.bus.fire("operation", {
|
|
1297
1293
|
name: "createSummary",
|
|
1298
1294
|
obj: n
|
|
@@ -1386,7 +1382,7 @@ function En(t, e) {
|
|
|
1386
1382
|
"stroke-width": n.borderWidth
|
|
1387
1383
|
}), i;
|
|
1388
1384
|
}
|
|
1389
|
-
function
|
|
1385
|
+
function z(t, e, n = !1) {
|
|
1390
1386
|
const o = getComputedStyle(e), { offsetLeft: s, offsetTop: i } = P(t.nodes, e), r = document.createElementNS(L, "rect");
|
|
1391
1387
|
D(r, {
|
|
1392
1388
|
x: s + "",
|
|
@@ -1426,8 +1422,8 @@ function Dn(t, e) {
|
|
|
1426
1422
|
href: e.src
|
|
1427
1423
|
}), i;
|
|
1428
1424
|
}
|
|
1429
|
-
const
|
|
1430
|
-
const n = t.nodes, o = n.offsetHeight +
|
|
1425
|
+
const F = 100, Ln = '<?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">', Mn = (t, e = !1) => {
|
|
1426
|
+
const n = t.nodes, o = n.offsetHeight + F * 2, s = n.offsetWidth + F * 2, i = vn(o + "px", s + "px"), r = document.createElementNS(L, "svg"), c = document.createElementNS(L, "rect");
|
|
1431
1427
|
D(c, {
|
|
1432
1428
|
x: "0",
|
|
1433
1429
|
y: "0",
|
|
@@ -1444,18 +1440,18 @@ const G = 100, Ln = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "
|
|
|
1444
1440
|
a && r.appendChild(a);
|
|
1445
1441
|
const f = n.querySelector(".summary")?.cloneNode(!0);
|
|
1446
1442
|
return f && r.appendChild(f), n.querySelectorAll("me-tpc").forEach((d) => {
|
|
1447
|
-
d.nodeObj.dangerouslySetInnerHTML ? r.appendChild(
|
|
1443
|
+
d.nodeObj.dangerouslySetInnerHTML ? r.appendChild(z(t, d, !e)) : (r.appendChild(En(t, d)), r.appendChild(z(t, d.text, !e)));
|
|
1448
1444
|
}), n.querySelectorAll(".tags > span").forEach((d) => {
|
|
1449
|
-
r.appendChild(
|
|
1445
|
+
r.appendChild(z(t, d));
|
|
1450
1446
|
}), n.querySelectorAll(".icons > span").forEach((d) => {
|
|
1451
|
-
r.appendChild(
|
|
1447
|
+
r.appendChild(z(t, d));
|
|
1452
1448
|
}), n.querySelectorAll(".hyper-link").forEach((d) => {
|
|
1453
1449
|
r.appendChild(Tn(t, d));
|
|
1454
1450
|
}), n.querySelectorAll("img").forEach((d) => {
|
|
1455
1451
|
r.appendChild(Dn(t, d));
|
|
1456
1452
|
}), D(r, {
|
|
1457
|
-
x:
|
|
1458
|
-
y:
|
|
1453
|
+
x: F + "",
|
|
1454
|
+
y: F + "",
|
|
1459
1455
|
overflow: "visible"
|
|
1460
1456
|
}), i.appendChild(r), i;
|
|
1461
1457
|
}, Pn = (t, e) => (e && t.insertAdjacentHTML("afterbegin", "<style>" + e + "</style>"), Ln + t.outerHTML);
|
|
@@ -1486,7 +1482,7 @@ const Nn = function(t = !1, e) {
|
|
|
1486
1482
|
exportPng: An,
|
|
1487
1483
|
exportSvg: Nn
|
|
1488
1484
|
}, Symbol.toStringTag, { value: "Module" })), Hn = {}, In = {
|
|
1489
|
-
getObjById:
|
|
1485
|
+
getObjById: G,
|
|
1490
1486
|
generateNewObj: Ot,
|
|
1491
1487
|
layout: Ft,
|
|
1492
1488
|
linkDiv: $e,
|
|
@@ -1517,7 +1513,7 @@ const Nn = function(t = !1, e) {
|
|
|
1517
1513
|
enableMobileMultiSelect(t) {
|
|
1518
1514
|
this.mobileMultiSelect = t;
|
|
1519
1515
|
}
|
|
1520
|
-
}, On = "5.12.2
|
|
1516
|
+
}, On = "5.12.2";
|
|
1521
1517
|
function Bn(t) {
|
|
1522
1518
|
return {
|
|
1523
1519
|
x: 0,
|
|
@@ -1577,7 +1573,7 @@ function A({
|
|
|
1577
1573
|
if (M === "[object HTMLDivElement]" ? S = t : M === "[object String]" && (S = document.querySelector(t)), !S) throw new Error("MindElixir: el is not a valid element");
|
|
1578
1574
|
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 = v ?? 0.1, this.scaleMax = b ?? 1.4, this.scaleMin = C ?? 0.2, this.generateMainBranch = d || Pt, this.generateSubBranch = p || kt, 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 = Ne(), this.container = document.createElement("div"), this.selectionContainer = c || this.container, this.container.className = "map-container";
|
|
1579
1575
|
const N = window.matchMedia("(prefers-color-scheme: dark)");
|
|
1580
|
-
this.theme = u || (N.matches ? et :
|
|
1576
|
+
this.theme = u || (N.matches ? et : tt);
|
|
1581
1577
|
const $ = document.createElement("div");
|
|
1582
1578
|
$.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(ke(this)), x && (this.pasteHandler = x);
|
|
1583
1579
|
}
|
|
@@ -1591,7 +1587,7 @@ Object.defineProperty(A.prototype, "currentNode", {
|
|
|
1591
1587
|
A.LEFT = 0;
|
|
1592
1588
|
A.RIGHT = 1;
|
|
1593
1589
|
A.SIDE = 2;
|
|
1594
|
-
A.THEME =
|
|
1590
|
+
A.THEME = tt;
|
|
1595
1591
|
A.DARK_THEME = et;
|
|
1596
1592
|
A.version = On;
|
|
1597
1593
|
A.E = Ct;
|
|
@@ -1600,6 +1596,6 @@ export {
|
|
|
1600
1596
|
Wn as LEFT,
|
|
1601
1597
|
Yn as RIGHT,
|
|
1602
1598
|
Rn as SIDE,
|
|
1603
|
-
|
|
1599
|
+
tt as THEME,
|
|
1604
1600
|
A as default
|
|
1605
1601
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -84,7 +84,7 @@ declare namespace MindElixir {
|
|
|
84
84
|
createChildren: (this: MindElixirInstance, wrappers: import("./docs").Wrapper[]) => import("./docs").Children;
|
|
85
85
|
createTopic: (this: MindElixirInstance, nodeObj: import("./docs").NodeObj) => Topic;
|
|
86
86
|
findEle: (this: MindElixirInstance, id: string, el?: HTMLElement) => Topic;
|
|
87
|
-
changeTheme: (this: MindElixirInstance, theme:
|
|
87
|
+
changeTheme: (this: MindElixirInstance, theme: import("./docs").Theme, shouldRefresh?: boolean) => void;
|
|
88
88
|
changeCompact: (this: MindElixirInstance, compact: boolean) => void;
|
|
89
89
|
};
|
|
90
90
|
export var LEFT: number;
|
package/dist/types/methods.d.ts
CHANGED
|
@@ -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:
|
|
96
|
+
changeTheme: (this: MindElixirInstance, theme: import("./types").Theme, shouldRefresh?: boolean) => void;
|
|
97
97
|
changeCompact: (this: MindElixirInstance, compact: boolean) => void;
|
|
98
98
|
};
|
|
99
99
|
export default methods;
|
|
@@ -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:
|
|
3
|
+
export declare const changeTheme: (this: MindElixirInstance, theme: Theme, shouldRefresh?: boolean) => void;
|
|
4
4
|
export declare const changeCompact: (this: MindElixirInstance, compact: boolean) => void;
|