mind-elixir 5.11.1-beta.4 → 5.11.3
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 +2 -2
- package/dist/MindElixir.js +11 -7
- package/dist/MindElixirLite.iife.js +4 -4
- package/dist/MindElixirLite.js +107 -103
- package/dist/types/index.d.ts +1 -1
- package/dist/types/interact.d.ts +1 -1
- package/dist/types/methods.d.ts +1 -1
- package/package.json +2 -2
package/dist/MindElixirLite.js
CHANGED
|
@@ -77,12 +77,12 @@ const G = function(t, e) {
|
|
|
77
77
|
});
|
|
78
78
|
};
|
|
79
79
|
function _(t, e, n, o) {
|
|
80
|
-
const s = n - t, i = o - e, c = Math.atan2(i, s) * 180 / Math.PI, l = 12, a = 30,
|
|
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
|
-
x1: n + Math.cos(
|
|
83
|
-
y1: o + Math.sin(
|
|
84
|
-
x2: n + Math.cos(
|
|
85
|
-
y2: o + Math.sin(
|
|
82
|
+
x1: n + Math.cos(f) * l,
|
|
83
|
+
y1: o + Math.sin(f) * l,
|
|
84
|
+
x2: n + Math.cos(d) * l,
|
|
85
|
+
y2: o + Math.sin(d) * l
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
88
|
function Y() {
|
|
@@ -203,13 +203,13 @@ function Rt(t, e, n) {
|
|
|
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;
|
|
206
|
-
const
|
|
207
|
-
n.clientY >
|
|
206
|
+
const f = a.getBoundingClientRect(), d = f.y;
|
|
207
|
+
n.clientY > d + f.height ? e.insertType = "after" : e.insertType = "in";
|
|
208
208
|
} else {
|
|
209
|
-
const
|
|
210
|
-
if (dt(
|
|
211
|
-
e.meet =
|
|
212
|
-
const p =
|
|
209
|
+
const f = document.elementFromPoint(n.clientX, n.clientY + l);
|
|
210
|
+
if (dt(f, o)) {
|
|
211
|
+
e.meet = f;
|
|
212
|
+
const p = f.getBoundingClientRect().y;
|
|
213
213
|
n.clientY < p ? e.insertType = "before" : e.insertType = "in";
|
|
214
214
|
} else
|
|
215
215
|
e.insertType = null, e.meet = null;
|
|
@@ -385,11 +385,11 @@ function Zt(t) {
|
|
|
385
385
|
theme: t.theme
|
|
386
386
|
};
|
|
387
387
|
}
|
|
388
|
-
const Qt = function(t) {
|
|
389
|
-
const
|
|
390
|
-
if (
|
|
391
|
-
const
|
|
392
|
-
this.move(-
|
|
388
|
+
const Qt = function(t, e = !1) {
|
|
389
|
+
const n = this.container, o = t.getBoundingClientRect(), s = n.getBoundingClientRect();
|
|
390
|
+
if (e || o.top > s.bottom - 50 || o.bottom < s.top + 50 || o.left > s.right - 50 || o.right < s.left + 50) {
|
|
391
|
+
const r = o.left + o.width / 2, c = o.top + o.height / 2, l = s.left + s.width / 2, a = s.top + s.height / 2, f = r - l, d = c - a;
|
|
392
|
+
this.move(-f, -d, !0);
|
|
393
393
|
}
|
|
394
394
|
}, te = function(t, e, n) {
|
|
395
395
|
this.clearSelection(), this.scrollIntoView(t), this.selection?.select(t), e && this.bus.fire("selectNewNode", t.nodeObj);
|
|
@@ -415,7 +415,7 @@ const Qt = function(t) {
|
|
|
415
415
|
this.editable = !1;
|
|
416
416
|
}, le = function(t, e = { x: 0, y: 0 }) {
|
|
417
417
|
if (t < this.scaleMin && t < this.scaleVal || t > this.scaleMax && t > this.scaleVal) return;
|
|
418
|
-
const n = this.container.getBoundingClientRect(), o = e.x ? e.x - n.left - n.width / 2 : 0, s = e.y ? e.y - n.top - n.height / 2 : 0, { dx: i, dy: r } = st(this), c = this.map.style.transform, { x: l, y: a } = ot(c),
|
|
418
|
+
const n = this.container.getBoundingClientRect(), o = e.x ? e.x - n.left - n.width / 2 : 0, s = e.y ? e.y - n.top - n.height / 2 : 0, { dx: i, dy: r } = st(this), c = this.map.style.transform, { x: l, y: a } = ot(c), f = l - i, d = a - r, p = this.scaleVal, w = (-o + f) * (1 - t / p), y = (-s + d) * (1 - t / p);
|
|
419
419
|
this.map.style.transform = `translate3d(${l - w}px, ${a - y}px, 0) scale(${t})`, this.scaleVal = t, this.bus.fire("scale", t);
|
|
420
420
|
}, ae = function() {
|
|
421
421
|
const t = this.nodes.offsetHeight / this.container.offsetHeight, e = this.nodes.offsetWidth / this.container.offsetWidth, n = 1 / Math.max(1, Math.max(t, e));
|
|
@@ -427,27 +427,27 @@ const Qt = function(t) {
|
|
|
427
427
|
if (n && o.style.transition === "transform 0.3s")
|
|
428
428
|
return;
|
|
429
429
|
const l = o.style.transform;
|
|
430
|
-
let { x: a, y:
|
|
431
|
-
const
|
|
430
|
+
let { x: a, y: f } = ot(l);
|
|
431
|
+
const d = r.getBoundingClientRect(), p = c.getBoundingClientRect(), w = p.left < d.right && p.right > d.left, y = p.top < d.bottom && p.bottom > d.top;
|
|
432
432
|
if (w) {
|
|
433
433
|
const u = p.left + t, g = p.right + t;
|
|
434
|
-
(u >=
|
|
434
|
+
(u >= d.right || g <= d.left) && (t = 0);
|
|
435
435
|
}
|
|
436
436
|
if (y) {
|
|
437
437
|
const u = p.top + e, g = p.bottom + e;
|
|
438
|
-
(u >=
|
|
438
|
+
(u >= d.bottom || g <= d.top) && (e = 0);
|
|
439
439
|
}
|
|
440
|
-
a += t,
|
|
440
|
+
a += t, f += e, n && (o.style.transition = "transform 0.3s", setTimeout(() => {
|
|
441
441
|
o.style.transition = "none";
|
|
442
|
-
}, 300)), o.style.transform = `translate3d(${a}px, ${
|
|
442
|
+
}, 300)), o.style.transform = `translate3d(${a}px, ${f}px, 0) scale(${s})`, i.fire("move", { dx: t, dy: e });
|
|
443
443
|
}, st = (t, e = !1) => {
|
|
444
444
|
const { container: n, map: o, nodes: s } = t;
|
|
445
445
|
let i, r;
|
|
446
446
|
if (t.alignment === "nodes" || e)
|
|
447
447
|
i = (n.offsetWidth - s.offsetWidth) / 2, r = (n.offsetHeight - s.offsetHeight) / 2, o.style.transformOrigin = "50% 50%";
|
|
448
448
|
else {
|
|
449
|
-
const c = o.querySelector("me-root"), l = c.offsetTop, a = c.offsetLeft,
|
|
450
|
-
i = n.offsetWidth / 2 - a -
|
|
449
|
+
const c = o.querySelector("me-root"), l = c.offsetTop, a = c.offsetLeft, f = c.offsetWidth, d = c.offsetHeight;
|
|
450
|
+
i = n.offsetWidth / 2 - a - f / 2, r = n.offsetHeight / 2 - l - d / 2, o.style.transformOrigin = `${a + f / 2}px 50%`;
|
|
451
451
|
}
|
|
452
452
|
return { dx: i, dy: r };
|
|
453
453
|
}, de = function() {
|
|
@@ -473,18 +473,18 @@ const Qt = function(t) {
|
|
|
473
473
|
y: o.top
|
|
474
474
|
}, i = t.parentNode, r = i.children[1];
|
|
475
475
|
if (r.expanded = n.expanded, r.className = n.expanded ? "minus" : "", Jt(t), n.expanded) {
|
|
476
|
-
const
|
|
476
|
+
const d = this.createChildren(
|
|
477
477
|
n.children.map((p) => this.createWrapper(p).grp)
|
|
478
478
|
);
|
|
479
|
-
i.parentNode.appendChild(
|
|
479
|
+
i.parentNode.appendChild(d);
|
|
480
480
|
} else
|
|
481
481
|
i.parentNode.children[1].remove();
|
|
482
482
|
this.linkDiv(t.closest("me-main > me-wrapper"));
|
|
483
483
|
const c = t.getBoundingClientRect(), l = {
|
|
484
484
|
x: c.left,
|
|
485
485
|
y: c.top
|
|
486
|
-
}, a = s.x - l.x,
|
|
487
|
-
this.move(a,
|
|
486
|
+
}, a = s.x - l.x, f = s.y - l.y;
|
|
487
|
+
this.move(a, f), this.bus.fire("expandNode", n);
|
|
488
488
|
}, ve = function(t, e) {
|
|
489
489
|
const n = t.nodeObj, o = t.getBoundingClientRect(), s = {
|
|
490
490
|
x: o.left,
|
|
@@ -546,6 +546,10 @@ function Me(t) {
|
|
|
546
546
|
lastTapTarget: null,
|
|
547
547
|
DOUBLE_CLICK_THRESHOLD: 300,
|
|
548
548
|
detect(h, m) {
|
|
549
|
+
if (h.button !== 0) {
|
|
550
|
+
this.clear();
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
549
553
|
const x = (/* @__PURE__ */ new Date()).getTime(), S = x - this.lastTap, E = S < this.DOUBLE_CLICK_THRESHOLD && S > 0 && this.lastTapTarget === h.target;
|
|
550
554
|
this.lastTap = x, this.lastTapTarget = h.target, E && m(h);
|
|
551
555
|
},
|
|
@@ -619,7 +623,7 @@ function Me(t) {
|
|
|
619
623
|
if (!E?.type || !E?.element) return !1;
|
|
620
624
|
const { type: P, element: k } = E;
|
|
621
625
|
return t.clearSelection(), P === "arrow" ? m ? t.editArrowLabel(k) : t.selectArrow(k) : m ? t.editSummary(k) : t.selectSummary(k), !0;
|
|
622
|
-
},
|
|
626
|
+
}, f = (h) => {
|
|
623
627
|
if (h.pointerType === "mouse" && h.button !== 0) return;
|
|
624
628
|
if (t.helper1?.moved) {
|
|
625
629
|
t.helper1.clear();
|
|
@@ -637,7 +641,7 @@ function Me(t) {
|
|
|
637
641
|
return;
|
|
638
642
|
const m = h.target;
|
|
639
643
|
m.tagName === "ME-EPD" && (h.ctrlKey || h.metaKey ? t.expandNodeAll(m.previousSibling) : t.expandNode(m.previousSibling));
|
|
640
|
-
},
|
|
644
|
+
}, d = (h) => {
|
|
641
645
|
if (!t.editable) return;
|
|
642
646
|
const m = h.target;
|
|
643
647
|
if (J(m)) {
|
|
@@ -695,12 +699,12 @@ function Me(t) {
|
|
|
695
699
|
e.handlePointerUp(h);
|
|
696
700
|
break;
|
|
697
701
|
}
|
|
698
|
-
s.detect(h,
|
|
702
|
+
s.detect(h, d), (t.ptState !== i.Pinch || r.activePointers.size < 2) && (t.ptState = i.Idle), o && (!m && !x && t.selection?.deselect(o), o = null);
|
|
699
703
|
}, u = () => {
|
|
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);
|
|
@@ -718,7 +722,7 @@ function Me(t) {
|
|
|
718
722
|
{ dom: n, evt: "pointermove", func: w },
|
|
719
723
|
{ dom: n, evt: "pointerup", func: y },
|
|
720
724
|
{ dom: n, evt: "pointercancel", func: u },
|
|
721
|
-
{ dom: n, evt: "click", func:
|
|
725
|
+
{ dom: n, evt: "click", func: f },
|
|
722
726
|
{ dom: n, evt: "contextmenu", func: g },
|
|
723
727
|
{ dom: n, evt: "wheel", func: typeof t.handleWheel == "function" ? t.handleWheel : b },
|
|
724
728
|
{ dom: n, evt: "blur", func: u },
|
|
@@ -789,21 +793,21 @@ 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(N, "path"),
|
|
796
|
+
const l = r.d, a = document.createElementNS(N, "path"), f = {
|
|
793
797
|
d: l,
|
|
794
798
|
stroke: o?.stroke || "rgb(227, 125, 116)",
|
|
795
799
|
fill: "none",
|
|
796
800
|
"stroke-linecap": o?.strokeLinecap || "cap",
|
|
797
801
|
"stroke-width": String(o?.strokeWidth || "2")
|
|
798
802
|
};
|
|
799
|
-
o?.opacity !== void 0 && (
|
|
800
|
-
const
|
|
801
|
-
D(
|
|
803
|
+
o?.opacity !== void 0 && (f.opacity = String(o.opacity)), D(a, f), c === 0 && a.setAttribute("stroke-dasharray", o?.strokeDasharray || "8,2");
|
|
804
|
+
const d = document.createElementNS(N, "path");
|
|
805
|
+
D(d, {
|
|
802
806
|
d: l,
|
|
803
807
|
stroke: "transparent",
|
|
804
808
|
fill: "none",
|
|
805
809
|
"stroke-width": "15"
|
|
806
|
-
}), s.appendChild(
|
|
810
|
+
}), s.appendChild(d), s.appendChild(a), s[r.name] = a;
|
|
807
811
|
}), s;
|
|
808
812
|
}, Lt = function(t, e, n) {
|
|
809
813
|
if (!e) return;
|
|
@@ -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:
|
|
843
|
+
const l = r[c], a = l.querySelector("me-tpc"), { offsetLeft: f, offsetTop: d } = M(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;
|
|
@@ -846,9 +850,9 @@ const N = "http://www.w3.org/2000/svg", U = function(t) {
|
|
|
846
850
|
}, Mt = function(t, e, n, o, s, i) {
|
|
847
851
|
const r = o.firstChild, c = o.children[1].children;
|
|
848
852
|
if (c.length === 0) return;
|
|
849
|
-
const l = r.offsetTop, a = r.offsetLeft,
|
|
853
|
+
const l = r.offsetTop, a = r.offsetLeft, f = r.offsetWidth, d = r.offsetHeight;
|
|
850
854
|
for (let p = 0; p < c.length; p++) {
|
|
851
|
-
const w = c[p], y = w.firstChild, u = y.offsetTop, g = y.offsetLeft, b = y.offsetWidth, v = y.offsetHeight, C = y.firstChild.nodeObj.branchColor || n, T = t.generateSubBranch({ pT: l, pL: a, pW:
|
|
855
|
+
const w = c[p], y = w.firstChild, u = y.offsetTop, g = y.offsetLeft, b = y.offsetWidth, v = y.offsetHeight, C = y.firstChild.nodeObj.branchColor || n, T = t.generateSubBranch({ pT: l, pL: a, pW: f, pH: d, cT: u, cL: g, cW: b, cH: v, direction: s, isFirst: i });
|
|
852
856
|
e.appendChild(Dt(T, C, "2"));
|
|
853
857
|
const h = y.children[1];
|
|
854
858
|
if (h) {
|
|
@@ -874,16 +878,16 @@ function Re(t) {
|
|
|
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 = () => {
|
|
877
|
-
const a = t.container.getBoundingClientRect(),
|
|
881
|
+
const a = t.container.getBoundingClientRect(), f = ot(t.map.style.transform), d = a.width / 2, p = a.height / 2, w = (d - f.x) / t.scaleVal, y = (p - f.y) / t.scaleVal;
|
|
878
882
|
r = {
|
|
879
883
|
containerRect: a,
|
|
880
|
-
currentTransform:
|
|
884
|
+
currentTransform: f,
|
|
881
885
|
mapCenterX: w,
|
|
882
886
|
mapCenterY: y
|
|
883
887
|
};
|
|
884
888
|
}, l = () => {
|
|
885
889
|
if (r) {
|
|
886
|
-
const a = t.container.getBoundingClientRect(),
|
|
890
|
+
const a = t.container.getBoundingClientRect(), f = a.width / 2, d = a.height / 2, p = f - r.mapCenterX * t.scaleVal, w = d - r.mapCenterY * t.scaleVal, y = p - r.currentTransform.x, u = w - r.currentTransform.y;
|
|
887
891
|
t.move(y, u);
|
|
888
892
|
}
|
|
889
893
|
};
|
|
@@ -977,17 +981,17 @@ function V(t, e, n, o, s) {
|
|
|
977
981
|
});
|
|
978
982
|
}
|
|
979
983
|
function mt(t, e, n, o, s, i, r, c, l, a) {
|
|
980
|
-
const
|
|
981
|
-
if (t.line.setAttribute("d",
|
|
984
|
+
const f = `M ${e} ${n} C ${o} ${s} ${i} ${r} ${c} ${l}`;
|
|
985
|
+
if (t.line.setAttribute("d", f), a.style) {
|
|
982
986
|
const u = a.style;
|
|
983
987
|
u.stroke && t.line.setAttribute("stroke", u.stroke), u.strokeWidth && t.line.setAttribute("stroke-width", String(u.strokeWidth)), u.strokeDasharray && t.line.setAttribute("stroke-dasharray", u.strokeDasharray), u.strokeLinecap && t.line.setAttribute("stroke-linecap", u.strokeLinecap), u.opacity !== void 0 && t.line.setAttribute("opacity", String(u.opacity));
|
|
984
988
|
}
|
|
985
|
-
const
|
|
986
|
-
|
|
989
|
+
const d = t.querySelectorAll('path[stroke="transparent"]');
|
|
990
|
+
d.length > 0 && d[0].setAttribute("d", f);
|
|
987
991
|
const p = _(i, r, c, l);
|
|
988
992
|
if (p) {
|
|
989
993
|
const u = `M ${p.x1} ${p.y1} L ${c} ${l} L ${p.x2} ${p.y2}`;
|
|
990
|
-
if (t.arrow1.setAttribute("d", u),
|
|
994
|
+
if (t.arrow1.setAttribute("d", u), d.length > 1 && d[1].setAttribute("d", u), a.style) {
|
|
991
995
|
const g = a.style;
|
|
992
996
|
g.stroke && t.arrow1.setAttribute("stroke", g.stroke), g.strokeWidth && t.arrow1.setAttribute("stroke-width", String(g.strokeWidth)), g.strokeLinecap && t.arrow1.setAttribute("stroke-linecap", g.strokeLinecap), g.opacity !== void 0 && t.arrow1.setAttribute("opacity", String(g.opacity));
|
|
993
997
|
}
|
|
@@ -996,7 +1000,7 @@ function mt(t, e, n, o, s, i, r, c, l, a) {
|
|
|
996
1000
|
const u = _(o, s, e, n);
|
|
997
1001
|
if (u) {
|
|
998
1002
|
const g = `M ${u.x1} ${u.y1} L ${e} ${n} L ${u.x2} ${u.y2}`;
|
|
999
|
-
if (t.arrow2.setAttribute("d", g),
|
|
1003
|
+
if (t.arrow2.setAttribute("d", g), d.length > 2 && d[2].setAttribute("d", g), a.style) {
|
|
1000
1004
|
const b = a.style;
|
|
1001
1005
|
b.stroke && t.arrow2.setAttribute("stroke", b.stroke), b.strokeWidth && t.arrow2.setAttribute("stroke-width", String(b.strokeWidth)), b.strokeLinecap && t.arrow2.setAttribute("stroke-linecap", b.strokeLinecap), b.opacity !== void 0 && t.arrow2.setAttribute("opacity", String(b.opacity));
|
|
1002
1006
|
}
|
|
@@ -1010,14 +1014,14 @@ function mt(t, e, n, o, s, i, r, c, l, a) {
|
|
|
1010
1014
|
Qe(t);
|
|
1011
1015
|
}
|
|
1012
1016
|
function q(t, e, n) {
|
|
1013
|
-
const { offsetLeft: o, offsetTop: s } = M(t.nodes, e), i = e.offsetWidth, r = e.offsetHeight, c = o + i / 2, l = s + r / 2, a = c + n.x,
|
|
1017
|
+
const { offsetLeft: o, offsetTop: s } = M(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
1018
|
return {
|
|
1015
1019
|
w: i,
|
|
1016
1020
|
h: r,
|
|
1017
1021
|
cx: c,
|
|
1018
1022
|
cy: l,
|
|
1019
1023
|
ctrlX: a,
|
|
1020
|
-
ctrlY:
|
|
1024
|
+
ctrlY: f
|
|
1021
1025
|
};
|
|
1022
1026
|
}
|
|
1023
1027
|
function H(t) {
|
|
@@ -1029,19 +1033,19 @@ function H(t) {
|
|
|
1029
1033
|
};
|
|
1030
1034
|
}
|
|
1031
1035
|
const _e = function(t, e, n) {
|
|
1032
|
-
const o = M(t.nodes, e), s = M(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,
|
|
1036
|
+
const o = M(t.nodes, e), s = M(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
1037
|
let u, g;
|
|
1034
|
-
if (
|
|
1038
|
+
if (d < 150) {
|
|
1035
1039
|
const v = e.closest("me-main").className === "lhs" ? -1 : 1;
|
|
1036
1040
|
u = { x: 200 * v, y: 0 }, g = { x: 200 * v, y: 0 };
|
|
1037
1041
|
} else if (w > y * 1.5) {
|
|
1038
1042
|
const v = a > 0 ? e.offsetWidth / 2 : -e.offsetWidth / 2, C = a > 0 ? -n.offsetWidth / 2 : n.offsetWidth / 2;
|
|
1039
1043
|
u = { x: v + (a > 0 ? p : -p), y: 0 }, g = { x: C + (a > 0 ? -p : p), y: 0 };
|
|
1040
1044
|
} else if (y > w * 1.5) {
|
|
1041
|
-
const v =
|
|
1042
|
-
u = { x: 0, y: v + (
|
|
1045
|
+
const v = f > 0 ? e.offsetHeight / 2 : -e.offsetHeight / 2, C = f > 0 ? -n.offsetHeight / 2 : n.offsetHeight / 2;
|
|
1046
|
+
u = { x: 0, y: v + (f > 0 ? p : -p) }, g = { x: 0, y: C + (f > 0 ? -p : p) };
|
|
1043
1047
|
} else {
|
|
1044
|
-
const v = Math.atan2(
|
|
1048
|
+
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), S = p * 0.7 * (f > 0 ? 1 : -1);
|
|
1045
1049
|
u = { x: C + x, y: T + S }, g = { x: h - x, y: m - S };
|
|
1046
1050
|
}
|
|
1047
1051
|
return {
|
|
@@ -1055,16 +1059,16 @@ const _e = function(t, e, n) {
|
|
|
1055
1059
|
const E = _e(t, e, n);
|
|
1056
1060
|
o.delta1 = E.delta1, o.delta2 = E.delta2;
|
|
1057
1061
|
}
|
|
1058
|
-
const i = q(t, e, o.delta1), r = q(t, n, o.delta2), { x: c, y: l } = H(i), { ctrlX: a, ctrlY:
|
|
1062
|
+
const i = q(t, e, o.delta1), r = q(t, n, o.delta2), { x: c, y: l } = H(i), { ctrlX: a, ctrlY: f } = i, { ctrlX: d, ctrlY: p } = r, { x: w, y } = H(r), u = _(d, p, w, y);
|
|
1059
1063
|
if (!u) return;
|
|
1060
1064
|
const g = `M ${u.x1} ${u.y1} L ${w} ${y} L ${u.x2} ${u.y2}`;
|
|
1061
1065
|
let b = "";
|
|
1062
1066
|
if (o.bidirectional) {
|
|
1063
|
-
const E = _(a,
|
|
1067
|
+
const E = _(a, f, c, l);
|
|
1064
1068
|
if (!E) return;
|
|
1065
1069
|
b = `M ${E.x1} ${E.y1} L ${c} ${l} L ${E.x2} ${E.y2}`;
|
|
1066
1070
|
}
|
|
1067
|
-
const v = ke(`M ${c} ${l} C ${a} ${
|
|
1071
|
+
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
1072
|
v.id = m;
|
|
1069
1073
|
const x = t.markdown ? t.markdown(o.label, o) : o.label, S = Q(x, C, T, {
|
|
1070
1074
|
anchor: "middle",
|
|
@@ -1141,18 +1145,18 @@ const _e = function(t, e, n) {
|
|
|
1141
1145
|
}, K = function(t) {
|
|
1142
1146
|
t.helper1?.destroy(), t.helper2?.destroy(), t.linkController.style.display = "none", t.P2.style.display = "none", t.P3.style.display = "none", t.currentArrow && Ze(t.currentArrow);
|
|
1143
1147
|
}, At = function(t, e, n, o) {
|
|
1144
|
-
const { linkController: s, P2: i, P3: r, line1: c, line2: l, nodes: a, map:
|
|
1145
|
-
if (!
|
|
1146
|
-
s.style.display = "initial", i.style.display = "initial", r.style.display = "initial", a.appendChild(s), a.appendChild(i), a.appendChild(r), Nt(
|
|
1148
|
+
const { linkController: s, P2: i, P3: r, line1: c, line2: l, nodes: a, map: f, currentArrow: d, bus: p } = t;
|
|
1149
|
+
if (!d) return;
|
|
1150
|
+
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
1151
|
let { x: w, y } = H(n), { ctrlX: u, ctrlY: g } = n, { ctrlX: b, ctrlY: v } = o, { x: C, y: T } = H(o);
|
|
1148
|
-
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(
|
|
1152
|
+
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
1153
|
u = u + h / t.scaleVal, g = g + m / t.scaleVal;
|
|
1150
1154
|
const x = H({ ...n, ctrlX: u, ctrlY: g });
|
|
1151
|
-
w = x.x, y = x.y, i.style.top = g + "px", i.style.left = u + "px", mt(
|
|
1152
|
-
}), t.helper2.init(
|
|
1155
|
+
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);
|
|
1156
|
+
}), t.helper2.init(f, (h, m) => {
|
|
1153
1157
|
b = b + h / t.scaleVal, v = v + m / t.scaleVal;
|
|
1154
1158
|
const x = H({ ...o, ctrlX: b, ctrlY: v });
|
|
1155
|
-
C = x.x, T = x.y, r.style.top = v + "px", r.style.left = b + "px", mt(
|
|
1159
|
+
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
1160
|
});
|
|
1157
1161
|
};
|
|
1158
1162
|
function tn() {
|
|
@@ -1187,22 +1191,22 @@ const on = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
1187
1191
|
if (t.length === 1) {
|
|
1188
1192
|
const l = t[0].nodeObj, a = t[0].nodeObj.parent;
|
|
1189
1193
|
if (!a) throw new Error("Can not select root node.");
|
|
1190
|
-
const
|
|
1194
|
+
const f = a.children.findIndex((d) => l === d);
|
|
1191
1195
|
return {
|
|
1192
1196
|
parent: a.id,
|
|
1193
|
-
start:
|
|
1194
|
-
end:
|
|
1197
|
+
start: f,
|
|
1198
|
+
end: f
|
|
1195
1199
|
};
|
|
1196
1200
|
}
|
|
1197
1201
|
let e = 0;
|
|
1198
1202
|
const n = t.map((l) => {
|
|
1199
1203
|
let a = l.nodeObj;
|
|
1200
|
-
const
|
|
1204
|
+
const f = [];
|
|
1201
1205
|
for (; a.parent; ) {
|
|
1202
|
-
const
|
|
1203
|
-
a =
|
|
1206
|
+
const d = a.parent, w = d.children?.indexOf(a);
|
|
1207
|
+
a = d, f.unshift({ node: a, index: w });
|
|
1204
1208
|
}
|
|
1205
|
-
return
|
|
1209
|
+
return f.length > e && (e = f.length), f;
|
|
1206
1210
|
});
|
|
1207
1211
|
let o = 0;
|
|
1208
1212
|
t: for (; o < e; o++) {
|
|
@@ -1236,7 +1240,7 @@ const on = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
1236
1240
|
let i;
|
|
1237
1241
|
return s.parent ? i = o.closest("me-main").className : i = t.findEle(s.children[n].id).closest("me-main").className, i;
|
|
1238
1242
|
}, rt = function(t, e) {
|
|
1239
|
-
const { id: n, label: o, parent: s, start: i, end: r, style: c } = e, { nodes: l, theme: a, summarySvg:
|
|
1243
|
+
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 = ln(t, e);
|
|
1240
1244
|
let y = 1 / 0, u = 0, g = 0, b = 0;
|
|
1241
1245
|
for (let B = i; B <= r; B++) {
|
|
1242
1246
|
const ct = p.children?.[B];
|
|
@@ -1249,7 +1253,7 @@ const on = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
1249
1253
|
const T = p.parent ? 10 : 0, h = g + T, m = b + T, x = (h + m) / 2, S = c?.stroke || a.cssVar["--color"], E = c?.labelColor || a.cssVar["--color"], P = "s-" + n, k = t.markdown ? t.markdown(o, e) : o;
|
|
1250
1254
|
w === I.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`, S), C = Q(k, y - 20, x, { anchor: "end", color: E, dataType: "summary", svgId: P })) : (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`, S), C = Q(k, u + 20, x, { anchor: "start", color: E, dataType: "summary", svgId: P }));
|
|
1251
1255
|
const O = rn(P);
|
|
1252
|
-
return O.appendChild(v), t.labelContainer.appendChild(C), U(C), O.summaryObj = e, O.labelEl = C,
|
|
1256
|
+
return O.appendChild(v), t.labelContainer.appendChild(C), U(C), O.summaryObj = e, O.labelEl = C, f.appendChild(O), O;
|
|
1253
1257
|
}, an = function(t = {}) {
|
|
1254
1258
|
if (!this.currentNodes) return;
|
|
1255
1259
|
const { currentNodes: e, summaries: n, bus: o } = this, { parent: s, start: i, end: r } = sn(e), c = { id: Y(), parent: s, start: i, end: r, label: "summary", style: t.style }, l = rt(this, c);
|
|
@@ -1400,25 +1404,25 @@ const F = 100, En = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "
|
|
|
1400
1404
|
width: `${s}`,
|
|
1401
1405
|
height: `${o}`,
|
|
1402
1406
|
fill: t.theme.cssVar["--bgcolor"]
|
|
1403
|
-
}), i.appendChild(c), n.querySelectorAll(".subLines").forEach((
|
|
1404
|
-
const p =
|
|
1407
|
+
}), i.appendChild(c), n.querySelectorAll(".subLines").forEach((d) => {
|
|
1408
|
+
const p = d.cloneNode(!0), { offsetLeft: w, offsetTop: y } = M(n, d.parentElement);
|
|
1405
1409
|
p.setAttribute("x", `${w}`), p.setAttribute("y", `${y}`), r.appendChild(p);
|
|
1406
1410
|
});
|
|
1407
1411
|
const l = n.querySelector(".lines")?.cloneNode(!0);
|
|
1408
1412
|
l && r.appendChild(l);
|
|
1409
1413
|
const a = n.querySelector(".topiclinks")?.cloneNode(!0);
|
|
1410
1414
|
a && r.appendChild(a);
|
|
1411
|
-
const
|
|
1412
|
-
return
|
|
1413
|
-
|
|
1414
|
-
}), n.querySelectorAll(".tags > span").forEach((
|
|
1415
|
-
r.appendChild(z(t,
|
|
1416
|
-
}), n.querySelectorAll(".icons > span").forEach((
|
|
1417
|
-
r.appendChild(z(t,
|
|
1418
|
-
}), n.querySelectorAll(".hyper-link").forEach((
|
|
1419
|
-
r.appendChild(Cn(t,
|
|
1420
|
-
}), n.querySelectorAll("img").forEach((
|
|
1421
|
-
r.appendChild(Sn(t,
|
|
1415
|
+
const f = n.querySelector(".summary")?.cloneNode(!0);
|
|
1416
|
+
return f && r.appendChild(f), n.querySelectorAll("me-tpc").forEach((d) => {
|
|
1417
|
+
d.nodeObj.dangerouslySetInnerHTML ? r.appendChild(z(t, d, !e)) : (r.appendChild(xn(t, d)), r.appendChild(z(t, d.text, !e)));
|
|
1418
|
+
}), n.querySelectorAll(".tags > span").forEach((d) => {
|
|
1419
|
+
r.appendChild(z(t, d));
|
|
1420
|
+
}), n.querySelectorAll(".icons > span").forEach((d) => {
|
|
1421
|
+
r.appendChild(z(t, d));
|
|
1422
|
+
}), n.querySelectorAll(".hyper-link").forEach((d) => {
|
|
1423
|
+
r.appendChild(Cn(t, d));
|
|
1424
|
+
}), n.querySelectorAll("img").forEach((d) => {
|
|
1425
|
+
r.appendChild(Sn(t, d));
|
|
1422
1426
|
}), D(r, {
|
|
1423
1427
|
x: F + "",
|
|
1424
1428
|
y: F + "",
|
|
@@ -1484,23 +1488,23 @@ const Mn = function(t = !1, e) {
|
|
|
1484
1488
|
}
|
|
1485
1489
|
};
|
|
1486
1490
|
function $n({ pT: t, pL: e, pW: n, pH: o, cT: s, cL: i, cW: r, cH: c, direction: l, containerHeight: a }) {
|
|
1487
|
-
let
|
|
1488
|
-
const
|
|
1491
|
+
let f = e + n / 2;
|
|
1492
|
+
const d = t + o / 2;
|
|
1489
1493
|
let p;
|
|
1490
1494
|
l === I.LHS ? p = i + r : p = i;
|
|
1491
|
-
const w = s + c / 2, u = (1 - Math.abs(w -
|
|
1492
|
-
return l === I.LHS ?
|
|
1495
|
+
const w = s + c / 2, u = (1 - Math.abs(w - d) / a) * 0.25 * (n / 2);
|
|
1496
|
+
return l === I.LHS ? f = f - n / 10 - u : f = f + n / 10 + u, `M ${f} ${d} Q ${f} ${w} ${p} ${w}`;
|
|
1493
1497
|
}
|
|
1494
1498
|
function Hn({ pT: t, pL: e, pW: n, pH: o, cT: s, cL: i, cW: r, cH: c, direction: l, isFirst: a }) {
|
|
1495
|
-
const
|
|
1496
|
-
let
|
|
1497
|
-
a ?
|
|
1499
|
+
const f = parseInt(this.container.style.getPropertyValue("--node-gap-x"));
|
|
1500
|
+
let d = 0, p = 0;
|
|
1501
|
+
a ? d = t + o / 2 : d = t + o;
|
|
1498
1502
|
const w = s + c;
|
|
1499
1503
|
let y = 0, u = 0, g = 0;
|
|
1500
|
-
const b = Math.abs(
|
|
1501
|
-
return l === I.LHS ? (g = e, y = g +
|
|
1504
|
+
const b = Math.abs(d - w) / 300 * f;
|
|
1505
|
+
return l === I.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
1506
|
}
|
|
1503
|
-
const In = "5.11.
|
|
1507
|
+
const In = "5.11.3";
|
|
1504
1508
|
function On(t) {
|
|
1505
1509
|
return {
|
|
1506
1510
|
x: 0,
|
|
@@ -1539,8 +1543,8 @@ function A({
|
|
|
1539
1543
|
selectionContainer: c,
|
|
1540
1544
|
before: l,
|
|
1541
1545
|
newTopicName: a,
|
|
1542
|
-
allowUndo:
|
|
1543
|
-
generateMainBranch:
|
|
1546
|
+
allowUndo: f,
|
|
1547
|
+
generateMainBranch: d,
|
|
1544
1548
|
generateSubBranch: p,
|
|
1545
1549
|
overflowHidden: w,
|
|
1546
1550
|
theme: y,
|
|
@@ -1557,7 +1561,7 @@ function A({
|
|
|
1557
1561
|
let S = null;
|
|
1558
1562
|
const E = Object.prototype.toString.call(t);
|
|
1559
1563
|
if (E === "[object HTMLDivElement]" ? S = t : E === "[object String]" && (S = document.querySelector(t)), !S) throw new Error("MindElixir: el is not a valid element");
|
|
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 =
|
|
1564
|
+
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 = g ?? 0.1, this.scaleMax = b ?? 1.4, this.scaleMin = v ?? 0.2, this.generateMainBranch = d || $n, this.generateSubBranch = p || Hn, this.overflowHidden = w ?? !1, this.alignment = u ?? "root", this.handleWheel = C ?? !0, this.markdown = T || void 0, this.imageProxy = h || void 0, this.currentNodes = [], this.currentArrow = null, this.scaleVal = 1, this.tempDirection = null, this.mobileMultiSelect = x ?? !1, this.panHelper = On(this), this.bus = Pe(), this.container = document.createElement("div"), this.selectionContainer = c || this.container, this.container.className = "map-container";
|
|
1561
1565
|
const P = window.matchMedia("(prefers-color-scheme: dark)");
|
|
1562
1566
|
this.theme = y || (P.matches ? et : tt);
|
|
1563
1567
|
const k = document.createElement("div");
|
package/dist/types/index.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ declare namespace MindElixir {
|
|
|
41
41
|
copyNodes: (this: MindElixirInstance, tpcs: Topic[], to: Topic) => Promise<void>;
|
|
42
42
|
rmSubline: (this: MindElixirInstance, tpc: Topic) => Promise<void>;
|
|
43
43
|
setNodeTopic: (this: MindElixirInstance, el: Topic, topic: string) => Promise<void>;
|
|
44
|
-
scrollIntoView: (this: MindElixirInstance, el: HTMLElement) => void;
|
|
44
|
+
scrollIntoView: (this: MindElixirInstance, el: HTMLElement, forceCenter?: boolean) => void;
|
|
45
45
|
selectNode: (this: MindElixirInstance, tpc: Topic, isNewNode?: boolean, e?: MouseEvent) => void;
|
|
46
46
|
selectNodes: (this: MindElixirInstance, tpcs: Topic[]) => void;
|
|
47
47
|
unselectNodes: (this: MindElixirInstance, tpcs: Topic[]) => void;
|
package/dist/types/interact.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Topic } from './types/dom';
|
|
2
2
|
import type { MindElixirData, MindElixirInstance } from './types/index';
|
|
3
|
-
export declare const scrollIntoView: (this: MindElixirInstance, el: HTMLElement) => void;
|
|
3
|
+
export declare const scrollIntoView: (this: MindElixirInstance, el: HTMLElement, forceCenter?: boolean) => void;
|
|
4
4
|
export declare const selectNode: (this: MindElixirInstance, tpc: Topic, isNewNode?: boolean, e?: MouseEvent) => void;
|
|
5
5
|
export declare const selectNodes: (this: MindElixirInstance, tpcs: Topic[]) => void;
|
|
6
6
|
export declare const unselectNodes: (this: MindElixirInstance, tpcs: Topic[]) => void;
|
package/dist/types/methods.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ declare const methods: {
|
|
|
50
50
|
copyNodes: (this: MindElixirInstance, tpcs: import("./docs").Topic[], to: import("./docs").Topic) => Promise<void>;
|
|
51
51
|
rmSubline: (this: MindElixirInstance, tpc: import("./docs").Topic) => Promise<void>;
|
|
52
52
|
setNodeTopic: (this: MindElixirInstance, el: import("./docs").Topic, topic: string) => Promise<void>;
|
|
53
|
-
scrollIntoView: (this: MindElixirInstance, el: HTMLElement) => void;
|
|
53
|
+
scrollIntoView: (this: MindElixirInstance, el: HTMLElement, forceCenter?: boolean) => void;
|
|
54
54
|
selectNode: (this: MindElixirInstance, tpc: import("./docs").Topic, isNewNode?: boolean, e?: MouseEvent) => void;
|
|
55
55
|
selectNodes: (this: MindElixirInstance, tpcs: import("./docs").Topic[]) => void;
|
|
56
56
|
unselectNodes: (this: MindElixirInstance, tpcs: import("./docs").Topic[]) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mind-elixir",
|
|
3
|
-
"version": "5.11.
|
|
3
|
+
"version": "5.11.3",
|
|
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
|
+
}
|