@linkurious/ogma-annotations 1.0.5 → 1.0.8
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/index.mjs +186 -185
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +3 -3
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
var En = Object.defineProperty;
|
|
2
2
|
var kn = (u, l, t) => l in u ? En(u, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : u[l] = t;
|
|
3
|
-
var
|
|
3
|
+
var v = (u, l, t) => (kn(u, typeof l != "symbol" ? l + "" : l, t), t);
|
|
4
4
|
var Tn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
5
5
|
function oe(u) {
|
|
6
6
|
return u && u.__esModule && Object.prototype.hasOwnProperty.call(u, "default") ? u.default : u;
|
|
7
7
|
}
|
|
8
|
-
var
|
|
8
|
+
var Ce = { exports: {} };
|
|
9
9
|
(function(u) {
|
|
10
10
|
(function(l, t) {
|
|
11
11
|
u.exports = t();
|
|
@@ -16,12 +16,12 @@ var Pe = { exports: {} };
|
|
|
16
16
|
return Math.round(r * 1e8) / 1e8;
|
|
17
17
|
}
|
|
18
18
|
function g(r, d) {
|
|
19
|
-
var
|
|
20
|
-
return Math.sqrt(
|
|
19
|
+
var m = d.x - r.x, T = d.y - r.y;
|
|
20
|
+
return Math.sqrt(m * m + T * T);
|
|
21
21
|
}
|
|
22
|
-
function y(r, d,
|
|
22
|
+
function y(r, d, m) {
|
|
23
23
|
var T = d.y - r.y, _ = d.x - r.x, E = Math.atan2(T, _);
|
|
24
|
-
if (
|
|
24
|
+
if (m)
|
|
25
25
|
for (; E < 0; )
|
|
26
26
|
E += t;
|
|
27
27
|
return E;
|
|
@@ -30,8 +30,8 @@ var Pe = { exports: {} };
|
|
|
30
30
|
this.x = r !== void 0 ? r : 0, this.y = d !== void 0 ? d : 0;
|
|
31
31
|
}
|
|
32
32
|
return f.fromRadians = function(r) {
|
|
33
|
-
var d = Math.cos(r),
|
|
34
|
-
return new f(d,
|
|
33
|
+
var d = Math.cos(r), m = Math.sin(r);
|
|
34
|
+
return new f(d, m);
|
|
35
35
|
}, f.fromDegrees = function(r) {
|
|
36
36
|
var d = r * (Math.PI / 180);
|
|
37
37
|
return f.fromRadians(d);
|
|
@@ -191,7 +191,7 @@ var Pe = { exports: {} };
|
|
|
191
191
|
// @param radians - radians to rotate this vector by (can be positive or negative).
|
|
192
192
|
// @return self.
|
|
193
193
|
rotateRadiansSelf: function(r) {
|
|
194
|
-
var d = Math.cos(r),
|
|
194
|
+
var d = Math.cos(r), m = Math.sin(r), T = this.x * d - this.y * m, _ = this.x * m + this.y * d;
|
|
195
195
|
return this.x = c(T), this.y = c(_), this;
|
|
196
196
|
},
|
|
197
197
|
// [API]
|
|
@@ -482,8 +482,8 @@ var Pe = { exports: {} };
|
|
|
482
482
|
}();
|
|
483
483
|
return l.zero = new l(0, 0), l.one = new l(1, 1), l.up = new l(0, -1), l.down = new l(0, 1), l.left = new l(-1, 0), l.right = new l(1, 0), l.upLeft = new l(-1, -1), l.downLeft = new l(-1, 1), l.upRight = new l(1, -1), l.downRight = new l(1, 1), l.prototype.magnitude = l.prototype.length, Object.freeze && (Object.freeze(l.zero), Object.freeze(l.one), Object.freeze(l.up), Object.freeze(l.down), Object.freeze(l.left), Object.freeze(l.right), Object.freeze(l.upLeft), Object.freeze(l.downLeft), Object.freeze(l.upRight), Object.freeze(l.downRight)), l;
|
|
484
484
|
});
|
|
485
|
-
})(
|
|
486
|
-
var In =
|
|
485
|
+
})(Ce);
|
|
486
|
+
var In = Ce.exports;
|
|
487
487
|
const rt = /* @__PURE__ */ oe(In);
|
|
488
488
|
let jt = (u = 21) => crypto.getRandomValues(new Uint8Array(u)).reduce((l, t) => (t &= 63, t < 36 ? l += t.toString(36) : t < 62 ? l += (t - 26).toString(36).toUpperCase() : t > 62 ? l += "-" : l += "_", l), "");
|
|
489
489
|
const Dt = {
|
|
@@ -539,18 +539,18 @@ const Dt = {
|
|
|
539
539
|
function It(u) {
|
|
540
540
|
return document.createElementNS(Dn, u);
|
|
541
541
|
}
|
|
542
|
-
function
|
|
542
|
+
function Pe(u) {
|
|
543
543
|
return u.geometry.bbox || On(u), u.geometry.bbox;
|
|
544
544
|
}
|
|
545
545
|
function dt(u) {
|
|
546
|
-
const l =
|
|
546
|
+
const l = Pe(u);
|
|
547
547
|
return {
|
|
548
548
|
width: l[2] - l[0],
|
|
549
549
|
height: l[3] - l[1]
|
|
550
550
|
};
|
|
551
551
|
}
|
|
552
552
|
function yt(u) {
|
|
553
|
-
const l =
|
|
553
|
+
const l = Pe(u);
|
|
554
554
|
return { x: l[0], y: l[1] };
|
|
555
555
|
}
|
|
556
556
|
function On(u) {
|
|
@@ -639,14 +639,14 @@ function ke(u, l, t, s) {
|
|
|
639
639
|
return `M ${c.x} ${c.y} L ${y} ${g.x} ${g.y} ${t === "arrow" ? "" : `${c.x} ${c.y}`}`;
|
|
640
640
|
}
|
|
641
641
|
function zn(u, l, t, s, a) {
|
|
642
|
-
const { start: c, end: g } = Rt(u), { tail: y, head: f, strokeColor: r, strokeWidth: d } = u.properties.style || t,
|
|
643
|
-
|
|
642
|
+
const { start: c, end: g } = Rt(u), { tail: y, head: f, strokeColor: r, strokeWidth: d } = u.properties.style || t, m = new rt(c.x, c.y), T = new rt(g.x, g.y), _ = T.clone().sub(m), E = Re(u, s, a), C = It("path");
|
|
643
|
+
C.setAttribute("data-annotation", `${u.id}`), C.setAttribute("data-annotation-type", "arrow");
|
|
644
644
|
const A = f === "arrow-plain" || y === "arrow";
|
|
645
|
-
|
|
646
|
-
const U = ke(
|
|
647
|
-
|
|
645
|
+
C.setAttribute("stroke", r || "none"), C.setAttribute("stroke-width", `${d}`), C.setAttribute("fill", A ? r || "" : "none"), C.setAttribute("stroke-linecap", "round"), C.setAttribute("stroke-linejoin", "round");
|
|
646
|
+
const U = ke(m, _.clone().invert(), y, E), N = ke(T, _, f, E), z = U + `M ${m.x} ${m.y} ${T.x} ${T.y}` + N;
|
|
647
|
+
C.setAttribute("d", z), l.appendChild(C);
|
|
648
648
|
}
|
|
649
|
-
const B = -1, ae = "dragging", le = "dragstart", Ot = "dragend", ee = "select", ne = "unselect", Ln = "hover",
|
|
649
|
+
const B = -1, ae = "dragging", le = "dragstart", Ot = "dragend", ee = "select", ne = "unselect", Ln = "hover", Cn = "unhover", ie = "remove", re = "add", Pn = "cancelDrawing", se = "update", Nn = "link";
|
|
650
650
|
var je = { exports: {} };
|
|
651
651
|
(function(u) {
|
|
652
652
|
var l = Object.prototype.hasOwnProperty, t = "~";
|
|
@@ -656,10 +656,10 @@ var je = { exports: {} };
|
|
|
656
656
|
function a(f, r, d) {
|
|
657
657
|
this.fn = f, this.context = r, this.once = d || !1;
|
|
658
658
|
}
|
|
659
|
-
function c(f, r, d,
|
|
659
|
+
function c(f, r, d, m, T) {
|
|
660
660
|
if (typeof d != "function")
|
|
661
661
|
throw new TypeError("The listener must be a function");
|
|
662
|
-
var _ = new a(d,
|
|
662
|
+
var _ = new a(d, m || f, T), E = t ? t + r : r;
|
|
663
663
|
return f._events[E] ? f._events[E].fn ? f._events[E] = [f._events[E], _] : f._events[E].push(_) : (f._events[E] = _, f._eventsCount++), f;
|
|
664
664
|
}
|
|
665
665
|
function g(f, r) {
|
|
@@ -669,29 +669,29 @@ var je = { exports: {} };
|
|
|
669
669
|
this._events = new s(), this._eventsCount = 0;
|
|
670
670
|
}
|
|
671
671
|
y.prototype.eventNames = function() {
|
|
672
|
-
var r = [], d,
|
|
672
|
+
var r = [], d, m;
|
|
673
673
|
if (this._eventsCount === 0)
|
|
674
674
|
return r;
|
|
675
|
-
for (
|
|
676
|
-
l.call(d,
|
|
675
|
+
for (m in d = this._events)
|
|
676
|
+
l.call(d, m) && r.push(t ? m.slice(1) : m);
|
|
677
677
|
return Object.getOwnPropertySymbols ? r.concat(Object.getOwnPropertySymbols(d)) : r;
|
|
678
678
|
}, y.prototype.listeners = function(r) {
|
|
679
|
-
var d = t ? t + r : r,
|
|
680
|
-
if (!
|
|
679
|
+
var d = t ? t + r : r, m = this._events[d];
|
|
680
|
+
if (!m)
|
|
681
681
|
return [];
|
|
682
|
-
if (
|
|
683
|
-
return [
|
|
684
|
-
for (var T = 0, _ =
|
|
685
|
-
E[T] =
|
|
682
|
+
if (m.fn)
|
|
683
|
+
return [m.fn];
|
|
684
|
+
for (var T = 0, _ = m.length, E = new Array(_); T < _; T++)
|
|
685
|
+
E[T] = m[T].fn;
|
|
686
686
|
return E;
|
|
687
687
|
}, y.prototype.listenerCount = function(r) {
|
|
688
|
-
var d = t ? t + r : r,
|
|
689
|
-
return
|
|
690
|
-
}, y.prototype.emit = function(r, d,
|
|
691
|
-
var
|
|
692
|
-
if (!this._events[
|
|
688
|
+
var d = t ? t + r : r, m = this._events[d];
|
|
689
|
+
return m ? m.fn ? 1 : m.length : 0;
|
|
690
|
+
}, y.prototype.emit = function(r, d, m, T, _, E) {
|
|
691
|
+
var C = t ? t + r : r;
|
|
692
|
+
if (!this._events[C])
|
|
693
693
|
return !1;
|
|
694
|
-
var A = this._events[
|
|
694
|
+
var A = this._events[C], U = arguments.length, N, z;
|
|
695
695
|
if (A.fn) {
|
|
696
696
|
switch (A.once && this.removeListener(r, A.fn, void 0, !0), U) {
|
|
697
697
|
case 1:
|
|
@@ -699,13 +699,13 @@ var je = { exports: {} };
|
|
|
699
699
|
case 2:
|
|
700
700
|
return A.fn.call(A.context, d), !0;
|
|
701
701
|
case 3:
|
|
702
|
-
return A.fn.call(A.context, d,
|
|
702
|
+
return A.fn.call(A.context, d, m), !0;
|
|
703
703
|
case 4:
|
|
704
|
-
return A.fn.call(A.context, d,
|
|
704
|
+
return A.fn.call(A.context, d, m, T), !0;
|
|
705
705
|
case 5:
|
|
706
|
-
return A.fn.call(A.context, d,
|
|
706
|
+
return A.fn.call(A.context, d, m, T, _), !0;
|
|
707
707
|
case 6:
|
|
708
|
-
return A.fn.call(A.context, d,
|
|
708
|
+
return A.fn.call(A.context, d, m, T, _, E), !0;
|
|
709
709
|
}
|
|
710
710
|
for (z = 1, N = new Array(U - 1); z < U; z++)
|
|
711
711
|
N[z - 1] = arguments[z];
|
|
@@ -721,10 +721,10 @@ var je = { exports: {} };
|
|
|
721
721
|
A[z].fn.call(A[z].context, d);
|
|
722
722
|
break;
|
|
723
723
|
case 3:
|
|
724
|
-
A[z].fn.call(A[z].context, d,
|
|
724
|
+
A[z].fn.call(A[z].context, d, m);
|
|
725
725
|
break;
|
|
726
726
|
case 4:
|
|
727
|
-
A[z].fn.call(A[z].context, d,
|
|
727
|
+
A[z].fn.call(A[z].context, d, m, T);
|
|
728
728
|
break;
|
|
729
729
|
default:
|
|
730
730
|
if (!N)
|
|
@@ -734,11 +734,11 @@ var je = { exports: {} };
|
|
|
734
734
|
}
|
|
735
735
|
}
|
|
736
736
|
return !0;
|
|
737
|
-
}, y.prototype.on = function(r, d,
|
|
738
|
-
return c(this, r, d,
|
|
739
|
-
}, y.prototype.once = function(r, d,
|
|
740
|
-
return c(this, r, d,
|
|
741
|
-
}, y.prototype.removeListener = function(r, d,
|
|
737
|
+
}, y.prototype.on = function(r, d, m) {
|
|
738
|
+
return c(this, r, d, m, !1);
|
|
739
|
+
}, y.prototype.once = function(r, d, m) {
|
|
740
|
+
return c(this, r, d, m, !0);
|
|
741
|
+
}, y.prototype.removeListener = function(r, d, m, T) {
|
|
742
742
|
var _ = t ? t + r : r;
|
|
743
743
|
if (!this._events[_])
|
|
744
744
|
return this;
|
|
@@ -746,10 +746,10 @@ var je = { exports: {} };
|
|
|
746
746
|
return g(this, _), this;
|
|
747
747
|
var E = this._events[_];
|
|
748
748
|
if (E.fn)
|
|
749
|
-
E.fn === d && (!T || E.once) && (!
|
|
749
|
+
E.fn === d && (!T || E.once) && (!m || E.context === m) && g(this, _);
|
|
750
750
|
else {
|
|
751
|
-
for (var
|
|
752
|
-
(E[
|
|
751
|
+
for (var C = 0, A = [], U = E.length; C < U; C++)
|
|
752
|
+
(E[C].fn !== d || T && !E[C].once || m && E[C].context !== m) && A.push(E[C]);
|
|
753
753
|
A.length ? this._events[_] = A.length === 1 ? A[0] : A : g(this, _);
|
|
754
754
|
}
|
|
755
755
|
return this;
|
|
@@ -763,21 +763,21 @@ const Fe = /* @__PURE__ */ oe($n);
|
|
|
763
763
|
class qe extends Fe {
|
|
764
764
|
constructor(t, s) {
|
|
765
765
|
super();
|
|
766
|
-
|
|
767
|
-
|
|
766
|
+
v(this, "ogma");
|
|
767
|
+
v(this, "elements");
|
|
768
768
|
// layer to draw elements
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
769
|
+
v(this, "layer");
|
|
770
|
+
v(this, "editor");
|
|
771
|
+
v(this, "selectedId", B);
|
|
772
|
+
v(this, "hoveredId", B);
|
|
773
773
|
// used to remember ogma options before we change them
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
774
|
+
v(this, "ogmaOptions");
|
|
775
|
+
v(this, "shouldDetect");
|
|
776
|
+
v(this, "isDragging");
|
|
777
|
+
v(this, "_onKeyUp", (t) => {
|
|
778
778
|
t.code === 27 && this.selectedId !== B ? this.unselect() : (t.code === 46 || t.code === 8) && this.selectedId !== B && this._canRemove() && this.remove(this.selectedId);
|
|
779
779
|
});
|
|
780
|
-
|
|
780
|
+
v(this, "_onClickMouseMove", (t) => {
|
|
781
781
|
if (!t.domEvent || this.isDragging || !this.shouldDetect)
|
|
782
782
|
return;
|
|
783
783
|
const s = this.ogma.view.screenToGraphCoordinates(t), a = this.shouldDetect || !this.shouldDetect && +this.selectedId > -1 ? this.detect(s, 0) : void 0;
|
|
@@ -890,7 +890,7 @@ class qe extends Fe {
|
|
|
890
890
|
}
|
|
891
891
|
unhover() {
|
|
892
892
|
const t = this.getById(this.hoveredId);
|
|
893
|
-
return this.emit(
|
|
893
|
+
return this.emit(Cn, t), this.hoveredId = B, this.selectedId === B && this.editor.hide(), this.layer.refresh(), this;
|
|
894
894
|
}
|
|
895
895
|
/**
|
|
896
896
|
* @method remove
|
|
@@ -961,30 +961,31 @@ class Hn extends qe {
|
|
|
961
961
|
`
|
|
962
962
|
);
|
|
963
963
|
// active handle id
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
964
|
+
v(this, "draggedHandle", B);
|
|
965
|
+
v(this, "start", { x: 0, y: 0 });
|
|
966
|
+
v(this, "end", { x: 0, y: 0 });
|
|
967
|
+
v(this, "arrow", { ...Se });
|
|
968
|
+
v(this, "startX", 0);
|
|
969
|
+
v(this, "startY", 0);
|
|
970
|
+
v(this, "minArrowHeight", 0);
|
|
971
|
+
v(this, "maxArrowHeight", 0);
|
|
972
|
+
v(this, "handles", []);
|
|
973
|
+
v(this, "onHandleMouseDown", (t) => {
|
|
974
974
|
const s = this.getById(this.selectedId) || this.getById(this.hoveredId);
|
|
975
975
|
s && (this.startDragging(s, t.clientX, t.clientY), this.draggedHandle = He(t.target));
|
|
976
976
|
});
|
|
977
|
-
|
|
977
|
+
v(this, "onMouseUp", () => {
|
|
978
978
|
this.draggedHandle !== -1 && (this.restoreDragging(), this.isDragging = !1, this.draggedHandle = B, this.emit(Ot, this.arrow));
|
|
979
979
|
});
|
|
980
|
-
|
|
980
|
+
v(this, "onMouseMove", (t) => {
|
|
981
|
+
var m;
|
|
981
982
|
if (!this.isDragging || this.draggedHandle === B)
|
|
982
983
|
return;
|
|
983
|
-
const s = this.handles[this.draggedHandle], a = this.ogma.view.getZoom(), c = (t.clientX - this.startX) / a,
|
|
984
|
-
(
|
|
984
|
+
const s = this.handles[this.draggedHandle], a = this.ogma.view.getZoom(), c = (m = this.ogma.getContainer()) == null ? void 0 : m.getBoundingClientRect(), g = (t.clientX - this.startX - c.left) / a, y = (t.clientY - this.startY - c.top) / a, f = s.id === Te, r = s.id === Ie, d = s.id === _e;
|
|
985
|
+
(f || r) && Ne(this.arrow, this.start.x + g, this.start.y + y), (f || d) && $e(this.arrow, this.end.x + g, this.end.y + y), this.emit(
|
|
985
986
|
ae,
|
|
986
987
|
this.arrow,
|
|
987
|
-
|
|
988
|
+
f ? "line" : r ? "start" : "end"
|
|
988
989
|
), this.refreshEditor(), this.layer.refresh();
|
|
989
990
|
});
|
|
990
991
|
this.minArrowHeight = s.minArrowHeight || 0, this.maxArrowHeight = s.maxArrowHeight || 1e6, this.handles = Array.prototype.slice.call(
|
|
@@ -1014,8 +1015,8 @@ class Hn extends qe {
|
|
|
1014
1015
|
return this.elements.find((a) => {
|
|
1015
1016
|
const { start: c, end: g } = Rt(a), y = new rt(t.x, t.y).sub(
|
|
1016
1017
|
new rt((c.x + g.x) / 2, (c.y + g.y) / 2)
|
|
1017
|
-
), f = new rt(g.x, g.y).sub(new rt(c.x, c.y)), r = f.length(), d = f.normalize(),
|
|
1018
|
-
return Math.abs(d.dot(y)) < r / 2 + s && Math.abs(d.rotateRadians(Math.PI / 2).dot(y)) <
|
|
1018
|
+
), f = new rt(g.x, g.y).sub(new rt(c.x, c.y)), r = f.length(), d = f.normalize(), m = Re(a);
|
|
1019
|
+
return Math.abs(d.dot(y)) < r / 2 + s && Math.abs(d.rotateRadians(Math.PI / 2).dot(y)) < m / 2 + s;
|
|
1019
1020
|
});
|
|
1020
1021
|
}
|
|
1021
1022
|
refreshEditor() {
|
|
@@ -1030,8 +1031,8 @@ class Hn extends qe {
|
|
|
1030
1031
|
const f = {
|
|
1031
1032
|
x: (a.x + s.x) / 2,
|
|
1032
1033
|
y: (a.y + s.y) / 2
|
|
1033
|
-
}, r = new rt(a.x - s.x, a.y - s.y), d = r.mul(1 / r.length()),
|
|
1034
|
-
c.style.width = `${r.length()}px`, c.style.left = `${f.x}px`, c.style.top = `${f.y}px`, c.style.transform = `translate(-50%, -50%) rotate(${
|
|
1034
|
+
}, r = new rt(a.x - s.x, a.y - s.y), d = r.mul(1 / r.length()), m = Math.atan2(d.y, d.x);
|
|
1035
|
+
c.style.width = `${r.length()}px`, c.style.left = `${f.x}px`, c.style.top = `${f.y}px`, c.style.transform = `translate(-50%, -50%) rotate(${m}rad)`;
|
|
1035
1036
|
}
|
|
1036
1037
|
getDefaultOptions() {
|
|
1037
1038
|
return Se;
|
|
@@ -1119,11 +1120,11 @@ var Be = { exports: {} };
|
|
|
1119
1120
|
}
|
|
1120
1121
|
t.d(s, { default: () => Sn });
|
|
1121
1122
|
var c = /^((?:[a-z\d-]+\s+)*)([\d.]+(%|em|px)|(?:x+-)?large|(?:x+-)?small|medium)(?:\s*\/\s*(normal|[\d.]+(%|px|em)?))?(\s.+)?$/, g = /\bsmall-caps\b/, y = /\b(?:italic|oblique)\b/, f = /\bbold(?:er)?\b/, r = 13.3333333, d = { "xx-small": 9, "x-small": 10, smaller: 13.3333, small: 13, medium: 16, large: 18, larger: 19.2, "x-large": 24, "xx-large": 32 };
|
|
1122
|
-
function
|
|
1123
|
+
function m(e) {
|
|
1123
1124
|
var n = "", o = this;
|
|
1124
1125
|
return o.style && o.style !== "normal" && (n += o.style), o.variant && o.variant !== "normal" && (n += (n ? " " : "") + o.variant), o.weight && o.weight !== "normal" && (n += (n ? " " : "") + o.weight), o.size && (n += (n ? " " : "") + o.size + "px", o.height !== o.size && (n += "/" + o.height + "px")), o.family && (n += (n ? " " : "") + o.family), e && (n += "::" + o.baseline), e && (n += "::" + o.color), n;
|
|
1125
1126
|
}
|
|
1126
|
-
var T = { id: "", family: "sans-serif", height: 14, size: 12, variant: "", style: "", weight: "", baseline: "", color: null, toString:
|
|
1127
|
+
var T = { id: "", family: "sans-serif", height: 14, size: 12, variant: "", style: "", weight: "", baseline: "", color: null, toString: m, valueOf: m };
|
|
1127
1128
|
function _(e) {
|
|
1128
1129
|
var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, o = c.exec(e);
|
|
1129
1130
|
n.family = (o[6] || "").trim();
|
|
@@ -1150,9 +1151,9 @@ var Be = { exports: {} };
|
|
|
1150
1151
|
a(i) === "object" && (e = i.family, w = i.size, p = i.height, S = i.variant, x = i.weight, b = i.style, n = i.baseline, o = i.color);
|
|
1151
1152
|
h.size && h.size < 3 && (w *= h.size), p = p !== "normal" && p ? parseFloat(p) : w * (7 / 6), h.height && h.height < 3 && (p *= h.height);
|
|
1152
1153
|
var M = Object.create(T);
|
|
1153
|
-
return M.family = h.family || e || "sans-serif", M.height = p ?? 14, M.size = w ?? 12, M.variant = h.variant || S || "", M.style = h.style || b || "", M.weight = h.weight || x || "", M.baseline = n || 0, h.baseline != null && (M.baseline = h.baseline), M.color = h.color || o || "", M.id =
|
|
1154
|
+
return M.family = h.family || e || "sans-serif", M.height = p ?? 14, M.size = w ?? 12, M.variant = h.variant || S || "", M.style = h.style || b || "", M.weight = h.weight || x || "", M.baseline = n || 0, h.baseline != null && (M.baseline = h.baseline), M.color = h.color || o || "", M.id = m.call(M, !0), M;
|
|
1154
1155
|
}
|
|
1155
|
-
const
|
|
1156
|
+
const C = { "\n": 0.28, "\r": 0.28, " ": 0.28, " ": 0.28, " ": 0.28, "": 0, " ": 0.5, " ": 1, " ": 0.5, " ": 1, " ": 0.33, " ": 0.25, " ": 0.16, " ": 0.56, " ": 0.28, " ": 0.2, " ": 0.15, "": 0, " ": 0.16, " ": 0.22, " ": 1, "\uFEFF": 0 };
|
|
1156
1157
|
var A, U = function(e) {
|
|
1157
1158
|
var n = typeof OffscreenCanvas < "u" && new OffscreenCanvas(100, 100) || e && e.createElement("canvas");
|
|
1158
1159
|
if (n && n.getContext) {
|
|
@@ -1173,7 +1174,7 @@ var Be = { exports: {} };
|
|
|
1173
1174
|
var i = Object.assign({}, z, o), h = String(e);
|
|
1174
1175
|
if (!h)
|
|
1175
1176
|
return 0;
|
|
1176
|
-
if (h in
|
|
1177
|
+
if (h in C) {
|
|
1177
1178
|
var p = n.id + "/" + h;
|
|
1178
1179
|
return p in N || (N[p] = U("_".concat(h, "_"), n) - U("__", n)), N[p];
|
|
1179
1180
|
}
|
|
@@ -1295,7 +1296,7 @@ var Be = { exports: {} };
|
|
|
1295
1296
|
}
|
|
1296
1297
|
return Lt(o);
|
|
1297
1298
|
}(H), Vt = /^[\n\r\t\x20\xA0\u2000-\u200B\u205F\u3000]/, Ue = /^[^\n\r\t\u0020\u2000-\u200B\u205F\u3000]{2,}/, ue = /^[\xA0\u2011\u202F\u2060\uFEFF]/, Ye = /^(?:[;\xAD%?…]|,(?!\d))/, Xe = /^[´±°¢£¤$¥\u2212]/;
|
|
1298
|
-
function
|
|
1299
|
+
function Ct(e, n) {
|
|
1299
1300
|
n !== !1 && (e = e.trim());
|
|
1300
1301
|
for (var o, i, h = [], p = e.charAt(0), w = 0, x = 1, b = e.length; x < b; x++) {
|
|
1301
1302
|
o = e.charAt(x), i = e.charAt(x + 1);
|
|
@@ -1434,8 +1435,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1434
1435
|
if (e.length) {
|
|
1435
1436
|
var b = i.height, S = n.valign(), D = n.height()(), O = n.width()(0), k = !isFinite(O) && e.length === 1, M = k ? null : n.x(), R = mt(b / h), K = k ? null : mt(b / (1.15 * h + (b - h) / 2));
|
|
1436
1437
|
if (fn[S] && isFinite(D)) {
|
|
1437
|
-
var
|
|
1438
|
-
K += (D *
|
|
1438
|
+
var P = S === "bottom" ? 1 : 0.5;
|
|
1439
|
+
K += (D * P - b * e.length * P) / h;
|
|
1439
1440
|
}
|
|
1440
1441
|
var L = w === "justify", j = 0;
|
|
1441
1442
|
w === "right" ? j = O : w === "center" && (j = O / 2);
|
|
@@ -1449,7 +1450,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1449
1450
|
var ot = "", ht = "", st = 0, at = e[et];
|
|
1450
1451
|
if (at.length) {
|
|
1451
1452
|
$ = [];
|
|
1452
|
-
for (var vt = 0, kt = 0, lt = void 0, X = 0,
|
|
1453
|
+
for (var vt = 0, kt = 0, lt = void 0, X = 0, Pt = at.length; X < Pt; X++) {
|
|
1453
1454
|
var q = at[X], G = q.font;
|
|
1454
1455
|
q.whitespace && vt++, kt += q.width, X && !q.tracking && !st && Yt(G.id, ot) && Yt(q.class, ht) && Yt(lt, q.href) ? F += q.value : (I(), F = q.value, Y = { fontFamily: G.family !== p ? G.family : null, fontSize: G.size !== h ? G.size : null, fontWeight: G.weight || null, fontStyle: G.style || null, fontVariant: G.variant !== "normal" && G.variant || null, fill: G.color || null, baselineShift: G.baseline ? 100 * G.baseline + "%" : null, className: q.class || null }, st && (Y.dx = mt(st), st = 0), q.tracking && (st = G.size * q.tracking), q.href && !lt ? (lt = q.href, J = "a", Y.href = lt, Y.rel = q.rel, Y.target = q.target) : lt = null, ot = G.id, ht = q.class);
|
|
1455
1456
|
}
|
|
@@ -1475,7 +1476,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1475
1476
|
O += x * k - M * k;
|
|
1476
1477
|
}
|
|
1477
1478
|
e.forEach(function(R, K) {
|
|
1478
|
-
var
|
|
1479
|
+
var P = n.x()(K), L = K * h + O, j = 0, $ = 0;
|
|
1479
1480
|
R.forEach(function(F) {
|
|
1480
1481
|
F.whitespace && j++, $ += F.width;
|
|
1481
1482
|
});
|
|
@@ -1487,12 +1488,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1487
1488
|
return ht.color ? ht.color : st.href ? "#00C" : "#000";
|
|
1488
1489
|
}(I, F);
|
|
1489
1490
|
var Q = 0;
|
|
1490
|
-
if (S === "right" ? Q += b - $ : S === "center" ? Q += b / 2 - $ / 2 : S === "justify" && (F.whitespace || F instanceof tt) && (
|
|
1491
|
+
if (S === "right" ? Q += b - $ : S === "center" ? Q += b / 2 - $ / 2 : S === "justify" && (F.whitespace || F instanceof tt) && (P += J), o.fillText(F.value, P + Q, L + et), F.href) {
|
|
1491
1492
|
o.beginPath(), o.strokeStyle = o.fillStyle;
|
|
1492
1493
|
var ot = Math.floor(L + 0.45 * p) + 0.5;
|
|
1493
|
-
o.moveTo(
|
|
1494
|
+
o.moveTo(P + Q, ot), o.lineTo(P + Q + F.width, ot), o.stroke();
|
|
1494
1495
|
}
|
|
1495
|
-
|
|
1496
|
+
P += F.width;
|
|
1496
1497
|
});
|
|
1497
1498
|
});
|
|
1498
1499
|
}
|
|
@@ -1560,12 +1561,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1560
1561
|
var h = this, p = this.props.parser(String(i)), w = this.font(), x = function(b, S, D) {
|
|
1561
1562
|
if (!b.length)
|
|
1562
1563
|
return [];
|
|
1563
|
-
var O = S.height(), k = S.width(), M = S.overflowLine(), R = S.overflowWrap(), K = E(D, !0, !1),
|
|
1564
|
-
if (!O() && !k(0) || !
|
|
1564
|
+
var O = S.height(), k = S.width(), M = S.overflowLine(), R = S.overflowWrap(), K = E(D, !0, !1), P = isFinite(O()) ? Math.floor(O() / D.height) : 1 / 0;
|
|
1565
|
+
if (!O() && !k(0) || !P)
|
|
1565
1566
|
return [];
|
|
1566
|
-
for (var L = 0, j = 0, $ = 0, J = [], Y = [], F = !1; L < b.length && j <
|
|
1567
|
+
for (var L = 0, j = 0, $ = 0, J = [], Y = [], F = !1; L < b.length && j < P; ) {
|
|
1567
1568
|
var I = b[L], et = cn(I, D);
|
|
1568
|
-
if (I.width = W(I, et), I.font = et, I.line = j, I.whitespace = I.value in
|
|
1569
|
+
if (I.width = W(I, et), I.font = et, I.line = j, I.whitespace = I.value in C, I.value && (I.value = I.value.replace(un, " ")), !(!$ && I.whitespace || F && I.whitespace))
|
|
1569
1570
|
if (I instanceof tt)
|
|
1570
1571
|
$ = 0, Y = [], J.push(L + 1), j++;
|
|
1571
1572
|
else if (I instanceof St || I instanceof ft)
|
|
@@ -1609,12 +1610,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1609
1610
|
}, 0), xt.width > lt && (lt = xt.width), xt;
|
|
1610
1611
|
});
|
|
1611
1612
|
if (X.hasLineOverflow = !1, M) {
|
|
1612
|
-
var
|
|
1613
|
+
var Pt = M === "ellipsis" ? "…" : M;
|
|
1613
1614
|
X.forEach(function(pt, Z) {
|
|
1614
1615
|
var gt = k(Z);
|
|
1615
1616
|
if (pt.width > gt) {
|
|
1616
|
-
var ut = new H(
|
|
1617
|
-
ut.font = D, ut.width = W(
|
|
1617
|
+
var ut = new H(Pt);
|
|
1618
|
+
ut.font = D, ut.width = W(Pt, K), ge(pt, gt, ut), X.hasLineOverflow = !0;
|
|
1618
1619
|
}
|
|
1619
1620
|
});
|
|
1620
1621
|
}
|
|
@@ -1795,7 +1796,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1795
1796
|
}), o;
|
|
1796
1797
|
}
|
|
1797
1798
|
}
|
|
1798
|
-
it.createElement = be, it.textparser =
|
|
1799
|
+
it.createElement = be, it.textparser = Ct, it.defaultparser = Ct, it.htmlparser = function(e) {
|
|
1799
1800
|
e = String(e || "").trim();
|
|
1800
1801
|
for (var n, o, i = { weight: null, style: null, sub: !1, sup: !1, href: null, color: null, rel: null, target: null }, h = [], p = [], w = function(O) {
|
|
1801
1802
|
for (var k in i)
|
|
@@ -1813,7 +1814,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1813
1814
|
}
|
|
1814
1815
|
}; e.length; ) {
|
|
1815
1816
|
if (n = /^[^<]+/.exec(e))
|
|
1816
|
-
|
|
1817
|
+
Ct(fe(n[0]), !1).forEach(w);
|
|
1817
1818
|
else if (!(n = Ke.exec(e)))
|
|
1818
1819
|
if (n = We.exec(e))
|
|
1819
1820
|
p.length && (i = p.pop()), x(n[1]);
|
|
@@ -1832,25 +1833,25 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1832
1833
|
}, it.latexparser = function(e) {
|
|
1833
1834
|
e = String(e || "").trim();
|
|
1834
1835
|
var n = [0];
|
|
1835
|
-
e = e.replace(/\\verb,(.*?),/, function(
|
|
1836
|
+
e = e.replace(/\\verb,(.*?),/, function(P, L) {
|
|
1836
1837
|
return n.push(L), "\\verb," + (n.length - 1) + ",";
|
|
1837
1838
|
}).replace(/\\\\\n/g, function() {
|
|
1838
1839
|
return "\\\\";
|
|
1839
|
-
}).replace(ln, function(
|
|
1840
|
-
return j.charAt(L - 1) === "\\" ?
|
|
1841
|
-
}).replace(/\n\s+/g, function(
|
|
1842
|
-
return /\n/.test(
|
|
1843
|
-
}).replace(/\\symbol\{(\d+)\}/, function(
|
|
1844
|
-
return $.charAt(j - 1) === "\\" ?
|
|
1845
|
-
}).replace(/(^|[^\\])(\^|_)(\d|[^{]\S*)/g, function(
|
|
1840
|
+
}).replace(ln, function(P, L, j) {
|
|
1841
|
+
return j.charAt(L - 1) === "\\" ? P : hn[P];
|
|
1842
|
+
}).replace(/\n\s+/g, function(P) {
|
|
1843
|
+
return /\n/.test(P.slice(1)) ? "\\par " : P;
|
|
1844
|
+
}).replace(/\\symbol\{(\d+)\}/, function(P, L, j, $) {
|
|
1845
|
+
return $.charAt(j - 1) === "\\" ? P : String.fromCharCode(1 * L);
|
|
1846
|
+
}).replace(/(^|[^\\])(\^|_)(\d|[^{]\S*)/g, function(P, L, j, $) {
|
|
1846
1847
|
return L + j + "{" + $ + "}";
|
|
1847
|
-
}).replace(/\\verb,(.*?),/, function(
|
|
1848
|
+
}).replace(/\\verb,(.*?),/, function(P, L) {
|
|
1848
1849
|
return "\\verb,".concat(n[+L], ",");
|
|
1849
1850
|
});
|
|
1850
|
-
for (var o, i = { weight: null, italic: null, variant: null, sub: !1, sup: !1, href: null }, h = [], p = [], w = function(
|
|
1851
|
+
for (var o, i = { weight: null, italic: null, variant: null, sub: !1, sup: !1, href: null }, h = [], p = [], w = function(P) {
|
|
1851
1852
|
for (var L in i)
|
|
1852
|
-
i[L] && (
|
|
1853
|
-
return h.push(
|
|
1853
|
+
i[L] && (P[L] = i[L]);
|
|
1854
|
+
return h.push(P), P;
|
|
1854
1855
|
}, x = function() {
|
|
1855
1856
|
p.push(i), i = Object.create(i);
|
|
1856
1857
|
}, b = function() {
|
|
@@ -1859,7 +1860,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1859
1860
|
i = p.pop();
|
|
1860
1861
|
}, S = { tokens: h, open_context: x, close_context: b, add_token: w }; e.length; ) {
|
|
1861
1862
|
if (o = on.exec(e))
|
|
1862
|
-
|
|
1863
|
+
Ct(o[0], !1).forEach(w);
|
|
1863
1864
|
else if (o = an.exec(e))
|
|
1864
1865
|
w(new H(o[1]));
|
|
1865
1866
|
else if (!(o = sn.exec(e))) {
|
|
@@ -1945,63 +1946,63 @@ class qn extends qe {
|
|
|
1945
1946
|
</div>
|
|
1946
1947
|
`
|
|
1947
1948
|
);
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1949
|
+
v(this, "textArea");
|
|
1950
|
+
v(this, "handleSize");
|
|
1951
|
+
v(this, "rect", { x: 0, y: 0, width: 0, height: 0 });
|
|
1952
|
+
v(this, "annotation", { ...te });
|
|
1953
|
+
v(this, "startX", 0);
|
|
1954
|
+
v(this, "startY", 0);
|
|
1955
|
+
v(this, "handles", []);
|
|
1956
|
+
v(this, "draggedHandle", B);
|
|
1957
|
+
v(this, "isFocused", !1);
|
|
1958
|
+
v(this, "placeholder", "Type your text here...");
|
|
1959
|
+
v(this, "_onFocus", () => {
|
|
1959
1960
|
this.textArea.value === this.placeholder && (this.textArea.value = ""), this.isFocused = !0;
|
|
1960
1961
|
});
|
|
1961
|
-
|
|
1962
|
+
v(this, "_onBlur", () => {
|
|
1962
1963
|
this.isFocused = !1;
|
|
1963
1964
|
});
|
|
1964
|
-
|
|
1965
|
+
v(this, "startDrawing", (t, s, a = Rn(t, s, 0, 0, "", bt)) => {
|
|
1965
1966
|
this.add(a);
|
|
1966
1967
|
const c = this.ogma.view.graphToScreenCoordinates({ x: t, y: s });
|
|
1967
1968
|
this.select(a.id), this.startDragging(this.getById(a.id), c.x, c.y), this.draggedHandle = 6;
|
|
1968
1969
|
});
|
|
1969
|
-
|
|
1970
|
+
v(this, "cancelDrawing", () => {
|
|
1970
1971
|
this.isDragging && (this.remove(this.annotation.id), this.annotation = { ...te }, this.draggedHandle = B, this.isDragging = !1, this.emit(Ot, this.annotation));
|
|
1971
1972
|
});
|
|
1972
|
-
|
|
1973
|
+
v(this, "startDragging", (t, s, a) => {
|
|
1973
1974
|
this.annotation = t;
|
|
1974
1975
|
const c = yt(this.annotation), g = dt(this.annotation);
|
|
1975
1976
|
this.rect.x = c.x, this.rect.y = c.y, this.rect.width = g.width, this.rect.height = g.height, this.startX = s, this.startY = a, this.disableDragging(), this.textArea.classList.add("noevents"), this.textArea.setAttribute("disabled", "disabled"), this.emit(le, this.annotation), this.isDragging = !0;
|
|
1976
1977
|
});
|
|
1977
|
-
|
|
1978
|
+
v(this, "onHandleMouseDown", (t) => {
|
|
1978
1979
|
const s = this.getById(this.selectedId) || this.getById(this.hoveredId);
|
|
1979
1980
|
s && (this.selectedId !== s.id && this.select(this.hoveredId), this.startDragging(s, t.clientX, t.clientY), this.draggedHandle = He(t.target));
|
|
1980
1981
|
});
|
|
1981
|
-
|
|
1982
|
+
v(this, "onMouseMove", (t) => {
|
|
1982
1983
|
requestAnimationFrame(() => this._onMouseMove(t));
|
|
1983
1984
|
});
|
|
1984
|
-
|
|
1985
|
+
v(this, "_onMouseMove", (t) => {
|
|
1985
1986
|
if (!this.isDragging)
|
|
1986
1987
|
return;
|
|
1987
1988
|
t.stopPropagation(), t.preventDefault();
|
|
1988
|
-
const s = this.handles[this.draggedHandle], a = s.classList.contains("top"), c = s.classList.contains("left"), g = s.classList.contains("right"), y = s.classList.contains("bottom"), f = s.classList.contains("line-handle"), r = this.ogma.view.getZoom(), d = (t.clientX - this.startX) / r,
|
|
1989
|
+
const s = this.handles[this.draggedHandle], a = s.classList.contains("top"), c = s.classList.contains("left"), g = s.classList.contains("right"), y = s.classList.contains("bottom"), f = s.classList.contains("line-handle"), r = this.ogma.view.getZoom(), d = (t.clientX - this.startX) / r, m = (t.clientY - this.startY) / r, T = c || f ? this.rect.x + d : this.rect.x, _ = a || f ? this.rect.y + m : this.rect.y, E = Math.max(
|
|
1989
1990
|
this.rect.width + d * (f ? 0 : c ? -1 : g ? 1 : 0),
|
|
1990
1991
|
Me
|
|
1991
|
-
),
|
|
1992
|
-
this.rect.height +
|
|
1992
|
+
), C = Math.max(
|
|
1993
|
+
this.rect.height + m * (f ? 0 : a ? -1 : y ? 1 : 0),
|
|
1993
1994
|
Me
|
|
1994
1995
|
);
|
|
1995
|
-
Mn(this.annotation, T, _, E,
|
|
1996
|
+
Mn(this.annotation, T, _, E, C), this.emit(ae, this.annotation, "text"), this.refreshEditor(), this.layer.refresh();
|
|
1996
1997
|
});
|
|
1997
|
-
|
|
1998
|
+
v(this, "onMouseUp", () => {
|
|
1998
1999
|
!this.isDragging || this.draggedHandle === B || (this.restoreDragging(), this.textArea.classList.remove("noevents"), this.textArea.removeAttribute("disabled"), this.emit(Ot, this.annotation), this.isDragging = !1, this.draggedHandle = B);
|
|
1999
2000
|
});
|
|
2000
|
-
|
|
2001
|
+
v(this, "onViewChanged", () => {
|
|
2001
2002
|
const t = Math.max(2, this.handleSize / this.ogma.view.getZoom());
|
|
2002
2003
|
document.documentElement.style.setProperty("--handle-width", `${t}px`);
|
|
2003
2004
|
});
|
|
2004
|
-
|
|
2005
|
+
v(this, "_onInput", () => {
|
|
2005
2006
|
const t = this.getById(this.selectedId);
|
|
2006
2007
|
t && (this.textArea.value = this.textArea.value.replace(/ +(?= )/g, ""), this.textArea.focus(), t.properties.content = this.textArea.value, this.emit(se, t), this.layer.refresh());
|
|
2007
2008
|
});
|
|
@@ -2027,21 +2028,21 @@ class qn extends qe {
|
|
|
2027
2028
|
const s = "";
|
|
2028
2029
|
this.elements.forEach((c, g) => {
|
|
2029
2030
|
const y = `class${g}`, f = dt(c), r = yt(c), d = c.id, {
|
|
2030
|
-
color:
|
|
2031
|
+
color: m,
|
|
2031
2032
|
fontSize: T,
|
|
2032
2033
|
font: _,
|
|
2033
2034
|
strokeColor: E,
|
|
2034
|
-
strokeWidth:
|
|
2035
|
+
strokeWidth: C,
|
|
2035
2036
|
strokeType: A,
|
|
2036
2037
|
background: U
|
|
2037
2038
|
} = c.properties.style || bt;
|
|
2038
2039
|
if (d === this.selectedId || this.selectedId === -1 && d === this.hoveredId)
|
|
2039
2040
|
return;
|
|
2040
2041
|
const N = It("g");
|
|
2041
|
-
N.setAttribute("fill", `${
|
|
2042
|
+
N.setAttribute("fill", `${m}`), N.setAttribute("font-size", `${T}`), N.setAttribute("font-family", `${_}`);
|
|
2042
2043
|
const z = It("rect");
|
|
2043
2044
|
let W = !1;
|
|
2044
|
-
A && A !== "none" && (W = !0, z.setAttribute("stroke", E || "black"), z.setAttribute("stroke-width", `${
|
|
2045
|
+
A && A !== "none" && (W = !0, z.setAttribute("stroke", E || "black"), z.setAttribute("stroke-width", `${C}`), A === "dashed" && z.setAttribute("stroke-dasharray", "5,5")), (U && U.length || W) && (W = !0, z.setAttribute("fill", U || "transparent")), W && (z.setAttribute("width", `${f.width}`), z.setAttribute("height", `${f.height}`)), N.appendChild(z), Fn(c, N), N.setAttribute("transform", `translate(${r.x},${r.y})`), N.classList.add(y), N.setAttribute("data-annotation", `${c.id}`), N.setAttribute("data-annotation-type", "text"), t.appendChild(N);
|
|
2045
2046
|
});
|
|
2046
2047
|
const a = It("style");
|
|
2047
2048
|
a.innerHTML = s, t.firstChild && t.insertBefore(a, t.firstChild);
|
|
@@ -2070,9 +2071,9 @@ class qn extends qe {
|
|
|
2070
2071
|
}
|
|
2071
2072
|
class Bn {
|
|
2072
2073
|
constructor() {
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2074
|
+
v(this, "links", {});
|
|
2075
|
+
v(this, "linksByTargetId", {});
|
|
2076
|
+
v(this, "linksByArrowId", {});
|
|
2076
2077
|
}
|
|
2077
2078
|
add(l, t, s, a, c) {
|
|
2078
2079
|
const g = jt(), y = l.id, f = {
|
|
@@ -2143,20 +2144,20 @@ const ct = (u) => u.properties.type === "arrow", wt = (u) => u.properties.type =
|
|
|
2143
2144
|
class Gn extends Fe {
|
|
2144
2145
|
constructor(t, s = {}) {
|
|
2145
2146
|
super();
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2147
|
+
v(this, "arrows");
|
|
2148
|
+
v(this, "texts");
|
|
2149
|
+
v(this, "links", new Bn());
|
|
2150
|
+
v(this, "layer");
|
|
2151
|
+
v(this, "annotations");
|
|
2152
|
+
v(this, "ogma");
|
|
2153
|
+
v(this, "options");
|
|
2154
|
+
v(this, "selected", null);
|
|
2155
|
+
v(this, "updateTimeout", 0);
|
|
2156
|
+
v(this, "hoveredNode", null);
|
|
2157
|
+
v(this, "dragged", null);
|
|
2158
|
+
v(this, "textToMagnet");
|
|
2159
|
+
v(this, "activeLinks", []);
|
|
2160
|
+
v(this, "_render", (t) => {
|
|
2160
2161
|
if (!this.dragged || this.textToMagnet === void 0)
|
|
2161
2162
|
return;
|
|
2162
2163
|
t.beginPath(), t.fillStyle = "green";
|
|
@@ -2168,7 +2169,7 @@ class Gn extends Fe {
|
|
|
2168
2169
|
t.moveTo(y, f), t.arc(y, f, this.options.magnetHandleRadius / s, 0, Math.PI * 2);
|
|
2169
2170
|
}), t.fill(), t.closePath();
|
|
2170
2171
|
});
|
|
2171
|
-
|
|
2172
|
+
v(this, "_onFeatureDrag", (t, s) => {
|
|
2172
2173
|
const a = s;
|
|
2173
2174
|
if (ct(t) && a === "line")
|
|
2174
2175
|
["start", "end"].find((c) => {
|
|
@@ -2180,12 +2181,12 @@ class Gn extends Fe {
|
|
|
2180
2181
|
this._snapToText(t, a, c) || this._findAndSnapToNode(t, a, c);
|
|
2181
2182
|
} else
|
|
2182
2183
|
wt(t) && (this.activeLinks.forEach(({ arrow: c, side: g, connectionPoint: y }) => {
|
|
2183
|
-
const f = this.getAnnotation(c), r = dt(t), d = yt(t),
|
|
2184
|
-
f.geometry.coordinates[g === "start" ? 0 : 1] = [
|
|
2184
|
+
const f = this.getAnnotation(c), r = dt(t), d = yt(t), m = new rt(y.x, y.y).mul({ x: r.width, y: r.height }).add(d);
|
|
2185
|
+
f.geometry.coordinates[g === "start" ? 0 : 1] = [m.x, m.y];
|
|
2185
2186
|
}), this.activeLinks.length && this.arrows.refreshLayer());
|
|
2186
2187
|
this.layer.refresh();
|
|
2187
2188
|
});
|
|
2188
|
-
|
|
2189
|
+
v(this, "_onFeatureDragEnd", (t) => {
|
|
2189
2190
|
this.dragged !== null && ct(t) && _t(this.dragged) && ze.forEach((s) => {
|
|
2190
2191
|
this.links.getArrowLink(t.id, s) && this.emit(Nn, {
|
|
2191
2192
|
arrow: t,
|
|
@@ -2193,41 +2194,41 @@ class Gn extends Fe {
|
|
|
2193
2194
|
});
|
|
2194
2195
|
}), (wt(t) || ct(t)) && this.onUpdate(t), this.dragged = null, this.activeLinks = [], this.textToMagnet = void 0, this.annotations.forEach((s) => s.enableDetection()), this.layer.refresh();
|
|
2195
2196
|
});
|
|
2196
|
-
|
|
2197
|
+
v(this, "_onFeatureDragStart", (t) => {
|
|
2197
2198
|
this.textToMagnet = void 0, ct(t) ? this.dragged = t : wt(t) && this.activeLinks.push(...this.links.getTargetLinks(t.id)), this.annotations.forEach((s) => {
|
|
2198
2199
|
const a = s.getSelectedFeature();
|
|
2199
2200
|
a && a !== t && s.unhover().unselect(), s.disableDetection();
|
|
2200
2201
|
});
|
|
2201
2202
|
});
|
|
2202
|
-
|
|
2203
|
+
v(this, "_onNodesDragStart", () => {
|
|
2203
2204
|
this.arrows.unhover().unselect(), this.texts.unhover().unselect();
|
|
2204
2205
|
});
|
|
2205
|
-
|
|
2206
|
+
v(this, "_onNodesDrag", (t) => {
|
|
2206
2207
|
const { dx: s, dy: a } = t;
|
|
2207
2208
|
this._moveNodes(t.nodes, s, a);
|
|
2208
2209
|
});
|
|
2209
|
-
|
|
2210
|
+
v(this, "_onAdded", (t) => {
|
|
2210
2211
|
this.emit(re, t);
|
|
2211
2212
|
});
|
|
2212
|
-
|
|
2213
|
+
v(this, "_onRemoved", (t) => {
|
|
2213
2214
|
this.emit(ie, t);
|
|
2214
2215
|
});
|
|
2215
|
-
|
|
2216
|
+
v(this, "_onUnselect", (t) => {
|
|
2216
2217
|
this.selected = null, this.emit(ne, t);
|
|
2217
2218
|
});
|
|
2218
|
-
|
|
2219
|
+
v(this, "_onSelect", (t) => {
|
|
2219
2220
|
this.selected !== t && (this.selected = t, this.emit(ee, this.selected));
|
|
2220
2221
|
});
|
|
2221
2222
|
/**
|
|
2222
2223
|
* Triggers the update event on the annotation
|
|
2223
2224
|
* @param annotation The annotation updated
|
|
2224
2225
|
*/
|
|
2225
|
-
|
|
2226
|
+
v(this, "onUpdate", (t) => {
|
|
2226
2227
|
cancelAnimationFrame(this.updateTimeout), this.updateTimeout = requestAnimationFrame(
|
|
2227
2228
|
() => this._onUpdate(t)
|
|
2228
2229
|
);
|
|
2229
2230
|
});
|
|
2230
|
-
|
|
2231
|
+
v(this, "_onUpdate", (t) => {
|
|
2231
2232
|
this.emit(se, t);
|
|
2232
2233
|
});
|
|
2233
2234
|
this.options = this.setOptions({ ...Un, ...s }), this.ogma = t, this.arrows = new Hn(t, this.options), this.texts = new qn(t, this.options), this.annotations = [this.arrows, this.texts], this.annotations.forEach((a) => {
|
|
@@ -2238,13 +2239,13 @@ class Gn extends Fe {
|
|
|
2238
2239
|
t.forEach((c) => {
|
|
2239
2240
|
const g = this.links.getTargetLinks(c.getId()), y = c.getPosition();
|
|
2240
2241
|
g.forEach((f) => {
|
|
2241
|
-
const r = this.getAnnotation(f.arrow), d = f.side,
|
|
2242
|
+
const r = this.getAnnotation(f.arrow), d = f.side, m = Ae(
|
|
2242
2243
|
r,
|
|
2243
2244
|
d === "start" ? "end" : "start"
|
|
2244
2245
|
);
|
|
2245
2246
|
let T = y;
|
|
2246
2247
|
const _ = +c.getAttribute("radius"), E = 1e-6;
|
|
2247
|
-
(f.connectionPoint.x - (y.x - s) > E || f.connectionPoint.y - (y.y - a) > E) && (T = Ee(
|
|
2248
|
+
(f.connectionPoint.x - (y.x - s) > E || f.connectionPoint.y - (y.y - a) > E) && (T = Ee(m, y, _)), Qt(r, d, T.x, T.y);
|
|
2248
2249
|
});
|
|
2249
2250
|
}), this.arrows.refreshLayer();
|
|
2250
2251
|
}
|
|
@@ -2261,10 +2262,10 @@ class Gn extends Fe {
|
|
|
2261
2262
|
this.links.remove(t, s), g && g.isNode ? (this.hoveredNode = g, this.hoveredNode.setSelected(!0), this._snapToNode(t, s, g, c)) : (this.hoveredNode && this.hoveredNode.setSelected(!1), this.hoveredNode = null);
|
|
2262
2263
|
}
|
|
2263
2264
|
_snapToNode(t, s, a, c) {
|
|
2264
|
-
const g = a.getPositionOnScreen(), y = +a.getAttribute("radius"), f = y * this.ogma.view.getZoom(), r = c.x - g.x, d = c.y - g.y,
|
|
2265
|
-
if (
|
|
2265
|
+
const g = a.getPositionOnScreen(), y = +a.getAttribute("radius"), f = y * this.ogma.view.getZoom(), r = c.x - g.x, d = c.y - g.y, m = Math.sqrt(r * r + d * d), T = a.getPosition();
|
|
2266
|
+
if (m < f + this.options.detectMargin) {
|
|
2266
2267
|
let _ = T;
|
|
2267
|
-
if (
|
|
2268
|
+
if (m > f / 2) {
|
|
2268
2269
|
const E = Ae(t, s === "end" ? "start" : "end");
|
|
2269
2270
|
_ = Ee(E, _, y);
|
|
2270
2271
|
}
|
|
@@ -2280,8 +2281,8 @@ class Gn extends Fe {
|
|
|
2280
2281
|
findMagnetPoint(t, s, a) {
|
|
2281
2282
|
let c;
|
|
2282
2283
|
for (const g of t) {
|
|
2283
|
-
const y = dt(s), f = yt(s), r = new rt(g.x, g.y).mul({ x: y.width, y: y.height }).add(f), d = r.sub(a).length(),
|
|
2284
|
-
if (d < Math.max(
|
|
2284
|
+
const y = dt(s), f = yt(s), r = new rt(g.x, g.y).mul({ x: y.width, y: y.height }).add(f), d = r.sub(a).length(), m = this.options.magnetRadius * this.ogma.view.getZoom();
|
|
2285
|
+
if (d < Math.max(m, this.options.magnetHandleRadius)) {
|
|
2285
2286
|
c = {
|
|
2286
2287
|
point: r,
|
|
2287
2288
|
magnet: g
|
|
@@ -2372,7 +2373,7 @@ class Gn extends Fe {
|
|
|
2372
2373
|
* Cancel drawing on the current frame
|
|
2373
2374
|
*/
|
|
2374
2375
|
cancelDrawing() {
|
|
2375
|
-
this.annotations.forEach((t) => t.cancelDrawing()), this.emit(
|
|
2376
|
+
this.annotations.forEach((t) => t.cancelDrawing()), this.emit(Pn);
|
|
2376
2377
|
}
|
|
2377
2378
|
/**
|
|
2378
2379
|
* Update the style of the annotation with the given id
|
|
@@ -2430,7 +2431,7 @@ export {
|
|
|
2430
2431
|
_t as getArrowStart,
|
|
2431
2432
|
Ee as getAttachmentPointOnNode,
|
|
2432
2433
|
He as getHandleId,
|
|
2433
|
-
|
|
2434
|
+
Pe as getTextBbox,
|
|
2434
2435
|
yt as getTextPosition,
|
|
2435
2436
|
dt as getTextSize,
|
|
2436
2437
|
Vn as isAnnotationCollection,
|