mind-elixir 5.11.2 → 5.12.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.
- package/dist/MindElixir.iife.js +4 -4
- package/dist/MindElixir.js +230 -220
- package/dist/MindElixirLite.iife.js +4 -4
- package/dist/MindElixirLite.js +174 -164
- package/dist/types/index.d.ts +4 -2
- package/dist/types/methods.d.ts +7 -1
- package/dist/types/types/index.d.ts +4 -0
- package/dist/types/utils/theme.d.ts +1 -0
- package/package.json +1 -1
package/dist/MindElixirLite.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
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"],
|
|
@@ -94,7 +94,7 @@ const Ht = function() {
|
|
|
94
94
|
topic: this.newTopicName,
|
|
95
95
|
id: t
|
|
96
96
|
};
|
|
97
|
-
},
|
|
97
|
+
}, P = (t, e) => {
|
|
98
98
|
let n = 0, o = 0;
|
|
99
99
|
for (; e && e !== t; )
|
|
100
100
|
n += e.offsetLeft, o += e.offsetTop, e = e.offsetParent;
|
|
@@ -234,7 +234,7 @@ function ut(t, e) {
|
|
|
234
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;
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
|
-
const
|
|
237
|
+
const O = {
|
|
238
238
|
LHS: "lhs",
|
|
239
239
|
RHS: "rhs"
|
|
240
240
|
}, Vt = function() {
|
|
@@ -253,9 +253,9 @@ const I = {
|
|
|
253
253
|
zt(this, n, e);
|
|
254
254
|
}, zt = function(t, e, n) {
|
|
255
255
|
const o = document.createElement("me-main");
|
|
256
|
-
o.className =
|
|
256
|
+
o.className = O.LHS;
|
|
257
257
|
const s = document.createElement("me-main");
|
|
258
|
-
s.className =
|
|
258
|
+
s.className = O.RHS;
|
|
259
259
|
for (let i = 0; i < e.length; i++) {
|
|
260
260
|
const r = e[i], { grp: c } = t.createWrapper(r);
|
|
261
261
|
t.direction === 2 ? r.direction === 0 ? o.appendChild(c) : s.appendChild(c) : t.direction === 0 ? o.appendChild(c) : s.appendChild(c);
|
|
@@ -336,7 +336,7 @@ function Et(t) {
|
|
|
336
336
|
}
|
|
337
337
|
const Ut = function(t) {
|
|
338
338
|
if (!t) return;
|
|
339
|
-
const e = document.createElement("div"), n = t.nodeObj, o = n.topic, { offsetLeft: s, offsetTop: i } =
|
|
339
|
+
const e = document.createElement("div"), n = t.nodeObj, o = n.topic, { offsetLeft: s, offsetTop: i } = P(this.nodes, t);
|
|
340
340
|
this.nodes.appendChild(e), e.id = "input-box", e.textContent = o, e.contentEditable = "plaintext-only", e.spellcheck = !1;
|
|
341
341
|
const r = getComputedStyle(t);
|
|
342
342
|
e.style.cssText = `
|
|
@@ -546,8 +546,12 @@ function Me(t) {
|
|
|
546
546
|
lastTapTarget: null,
|
|
547
547
|
DOUBLE_CLICK_THRESHOLD: 300,
|
|
548
548
|
detect(h, m) {
|
|
549
|
-
|
|
550
|
-
|
|
549
|
+
if (h.button !== 0) {
|
|
550
|
+
this.clear();
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
const x = (/* @__PURE__ */ new Date()).getTime(), E = x - this.lastTap, S = E < this.DOUBLE_CLICK_THRESHOLD && E > 0 && this.lastTapTarget === h.target;
|
|
554
|
+
this.lastTap = x, this.lastTapTarget = h.target, S && m(h);
|
|
551
555
|
},
|
|
552
556
|
clear() {
|
|
553
557
|
this.lastTap = 0, this.lastTapTarget = null;
|
|
@@ -575,15 +579,15 @@ function Me(t) {
|
|
|
575
579
|
handlePointerMove(h) {
|
|
576
580
|
if (h.pointerType !== "touch" || !this.activePointers.has(h.pointerId)) return !1;
|
|
577
581
|
if (this.activePointers.set(h.pointerId, { x: h.clientX, y: h.clientY }), this.activePointers.size >= 2) {
|
|
578
|
-
const [m, x] = Array.from(this.activePointers.values()),
|
|
582
|
+
const [m, x] = Array.from(this.activePointers.values()), E = ht(m, x);
|
|
579
583
|
if (this.lastDistance !== null && this.lastDistance > 0) {
|
|
580
|
-
const
|
|
581
|
-
t.scale(t.scaleVal *
|
|
584
|
+
const S = E / this.lastDistance;
|
|
585
|
+
t.scale(t.scaleVal * S, {
|
|
582
586
|
x: (m.x + x.x) / 2,
|
|
583
587
|
y: (m.y + x.y) / 2
|
|
584
588
|
});
|
|
585
589
|
}
|
|
586
|
-
return this.lastDistance =
|
|
590
|
+
return this.lastDistance = E, !0;
|
|
587
591
|
}
|
|
588
592
|
return !1;
|
|
589
593
|
},
|
|
@@ -615,10 +619,10 @@ function Me(t) {
|
|
|
615
619
|
}
|
|
616
620
|
}, a = (h, m) => {
|
|
617
621
|
if (h.closest("#input-box")) return !1;
|
|
618
|
-
const x = h.closest(".svg-label"),
|
|
619
|
-
if (!
|
|
620
|
-
const { type:
|
|
621
|
-
return t.clearSelection(),
|
|
622
|
+
const x = h.closest(".svg-label"), E = h.closest(".topiclinks, .summary"), S = x ? { type: x.dataset.type, element: document.getElementById(x.dataset.svgId) } : E ? { type: E.classList.contains("topiclinks") ? "arrow" : "summary", element: h.closest("g") } : null;
|
|
623
|
+
if (!S?.type || !S?.element) return !1;
|
|
624
|
+
const { type: M, element: N } = S;
|
|
625
|
+
return t.clearSelection(), M === "arrow" ? m ? t.editArrowLabel(N) : t.selectArrow(N) : m ? t.editSummary(N) : t.selectSummary(N), !0;
|
|
622
626
|
}, f = (h) => {
|
|
623
627
|
if (h.pointerType === "mouse" && h.button !== 0) return;
|
|
624
628
|
if (t.helper1?.moved) {
|
|
@@ -659,10 +663,10 @@ function Me(t) {
|
|
|
659
663
|
if (e.handlePointerDown(h), e.mousedown && (t.ptState = i.Pan), h.button === 0 || h.pointerType === "touch")
|
|
660
664
|
if (J(m)) {
|
|
661
665
|
t.selection?.cancel();
|
|
662
|
-
const
|
|
663
|
-
if (h.ctrlKey || h.metaKey || t.mobileMultiSelect ?
|
|
664
|
-
h.pointerType === "touch" ? (t.ptState = i.DragWait, l.start(h, (
|
|
665
|
-
ft(t, c,
|
|
666
|
+
const E = t.currentNodes || [];
|
|
667
|
+
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;
|
|
668
|
+
h.pointerType === "touch" ? (t.ptState = i.DragWait, l.start(h, (M) => {
|
|
669
|
+
ft(t, c, M, !0) && (t.ptState = i.Drag, m.setPointerCapture(M.pointerId));
|
|
666
670
|
})) : ft(t, c, h, !1) && (t.ptState = i.Drag, m.setPointerCapture(h.pointerId));
|
|
667
671
|
} else
|
|
668
672
|
a(m, !1);
|
|
@@ -700,7 +704,7 @@ function Me(t) {
|
|
|
700
704
|
r.clear(), l.clear(), e.clear(), s.clear(), (c.isDragging || c.pointerId !== null) && ut(t, c), t.ptState = i.Idle, o = null;
|
|
701
705
|
}, g = (h) => {
|
|
702
706
|
h.preventDefault(), h.button === 2 && t.editable && setTimeout(() => {
|
|
703
|
-
if (t.panHelper.moved) return;
|
|
707
|
+
if (t.panHelper.moved || t.ptState !== i.Idle && t.ptState !== i.Pan) return;
|
|
704
708
|
const m = h.target;
|
|
705
709
|
J(m) && !m.classList.contains("selected") && t.selectNode(m), t.bus.fire("showContextMenu", h);
|
|
706
710
|
}, 200);
|
|
@@ -750,7 +754,7 @@ function Pe() {
|
|
|
750
754
|
}
|
|
751
755
|
};
|
|
752
756
|
}
|
|
753
|
-
const
|
|
757
|
+
const k = "http://www.w3.org/2000/svg", U = function(t) {
|
|
754
758
|
const e = t.clientWidth, n = t.clientHeight, o = t.dataset, s = Number(o.x), i = Number(o.y), r = o.anchor;
|
|
755
759
|
let c = s;
|
|
756
760
|
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";
|
|
@@ -760,7 +764,7 @@ const N = "http://www.w3.org/2000/svg", U = function(t) {
|
|
|
760
764
|
const a = "label-" + c;
|
|
761
765
|
return l.id = a, l.innerHTML = t, l.dataset.type = r, l.dataset.svgId = c, l.dataset.x = e.toString(), l.dataset.y = n.toString(), l.dataset.anchor = s, l;
|
|
762
766
|
}, Dt = function(t, e, n) {
|
|
763
|
-
const o = document.createElementNS(
|
|
767
|
+
const o = document.createElementNS(k, "path");
|
|
764
768
|
return D(o, {
|
|
765
769
|
d: t,
|
|
766
770
|
stroke: e || "#666",
|
|
@@ -768,13 +772,13 @@ const N = "http://www.w3.org/2000/svg", U = function(t) {
|
|
|
768
772
|
"stroke-width": n
|
|
769
773
|
}), o;
|
|
770
774
|
}, W = function(t) {
|
|
771
|
-
const e = document.createElementNS(
|
|
775
|
+
const e = document.createElementNS(k, "svg");
|
|
772
776
|
return e.setAttribute("class", t), e.setAttribute("overflow", "visible"), e;
|
|
773
777
|
}, pt = function() {
|
|
774
|
-
const t = document.createElementNS(
|
|
778
|
+
const t = document.createElementNS(k, "line");
|
|
775
779
|
return t.setAttribute("stroke", "#4dc4ff"), t.setAttribute("fill", "none"), t.setAttribute("stroke-width", "2"), t.setAttribute("opacity", "0.45"), t;
|
|
776
780
|
}, ke = function(t, e, n, o) {
|
|
777
|
-
const s = document.createElementNS(
|
|
781
|
+
const s = document.createElementNS(k, "g");
|
|
778
782
|
return [
|
|
779
783
|
{
|
|
780
784
|
name: "line",
|
|
@@ -789,7 +793,7 @@ const N = "http://www.w3.org/2000/svg", U = function(t) {
|
|
|
789
793
|
d: n
|
|
790
794
|
}
|
|
791
795
|
].forEach((r, c) => {
|
|
792
|
-
const l = r.d, a = document.createElementNS(
|
|
796
|
+
const l = r.d, a = document.createElementNS(k, "path"), f = {
|
|
793
797
|
d: l,
|
|
794
798
|
stroke: o?.stroke || "rgb(227, 125, 116)",
|
|
795
799
|
fill: "none",
|
|
@@ -797,7 +801,7 @@ const N = "http://www.w3.org/2000/svg", U = function(t) {
|
|
|
797
801
|
"stroke-width": String(o?.strokeWidth || "2")
|
|
798
802
|
};
|
|
799
803
|
o?.opacity !== void 0 && (f.opacity = String(o.opacity)), D(a, f), c === 0 && a.setAttribute("stroke-dasharray", o?.strokeDasharray || "8,2");
|
|
800
|
-
const d = document.createElementNS(
|
|
804
|
+
const d = document.createElementNS(k, "path");
|
|
801
805
|
D(d, {
|
|
802
806
|
d: l,
|
|
803
807
|
stroke: "transparent",
|
|
@@ -836,7 +840,7 @@ const N = "http://www.w3.org/2000/svg", U = function(t) {
|
|
|
836
840
|
const e = this.map.querySelector("me-root"), n = e.offsetTop, o = e.offsetLeft, s = e.offsetWidth, i = e.offsetHeight, r = this.map.querySelectorAll("me-main > me-wrapper");
|
|
837
841
|
this.lines.innerHTML = "";
|
|
838
842
|
for (let c = 0; c < r.length; c++) {
|
|
839
|
-
const l = r[c], a = l.querySelector("me-tpc"), { offsetLeft: f, offsetTop: d } =
|
|
843
|
+
const l = r[c], a = l.querySelector("me-tpc"), { offsetLeft: f, offsetTop: d } = P(this.nodes, a), p = a.offsetWidth, w = a.offsetHeight, y = l.parentNode.className, u = this.generateMainBranch({ pT: n, pL: o, pW: s, pH: i, cT: d, cL: f, cW: p, cH: w, direction: y, containerHeight: this.nodes.offsetHeight }), g = this.theme.palette, b = a.nodeObj.branchColor || g[c % g.length];
|
|
840
844
|
if (a.style.borderColor = b, this.lines.appendChild(Dt(u, b, "3")), t && t !== l)
|
|
841
845
|
continue;
|
|
842
846
|
const v = W("subLines"), C = l.lastChild;
|
|
@@ -865,12 +869,12 @@ const N = "http://www.w3.org/2000/svg", U = function(t) {
|
|
|
865
869
|
living: Oe,
|
|
866
870
|
zoomin: Be,
|
|
867
871
|
zoomout: We
|
|
868
|
-
},
|
|
872
|
+
}, H = (t, e) => {
|
|
869
873
|
const n = document.createElement("span");
|
|
870
874
|
return n.id = t, n.innerHTML = Ye[e], n;
|
|
871
875
|
};
|
|
872
876
|
function Re(t) {
|
|
873
|
-
const e = document.createElement("div"), n =
|
|
877
|
+
const e = document.createElement("div"), n = H("fullscreen", "full"), o = H("toCenter", "living"), s = H("zoomout", "zoomout"), i = H("zoomin", "zoomin");
|
|
874
878
|
e.appendChild(n), e.appendChild(o), e.appendChild(s), e.appendChild(i), e.className = "mind-elixir-toolbar rb";
|
|
875
879
|
let r = null;
|
|
876
880
|
const c = () => {
|
|
@@ -898,7 +902,7 @@ function Re(t) {
|
|
|
898
902
|
}, e;
|
|
899
903
|
}
|
|
900
904
|
function Xe(t) {
|
|
901
|
-
const e = document.createElement("div"), n =
|
|
905
|
+
const e = document.createElement("div"), n = H("tbltl", "left"), o = H("tbltr", "right"), s = H("tblts", "side");
|
|
902
906
|
return e.appendChild(n), e.appendChild(o), e.appendChild(s), e.className = "mind-elixir-toolbar lt", n.onclick = () => {
|
|
903
907
|
t.initLeft();
|
|
904
908
|
}, o.onclick = () => {
|
|
@@ -915,13 +919,17 @@ const ze = function(t, e = !0) {
|
|
|
915
919
|
const o = {
|
|
916
920
|
...(t.type === "dark" ? et : tt).cssVar,
|
|
917
921
|
...t.cssVar
|
|
918
|
-
}
|
|
922
|
+
};
|
|
923
|
+
this.compact && (o["--node-gap-x"] = "15px", o["--node-gap-y"] = "2px", o["--main-gap-x"] = "30px", o["--main-gap-y"] = "6px");
|
|
924
|
+
const s = Object.keys(o);
|
|
919
925
|
for (let i = 0; i < s.length; i++) {
|
|
920
926
|
const r = s[i];
|
|
921
927
|
this.container.style.setProperty(r, o[r]);
|
|
922
928
|
}
|
|
923
929
|
e && this.refresh();
|
|
924
930
|
}, Fe = function(t) {
|
|
931
|
+
this.compact = t, this.theme && this.changeTheme(this.theme);
|
|
932
|
+
}, Ge = function(t) {
|
|
925
933
|
return {
|
|
926
934
|
dom: t,
|
|
927
935
|
moved: !1,
|
|
@@ -957,7 +965,7 @@ const ze = function(t, e = !0) {
|
|
|
957
965
|
}
|
|
958
966
|
};
|
|
959
967
|
}, gt = {
|
|
960
|
-
create:
|
|
968
|
+
create: Ge
|
|
961
969
|
}, Pt = "#4dc4ff";
|
|
962
970
|
function kt(t, e, n, o, s, i, r, c) {
|
|
963
971
|
return {
|
|
@@ -965,7 +973,7 @@ function kt(t, e, n, o, s, i, r, c) {
|
|
|
965
973
|
y: e / 8 + o * 3 / 8 + i * 3 / 8 + c / 8
|
|
966
974
|
};
|
|
967
975
|
}
|
|
968
|
-
function
|
|
976
|
+
function _e(t, e, n) {
|
|
969
977
|
t && (t.dataset.x = e.toString(), t.dataset.y = n.toString(), U(t));
|
|
970
978
|
}
|
|
971
979
|
function V(t, e, n, o, s) {
|
|
@@ -1003,14 +1011,14 @@ function mt(t, e, n, o, s, i, r, c, l, a) {
|
|
|
1003
1011
|
}
|
|
1004
1012
|
}
|
|
1005
1013
|
const { x: w, y } = kt(e, n, o, s, i, r, c, l);
|
|
1006
|
-
if (t.labelEl &&
|
|
1014
|
+
if (t.labelEl && _e(t.labelEl, w, y), a.style?.labelColor) {
|
|
1007
1015
|
const u = t.labelEl;
|
|
1008
1016
|
u && (u.style.color = a.style.labelColor);
|
|
1009
1017
|
}
|
|
1010
|
-
|
|
1018
|
+
tn(t);
|
|
1011
1019
|
}
|
|
1012
1020
|
function q(t, e, n) {
|
|
1013
|
-
const { offsetLeft: o, offsetTop: s } =
|
|
1021
|
+
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;
|
|
1014
1022
|
return {
|
|
1015
1023
|
w: i,
|
|
1016
1024
|
h: r,
|
|
@@ -1020,7 +1028,7 @@ function q(t, e, n) {
|
|
|
1020
1028
|
ctrlY: f
|
|
1021
1029
|
};
|
|
1022
1030
|
}
|
|
1023
|
-
function
|
|
1031
|
+
function I(t) {
|
|
1024
1032
|
let e, n;
|
|
1025
1033
|
const o = (t.cy - t.ctrlY) / (t.ctrlX - t.cx);
|
|
1026
1034
|
return o > t.h / t.w || o < -t.h / t.w ? t.cy - t.ctrlY < 0 ? (e = t.cx - t.h / 2 / o, n = t.cy + t.h / 2) : (e = t.cx + t.h / 2 / o, n = t.cy - t.h / 2) : t.cx - t.ctrlX < 0 ? (e = t.cx + t.w / 2, n = t.cy - t.w * o / 2) : (e = t.cx - t.w / 2, n = t.cy + t.w * o / 2), {
|
|
@@ -1028,8 +1036,8 @@ function H(t) {
|
|
|
1028
1036
|
y: n
|
|
1029
1037
|
};
|
|
1030
1038
|
}
|
|
1031
|
-
const
|
|
1032
|
-
const o =
|
|
1039
|
+
const qe = function(t, e, n) {
|
|
1040
|
+
const o = P(t.nodes, e), s = P(t.nodes, n), i = o.offsetLeft + e.offsetWidth / 2, r = o.offsetTop + e.offsetHeight / 2, c = s.offsetLeft + n.offsetWidth / 2, l = s.offsetTop + n.offsetHeight / 2, a = c - i, f = l - r, d = Math.sqrt(a * a + f * f), p = Math.max(50, Math.min(200, d * 0.3)), w = Math.abs(a), y = Math.abs(f);
|
|
1033
1041
|
let u, g;
|
|
1034
1042
|
if (d < 150) {
|
|
1035
1043
|
const v = e.closest("me-main").className === "lhs" ? -1 : 1;
|
|
@@ -1041,8 +1049,8 @@ const _e = function(t, e, n) {
|
|
|
1041
1049
|
const v = f > 0 ? e.offsetHeight / 2 : -e.offsetHeight / 2, C = f > 0 ? -n.offsetHeight / 2 : n.offsetHeight / 2;
|
|
1042
1050
|
u = { x: 0, y: v + (f > 0 ? p : -p) }, g = { x: 0, y: C + (f > 0 ? -p : p) };
|
|
1043
1051
|
} else {
|
|
1044
|
-
const v = Math.atan2(f, a), C = e.offsetWidth / 2 * Math.cos(v), T = e.offsetHeight / 2 * Math.sin(v), h = -(n.offsetWidth / 2) * Math.cos(v), m = -(n.offsetHeight / 2) * Math.sin(v), x = p * 0.7 * (a > 0 ? 1 : -1),
|
|
1045
|
-
u = { x: C + x, y: T +
|
|
1052
|
+
const v = Math.atan2(f, a), C = e.offsetWidth / 2 * Math.cos(v), T = e.offsetHeight / 2 * Math.sin(v), h = -(n.offsetWidth / 2) * Math.cos(v), m = -(n.offsetHeight / 2) * Math.sin(v), x = p * 0.7 * (a > 0 ? 1 : -1), E = p * 0.7 * (f > 0 ? 1 : -1);
|
|
1053
|
+
u = { x: C + x, y: T + E }, g = { x: h - x, y: m - E };
|
|
1046
1054
|
}
|
|
1047
1055
|
return {
|
|
1048
1056
|
delta1: { x: Math.round(u.x), y: Math.round(u.y) },
|
|
@@ -1052,28 +1060,28 @@ const _e = function(t, e, n) {
|
|
|
1052
1060
|
if (!e || !n)
|
|
1053
1061
|
return;
|
|
1054
1062
|
if (!o.delta1 || !o.delta2) {
|
|
1055
|
-
const
|
|
1056
|
-
o.delta1 =
|
|
1063
|
+
const S = qe(t, e, n);
|
|
1064
|
+
o.delta1 = S.delta1, o.delta2 = S.delta2;
|
|
1057
1065
|
}
|
|
1058
|
-
const i = q(t, e, o.delta1), r = q(t, n, o.delta2), { x: c, y: l } =
|
|
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);
|
|
1059
1067
|
if (!u) return;
|
|
1060
1068
|
const g = `M ${u.x1} ${u.y1} L ${w} ${y} L ${u.x2} ${u.y2}`;
|
|
1061
1069
|
let b = "";
|
|
1062
1070
|
if (o.bidirectional) {
|
|
1063
|
-
const
|
|
1064
|
-
if (!
|
|
1065
|
-
b = `M ${
|
|
1071
|
+
const S = _(a, f, c, l);
|
|
1072
|
+
if (!S) return;
|
|
1073
|
+
b = `M ${S.x1} ${S.y1} L ${c} ${l} L ${S.x2} ${S.y2}`;
|
|
1066
1074
|
}
|
|
1067
1075
|
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;
|
|
1068
1076
|
v.id = m;
|
|
1069
|
-
const x = t.markdown ? t.markdown(o.label, o) : o.label,
|
|
1077
|
+
const x = t.markdown ? t.markdown(o.label, o) : o.label, E = Q(x, C, T, {
|
|
1070
1078
|
anchor: "middle",
|
|
1071
1079
|
color: h,
|
|
1072
1080
|
dataType: "arrow",
|
|
1073
1081
|
svgId: m
|
|
1074
1082
|
});
|
|
1075
|
-
v.labelEl =
|
|
1076
|
-
},
|
|
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));
|
|
1084
|
+
}, je = function(t, e, n = {}) {
|
|
1077
1085
|
const o = {
|
|
1078
1086
|
id: Y(),
|
|
1079
1087
|
label: "Custom Link",
|
|
@@ -1085,14 +1093,14 @@ const _e = function(t, e, n) {
|
|
|
1085
1093
|
name: "createArrow",
|
|
1086
1094
|
obj: o
|
|
1087
1095
|
});
|
|
1088
|
-
},
|
|
1096
|
+
}, Ue = function(t) {
|
|
1089
1097
|
K(this);
|
|
1090
1098
|
const e = { ...t, id: Y() };
|
|
1091
1099
|
it(this, this.findEle(e.from), this.findEle(e.to), e), this.bus.fire("operation", {
|
|
1092
1100
|
name: "createArrow",
|
|
1093
1101
|
obj: e
|
|
1094
1102
|
});
|
|
1095
|
-
},
|
|
1103
|
+
}, Ke = function(t) {
|
|
1096
1104
|
let e;
|
|
1097
1105
|
if (t ? e = t : e = this.currentArrow, !e) return;
|
|
1098
1106
|
K(this);
|
|
@@ -1103,14 +1111,14 @@ const _e = function(t, e, n) {
|
|
|
1103
1111
|
id: n
|
|
1104
1112
|
}
|
|
1105
1113
|
});
|
|
1106
|
-
},
|
|
1114
|
+
}, Je = function(t) {
|
|
1107
1115
|
this.currentArrow = t;
|
|
1108
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);
|
|
1109
1117
|
this.editable ? At(this, e, s, i) : Nt(t, Pt), this.bus.fire("selectArrow", e);
|
|
1110
|
-
},
|
|
1118
|
+
}, Ze = function() {
|
|
1111
1119
|
K(this), this.currentArrow = null, this.bus.fire("unselectArrow");
|
|
1112
1120
|
}, Z = function(t, e) {
|
|
1113
|
-
const n = document.createElementNS(
|
|
1121
|
+
const n = document.createElementNS(k, "path");
|
|
1114
1122
|
return D(n, {
|
|
1115
1123
|
d: t,
|
|
1116
1124
|
stroke: e,
|
|
@@ -1120,7 +1128,7 @@ const _e = function(t, e, n) {
|
|
|
1120
1128
|
"stroke-linejoin": "round"
|
|
1121
1129
|
}), n;
|
|
1122
1130
|
}, Nt = function(t, e) {
|
|
1123
|
-
const n = document.createElementNS(
|
|
1131
|
+
const n = document.createElementNS(k, "g");
|
|
1124
1132
|
n.setAttribute("class", "arrow-highlight"), n.setAttribute("opacity", "0.45");
|
|
1125
1133
|
const o = Z(t.line.getAttribute("d"), e);
|
|
1126
1134
|
n.appendChild(o);
|
|
@@ -1130,32 +1138,32 @@ const _e = function(t, e, n) {
|
|
|
1130
1138
|
n.appendChild(i);
|
|
1131
1139
|
}
|
|
1132
1140
|
t.insertBefore(n, t.firstChild);
|
|
1133
|
-
},
|
|
1141
|
+
}, Qe = function(t) {
|
|
1134
1142
|
const e = t.querySelector(".arrow-highlight");
|
|
1135
1143
|
e && e.remove();
|
|
1136
|
-
},
|
|
1144
|
+
}, tn = function(t) {
|
|
1137
1145
|
const e = t.querySelector(".arrow-highlight");
|
|
1138
1146
|
if (!e) return;
|
|
1139
1147
|
const n = e.querySelectorAll("path");
|
|
1140
1148
|
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"));
|
|
1141
1149
|
}, K = function(t) {
|
|
1142
|
-
t.helper1?.destroy(), t.helper2?.destroy(), t.linkController.style.display = "none", t.P2.style.display = "none", t.P3.style.display = "none", t.currentArrow &&
|
|
1150
|
+
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);
|
|
1143
1151
|
}, At = function(t, e, n, o) {
|
|
1144
1152
|
const { linkController: s, P2: i, P3: r, line1: c, line2: l, nodes: a, map: f, currentArrow: d, bus: p } = t;
|
|
1145
1153
|
if (!d) return;
|
|
1146
1154
|
s.style.display = "initial", i.style.display = "initial", r.style.display = "initial", a.appendChild(s), a.appendChild(i), a.appendChild(r), Nt(d, Pt);
|
|
1147
|
-
let { x: w, y } =
|
|
1155
|
+
let { x: w, y } = I(n), { ctrlX: u, ctrlY: g } = n, { ctrlX: b, ctrlY: v } = o, { x: C, y: T } = I(o);
|
|
1148
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) => {
|
|
1149
1157
|
u = u + h / t.scaleVal, g = g + m / t.scaleVal;
|
|
1150
|
-
const x =
|
|
1158
|
+
const x = I({ ...n, ctrlX: u, ctrlY: g });
|
|
1151
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);
|
|
1152
1160
|
}), t.helper2.init(f, (h, m) => {
|
|
1153
1161
|
b = b + h / t.scaleVal, v = v + m / t.scaleVal;
|
|
1154
|
-
const x =
|
|
1162
|
+
const x = I({ ...o, ctrlX: b, ctrlY: v });
|
|
1155
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);
|
|
1156
1164
|
});
|
|
1157
1165
|
};
|
|
1158
|
-
function
|
|
1166
|
+
function en() {
|
|
1159
1167
|
this.arrowSvg.innerHTML = "", this.labelContainer.querySelectorAll('.svg-label[data-type="arrow"]').forEach((e) => e.remove());
|
|
1160
1168
|
for (let e = 0; e < this.arrows.length; e++) {
|
|
1161
1169
|
const n = this.arrows[e];
|
|
@@ -1166,23 +1174,23 @@ function tn() {
|
|
|
1166
1174
|
}
|
|
1167
1175
|
this.nodes.appendChild(this.arrowSvg);
|
|
1168
1176
|
}
|
|
1169
|
-
function
|
|
1177
|
+
function nn(t) {
|
|
1170
1178
|
K(this), t && t.labelEl && Lt(this, t.labelEl, t.arrowObj);
|
|
1171
1179
|
}
|
|
1172
|
-
function
|
|
1180
|
+
function on() {
|
|
1173
1181
|
this.arrows = this.arrows.filter((t) => G(t.from, this.nodeData) && G(t.to, this.nodeData));
|
|
1174
1182
|
}
|
|
1175
|
-
const
|
|
1183
|
+
const sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1176
1184
|
__proto__: null,
|
|
1177
|
-
createArrow:
|
|
1178
|
-
createArrowFrom:
|
|
1179
|
-
editArrowLabel:
|
|
1180
|
-
removeArrow:
|
|
1181
|
-
renderArrow:
|
|
1182
|
-
selectArrow:
|
|
1183
|
-
tidyArrow:
|
|
1184
|
-
unselectArrow:
|
|
1185
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
1185
|
+
createArrow: je,
|
|
1186
|
+
createArrowFrom: Ue,
|
|
1187
|
+
editArrowLabel: nn,
|
|
1188
|
+
removeArrow: Ke,
|
|
1189
|
+
renderArrow: en,
|
|
1190
|
+
selectArrow: Je,
|
|
1191
|
+
tidyArrow: on,
|
|
1192
|
+
unselectArrow: Ze
|
|
1193
|
+
}, Symbol.toStringTag, { value: "Module" })), rn = function(t) {
|
|
1186
1194
|
if (t.length === 0) throw new Error("No selected node.");
|
|
1187
1195
|
if (t.length === 1) {
|
|
1188
1196
|
const l = t[0].nodeObj, a = t[0].nodeObj.parent;
|
|
@@ -1219,11 +1227,11 @@ const on = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
1219
1227
|
start: i,
|
|
1220
1228
|
end: r
|
|
1221
1229
|
};
|
|
1222
|
-
},
|
|
1223
|
-
const e = document.createElementNS(
|
|
1230
|
+
}, cn = function(t) {
|
|
1231
|
+
const e = document.createElementNS(k, "g");
|
|
1224
1232
|
return e.setAttribute("id", t), e;
|
|
1225
1233
|
}, yt = function(t, e) {
|
|
1226
|
-
const n = document.createElementNS(
|
|
1234
|
+
const n = document.createElementNS(k, "path");
|
|
1227
1235
|
return D(n, {
|
|
1228
1236
|
d: t,
|
|
1229
1237
|
stroke: e || "#666",
|
|
@@ -1231,69 +1239,69 @@ const on = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
1231
1239
|
"stroke-linecap": "round",
|
|
1232
1240
|
"stroke-width": "2"
|
|
1233
1241
|
}), n;
|
|
1234
|
-
},
|
|
1242
|
+
}, ln = (t) => t.parentElement.parentElement, an = function(t, { parent: e, start: n }) {
|
|
1235
1243
|
const o = t.findEle(e), s = o.nodeObj;
|
|
1236
1244
|
let i;
|
|
1237
1245
|
return s.parent ? i = o.closest("me-main").className : i = t.findEle(s.children[n].id).closest("me-main").className, i;
|
|
1238
1246
|
}, rt = function(t, e) {
|
|
1239
|
-
const { id: n, label: o, parent: s, start: i, end: r, style: c } = e, { nodes: l, theme: a, summarySvg: f } = t, p = t.findEle(s).nodeObj, w =
|
|
1247
|
+
const { id: n, label: o, parent: s, start: i, end: r, style: c } = e, { nodes: l, theme: a, summarySvg: f } = t, p = t.findEle(s).nodeObj, w = an(t, e);
|
|
1240
1248
|
let y = 1 / 0, u = 0, g = 0, b = 0;
|
|
1241
1249
|
for (let B = i; B <= r; B++) {
|
|
1242
1250
|
const ct = p.children?.[B];
|
|
1243
1251
|
if (!ct)
|
|
1244
1252
|
return t.removeSummary(n), null;
|
|
1245
|
-
const R =
|
|
1253
|
+
const R = ln(t.findEle(ct.id)), { offsetLeft: X, offsetTop: lt } = P(l, R), at = i === r ? 10 : 20;
|
|
1246
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);
|
|
1247
1255
|
}
|
|
1248
1256
|
let v, C;
|
|
1249
|
-
const T = p.parent ? 10 : 0, h = g + T, m = b + T, x = (h + m) / 2,
|
|
1250
|
-
w ===
|
|
1251
|
-
const
|
|
1252
|
-
return
|
|
1253
|
-
},
|
|
1257
|
+
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 }));
|
|
1259
|
+
const $ = cn(M);
|
|
1260
|
+
return $.appendChild(v), t.labelContainer.appendChild(C), U(C), $.summaryObj = e, $.labelEl = C, f.appendChild($), $;
|
|
1261
|
+
}, hn = function(t = {}) {
|
|
1254
1262
|
if (!this.currentNodes) return;
|
|
1255
|
-
const { currentNodes: e, summaries: n, bus: o } = this, { parent: s, start: i, end: r } =
|
|
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);
|
|
1256
1264
|
n.push(c), this.editSummary(l), o.fire("operation", {
|
|
1257
1265
|
name: "createSummary",
|
|
1258
1266
|
obj: c
|
|
1259
1267
|
});
|
|
1260
|
-
},
|
|
1268
|
+
}, dn = function(t) {
|
|
1261
1269
|
const e = Y(), n = { ...t, id: e };
|
|
1262
1270
|
rt(this, n), this.summaries.push(n), this.bus.fire("operation", {
|
|
1263
1271
|
name: "createSummary",
|
|
1264
1272
|
obj: n
|
|
1265
1273
|
});
|
|
1266
|
-
},
|
|
1274
|
+
}, fn = function(t) {
|
|
1267
1275
|
const e = this.summaries.findIndex((n) => n.id === t);
|
|
1268
1276
|
e > -1 && (this.summaries.splice(e, 1), this.nodes.querySelector("#s-" + t)?.remove(), this.nodes.querySelector("#label-s-" + t)?.remove()), this.bus.fire("operation", {
|
|
1269
1277
|
name: "removeSummary",
|
|
1270
1278
|
obj: { id: t }
|
|
1271
1279
|
});
|
|
1272
|
-
},
|
|
1280
|
+
}, un = function(t) {
|
|
1273
1281
|
const e = t.labelEl;
|
|
1274
1282
|
e && e.classList.add("selected"), this.currentSummary = t, this.bus.fire("selectSummary", t.summaryObj);
|
|
1275
|
-
}, un = function() {
|
|
1276
|
-
this.currentSummary?.labelEl?.classList.remove("selected"), this.currentSummary = null, this.bus.fire("unselectSummary");
|
|
1277
1283
|
}, pn = function() {
|
|
1284
|
+
this.currentSummary?.labelEl?.classList.remove("selected"), this.currentSummary = null, this.bus.fire("unselectSummary");
|
|
1285
|
+
}, gn = function() {
|
|
1278
1286
|
this.summarySvg.innerHTML = "", this.summaries.forEach((t) => {
|
|
1279
1287
|
try {
|
|
1280
1288
|
rt(this, t);
|
|
1281
1289
|
} catch {
|
|
1282
1290
|
}
|
|
1283
1291
|
}), this.nodes.insertAdjacentElement("beforeend", this.summarySvg);
|
|
1284
|
-
},
|
|
1292
|
+
}, mn = function(t) {
|
|
1285
1293
|
t && t.labelEl && Lt(this, t.labelEl, t.summaryObj);
|
|
1286
|
-
},
|
|
1294
|
+
}, yn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1287
1295
|
__proto__: null,
|
|
1288
|
-
createSummary:
|
|
1289
|
-
createSummaryFrom:
|
|
1290
|
-
editSummary:
|
|
1291
|
-
removeSummary:
|
|
1292
|
-
renderSummary:
|
|
1293
|
-
selectSummary:
|
|
1294
|
-
unselectSummary:
|
|
1296
|
+
createSummary: hn,
|
|
1297
|
+
createSummaryFrom: dn,
|
|
1298
|
+
editSummary: mn,
|
|
1299
|
+
removeSummary: fn,
|
|
1300
|
+
renderSummary: gn,
|
|
1301
|
+
selectSummary: un,
|
|
1302
|
+
unselectSummary: pn
|
|
1295
1303
|
}, Symbol.toStringTag, { value: "Module" })), L = "http://www.w3.org/2000/svg";
|
|
1296
|
-
function
|
|
1304
|
+
function wn(t, e) {
|
|
1297
1305
|
const n = document.createElementNS(L, "svg");
|
|
1298
1306
|
return D(n, {
|
|
1299
1307
|
version: "1.1",
|
|
@@ -1302,10 +1310,10 @@ function yn(t, e) {
|
|
|
1302
1310
|
width: e
|
|
1303
1311
|
}), n;
|
|
1304
1312
|
}
|
|
1305
|
-
function
|
|
1313
|
+
function vn(t, e) {
|
|
1306
1314
|
return (parseInt(t) - parseInt(e)) / 2;
|
|
1307
1315
|
}
|
|
1308
|
-
function
|
|
1316
|
+
function bn(t, e, n, o) {
|
|
1309
1317
|
const s = document.createElementNS(L, "g");
|
|
1310
1318
|
let i = "";
|
|
1311
1319
|
return t.text ? i = t.text.textContent : i = t.childNodes[0].textContent, i.split(`
|
|
@@ -1313,7 +1321,7 @@ function vn(t, e, n, o) {
|
|
|
1313
1321
|
const a = document.createElementNS(L, "text");
|
|
1314
1322
|
D(a, {
|
|
1315
1323
|
x: n + parseInt(e.paddingLeft) + "",
|
|
1316
|
-
y: o + parseInt(e.paddingTop) +
|
|
1324
|
+
y: o + parseInt(e.paddingTop) + vn(e.lineHeight, e.fontSize) * (l + 1) + parseFloat(e.fontSize) * (l + 1) + "",
|
|
1317
1325
|
"text-anchor": "start",
|
|
1318
1326
|
"font-family": e.fontFamily,
|
|
1319
1327
|
"font-size": `${e.fontSize}`,
|
|
@@ -1322,7 +1330,7 @@ function vn(t, e, n, o) {
|
|
|
1322
1330
|
}), a.innerHTML = c, s.appendChild(a);
|
|
1323
1331
|
}), s;
|
|
1324
1332
|
}
|
|
1325
|
-
function
|
|
1333
|
+
function xn(t, e, n, o) {
|
|
1326
1334
|
let s = "";
|
|
1327
1335
|
t.nodeObj?.dangerouslySetInnerHTML ? s = t.nodeObj.dangerouslySetInnerHTML : t.text ? s = t.text.textContent : s = t.childNodes[0].textContent;
|
|
1328
1336
|
const i = document.createElementNS(L, "foreignObject");
|
|
@@ -1338,8 +1346,8 @@ function bn(t, e, n, o) {
|
|
|
1338
1346
|
style: `font-family: ${e.fontFamily}; font-size: ${e.fontSize}; font-weight: ${e.fontWeight}; color: ${e.color}; white-space: pre-wrap;`
|
|
1339
1347
|
}), r.innerHTML = s, i.appendChild(r), i;
|
|
1340
1348
|
}
|
|
1341
|
-
function
|
|
1342
|
-
const n = getComputedStyle(e), { offsetLeft: o, offsetTop: s } =
|
|
1349
|
+
function Cn(t, e) {
|
|
1350
|
+
const n = getComputedStyle(e), { offsetLeft: o, offsetTop: s } = P(t.nodes, e), i = document.createElementNS(L, "rect");
|
|
1343
1351
|
return D(i, {
|
|
1344
1352
|
x: o + "",
|
|
1345
1353
|
y: s + "",
|
|
@@ -1353,7 +1361,7 @@ function xn(t, e) {
|
|
|
1353
1361
|
}), i;
|
|
1354
1362
|
}
|
|
1355
1363
|
function z(t, e, n = !1) {
|
|
1356
|
-
const o = getComputedStyle(e), { offsetLeft: s, offsetTop: i } =
|
|
1364
|
+
const o = getComputedStyle(e), { offsetLeft: s, offsetTop: i } = P(t.nodes, e), r = document.createElementNS(L, "rect");
|
|
1357
1365
|
D(r, {
|
|
1358
1366
|
x: s + "",
|
|
1359
1367
|
y: i + "",
|
|
@@ -1368,10 +1376,10 @@ function z(t, e, n = !1) {
|
|
|
1368
1376
|
const c = document.createElementNS(L, "g");
|
|
1369
1377
|
c.appendChild(r);
|
|
1370
1378
|
let l;
|
|
1371
|
-
return n ? l =
|
|
1379
|
+
return n ? l = xn(e, o, s, i) : l = bn(e, o, s, i), c.appendChild(l), c;
|
|
1372
1380
|
}
|
|
1373
|
-
function
|
|
1374
|
-
const n = getComputedStyle(e), { offsetLeft: o, offsetTop: s } =
|
|
1381
|
+
function Sn(t, e) {
|
|
1382
|
+
const n = getComputedStyle(e), { offsetLeft: o, offsetTop: s } = P(t.nodes, e), i = document.createElementNS(L, "a"), r = document.createElementNS(L, "text");
|
|
1375
1383
|
return D(r, {
|
|
1376
1384
|
x: o + "",
|
|
1377
1385
|
y: s + parseInt(n.fontSize) + "",
|
|
@@ -1382,8 +1390,8 @@ function Cn(t, e) {
|
|
|
1382
1390
|
fill: `${n.color}`
|
|
1383
1391
|
}), r.innerHTML = e.textContent, i.appendChild(r), i.setAttribute("href", e.href), i;
|
|
1384
1392
|
}
|
|
1385
|
-
function
|
|
1386
|
-
const n = getComputedStyle(e), { offsetLeft: o, offsetTop: s } =
|
|
1393
|
+
function En(t, e) {
|
|
1394
|
+
const n = getComputedStyle(e), { offsetLeft: o, offsetTop: s } = P(t.nodes, e), i = document.createElementNS(L, "image");
|
|
1387
1395
|
return D(i, {
|
|
1388
1396
|
x: o + "",
|
|
1389
1397
|
y: s + "",
|
|
@@ -1392,8 +1400,8 @@ function Sn(t, e) {
|
|
|
1392
1400
|
href: e.src
|
|
1393
1401
|
}), i;
|
|
1394
1402
|
}
|
|
1395
|
-
const F = 100,
|
|
1396
|
-
const n = t.nodes, o = n.offsetHeight + F * 2, s = n.offsetWidth + F * 2, i =
|
|
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");
|
|
1397
1405
|
D(c, {
|
|
1398
1406
|
x: "0",
|
|
1399
1407
|
y: "0",
|
|
@@ -1401,7 +1409,7 @@ const F = 100, En = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "
|
|
|
1401
1409
|
height: `${o}`,
|
|
1402
1410
|
fill: t.theme.cssVar["--bgcolor"]
|
|
1403
1411
|
}), i.appendChild(c), n.querySelectorAll(".subLines").forEach((d) => {
|
|
1404
|
-
const p = d.cloneNode(!0), { offsetLeft: w, offsetTop: y } =
|
|
1412
|
+
const p = d.cloneNode(!0), { offsetLeft: w, offsetTop: y } = P(n, d.parentElement);
|
|
1405
1413
|
p.setAttribute("x", `${w}`), p.setAttribute("y", `${y}`), r.appendChild(p);
|
|
1406
1414
|
});
|
|
1407
1415
|
const l = n.querySelector(".lines")?.cloneNode(!0);
|
|
@@ -1410,22 +1418,22 @@ const F = 100, En = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "
|
|
|
1410
1418
|
a && r.appendChild(a);
|
|
1411
1419
|
const f = n.querySelector(".summary")?.cloneNode(!0);
|
|
1412
1420
|
return f && r.appendChild(f), n.querySelectorAll("me-tpc").forEach((d) => {
|
|
1413
|
-
d.nodeObj.dangerouslySetInnerHTML ? r.appendChild(z(t, d, !e)) : (r.appendChild(
|
|
1421
|
+
d.nodeObj.dangerouslySetInnerHTML ? r.appendChild(z(t, d, !e)) : (r.appendChild(Cn(t, d)), r.appendChild(z(t, d.text, !e)));
|
|
1414
1422
|
}), n.querySelectorAll(".tags > span").forEach((d) => {
|
|
1415
1423
|
r.appendChild(z(t, d));
|
|
1416
1424
|
}), n.querySelectorAll(".icons > span").forEach((d) => {
|
|
1417
1425
|
r.appendChild(z(t, d));
|
|
1418
1426
|
}), n.querySelectorAll(".hyper-link").forEach((d) => {
|
|
1419
|
-
r.appendChild(Cn(t, d));
|
|
1420
|
-
}), n.querySelectorAll("img").forEach((d) => {
|
|
1421
1427
|
r.appendChild(Sn(t, d));
|
|
1428
|
+
}), n.querySelectorAll("img").forEach((d) => {
|
|
1429
|
+
r.appendChild(En(t, d));
|
|
1422
1430
|
}), D(r, {
|
|
1423
1431
|
x: F + "",
|
|
1424
1432
|
y: F + "",
|
|
1425
1433
|
overflow: "visible"
|
|
1426
1434
|
}), i.appendChild(r), i;
|
|
1427
|
-
},
|
|
1428
|
-
function
|
|
1435
|
+
}, Ln = (t, e) => (e && t.insertAdjacentHTML("afterbegin", "<style>" + e + "</style>"), Tn + t.outerHTML);
|
|
1436
|
+
function Mn(t) {
|
|
1429
1437
|
return new Promise((e, n) => {
|
|
1430
1438
|
const o = new FileReader();
|
|
1431
1439
|
o.onload = (s) => {
|
|
@@ -1435,11 +1443,11 @@ function Ln(t) {
|
|
|
1435
1443
|
}, o.readAsDataURL(t);
|
|
1436
1444
|
});
|
|
1437
1445
|
}
|
|
1438
|
-
const
|
|
1439
|
-
const n =
|
|
1446
|
+
const Pn = function(t = !1, e) {
|
|
1447
|
+
const n = Dn(this, t), o = Ln(n, e);
|
|
1440
1448
|
return new Blob([o], { type: "image/svg+xml" });
|
|
1441
|
-
},
|
|
1442
|
-
const n = this.exportSvg(t, e), o = await
|
|
1449
|
+
}, kn = async function(t = !1, e) {
|
|
1450
|
+
const n = this.exportSvg(t, e), o = await Mn(n);
|
|
1443
1451
|
return new Promise((s, i) => {
|
|
1444
1452
|
const r = new Image();
|
|
1445
1453
|
r.setAttribute("crossOrigin", "anonymous"), r.onload = () => {
|
|
@@ -1447,11 +1455,11 @@ const Mn = function(t = !1, e) {
|
|
|
1447
1455
|
c.width = r.width, c.height = r.height, c.getContext("2d").drawImage(r, 0, 0), c.toBlob(s, "image/png", 1);
|
|
1448
1456
|
}, r.src = o, r.onerror = i;
|
|
1449
1457
|
});
|
|
1450
|
-
},
|
|
1458
|
+
}, Nn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1451
1459
|
__proto__: null,
|
|
1452
|
-
exportPng:
|
|
1453
|
-
exportSvg:
|
|
1454
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
1460
|
+
exportPng: kn,
|
|
1461
|
+
exportSvg: Pn
|
|
1462
|
+
}, Symbol.toStringTag, { value: "Module" })), An = {}, $n = {
|
|
1455
1463
|
getObjById: G,
|
|
1456
1464
|
generateNewObj: Ht,
|
|
1457
1465
|
layout: Vt,
|
|
@@ -1463,11 +1471,12 @@ const Mn = function(t = !1, e) {
|
|
|
1463
1471
|
createTopic: jt,
|
|
1464
1472
|
findEle: Ct,
|
|
1465
1473
|
changeTheme: ze,
|
|
1474
|
+
changeCompact: Fe,
|
|
1466
1475
|
...xe,
|
|
1476
|
+
...An,
|
|
1477
|
+
...sn,
|
|
1478
|
+
...yn,
|
|
1467
1479
|
...Nn,
|
|
1468
|
-
...on,
|
|
1469
|
-
...mn,
|
|
1470
|
-
...kn,
|
|
1471
1480
|
init(t) {
|
|
1472
1481
|
if (t = JSON.parse(JSON.stringify(t)), !t || !t.nodeData) return new Error("MindElixir: `data` is required");
|
|
1473
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();
|
|
@@ -1483,25 +1492,25 @@ const Mn = function(t = !1, e) {
|
|
|
1483
1492
|
this.mobileMultiSelect = t;
|
|
1484
1493
|
}
|
|
1485
1494
|
};
|
|
1486
|
-
function
|
|
1495
|
+
function Hn({ pT: t, pL: e, pW: n, pH: o, cT: s, cL: i, cW: r, cH: c, direction: l, containerHeight: a }) {
|
|
1487
1496
|
let f = e + n / 2;
|
|
1488
1497
|
const d = t + o / 2;
|
|
1489
1498
|
let p;
|
|
1490
|
-
l ===
|
|
1499
|
+
l === O.LHS ? p = i + r : p = i;
|
|
1491
1500
|
const w = s + c / 2, u = (1 - Math.abs(w - d) / a) * 0.25 * (n / 2);
|
|
1492
|
-
return l ===
|
|
1501
|
+
return l === O.LHS ? f = f - n / 10 - u : f = f + n / 10 + u, `M ${f} ${d} Q ${f} ${w} ${p} ${w}`;
|
|
1493
1502
|
}
|
|
1494
|
-
function
|
|
1503
|
+
function In({ pT: t, pL: e, pW: n, pH: o, cT: s, cL: i, cW: r, cH: c, direction: l, isFirst: a }) {
|
|
1495
1504
|
const f = parseInt(this.container.style.getPropertyValue("--node-gap-x"));
|
|
1496
1505
|
let d = 0, p = 0;
|
|
1497
1506
|
a ? d = t + o / 2 : d = t + o;
|
|
1498
1507
|
const w = s + c;
|
|
1499
1508
|
let y = 0, u = 0, g = 0;
|
|
1500
1509
|
const b = Math.abs(d - w) / 300 * f;
|
|
1501
|
-
return l ===
|
|
1510
|
+
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}`);
|
|
1502
1511
|
}
|
|
1503
|
-
const
|
|
1504
|
-
function
|
|
1512
|
+
const On = "5.12.0";
|
|
1513
|
+
function Bn(t) {
|
|
1505
1514
|
return {
|
|
1506
1515
|
x: 0,
|
|
1507
1516
|
y: 0,
|
|
@@ -1543,27 +1552,28 @@ function A({
|
|
|
1543
1552
|
generateMainBranch: d,
|
|
1544
1553
|
generateSubBranch: p,
|
|
1545
1554
|
overflowHidden: w,
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1555
|
+
compact: y,
|
|
1556
|
+
theme: u,
|
|
1557
|
+
alignment: g,
|
|
1558
|
+
scaleSensitivity: b,
|
|
1559
|
+
scaleMax: v,
|
|
1560
|
+
scaleMin: C,
|
|
1561
|
+
handleWheel: T,
|
|
1562
|
+
markdown: h,
|
|
1563
|
+
imageProxy: m,
|
|
1564
|
+
pasteHandler: x,
|
|
1565
|
+
mobileMultiSelect: E
|
|
1556
1566
|
}) {
|
|
1557
1567
|
let S = null;
|
|
1558
|
-
const
|
|
1559
|
-
if (
|
|
1560
|
-
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 =
|
|
1561
|
-
const
|
|
1562
|
-
this.theme =
|
|
1563
|
-
const
|
|
1564
|
-
|
|
1568
|
+
const M = Object.prototype.toString.call(t);
|
|
1569
|
+
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
|
+
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
|
+
const N = window.matchMedia("(prefers-color-scheme: dark)");
|
|
1572
|
+
this.theme = u || (N.matches ? et : tt);
|
|
1573
|
+
const $ = document.createElement("div");
|
|
1574
|
+
$.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);
|
|
1565
1575
|
}
|
|
1566
|
-
A.prototype =
|
|
1576
|
+
A.prototype = $n;
|
|
1567
1577
|
Object.defineProperty(A.prototype, "currentNode", {
|
|
1568
1578
|
get() {
|
|
1569
1579
|
return this.currentNodes[this.currentNodes.length - 1];
|
|
@@ -1575,13 +1585,13 @@ A.RIGHT = 1;
|
|
|
1575
1585
|
A.SIDE = 2;
|
|
1576
1586
|
A.THEME = tt;
|
|
1577
1587
|
A.DARK_THEME = et;
|
|
1578
|
-
A.version =
|
|
1588
|
+
A.version = On;
|
|
1579
1589
|
A.E = Ct;
|
|
1580
1590
|
export {
|
|
1581
1591
|
et as DARK_THEME,
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1592
|
+
Wn as LEFT,
|
|
1593
|
+
Yn as RIGHT,
|
|
1594
|
+
Rn as SIDE,
|
|
1585
1595
|
tt as THEME,
|
|
1586
1596
|
A as default
|
|
1587
1597
|
};
|