@linkurious/ogma-annotations 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +308 -308
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +6 -6
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
var kn = Object.defineProperty;
|
|
2
|
-
var Tn = (
|
|
3
|
-
var v = (
|
|
2
|
+
var Tn = (u, l, t) => l in u ? kn(u, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : u[l] = t;
|
|
3
|
+
var v = (u, l, t) => (Tn(u, typeof l != "symbol" ? l + "" : l, t), t);
|
|
4
4
|
var In = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
5
|
-
function le(
|
|
6
|
-
return
|
|
5
|
+
function le(u) {
|
|
6
|
+
return u && u.__esModule && Object.prototype.hasOwnProperty.call(u, "default") ? u.default : u;
|
|
7
7
|
}
|
|
8
|
-
var
|
|
9
|
-
(function(
|
|
8
|
+
var Pe = { exports: {} };
|
|
9
|
+
(function(u) {
|
|
10
10
|
(function(l, t) {
|
|
11
|
-
|
|
11
|
+
u.exports = t();
|
|
12
12
|
})("Vector", function() {
|
|
13
13
|
var l = function() {
|
|
14
14
|
var t = Math.PI * 2, r = 180 / Math.PI, a = Math.PI / 180;
|
|
15
|
-
function
|
|
15
|
+
function c(s) {
|
|
16
16
|
return Math.round(s * 1e8) / 1e8;
|
|
17
17
|
}
|
|
18
18
|
function p(s, d) {
|
|
19
|
-
var m = d.x - s.x,
|
|
20
|
-
return Math.sqrt(m * m +
|
|
19
|
+
var m = d.x - s.x, k = d.y - s.y;
|
|
20
|
+
return Math.sqrt(m * m + k * k);
|
|
21
21
|
}
|
|
22
22
|
function y(s, d, m) {
|
|
23
|
-
var
|
|
23
|
+
var k = d.y - s.y, I = d.x - s.x, E = Math.atan2(k, I);
|
|
24
24
|
if (m)
|
|
25
|
-
for (;
|
|
26
|
-
|
|
27
|
-
return
|
|
25
|
+
for (; E < 0; )
|
|
26
|
+
E += t;
|
|
27
|
+
return E;
|
|
28
28
|
}
|
|
29
29
|
function f(s, d) {
|
|
30
30
|
this.x = s !== void 0 ? s : 0, this.y = d !== void 0 ? d : 0;
|
|
@@ -191,8 +191,8 @@ var $e = { exports: {} };
|
|
|
191
191
|
// @param radians - radians to rotate this vector by (can be positive or negative).
|
|
192
192
|
// @return self.
|
|
193
193
|
rotateRadiansSelf: function(s) {
|
|
194
|
-
var d = Math.cos(s), m = Math.sin(s),
|
|
195
|
-
return this.x =
|
|
194
|
+
var d = Math.cos(s), m = Math.sin(s), k = this.x * d - this.y * m, I = this.x * m + this.y * d;
|
|
195
|
+
return this.x = c(k), this.y = c(I), this;
|
|
196
196
|
},
|
|
197
197
|
// [API]
|
|
198
198
|
// [chainable]
|
|
@@ -482,10 +482,10 @@ var $e = { 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 _n =
|
|
485
|
+
})(Pe);
|
|
486
|
+
var _n = Pe.exports;
|
|
487
487
|
const rt = /* @__PURE__ */ le(_n);
|
|
488
|
-
let jt = (
|
|
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 = {
|
|
490
490
|
strokeType: "plain",
|
|
491
491
|
strokeColor: "black",
|
|
@@ -518,7 +518,7 @@ const Dt = {
|
|
|
518
518
|
// tail: 'arrow-plain',
|
|
519
519
|
// start: { x: 0, y: 0 },
|
|
520
520
|
// end: { x: 100, y: 100 }
|
|
521
|
-
}, Dn = (
|
|
521
|
+
}, Dn = (u = 0, l = 0, t = 0, r = 0, a = { ...Dt }) => ({
|
|
522
522
|
id: jt(),
|
|
523
523
|
type: "Feature",
|
|
524
524
|
properties: {
|
|
@@ -531,34 +531,34 @@ const Dt = {
|
|
|
531
531
|
geometry: {
|
|
532
532
|
type: "LineString",
|
|
533
533
|
coordinates: [
|
|
534
|
-
[
|
|
534
|
+
[u, l],
|
|
535
535
|
[t, r]
|
|
536
536
|
]
|
|
537
537
|
}
|
|
538
|
-
}),
|
|
539
|
-
function It(
|
|
540
|
-
return document.createElementNS(
|
|
538
|
+
}), On = "http://www.w3.org/2000/svg";
|
|
539
|
+
function It(u) {
|
|
540
|
+
return document.createElementNS(On, u);
|
|
541
541
|
}
|
|
542
|
-
function
|
|
543
|
-
return
|
|
542
|
+
function $e(u) {
|
|
543
|
+
return u.geometry.bbox || Mn(u), u.geometry.bbox;
|
|
544
544
|
}
|
|
545
|
-
function dt(
|
|
546
|
-
const l =
|
|
545
|
+
function dt(u) {
|
|
546
|
+
const l = $e(u);
|
|
547
547
|
return {
|
|
548
548
|
width: l[2] - l[0],
|
|
549
549
|
height: l[3] - l[1]
|
|
550
550
|
};
|
|
551
551
|
}
|
|
552
|
-
function yt(
|
|
553
|
-
const l =
|
|
552
|
+
function yt(u) {
|
|
553
|
+
const l = $e(u);
|
|
554
554
|
return { x: l[0], y: l[1] };
|
|
555
555
|
}
|
|
556
|
-
function
|
|
557
|
-
const [l, t] =
|
|
558
|
-
|
|
556
|
+
function Mn(u) {
|
|
557
|
+
const [l, t] = u.geometry.coordinates[0][0], [r, a] = u.geometry.coordinates[0][2];
|
|
558
|
+
u.geometry.bbox = [l, t, r, a];
|
|
559
559
|
}
|
|
560
|
-
function zn(
|
|
561
|
-
|
|
560
|
+
function zn(u, l, t, r, a) {
|
|
561
|
+
u.geometry.bbox = [l, t, l + r, t + a], u.geometry.coordinates = [
|
|
562
562
|
[
|
|
563
563
|
[l, t],
|
|
564
564
|
[l + r, t],
|
|
@@ -568,33 +568,33 @@ function zn(c, l, t, r, a) {
|
|
|
568
568
|
]
|
|
569
569
|
];
|
|
570
570
|
}
|
|
571
|
-
function _t(
|
|
572
|
-
const [l, t] =
|
|
571
|
+
function _t(u) {
|
|
572
|
+
const [l, t] = u.geometry.coordinates[0];
|
|
573
573
|
return { x: l, y: t };
|
|
574
574
|
}
|
|
575
|
-
function te(
|
|
576
|
-
const [t, r] =
|
|
575
|
+
function te(u, l) {
|
|
576
|
+
const [t, r] = u.geometry.coordinates[l === "start" ? 0 : 1];
|
|
577
577
|
return { x: t, y: r };
|
|
578
578
|
}
|
|
579
|
-
function Rt(
|
|
580
|
-
const [l, t] =
|
|
579
|
+
function Rt(u) {
|
|
580
|
+
const [l, t] = u.geometry.coordinates[1];
|
|
581
581
|
return { x: l, y: t };
|
|
582
582
|
}
|
|
583
|
-
function Ne(
|
|
584
|
-
|
|
583
|
+
function Ne(u, l, t) {
|
|
584
|
+
u.geometry.coordinates[0] = [l, t];
|
|
585
585
|
}
|
|
586
|
-
function He(
|
|
587
|
-
|
|
586
|
+
function He(u, l, t) {
|
|
587
|
+
u.geometry.coordinates[1] = [l, t];
|
|
588
588
|
}
|
|
589
|
-
function Ft(
|
|
590
|
-
return { start: _t(
|
|
589
|
+
function Ft(u) {
|
|
590
|
+
return { start: _t(u), end: Rt(u) };
|
|
591
591
|
}
|
|
592
|
-
function Nt(
|
|
593
|
-
l === "start" ? Ne(
|
|
592
|
+
function Nt(u, l, t, r) {
|
|
593
|
+
l === "start" ? Ne(u, t, r) : He(u, t, r);
|
|
594
594
|
}
|
|
595
|
-
const Re = (
|
|
596
|
-
function Xn(
|
|
597
|
-
return Ht(
|
|
595
|
+
const Re = (u) => parseInt(u.getAttribute("data-handle-id") || "-1");
|
|
596
|
+
function Xn(u) {
|
|
597
|
+
return Ht(u).reduce(
|
|
598
598
|
(l, t) => (l[0] = Math.min(t[0], l[0]), l[1] = Math.min(t[1], l[1]), l[2] = Math.max(t[0], l[2]), l[3] = Math.max(t[1], l[3]), l),
|
|
599
599
|
[
|
|
600
600
|
Number.POSITIVE_INFINITY,
|
|
@@ -604,51 +604,51 @@ function Xn(c) {
|
|
|
604
604
|
]
|
|
605
605
|
);
|
|
606
606
|
}
|
|
607
|
-
function Ht(
|
|
607
|
+
function Ht(u) {
|
|
608
608
|
let l = [];
|
|
609
|
-
return
|
|
609
|
+
return u.type == "Point" ? l = [u.coordinates] : u.type == "LineString" || u.type == "MultiPoint" ? l = u.coordinates : u.type == "Polygon" || u.type == "MultiLineString" ? l = u.coordinates.reduce(function(t, r) {
|
|
610
610
|
return t.concat(r);
|
|
611
|
-
}, []) :
|
|
612
|
-
(t, r) => t.concat(r.reduce((a,
|
|
611
|
+
}, []) : u.type == "MultiPolygon" ? l = u.coordinates.reduce(
|
|
612
|
+
(t, r) => t.concat(r.reduce((a, c) => a.concat(c), [])),
|
|
613
613
|
[]
|
|
614
|
-
) :
|
|
614
|
+
) : u.type == "Feature" ? l = Ht(u.geometry) : u.type == "GeometryCollection" ? l = u.geometries.reduce(
|
|
615
615
|
(t, r) => t.concat(Ht(r)),
|
|
616
616
|
[]
|
|
617
|
-
) :
|
|
617
|
+
) : u.type == "FeatureCollection" && (l = u.features.reduce(
|
|
618
618
|
(t, r) => t.concat(Ht(r)),
|
|
619
619
|
[]
|
|
620
620
|
)), l;
|
|
621
621
|
}
|
|
622
|
-
function ee(
|
|
623
|
-
const r = Math.atan2(
|
|
622
|
+
function ee(u, l, t) {
|
|
623
|
+
const r = Math.atan2(u.y - l.y, u.x - l.x);
|
|
624
624
|
return {
|
|
625
625
|
x: l.x + t * Math.cos(r),
|
|
626
626
|
y: l.y + t * Math.sin(r)
|
|
627
627
|
};
|
|
628
628
|
}
|
|
629
|
-
function Fe(
|
|
629
|
+
function Fe(u, l = 5, t = 30) {
|
|
630
630
|
var s;
|
|
631
|
-
const { start: r, end: a } = Ft(
|
|
631
|
+
const { start: r, end: a } = Ft(u), c = new rt(r.x, r.y), y = new rt(a.x, a.y).sub(c), f = u.properties.style && u.properties.style.strokeWidth ? (s = u.properties.style) == null ? void 0 : s.strokeWidth : 0;
|
|
632
632
|
return Math.min(t, Math.max(3 * f, y.length() * 0.1, l));
|
|
633
633
|
}
|
|
634
|
-
function ke(
|
|
634
|
+
function ke(u, l, t, r) {
|
|
635
635
|
const a = l.clone().normalize().invert().mul(r);
|
|
636
636
|
if (!t || t === "none")
|
|
637
637
|
return "";
|
|
638
|
-
const
|
|
639
|
-
return `M ${
|
|
638
|
+
const c = u.clone().add(a.rotateRadians(Math.PI / 8)), p = u.clone().add(a.rotateRadians(-Math.PI / 8)), y = `${u.x} ${u.y}`;
|
|
639
|
+
return `M ${c.x} ${c.y} L ${y} ${p.x} ${p.y} ${t === "arrow" ? "" : `${c.x} ${c.y}`}`;
|
|
640
640
|
}
|
|
641
|
-
function Ln(
|
|
642
|
-
const { start:
|
|
643
|
-
C.setAttribute("data-annotation", `${
|
|
644
|
-
const
|
|
645
|
-
C.setAttribute("stroke", s || "none"), C.setAttribute("stroke-width", `${d}`), C.setAttribute("fill",
|
|
646
|
-
const U = ke(m, I.clone().invert(), y,
|
|
641
|
+
function Ln(u, l, t, r, a) {
|
|
642
|
+
const { start: c, end: p } = Ft(u), { tail: y, head: f, strokeColor: s, strokeWidth: d } = u.properties.style || t, m = new rt(c.x, c.y), k = new rt(p.x, p.y), I = k.clone().sub(m), E = Fe(u, r, a), C = It("path");
|
|
643
|
+
C.setAttribute("data-annotation", `${u.id}`), C.setAttribute("data-annotation-type", "arrow");
|
|
644
|
+
const A = f === "arrow-plain" || y === "arrow";
|
|
645
|
+
C.setAttribute("stroke", s || "none"), C.setAttribute("stroke-width", `${d}`), C.setAttribute("fill", A ? s || "" : "none"), C.setAttribute("stroke-linecap", "round"), C.setAttribute("stroke-linejoin", "round");
|
|
646
|
+
const U = ke(m, I.clone().invert(), y, E), $ = ke(k, I, f, E), z = U + `M ${m.x} ${m.y} ${k.x} ${k.y}` + $;
|
|
647
647
|
C.setAttribute("d", z), l.appendChild(C);
|
|
648
648
|
}
|
|
649
|
-
const B = -1, he = "dragging", ce = "dragstart",
|
|
649
|
+
const B = -1, he = "dragging", ce = "dragstart", Ot = "dragend", ie = "select", re = "unselect", Cn = "hover", Pn = "unhover", se = "remove", oe = "add", $n = "cancelDrawing", ae = "update", Nn = "link";
|
|
650
650
|
var je = { exports: {} };
|
|
651
|
-
(function(
|
|
651
|
+
(function(u) {
|
|
652
652
|
var l = Object.prototype.hasOwnProperty, t = "~";
|
|
653
653
|
function r() {
|
|
654
654
|
}
|
|
@@ -656,11 +656,11 @@ var je = { exports: {} };
|
|
|
656
656
|
function a(f, s, d) {
|
|
657
657
|
this.fn = f, this.context = s, this.once = d || !1;
|
|
658
658
|
}
|
|
659
|
-
function
|
|
659
|
+
function c(f, s, d, m, k) {
|
|
660
660
|
if (typeof d != "function")
|
|
661
661
|
throw new TypeError("The listener must be a function");
|
|
662
|
-
var I = new a(d, m || f,
|
|
663
|
-
return f._events[
|
|
662
|
+
var I = new a(d, m || f, k), E = t ? t + s : s;
|
|
663
|
+
return f._events[E] ? f._events[E].fn ? f._events[E] = [f._events[E], I] : f._events[E].push(I) : (f._events[E] = I, f._eventsCount++), f;
|
|
664
664
|
}
|
|
665
665
|
function p(f, s) {
|
|
666
666
|
--f._eventsCount === 0 ? f._events = new r() : delete f._events[s];
|
|
@@ -681,82 +681,82 @@ var je = { exports: {} };
|
|
|
681
681
|
return [];
|
|
682
682
|
if (m.fn)
|
|
683
683
|
return [m.fn];
|
|
684
|
-
for (var
|
|
685
|
-
k
|
|
686
|
-
return
|
|
684
|
+
for (var k = 0, I = m.length, E = new Array(I); k < I; k++)
|
|
685
|
+
E[k] = m[k].fn;
|
|
686
|
+
return E;
|
|
687
687
|
}, y.prototype.listenerCount = function(s) {
|
|
688
688
|
var d = t ? t + s : s, m = this._events[d];
|
|
689
689
|
return m ? m.fn ? 1 : m.length : 0;
|
|
690
|
-
}, y.prototype.emit = function(s, d, m,
|
|
690
|
+
}, y.prototype.emit = function(s, d, m, k, I, E) {
|
|
691
691
|
var C = t ? t + s : s;
|
|
692
692
|
if (!this._events[C])
|
|
693
693
|
return !1;
|
|
694
|
-
var
|
|
695
|
-
if (
|
|
696
|
-
switch (
|
|
694
|
+
var A = this._events[C], U = arguments.length, $, z;
|
|
695
|
+
if (A.fn) {
|
|
696
|
+
switch (A.once && this.removeListener(s, A.fn, void 0, !0), U) {
|
|
697
697
|
case 1:
|
|
698
|
-
return
|
|
698
|
+
return A.fn.call(A.context), !0;
|
|
699
699
|
case 2:
|
|
700
|
-
return
|
|
700
|
+
return A.fn.call(A.context, d), !0;
|
|
701
701
|
case 3:
|
|
702
|
-
return
|
|
702
|
+
return A.fn.call(A.context, d, m), !0;
|
|
703
703
|
case 4:
|
|
704
|
-
return
|
|
704
|
+
return A.fn.call(A.context, d, m, k), !0;
|
|
705
705
|
case 5:
|
|
706
|
-
return
|
|
706
|
+
return A.fn.call(A.context, d, m, k, I), !0;
|
|
707
707
|
case 6:
|
|
708
|
-
return
|
|
708
|
+
return A.fn.call(A.context, d, m, k, I, E), !0;
|
|
709
709
|
}
|
|
710
|
-
for (z = 1,
|
|
711
|
-
|
|
712
|
-
|
|
710
|
+
for (z = 1, $ = new Array(U - 1); z < U; z++)
|
|
711
|
+
$[z - 1] = arguments[z];
|
|
712
|
+
A.fn.apply(A.context, $);
|
|
713
713
|
} else {
|
|
714
|
-
var Z =
|
|
714
|
+
var Z = A.length, nt;
|
|
715
715
|
for (z = 0; z < Z; z++)
|
|
716
|
-
switch (
|
|
716
|
+
switch (A[z].once && this.removeListener(s, A[z].fn, void 0, !0), U) {
|
|
717
717
|
case 1:
|
|
718
|
-
|
|
718
|
+
A[z].fn.call(A[z].context);
|
|
719
719
|
break;
|
|
720
720
|
case 2:
|
|
721
|
-
|
|
721
|
+
A[z].fn.call(A[z].context, d);
|
|
722
722
|
break;
|
|
723
723
|
case 3:
|
|
724
|
-
|
|
724
|
+
A[z].fn.call(A[z].context, d, m);
|
|
725
725
|
break;
|
|
726
726
|
case 4:
|
|
727
|
-
|
|
727
|
+
A[z].fn.call(A[z].context, d, m, k);
|
|
728
728
|
break;
|
|
729
729
|
default:
|
|
730
|
-
if (
|
|
731
|
-
for (nt = 1,
|
|
732
|
-
|
|
733
|
-
|
|
730
|
+
if (!$)
|
|
731
|
+
for (nt = 1, $ = new Array(U - 1); nt < U; nt++)
|
|
732
|
+
$[nt - 1] = arguments[nt];
|
|
733
|
+
A[z].fn.apply(A[z].context, $);
|
|
734
734
|
}
|
|
735
735
|
}
|
|
736
736
|
return !0;
|
|
737
737
|
}, y.prototype.on = function(s, d, m) {
|
|
738
|
-
return
|
|
738
|
+
return c(this, s, d, m, !1);
|
|
739
739
|
}, y.prototype.once = function(s, d, m) {
|
|
740
|
-
return
|
|
741
|
-
}, y.prototype.removeListener = function(s, d, m,
|
|
740
|
+
return c(this, s, d, m, !0);
|
|
741
|
+
}, y.prototype.removeListener = function(s, d, m, k) {
|
|
742
742
|
var I = t ? t + s : s;
|
|
743
743
|
if (!this._events[I])
|
|
744
744
|
return this;
|
|
745
745
|
if (!d)
|
|
746
746
|
return p(this, I), this;
|
|
747
|
-
var
|
|
748
|
-
if (
|
|
749
|
-
|
|
747
|
+
var E = this._events[I];
|
|
748
|
+
if (E.fn)
|
|
749
|
+
E.fn === d && (!k || E.once) && (!m || E.context === m) && p(this, I);
|
|
750
750
|
else {
|
|
751
|
-
for (var C = 0,
|
|
752
|
-
(
|
|
753
|
-
|
|
751
|
+
for (var C = 0, A = [], U = E.length; C < U; C++)
|
|
752
|
+
(E[C].fn !== d || k && !E[C].once || m && E[C].context !== m) && A.push(E[C]);
|
|
753
|
+
A.length ? this._events[I] = A.length === 1 ? A[0] : A : p(this, I);
|
|
754
754
|
}
|
|
755
755
|
return this;
|
|
756
756
|
}, y.prototype.removeAllListeners = function(s) {
|
|
757
757
|
var d;
|
|
758
758
|
return s ? (d = t ? t + s : s, this._events[d] && p(this, d)) : (this._events = new r(), this._eventsCount = 0), this;
|
|
759
|
-
}, y.prototype.off = y.prototype.removeListener, y.prototype.addListener = y.prototype.on, y.prefixed = t, y.EventEmitter = y,
|
|
759
|
+
}, y.prototype.off = y.prototype.removeListener, y.prototype.addListener = y.prototype.on, y.prefixed = t, y.EventEmitter = y, u.exports = y;
|
|
760
760
|
})(je);
|
|
761
761
|
var Hn = je.exports;
|
|
762
762
|
const qe = /* @__PURE__ */ le(Hn);
|
|
@@ -841,9 +841,9 @@ class Be extends qe {
|
|
|
841
841
|
if (!t)
|
|
842
842
|
return;
|
|
843
843
|
const a = t.id;
|
|
844
|
-
Object.keys(r).forEach((
|
|
845
|
-
if (
|
|
846
|
-
if (
|
|
844
|
+
Object.keys(r).forEach((c) => {
|
|
845
|
+
if (c !== "id")
|
|
846
|
+
if (c === "properties") {
|
|
847
847
|
const p = r.properties || { style: {} };
|
|
848
848
|
t.properties = {
|
|
849
849
|
...t.properties || {},
|
|
@@ -854,10 +854,10 @@ class Be extends qe {
|
|
|
854
854
|
}
|
|
855
855
|
};
|
|
856
856
|
} else
|
|
857
|
-
|
|
857
|
+
c === "geometry" ? t.geometry = {
|
|
858
858
|
...t.geometry,
|
|
859
859
|
...r.geometry
|
|
860
|
-
} : t[
|
|
860
|
+
} : t[c] = r[c];
|
|
861
861
|
}), a === this.selectedId && this.refreshEditor(), this.layer.refresh();
|
|
862
862
|
}
|
|
863
863
|
getById(t) {
|
|
@@ -889,7 +889,7 @@ class Be extends qe {
|
|
|
889
889
|
}
|
|
890
890
|
unhover() {
|
|
891
891
|
const t = this.getById(this.hoveredId);
|
|
892
|
-
return this.emit(
|
|
892
|
+
return this.emit(Pn, t), this.hoveredId = B, this.selectedId === B && this.editor.hide(), this.layer.refresh(), this;
|
|
893
893
|
}
|
|
894
894
|
/**
|
|
895
895
|
* @method remove
|
|
@@ -974,13 +974,13 @@ class Rn extends Be {
|
|
|
974
974
|
r && (this.startDragging(r, t.clientX, t.clientY), this.draggedHandle = Re(t.target));
|
|
975
975
|
});
|
|
976
976
|
v(this, "onMouseUp", () => {
|
|
977
|
-
this.draggedHandle !== -1 && (this.restoreDragging(), this.isDragging = !1, this.draggedHandle = B, this.emit(
|
|
977
|
+
this.draggedHandle !== -1 && (this.restoreDragging(), this.isDragging = !1, this.draggedHandle = B, this.emit(Ot, this.arrow));
|
|
978
978
|
});
|
|
979
979
|
v(this, "onMouseMove", (t) => {
|
|
980
980
|
if (!this.isDragging || this.draggedHandle === B)
|
|
981
981
|
return;
|
|
982
|
-
const r = this.handles[this.draggedHandle], a = this.ogma.view.getZoom(),
|
|
983
|
-
(y || f) && Ne(this.arrow, this.start.x +
|
|
982
|
+
const r = this.handles[this.draggedHandle], a = this.ogma.view.getZoom(), c = (t.clientX - this.startX) / a, p = (t.clientY - this.startY) / a, y = r.id === Te, f = r.id === Ie, s = r.id === _e;
|
|
983
|
+
(y || f) && Ne(this.arrow, this.start.x + c, this.start.y + p), (y || s) && He(this.arrow, this.end.x + c, this.end.y + p), this.emit(
|
|
984
984
|
he,
|
|
985
985
|
this.arrow,
|
|
986
986
|
y ? "line" : f ? "start" : "end"
|
|
@@ -1001,35 +1001,35 @@ class Rn extends Be {
|
|
|
1001
1001
|
startDrawing(t, r, a = Dn(t, r, t, r, Dt)) {
|
|
1002
1002
|
var y;
|
|
1003
1003
|
this.add(a), this.hoveredId = a.id;
|
|
1004
|
-
const
|
|
1005
|
-
this.startDragging(this.getById(a.id),
|
|
1004
|
+
const c = this.ogma.view.graphToScreenCoordinates({ x: t, y: r }), p = ((y = this.ogma.getContainer()) == null ? void 0 : y.getBoundingClientRect()) || { left: 0, top: 0 };
|
|
1005
|
+
this.startDragging(this.getById(a.id), c.x + (p == null ? void 0 : p.left), c.y + p.top), this.draggedHandle = 2;
|
|
1006
1006
|
}
|
|
1007
1007
|
cancelDrawing() {
|
|
1008
|
-
this.isDragging && (this.remove(this.arrow.id), this.emit(
|
|
1008
|
+
this.isDragging && (this.remove(this.arrow.id), this.emit(Ot, this.arrow), this.restoreDragging(), this.isDragging = !1, this.draggedHandle = B);
|
|
1009
1009
|
}
|
|
1010
1010
|
startDragging(t, r, a) {
|
|
1011
1011
|
this.selectedId !== t.id && this.select(this.hoveredId), this.arrow = t, this.startX = r, this.startY = a, this.start = _t(this.arrow), this.end = Rt(this.arrow), this.disableDragging(), this.emit(ce, this.arrow), this.isDragging = !0;
|
|
1012
1012
|
}
|
|
1013
1013
|
detect(t, r = 0) {
|
|
1014
1014
|
return this.elements.find((a) => {
|
|
1015
|
-
const { start:
|
|
1016
|
-
new rt((
|
|
1017
|
-
), f = new rt(p.x, p.y).sub(new rt(
|
|
1015
|
+
const { start: c, end: p } = Ft(a), y = new rt(t.x, t.y).sub(
|
|
1016
|
+
new rt((c.x + p.x) / 2, (c.y + p.y) / 2)
|
|
1017
|
+
), f = new rt(p.x, p.y).sub(new rt(c.x, c.y)), s = f.length(), d = f.normalize(), m = Fe(a);
|
|
1018
1018
|
return Math.abs(d.dot(y)) < s / 2 + r && Math.abs(d.rotateRadians(Math.PI / 2).dot(y)) < m / 2 + r;
|
|
1019
1019
|
});
|
|
1020
1020
|
}
|
|
1021
1021
|
refreshEditor() {
|
|
1022
1022
|
if (+this.selectedId < 0 && +this.hoveredId < 0)
|
|
1023
1023
|
return;
|
|
1024
|
-
const t = this.selectedId !== B ? this.getById(this.selectedId) : this.getById(this.hoveredId), r = Ft(t), a = this.ogma.view.graphToScreenCoordinates(r.start),
|
|
1024
|
+
const t = this.selectedId !== B ? this.getById(this.selectedId) : this.getById(this.hoveredId), r = Ft(t), a = this.ogma.view.graphToScreenCoordinates(r.start), c = this.ogma.view.graphToScreenCoordinates(r.end), p = Math.min(this.ogma.view.getZoom(), this.maxHandleScale), [y, f, s] = Array.prototype.slice.call(
|
|
1025
1025
|
this.editor.element.querySelectorAll(".handle")
|
|
1026
1026
|
);
|
|
1027
|
-
f.style.transform = `translate(${a.x}px, ${a.y}px) translate(-50%, -50%) scale(${p})`, s.style.transform = `translate(${
|
|
1027
|
+
f.style.transform = `translate(${a.x}px, ${a.y}px) translate(-50%, -50%) scale(${p})`, s.style.transform = `translate(${c.x}px, ${c.y}px) translate(-50%, -50%) scale(${p}`;
|
|
1028
1028
|
const d = {
|
|
1029
|
-
x: (
|
|
1030
|
-
y: (
|
|
1031
|
-
}, m = new rt(
|
|
1032
|
-
y.style.width = `${m.length()
|
|
1029
|
+
x: (c.x + a.x) / 2,
|
|
1030
|
+
y: (c.y + a.y) / 2
|
|
1031
|
+
}, m = new rt(c.x - a.x, c.y - a.y), k = m.mul(1 / m.length()), I = Math.atan2(k.y, k.x);
|
|
1032
|
+
y.style.width = `${m.length()}px`, y.style.left = `${d.x}px`, y.style.top = `${d.y}px`, y.style.transform = `translate(-50%, -50%) rotate(${I}rad)`;
|
|
1033
1033
|
}
|
|
1034
1034
|
getDefaultOptions() {
|
|
1035
1035
|
return Ee;
|
|
@@ -1078,31 +1078,31 @@ const bt = {
|
|
|
1078
1078
|
}, De = {
|
|
1079
1079
|
handleSize: 3.5,
|
|
1080
1080
|
placeholder: "Your text..."
|
|
1081
|
-
}, Fn = (
|
|
1081
|
+
}, Fn = (u = 0, l = 0, t = 100, r = 50, a = "", c = { ...bt }) => ({
|
|
1082
1082
|
id: jt(),
|
|
1083
1083
|
type: "Feature",
|
|
1084
1084
|
properties: {
|
|
1085
1085
|
type: "text",
|
|
1086
1086
|
content: a,
|
|
1087
|
-
style: { ...bt, ...
|
|
1087
|
+
style: { ...bt, ...c }
|
|
1088
1088
|
},
|
|
1089
1089
|
geometry: {
|
|
1090
1090
|
type: "Polygon",
|
|
1091
1091
|
coordinates: [
|
|
1092
1092
|
[
|
|
1093
|
-
[
|
|
1094
|
-
[
|
|
1095
|
-
[
|
|
1096
|
-
[
|
|
1097
|
-
[
|
|
1093
|
+
[u, l],
|
|
1094
|
+
[u + t, l],
|
|
1095
|
+
[u + t, l + r],
|
|
1096
|
+
[u, l + r],
|
|
1097
|
+
[u, l]
|
|
1098
1098
|
]
|
|
1099
1099
|
]
|
|
1100
1100
|
}
|
|
1101
1101
|
});
|
|
1102
1102
|
var Ve = { exports: {} };
|
|
1103
|
-
(function(
|
|
1103
|
+
(function(u, l) {
|
|
1104
1104
|
(function(t, r) {
|
|
1105
|
-
|
|
1105
|
+
u.exports = r();
|
|
1106
1106
|
})(In, () => (() => {
|
|
1107
1107
|
var t = { d: (e, n) => {
|
|
1108
1108
|
for (var o in n)
|
|
@@ -1116,14 +1116,14 @@ var Ve = { exports: {} };
|
|
|
1116
1116
|
}, a(e);
|
|
1117
1117
|
}
|
|
1118
1118
|
t.d(r, { default: () => An });
|
|
1119
|
-
var
|
|
1119
|
+
var c = /^((?:[a-z\d-]+\s+)*)([\d.]+(%|em|px)|(?:x+-)?large|(?:x+-)?small|medium)(?:\s*\/\s*(normal|[\d.]+(%|px|em)?))?(\s.+)?$/, p = /\bsmall-caps\b/, y = /\b(?:italic|oblique)\b/, f = /\bbold(?:er)?\b/, s = 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 };
|
|
1120
1120
|
function m(e) {
|
|
1121
1121
|
var n = "", o = this;
|
|
1122
1122
|
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;
|
|
1123
1123
|
}
|
|
1124
|
-
var
|
|
1124
|
+
var k = { id: "", family: "sans-serif", height: 14, size: 12, variant: "", style: "", weight: "", baseline: "", color: null, toString: m, valueOf: m };
|
|
1125
1125
|
function I(e) {
|
|
1126
|
-
var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, o =
|
|
1126
|
+
var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, o = c.exec(e);
|
|
1127
1127
|
n.family = (o[6] || "").trim();
|
|
1128
1128
|
var i = d[o[2]] || parseFloat(o[2]);
|
|
1129
1129
|
o[3] === "%" ? i *= 0.16 : o[3] === "em" ? i *= 16 : o[3] === "pt" && (i *= s), n.size = i;
|
|
@@ -1136,22 +1136,22 @@ var Ve = { exports: {} };
|
|
|
1136
1136
|
}
|
|
1137
1137
|
return n;
|
|
1138
1138
|
}
|
|
1139
|
-
function
|
|
1139
|
+
function E() {
|
|
1140
1140
|
var e, n, o, i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "12px/14px sans-serif", h = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, g = 14, w = 12, x = null, b = null, S = "";
|
|
1141
1141
|
if (i && i.nodeType) {
|
|
1142
|
-
var D = i && (i.ownerDocument && i.ownerDocument.defaultView || i.document && i || i.defaultView),
|
|
1143
|
-
e =
|
|
1142
|
+
var D = i && (i.ownerDocument && i.ownerDocument.defaultView || i.document && i || i.defaultView), O = D.getComputedStyle(i, null);
|
|
1143
|
+
e = O.getPropertyValue("font-family") || "", w = parseFloat(O.getPropertyValue("font-size")), g = O.getPropertyValue("line-height"), x = O.getPropertyValue("font-weight"), b = O.getPropertyValue("font-style"), S = O.getPropertyValue("font-variant") || "";
|
|
1144
1144
|
} else if (typeof i == "string") {
|
|
1145
1145
|
var T = I(i);
|
|
1146
1146
|
e = T.family, w = T.size, g = T.height, S = T.variant, b = T.style, x = T.weight;
|
|
1147
1147
|
} else
|
|
1148
1148
|
a(i) === "object" && (e = i.family, w = i.size, g = i.height, S = i.variant, x = i.weight, b = i.style, n = i.baseline, o = i.color);
|
|
1149
1149
|
h.size && h.size < 3 && (w *= h.size), g = g !== "normal" && g ? parseFloat(g) : w * (7 / 6), h.height && h.height < 3 && (g *= h.height);
|
|
1150
|
-
var
|
|
1151
|
-
return
|
|
1150
|
+
var M = Object.create(k);
|
|
1151
|
+
return M.family = h.family || e || "sans-serif", M.height = g ?? 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;
|
|
1152
1152
|
}
|
|
1153
1153
|
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 };
|
|
1154
|
-
var
|
|
1154
|
+
var A, U = function(e) {
|
|
1155
1155
|
var n = typeof OffscreenCanvas < "u" && new OffscreenCanvas(100, 100) || e && e.createElement("canvas");
|
|
1156
1156
|
if (n && n.getContext) {
|
|
1157
1157
|
var o = n.getContext("2d");
|
|
@@ -1160,20 +1160,20 @@ var Ve = { exports: {} };
|
|
|
1160
1160
|
return o.font = String(h), o.measureText(i).width;
|
|
1161
1161
|
};
|
|
1162
1162
|
}
|
|
1163
|
-
}(typeof document < "u" ? document : null) || (
|
|
1164
|
-
if (!
|
|
1165
|
-
var o =
|
|
1166
|
-
|
|
1163
|
+
}(typeof document < "u" ? document : null) || (A = {}, function(e, n) {
|
|
1164
|
+
if (!A[n]) {
|
|
1165
|
+
var o = E(n);
|
|
1166
|
+
A[n] = o, /\bmonospace\b/.test(o.family) ? o.size *= 0.6 : (o.size *= 0.45, o.weight && (o.size *= 1.18));
|
|
1167
1167
|
}
|
|
1168
|
-
return e.length *
|
|
1169
|
-
}),
|
|
1168
|
+
return e.length * A[n].size;
|
|
1169
|
+
}), $ = {}, z = { trim: !0, collapse: !0 };
|
|
1170
1170
|
function Z(e, n, o) {
|
|
1171
1171
|
var i = Object.assign({}, z, o), h = String(e);
|
|
1172
1172
|
if (!h)
|
|
1173
1173
|
return 0;
|
|
1174
1174
|
if (h in C) {
|
|
1175
1175
|
var g = n.id + "/" + h;
|
|
1176
|
-
return g in
|
|
1176
|
+
return g in $ || ($[g] = U("_".concat(h, "_"), n) - U("__", n)), $[g];
|
|
1177
1177
|
}
|
|
1178
1178
|
return i.trim && i.collapse ? i.trim ? h = h.trim() : i.collapse && (h = h.replace(/\s+/g, " ")) : h = h.replace(/\n/g, " "), U(h, n) + n.size * (e.tracking || 0);
|
|
1179
1179
|
}
|
|
@@ -1208,9 +1208,9 @@ var Ve = { exports: {} };
|
|
|
1208
1208
|
}
|
|
1209
1209
|
}();
|
|
1210
1210
|
return function() {
|
|
1211
|
-
var o, i =
|
|
1211
|
+
var o, i = Mt(e);
|
|
1212
1212
|
if (n) {
|
|
1213
|
-
var h =
|
|
1213
|
+
var h = Mt(this).constructor;
|
|
1214
1214
|
o = Reflect.construct(i, arguments, h);
|
|
1215
1215
|
} else
|
|
1216
1216
|
o = i.apply(this, arguments);
|
|
@@ -1228,10 +1228,10 @@ var Ve = { exports: {} };
|
|
|
1228
1228
|
return o;
|
|
1229
1229
|
}(e);
|
|
1230
1230
|
}
|
|
1231
|
-
function
|
|
1232
|
-
return
|
|
1231
|
+
function Mt(e) {
|
|
1232
|
+
return Mt = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(n) {
|
|
1233
1233
|
return n.__proto__ || Object.getPrototypeOf(n);
|
|
1234
|
-
},
|
|
1234
|
+
}, Mt(e);
|
|
1235
1235
|
}
|
|
1236
1236
|
function zt(e, n) {
|
|
1237
1237
|
if (!(e instanceof n))
|
|
@@ -1297,10 +1297,10 @@ var Ve = { exports: {} };
|
|
|
1297
1297
|
n !== !1 && (e = e.trim());
|
|
1298
1298
|
for (var o, i, h = [], g = e.charAt(0), w = 0, x = 1, b = e.length; x < b; x++) {
|
|
1299
1299
|
o = e.charAt(x), i = e.charAt(x + 1);
|
|
1300
|
-
var S = Ut.test(g), D = Ut.test(o),
|
|
1301
|
-
if ((Ge.test(o) && !de.test(g) || Xe.test(g + i) && !de.test(o)) && (
|
|
1302
|
-
var
|
|
1303
|
-
/\u00AD$/.test(
|
|
1300
|
+
var S = Ut.test(g), D = Ut.test(o), O = D || S, T = void 0;
|
|
1301
|
+
if ((Ge.test(o) && !de.test(g) || Xe.test(g + i) && !de.test(o)) && (O = !0), g !== "-" && g !== "‐" && g !== "–" && g !== "—" || ((T = Ut.test(e.charAt(x - 2))) && !D && (O = !1), !T && Ye.test(o + i) && (O = !0)), O) {
|
|
1302
|
+
var M = e.slice(w, x);
|
|
1303
|
+
/\u00AD$/.test(M) ? (h.push(new H(M.slice(0, -1))), h.push(new ft())) : (h.push(new H(M)), h.push(new St())), w = x;
|
|
1304
1304
|
}
|
|
1305
1305
|
g = o;
|
|
1306
1306
|
}
|
|
@@ -1389,12 +1389,12 @@ var Ve = { exports: {} };
|
|
|
1389
1389
|
function dn(e, n) {
|
|
1390
1390
|
e.sup && (e.baseline = 0.45, e.size = 0.7), e.sub && (e.baseline = -0.3, e.size = 0.7);
|
|
1391
1391
|
var o = n;
|
|
1392
|
-
return (e.style || e.weight || e.baseline || e.color || e.size || e.family) && (o =
|
|
1392
|
+
return (e.style || e.weight || e.baseline || e.color || e.size || e.family) && (o = E(n, e)), o;
|
|
1393
1393
|
}
|
|
1394
1394
|
function me(e, n, o) {
|
|
1395
1395
|
for (var i, h, g = e.width; g + o.width > n && e.length; )
|
|
1396
1396
|
h = (i = e[e.length - 1]).width, i.width > o.width ? (i.value = i.value.slice(0, -1), i.width = Z(i, i.font), g += i.width) : e.pop(), g -= h;
|
|
1397
|
-
e[e.length - 1] instanceof ft && e.pop(), i = e[e.length - 1] || i || {}, o.font =
|
|
1397
|
+
e[e.length - 1] instanceof ft && e.pop(), i = e[e.length - 1] || i || {}, o.font = E(o.font, i.bold, i.italic, ""), o.href = e.length ? i.href : null, o.rel = e.length ? i.rel : null, o.target = e.length ? i.target : null, e.push(o);
|
|
1398
1398
|
}
|
|
1399
1399
|
function mt(e) {
|
|
1400
1400
|
return Math.round(1e6 * e) / 1e6;
|
|
@@ -1430,13 +1430,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1430
1430
|
function gn(e, n) {
|
|
1431
1431
|
var o = [], i = n.font(), h = i.size, g = i.family, w = n.align(), x = n.createElement();
|
|
1432
1432
|
if (e.length) {
|
|
1433
|
-
var b = i.height, S = n.valign(), D = n.height()(),
|
|
1433
|
+
var b = i.height, S = n.valign(), D = n.height()(), O = n.width()(0), T = !isFinite(O) && e.length === 1, M = T ? null : n.x(), R = mt(b / h), K = T ? null : mt(b / (1.15 * h + (b - h) / 2));
|
|
1434
1434
|
if (pn[S] && isFinite(D)) {
|
|
1435
|
-
var
|
|
1436
|
-
K += (D *
|
|
1435
|
+
var P = S === "bottom" ? 1 : 0.5;
|
|
1436
|
+
K += (D * P - b * e.length * P) / h;
|
|
1437
1437
|
}
|
|
1438
1438
|
var L = w === "justify", F = 0;
|
|
1439
|
-
w === "right" ? F =
|
|
1439
|
+
w === "right" ? F = O : w === "center" && (F = O / 2);
|
|
1440
1440
|
for (var N = [], J = "tspan", Y = null, j = "", _ = function() {
|
|
1441
1441
|
if (j) {
|
|
1442
1442
|
var pt = x(J, Y, j);
|
|
@@ -1447,18 +1447,18 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1447
1447
|
var ot = "", ct = "", st = 0, at = e[et];
|
|
1448
1448
|
if (at.length) {
|
|
1449
1449
|
N = [];
|
|
1450
|
-
for (var vt = 0, kt = 0, lt = void 0, X = 0,
|
|
1450
|
+
for (var vt = 0, kt = 0, lt = void 0, X = 0, Pt = at.length; X < Pt; X++) {
|
|
1451
1451
|
var q = at[X], G = q.font;
|
|
1452
1452
|
q.whitespace && vt++, kt += q.width, X && !q.tracking && !st && Xt(G.id, ot) && Xt(q.class, ct) && Xt(lt, q.href) ? j += q.value : (_(), j = q.value, Y = { fontFamily: G.family !== g ? 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, ct = q.class);
|
|
1453
1453
|
}
|
|
1454
1454
|
if (_(), T)
|
|
1455
1455
|
o.push.apply(o, ve(N));
|
|
1456
1456
|
else {
|
|
1457
|
-
var
|
|
1458
|
-
L && at.length > 1 && !Tt && (
|
|
1457
|
+
var $t = null, Tt = et === Q - 1 || at[at.length - 1] instanceof tt;
|
|
1458
|
+
L && at.length > 1 && !Tt && ($t = mt((O - kt) / vt)), o.push(x.apply(void 0, ["tspan", { wordSpacing: $t, x: M(et) + F, dy: mt(et ? R : K) + "em" }].concat(ve(N))));
|
|
1459
1459
|
}
|
|
1460
1460
|
} else
|
|
1461
|
-
o.push(x("tspan", { x:
|
|
1461
|
+
o.push(x("tspan", { x: M(et), dy: mt(et ? R : K) + "em" }, " "));
|
|
1462
1462
|
}
|
|
1463
1463
|
}
|
|
1464
1464
|
return x.apply(void 0, ["text", { fontFamily: g, fontSize: h, textAnchor: fn[w] || "start" }].concat(o));
|
|
@@ -1467,13 +1467,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1467
1467
|
function mn(e, n, o) {
|
|
1468
1468
|
if (e.length) {
|
|
1469
1469
|
o.textBaseline = "middle";
|
|
1470
|
-
var i = n.font(), h = i.height, g = i.size, w = n.valign(), x = n.height()(), b = n.width()(0), S = n.align(), D = S === "justify",
|
|
1470
|
+
var i = n.font(), h = i.height, g = i.size, w = n.valign(), x = n.height()(), b = n.width()(0), S = n.align(), D = S === "justify", O = 0.5 * h, T = yn[w];
|
|
1471
1471
|
if (T && isFinite(x)) {
|
|
1472
|
-
var
|
|
1473
|
-
|
|
1472
|
+
var M = e.length * h;
|
|
1473
|
+
O += x * T - M * T;
|
|
1474
1474
|
}
|
|
1475
1475
|
e.forEach(function(R, K) {
|
|
1476
|
-
var
|
|
1476
|
+
var P = n.x()(K), L = K * h + O, F = 0, N = 0;
|
|
1477
1477
|
R.forEach(function(j) {
|
|
1478
1478
|
j.whitespace && F++, N += j.width;
|
|
1479
1479
|
});
|
|
@@ -1485,12 +1485,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1485
1485
|
return ct.color ? ct.color : st.href ? "#00C" : "#000";
|
|
1486
1486
|
}(_, j);
|
|
1487
1487
|
var Q = 0;
|
|
1488
|
-
if (S === "right" ? Q += b - N : S === "center" ? Q += b / 2 - N / 2 : S === "justify" && (j.whitespace || j instanceof tt) && (
|
|
1488
|
+
if (S === "right" ? Q += b - N : S === "center" ? Q += b / 2 - N / 2 : S === "justify" && (j.whitespace || j instanceof tt) && (P += J), o.fillText(j.value, P + Q, L + et), j.href) {
|
|
1489
1489
|
o.beginPath(), o.strokeStyle = o.fillStyle;
|
|
1490
1490
|
var ot = Math.floor(L + 0.45 * g) + 0.5;
|
|
1491
|
-
o.moveTo(
|
|
1491
|
+
o.moveTo(P + Q, ot), o.lineTo(P + Q + j.width, ot), o.stroke();
|
|
1492
1492
|
}
|
|
1493
|
-
|
|
1493
|
+
P += j.width;
|
|
1494
1494
|
});
|
|
1495
1495
|
});
|
|
1496
1496
|
}
|
|
@@ -1534,7 +1534,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1534
1534
|
}
|
|
1535
1535
|
var h;
|
|
1536
1536
|
}
|
|
1537
|
-
var xn =
|
|
1537
|
+
var xn = E(), Zt = function(e) {
|
|
1538
1538
|
return typeof e == "function" ? e : function() {
|
|
1539
1539
|
return e;
|
|
1540
1540
|
};
|
|
@@ -1558,10 +1558,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1558
1558
|
var h = this, g = this.props.parser(String(i)), w = this.font(), x = function(b, S, D) {
|
|
1559
1559
|
if (!b.length)
|
|
1560
1560
|
return [];
|
|
1561
|
-
var
|
|
1562
|
-
if (!
|
|
1561
|
+
var O = S.height(), T = S.width(), M = S.overflowLine(), R = S.overflowWrap(), K = E(D, !0, !1), P = isFinite(O()) ? Math.floor(O() / D.height) : 1 / 0;
|
|
1562
|
+
if (!O() && !T(0) || !P)
|
|
1563
1563
|
return [];
|
|
1564
|
-
for (var L = 0, F = 0, N = 0, J = [], Y = [], j = !1; L < b.length && F <
|
|
1564
|
+
for (var L = 0, F = 0, N = 0, J = [], Y = [], j = !1; L < b.length && F < P; ) {
|
|
1565
1565
|
var _ = b[L], et = dn(_, D);
|
|
1566
1566
|
if (_.width = Z(_, et), _.font = et, _.line = F, _.whitespace = _.value in C, _.value && (_.value = _.value.replace(un, " ")), !(!N && _.whitespace || j && _.whitespace))
|
|
1567
1567
|
if (_ instanceof tt)
|
|
@@ -1606,20 +1606,20 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1606
1606
|
return Qt + En.width;
|
|
1607
1607
|
}, 0), xt.width > lt && (lt = xt.width), xt;
|
|
1608
1608
|
});
|
|
1609
|
-
if (X.hasLineOverflow = !1,
|
|
1610
|
-
var
|
|
1609
|
+
if (X.hasLineOverflow = !1, M) {
|
|
1610
|
+
var Pt = M === "ellipsis" ? "…" : M;
|
|
1611
1611
|
X.forEach(function(pt, W) {
|
|
1612
1612
|
var gt = T(W);
|
|
1613
1613
|
if (pt.width > gt) {
|
|
1614
|
-
var ut = new H(
|
|
1615
|
-
ut.font = D, ut.width = Z(
|
|
1614
|
+
var ut = new H(Pt);
|
|
1615
|
+
ut.font = D, ut.width = Z(Pt, K), me(pt, gt, ut), X.hasLineOverflow = !0;
|
|
1616
1616
|
}
|
|
1617
1617
|
});
|
|
1618
1618
|
}
|
|
1619
1619
|
var q = S.overflow() === "ellipsis" ? "…" : S.overflow();
|
|
1620
1620
|
if (q && L !== b.length) {
|
|
1621
|
-
var G = T(X.length - 1),
|
|
1622
|
-
Tt.font = D, Tt.width = Z(q, K), me(
|
|
1621
|
+
var G = T(X.length - 1), $t = X[X.length - 1], Tt = new H(q);
|
|
1622
|
+
Tt.font = D, Tt.width = Z(q, K), me($t, G, Tt), X.hasOverflow = !0;
|
|
1623
1623
|
} else
|
|
1624
1624
|
X.hasOverflow = !1;
|
|
1625
1625
|
return X.font = D, X.width = lt, X;
|
|
@@ -1628,7 +1628,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1628
1628
|
return h.render(x, b);
|
|
1629
1629
|
}, x.svg = x.render, x.draw = x.render, x;
|
|
1630
1630
|
} }, { key: "font", value: function(i) {
|
|
1631
|
-
return arguments.length ? (this.props.font =
|
|
1631
|
+
return arguments.length ? (this.props.font = E(i), this) : this.props.font || E(xn);
|
|
1632
1632
|
} }, { key: "overflow", value: function(i) {
|
|
1633
1633
|
return arguments.length ? (this.props.overflow = String(i), this) : this.props.overflow;
|
|
1634
1634
|
} }, { key: "overflowLine", value: function(i) {
|
|
@@ -1795,18 +1795,18 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1795
1795
|
}
|
|
1796
1796
|
it.createElement = Ae, it.textparser = Ct, it.defaultparser = Ct, it.htmlparser = function(e) {
|
|
1797
1797
|
e = String(e || "").trim();
|
|
1798
|
-
for (var n, o, i = { weight: null, style: null, sub: !1, sup: !1, href: null, color: null, rel: null, target: null }, h = [], g = [], w = function(
|
|
1798
|
+
for (var n, o, i = { weight: null, style: null, sub: !1, sup: !1, href: null, color: null, rel: null, target: null }, h = [], g = [], w = function(O) {
|
|
1799
1799
|
for (var T in i)
|
|
1800
|
-
i[T] && (
|
|
1801
|
-
h.push(
|
|
1802
|
-
}, x = function(
|
|
1803
|
-
var T = h.length,
|
|
1804
|
-
if (T &&
|
|
1800
|
+
i[T] && (O[T] = i[T]);
|
|
1801
|
+
h.push(O);
|
|
1802
|
+
}, x = function(O) {
|
|
1803
|
+
var T = h.length, M = tn[O];
|
|
1804
|
+
if (T && M) {
|
|
1805
1805
|
for (var R = T - 1; h[R] && (h[R] instanceof St || Ze.test(h[R].value)); )
|
|
1806
1806
|
R--;
|
|
1807
|
-
for (;
|
|
1808
|
-
R--,
|
|
1809
|
-
for (;
|
|
1807
|
+
for (; M && h[R] && h[R] instanceof tt; )
|
|
1808
|
+
R--, M--;
|
|
1809
|
+
for (; M-- > 0; )
|
|
1810
1810
|
h.push(new tt());
|
|
1811
1811
|
}
|
|
1812
1812
|
}; e.length; ) {
|
|
@@ -1830,25 +1830,25 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1830
1830
|
}, it.latexparser = function(e) {
|
|
1831
1831
|
e = String(e || "").trim();
|
|
1832
1832
|
var n = [0];
|
|
1833
|
-
e = e.replace(/\\verb,(.*?),/, function(
|
|
1833
|
+
e = e.replace(/\\verb,(.*?),/, function(P, L) {
|
|
1834
1834
|
return n.push(L), "\\verb," + (n.length - 1) + ",";
|
|
1835
1835
|
}).replace(/\\\\\n/g, function() {
|
|
1836
1836
|
return "\\\\";
|
|
1837
|
-
}).replace(hn, function(
|
|
1838
|
-
return F.charAt(L - 1) === "\\" ?
|
|
1839
|
-
}).replace(/\n\s+/g, function(
|
|
1840
|
-
return /\n/.test(
|
|
1841
|
-
}).replace(/\\symbol\{(\d+)\}/, function(
|
|
1842
|
-
return N.charAt(F - 1) === "\\" ?
|
|
1843
|
-
}).replace(/(^|[^\\])(\^|_)(\d|[^{]\S*)/g, function(
|
|
1837
|
+
}).replace(hn, function(P, L, F) {
|
|
1838
|
+
return F.charAt(L - 1) === "\\" ? P : cn[P];
|
|
1839
|
+
}).replace(/\n\s+/g, function(P) {
|
|
1840
|
+
return /\n/.test(P.slice(1)) ? "\\par " : P;
|
|
1841
|
+
}).replace(/\\symbol\{(\d+)\}/, function(P, L, F, N) {
|
|
1842
|
+
return N.charAt(F - 1) === "\\" ? P : String.fromCharCode(1 * L);
|
|
1843
|
+
}).replace(/(^|[^\\])(\^|_)(\d|[^{]\S*)/g, function(P, L, F, N) {
|
|
1844
1844
|
return L + F + "{" + N + "}";
|
|
1845
|
-
}).replace(/\\verb,(.*?),/, function(
|
|
1845
|
+
}).replace(/\\verb,(.*?),/, function(P, L) {
|
|
1846
1846
|
return "\\verb,".concat(n[+L], ",");
|
|
1847
1847
|
});
|
|
1848
|
-
for (var o, i = { weight: null, italic: null, variant: null, sub: !1, sup: !1, href: null }, h = [], g = [], w = function(
|
|
1848
|
+
for (var o, i = { weight: null, italic: null, variant: null, sub: !1, sup: !1, href: null }, h = [], g = [], w = function(P) {
|
|
1849
1849
|
for (var L in i)
|
|
1850
|
-
i[L] && (
|
|
1851
|
-
return h.push(
|
|
1850
|
+
i[L] && (P[L] = i[L]);
|
|
1851
|
+
return h.push(P), P;
|
|
1852
1852
|
}, x = function() {
|
|
1853
1853
|
g.push(i), i = Object.create(i);
|
|
1854
1854
|
}, b = function() {
|
|
@@ -1869,26 +1869,26 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1869
1869
|
if (o = /^\\verb,([^,]+),/.exec(e))
|
|
1870
1870
|
w(new H(o[1]));
|
|
1871
1871
|
else if (o = sn.exec(e)) {
|
|
1872
|
-
var D = o[1].slice(1) || o[1],
|
|
1872
|
+
var D = o[1].slice(1) || o[1], O = !!o[2];
|
|
1873
1873
|
if (/^(La)?TeX$/i.test(D)) {
|
|
1874
1874
|
x(), i.family = "serif";
|
|
1875
1875
|
var T = void 0;
|
|
1876
1876
|
D === "LaTeX" && ((T = w(new H("L"))).tracking = -0.25, (T = w(new H("A"))).size = 0.7, T.baseline = 0.3, T.tracking = -0.1), (T = w(new H("T"))).tracking = -0.17, (T = w(new H("E"))).baseline = -0.22, T.tracking = -0.13, T = w(new H("X")), b();
|
|
1877
1877
|
} else if (D in ye)
|
|
1878
|
-
w(new H(ye[D])),
|
|
1878
|
+
w(new H(ye[D])), O && x();
|
|
1879
1879
|
else if (D in V) {
|
|
1880
|
-
var
|
|
1880
|
+
var M = [], R = V[D].length - 1, K = void 0;
|
|
1881
1881
|
if (R) {
|
|
1882
|
-
for (
|
|
1882
|
+
for (O = !1, e = e.slice(o[0].length - 1); R--; ) {
|
|
1883
1883
|
if (!(K = /^\{([^}]+)\}/.exec(e)))
|
|
1884
1884
|
throw new Error(D + " is missing an argument");
|
|
1885
|
-
|
|
1885
|
+
M.push(K[1]), e = e.slice(K[0].length);
|
|
1886
1886
|
}
|
|
1887
|
-
o[0] = /^\{/.exec(e) ? "{" : "",
|
|
1887
|
+
o[0] = /^\{/.exec(e) ? "{" : "", O = !!o[0];
|
|
1888
1888
|
}
|
|
1889
|
-
|
|
1889
|
+
O && x(), V[D].apply(S, [i].concat(M));
|
|
1890
1890
|
} else
|
|
1891
|
-
console.warn("unknown latex command", D), w(new H(o[1])),
|
|
1891
|
+
console.warn("unknown latex command", D), w(new H(o[1])), O && x();
|
|
1892
1892
|
} else
|
|
1893
1893
|
o = [e.slice(0, 1)], w(new H(o[0]));
|
|
1894
1894
|
}
|
|
@@ -1896,35 +1896,35 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1896
1896
|
}
|
|
1897
1897
|
return h;
|
|
1898
1898
|
}, it.measureText = function(e, n, o) {
|
|
1899
|
-
return Z(e,
|
|
1899
|
+
return Z(e, E(n), o);
|
|
1900
1900
|
}, it.Token = H, it.Break = St, it.LineBreak = tt, it.SoftHyphen = ft, it.Rotator = be, be.createElement = Ae;
|
|
1901
1901
|
const An = it;
|
|
1902
1902
|
return r.default;
|
|
1903
1903
|
})());
|
|
1904
1904
|
})(Ve);
|
|
1905
1905
|
var jn = Ve.exports;
|
|
1906
|
-
const
|
|
1907
|
-
function qn(
|
|
1908
|
-
const t = dt(
|
|
1906
|
+
const Oe = /* @__PURE__ */ le(jn);
|
|
1907
|
+
function qn(u, l) {
|
|
1908
|
+
const t = dt(u), { fontSize: r, font: a, padding: c = 0 } = u.properties.style || {};
|
|
1909
1909
|
if (t.width === t.height && t.width === 0)
|
|
1910
1910
|
return;
|
|
1911
|
-
const f = new
|
|
1911
|
+
const f = new Oe({
|
|
1912
1912
|
font: `${r}px/${r}px ${a}`.replace(/(px)+/g, "px"),
|
|
1913
|
-
width: t.width -
|
|
1914
|
-
height: t.height -
|
|
1913
|
+
width: t.width - c * 2,
|
|
1914
|
+
height: t.height - c * 2,
|
|
1915
1915
|
align: "left",
|
|
1916
1916
|
valign: "top",
|
|
1917
1917
|
x: 0,
|
|
1918
1918
|
overflow: "ellipsis",
|
|
1919
1919
|
parser: "html",
|
|
1920
|
-
createElement:
|
|
1920
|
+
createElement: Oe.createElement
|
|
1921
1921
|
}).linebreak(
|
|
1922
|
-
|
|
1922
|
+
u.properties.content.replaceAll(`
|
|
1923
1923
|
`, "<br>")
|
|
1924
1924
|
).render();
|
|
1925
|
-
f.setAttribute("transform", `translate(${
|
|
1925
|
+
f.setAttribute("transform", `translate(${c}, ${c})`), l.appendChild(f);
|
|
1926
1926
|
}
|
|
1927
|
-
const
|
|
1927
|
+
const Me = 20;
|
|
1928
1928
|
class Bn extends Be {
|
|
1929
1929
|
constructor(t, r = {}) {
|
|
1930
1930
|
super(
|
|
@@ -1961,16 +1961,16 @@ class Bn extends Be {
|
|
|
1961
1961
|
});
|
|
1962
1962
|
v(this, "startDrawing", (t, r, a = Fn(t, r, 0, 0, "", bt)) => {
|
|
1963
1963
|
this.add(a);
|
|
1964
|
-
const
|
|
1965
|
-
this.select(a.id), this.startDragging(this.getById(a.id),
|
|
1964
|
+
const c = this.ogma.view.graphToScreenCoordinates({ x: t, y: r });
|
|
1965
|
+
this.select(a.id), this.startDragging(this.getById(a.id), c.x, c.y), this.draggedHandle = 6;
|
|
1966
1966
|
});
|
|
1967
1967
|
v(this, "cancelDrawing", () => {
|
|
1968
|
-
this.isDragging && (this.remove(this.annotation.id), this.annotation = { ...ne }, this.draggedHandle = B, this.isDragging = !1, this.emit(
|
|
1968
|
+
this.isDragging && (this.remove(this.annotation.id), this.annotation = { ...ne }, this.draggedHandle = B, this.isDragging = !1, this.emit(Ot, this.annotation));
|
|
1969
1969
|
});
|
|
1970
1970
|
v(this, "startDragging", (t, r, a) => {
|
|
1971
1971
|
this.annotation = t;
|
|
1972
|
-
const
|
|
1973
|
-
this.rect.x =
|
|
1972
|
+
const c = yt(this.annotation), p = dt(this.annotation);
|
|
1973
|
+
this.rect.x = c.x, this.rect.y = c.y, this.rect.width = p.width, this.rect.height = p.height, this.startX = r, this.startY = a, this.disableDragging(), this.textArea.classList.add("noevents"), this.textArea.setAttribute("disabled", "disabled"), this.emit(ce, this.annotation), this.isDragging = !0;
|
|
1974
1974
|
});
|
|
1975
1975
|
v(this, "onHandleMouseDown", (t) => {
|
|
1976
1976
|
const r = this.getById(this.selectedId) || this.getById(this.hoveredId);
|
|
@@ -1983,21 +1983,21 @@ class Bn extends Be {
|
|
|
1983
1983
|
if (!this.isDragging)
|
|
1984
1984
|
return;
|
|
1985
1985
|
t.stopPropagation(), t.preventDefault();
|
|
1986
|
-
const r = this.handles[this.draggedHandle], a = r.classList.contains("top"),
|
|
1987
|
-
this.rect.width + d * (f ? 0 :
|
|
1988
|
-
|
|
1986
|
+
const r = this.handles[this.draggedHandle], a = r.classList.contains("top"), c = r.classList.contains("left"), p = r.classList.contains("right"), y = r.classList.contains("bottom"), f = r.classList.contains("line-handle"), s = this.ogma.view.getZoom(), d = (t.clientX - this.startX) / s, m = (t.clientY - this.startY) / s, k = c || f ? this.rect.x + d : this.rect.x, I = a || f ? this.rect.y + m : this.rect.y, E = Math.max(
|
|
1987
|
+
this.rect.width + d * (f ? 0 : c ? -1 : p ? 1 : 0),
|
|
1988
|
+
Me
|
|
1989
1989
|
), C = Math.max(
|
|
1990
1990
|
this.rect.height + m * (f ? 0 : a ? -1 : y ? 1 : 0),
|
|
1991
|
-
|
|
1991
|
+
Me
|
|
1992
1992
|
);
|
|
1993
|
-
zn(this.annotation,
|
|
1993
|
+
zn(this.annotation, k, I, E, C), this.emit(he, this.annotation, "text"), this.refreshEditor(), this.layer.refresh();
|
|
1994
1994
|
});
|
|
1995
1995
|
v(this, "onMouseUp", () => {
|
|
1996
|
-
!this.isDragging || this.draggedHandle === B || (this.restoreDragging(), this.textArea.classList.remove("noevents"), this.textArea.removeAttribute("disabled"), this.emit(
|
|
1996
|
+
!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);
|
|
1997
1997
|
});
|
|
1998
1998
|
v(this, "onViewChanged", () => {
|
|
1999
1999
|
const t = Math.max(2, this.handleSize / this.ogma.view.getZoom());
|
|
2000
|
-
document.documentElement.style.setProperty("--handle-
|
|
2000
|
+
document.documentElement.style.setProperty("--handle-scale", `${1 / t}`);
|
|
2001
2001
|
});
|
|
2002
2002
|
v(this, "_onInput", () => {
|
|
2003
2003
|
const t = this.getById(this.selectedId);
|
|
@@ -2008,38 +2008,38 @@ class Bn extends Be {
|
|
|
2008
2008
|
a.addEventListener("input", this._onInput), a.addEventListener("focus", this._onFocus), a.addEventListener("blur", this._onBlur), a.spellcheck = !1, this.handles = Array.prototype.slice.call(
|
|
2009
2009
|
this.editor.element.querySelectorAll(".annotation-text-handle > .handle")
|
|
2010
2010
|
), this.handles.forEach(
|
|
2011
|
-
(
|
|
2011
|
+
(c) => c.addEventListener("mousedown", this.onHandleMouseDown)
|
|
2012
2012
|
), document.addEventListener("mouseup", this.onMouseUp), document.addEventListener("mousemove", this.onMouseMove, !0), t.events.on(["viewChanged", "zoom"], this.onViewChanged);
|
|
2013
2013
|
}
|
|
2014
2014
|
_canRemove() {
|
|
2015
2015
|
return !this.isFocused;
|
|
2016
2016
|
}
|
|
2017
2017
|
detect({ x: t, y: r }, a = 0) {
|
|
2018
|
-
return this.elements.find((
|
|
2019
|
-
const { x: p, y } = yt(
|
|
2018
|
+
return this.elements.find((c) => {
|
|
2019
|
+
const { x: p, y } = yt(c), { width: f, height: s } = dt(c);
|
|
2020
2020
|
return p - a < t && y - a < r && p + f + a > t && y + s + a > r;
|
|
2021
2021
|
});
|
|
2022
2022
|
}
|
|
2023
2023
|
draw(t) {
|
|
2024
2024
|
t.innerHTML = "";
|
|
2025
2025
|
const r = "";
|
|
2026
|
-
this.elements.forEach((
|
|
2027
|
-
const y = `class${p}`, f = dt(
|
|
2026
|
+
this.elements.forEach((c, p) => {
|
|
2027
|
+
const y = `class${p}`, f = dt(c), s = yt(c), d = c.id, {
|
|
2028
2028
|
color: m,
|
|
2029
|
-
fontSize:
|
|
2029
|
+
fontSize: k,
|
|
2030
2030
|
font: I,
|
|
2031
|
-
strokeColor:
|
|
2031
|
+
strokeColor: E,
|
|
2032
2032
|
strokeWidth: C,
|
|
2033
|
-
strokeType:
|
|
2033
|
+
strokeType: A,
|
|
2034
2034
|
background: U
|
|
2035
|
-
} =
|
|
2035
|
+
} = c.properties.style || bt;
|
|
2036
2036
|
if (d === this.selectedId || this.selectedId === -1 && d === this.hoveredId)
|
|
2037
2037
|
return;
|
|
2038
|
-
const
|
|
2039
|
-
|
|
2038
|
+
const $ = It("g");
|
|
2039
|
+
$.setAttribute("fill", `${m}`), $.setAttribute("font-size", `${k}`), $.setAttribute("font-family", `${I}`);
|
|
2040
2040
|
const z = It("rect");
|
|
2041
2041
|
let Z = !1;
|
|
2042
|
-
|
|
2042
|
+
A && A !== "none" && (Z = !0, z.setAttribute("stroke", E || "black"), z.setAttribute("stroke-width", `${C}`), A === "dashed" && z.setAttribute("stroke-dasharray", "5,5")), (U && U.length || Z) && (Z = !0, z.setAttribute("fill", U || "transparent")), Z && (z.setAttribute("width", `${f.width}`), z.setAttribute("height", `${f.height}`)), $.appendChild(z), qn(c, $), $.setAttribute("transform", `translate(${s.x},${s.y})`), $.classList.add(y), $.setAttribute("data-annotation", `${c.id}`), $.setAttribute("data-annotation-type", "text"), t.appendChild($);
|
|
2043
2043
|
});
|
|
2044
2044
|
const a = It("style");
|
|
2045
2045
|
a.innerHTML = r, t.firstChild && t.insertBefore(a, t.firstChild);
|
|
@@ -2050,14 +2050,14 @@ class Bn extends Be {
|
|
|
2050
2050
|
refreshEditor() {
|
|
2051
2051
|
if (+this.selectedId < 0 && +this.hoveredId < 0)
|
|
2052
2052
|
return;
|
|
2053
|
-
const t = this.getById(this.selectedId) || this.getById(this.hoveredId), r = dt(t), a = this.ogma.view.graphToScreenCoordinates(yt(t)),
|
|
2054
|
-
font:
|
|
2055
|
-
fontSize:
|
|
2056
|
-
color:
|
|
2057
|
-
background:
|
|
2058
|
-
padding:
|
|
2059
|
-
} = t.properties.style || bt,
|
|
2060
|
-
this.textArea.value = t.properties.content, this.editor.element.style.transform = `translate(${a.x}px, ${a.y}px)translate(-50%, -50%)translate(${r.width / 2 *
|
|
2053
|
+
const t = this.getById(this.selectedId) || this.getById(this.hoveredId), r = dt(t), a = this.ogma.view.graphToScreenCoordinates(yt(t)), c = this.ogma.view.getZoom(), {
|
|
2054
|
+
font: p,
|
|
2055
|
+
fontSize: y,
|
|
2056
|
+
color: f,
|
|
2057
|
+
background: s,
|
|
2058
|
+
padding: d = 0
|
|
2059
|
+
} = t.properties.style || bt, m = +y * c;
|
|
2060
|
+
this.textArea.value = t.properties.content, this.editor.element.style.transform = `translate(${a.x}px, ${a.y}px)translate(-50%, -50%)translate(${r.width / 2 * c}px, ${r.height / 2 * c}px)`, this.editor.element.style.width = `${r.width * c}px`, this.editor.element.style.height = `${r.height * c}px`, this.textArea.style.font = `${m} ${p}`, this.textArea.style.fontFamily = p || "sans-serif", this.textArea.style.fontSize = `${m}px`, this.textArea.style.padding = `${d}px`, this.textArea.style.lineHeight = `${m}px`, this.textArea.style.boxSizing = "border-box", this.textArea.style.color = f || "black", this.textArea.style.background = s || "transparent", this.textArea.placeholder = this.placeholder, this.layer.refresh();
|
|
2061
2061
|
}
|
|
2062
2062
|
select(t) {
|
|
2063
2063
|
super.select(t), this.textArea.focus();
|
|
@@ -2072,20 +2072,20 @@ class Vn {
|
|
|
2072
2072
|
v(this, "linksByTargetId", {});
|
|
2073
2073
|
v(this, "linksByArrowId", {});
|
|
2074
2074
|
}
|
|
2075
|
-
add(l, t, r, a,
|
|
2075
|
+
add(l, t, r, a, c) {
|
|
2076
2076
|
const p = jt(), y = l.id, f = {
|
|
2077
2077
|
id: p,
|
|
2078
2078
|
arrow: y,
|
|
2079
2079
|
target: r,
|
|
2080
2080
|
targetType: a,
|
|
2081
|
-
connectionPoint:
|
|
2081
|
+
connectionPoint: c,
|
|
2082
2082
|
side: t
|
|
2083
2083
|
};
|
|
2084
2084
|
return this.links[p] = f, this.linksByTargetId[r] || (this.linksByTargetId[r] = []), this.linksByTargetId[r].push(p), this.linksByArrowId[y] || (this.linksByArrowId[y] = {}), this.linksByArrowId[y][t] = p, l.properties.link = l.properties.link || {}, l.properties.link[t] = {
|
|
2085
2085
|
id: r,
|
|
2086
2086
|
side: t,
|
|
2087
2087
|
type: a,
|
|
2088
|
-
magnet:
|
|
2088
|
+
magnet: c
|
|
2089
2089
|
}, this;
|
|
2090
2090
|
}
|
|
2091
2091
|
arrowIsLinked(l, t) {
|
|
@@ -2098,9 +2098,9 @@ class Vn {
|
|
|
2098
2098
|
const r = l.id, a = (y = this.linksByArrowId[r]) == null ? void 0 : y[t];
|
|
2099
2099
|
if ((f = l.properties.link) == null || delete f[t], !a)
|
|
2100
2100
|
return this;
|
|
2101
|
-
const
|
|
2101
|
+
const c = this.links[a];
|
|
2102
2102
|
delete this.links[a];
|
|
2103
|
-
const p = this.linksByTargetId[
|
|
2103
|
+
const p = this.linksByTargetId[c.target];
|
|
2104
2104
|
for (let s = 0; s < p.length; s++)
|
|
2105
2105
|
if (p[s] === a) {
|
|
2106
2106
|
p.splice(s, 1);
|
|
@@ -2118,7 +2118,7 @@ class Vn {
|
|
|
2118
2118
|
return ((t = this.linksByTargetId[l]) == null ? void 0 : t.map((r) => this.links[r])) ?? [];
|
|
2119
2119
|
}
|
|
2120
2120
|
}
|
|
2121
|
-
const ht = (
|
|
2121
|
+
const ht = (u) => u.properties.type === "arrow", wt = (u) => u.properties.type === "text", ze = (u) => u.type === "FeatureCollection", Un = {
|
|
2122
2122
|
magnetColor: "#3e8",
|
|
2123
2123
|
detectMargin: 20,
|
|
2124
2124
|
magnetHandleRadius: 5,
|
|
@@ -2162,23 +2162,23 @@ class Gn extends qe {
|
|
|
2162
2162
|
Ce.forEach((a) => {
|
|
2163
2163
|
if (!this.textToMagnet)
|
|
2164
2164
|
return;
|
|
2165
|
-
const
|
|
2165
|
+
const c = dt(this.textToMagnet), p = yt(this.textToMagnet), { x: y, y: f } = new rt(a.x, a.y).mul({ x: c.width, y: c.height }).add(p);
|
|
2166
2166
|
t.moveTo(y, f), t.arc(y, f, this.options.magnetHandleRadius / r, 0, Math.PI * 2);
|
|
2167
2167
|
}), t.fill(), t.closePath();
|
|
2168
2168
|
});
|
|
2169
2169
|
v(this, "_onFeatureDrag", (t, r) => {
|
|
2170
2170
|
const a = r;
|
|
2171
2171
|
if (ht(t) && a === "line")
|
|
2172
|
-
["start", "end"].find((
|
|
2173
|
-
const p =
|
|
2174
|
-
return this._snapToText(t, a, p) || this._findAndSnapToNode(t,
|
|
2172
|
+
["start", "end"].find((c) => {
|
|
2173
|
+
const p = c === "start" ? _t(t) : Rt(t);
|
|
2174
|
+
return this._snapToText(t, a, p) || this._findAndSnapToNode(t, c, p);
|
|
2175
2175
|
});
|
|
2176
2176
|
else if (ht(t) && a !== "line") {
|
|
2177
|
-
const
|
|
2178
|
-
this._snapToText(t, a,
|
|
2177
|
+
const c = a === "start" ? _t(t) : Rt(t);
|
|
2178
|
+
this._snapToText(t, a, c) || this._findAndSnapToNode(t, a, c);
|
|
2179
2179
|
} else
|
|
2180
|
-
wt(t) && (this.activeLinks.forEach(({ arrow:
|
|
2181
|
-
const f = this.getAnnotation(
|
|
2180
|
+
wt(t) && (this.activeLinks.forEach(({ arrow: c, side: p, connectionPoint: y }) => {
|
|
2181
|
+
const f = this.getAnnotation(c), s = dt(t), d = yt(t), m = new rt(y.x, y.y).mul({ x: s.width, y: s.height }).add(d);
|
|
2182
2182
|
f.geometry.coordinates[p === "start" ? 0 : 1] = [m.x, m.y];
|
|
2183
2183
|
}), this.activeLinks.length && this.arrows.refreshLayer());
|
|
2184
2184
|
this.layer.refresh();
|
|
@@ -2210,8 +2210,8 @@ class Gn extends qe {
|
|
|
2210
2210
|
const y = this.getAnnotation(p.arrow), f = p.side, s = te(
|
|
2211
2211
|
y,
|
|
2212
2212
|
f === "start" ? "end" : "start"
|
|
2213
|
-
), d = t.positions.current[a], m = this.ogma.getNode(r).getAttribute("radius"),
|
|
2214
|
-
Nt(y, f,
|
|
2213
|
+
), d = t.positions.current[a], m = this.ogma.getNode(r).getAttribute("radius"), k = ee(s, d, +m);
|
|
2214
|
+
Nt(y, f, k.x, k.y);
|
|
2215
2215
|
});
|
|
2216
2216
|
}), this.arrows.refreshLayer(), this.texts.refreshLayer();
|
|
2217
2217
|
});
|
|
@@ -2240,42 +2240,42 @@ class Gn extends qe {
|
|
|
2240
2240
|
this.emit(ae, t);
|
|
2241
2241
|
});
|
|
2242
2242
|
this.options = this.setOptions({ ...Un, ...r }), this.ogma = t, this.arrows = new Rn(t, this.options), this.texts = new Bn(t, this.options), this.annotations = [this.arrows, this.texts], this.annotations.forEach((a) => {
|
|
2243
|
-
a.on(ce, this._onFeatureDragStart).on(he, this._onFeatureDrag).on(
|
|
2243
|
+
a.on(ce, this._onFeatureDragStart).on(he, this._onFeatureDrag).on(Ot, this._onFeatureDragEnd).on(ae, this.onUpdate).on(re, this._onUnselect).on(ie, this._onSelect).on(oe, this._onAdded).on(se, this._onRemoved);
|
|
2244
2244
|
}), this.ogma.events.on("nodesDragStart", this._onNodesDragStart).on("nodesDragProgress", this._onNodesDrag).on("layoutEnd", this._onLayoutEnd), this.layer = t.layers.addCanvasLayer(this._render), this.layer.moveToBottom();
|
|
2245
2245
|
}
|
|
2246
2246
|
_moveNodes(t, r, a) {
|
|
2247
|
-
t.forEach((
|
|
2248
|
-
const p = this.links.getTargetLinks(
|
|
2247
|
+
t.forEach((c) => {
|
|
2248
|
+
const p = this.links.getTargetLinks(c.getId()), y = c.getPosition();
|
|
2249
2249
|
p.forEach((f) => {
|
|
2250
2250
|
const s = this.getAnnotation(f.arrow), d = f.side, m = te(
|
|
2251
2251
|
s,
|
|
2252
2252
|
d === "start" ? "end" : "start"
|
|
2253
2253
|
);
|
|
2254
|
-
let
|
|
2255
|
-
const I = +
|
|
2256
|
-
(f.connectionPoint.x - (y.x - r) >
|
|
2254
|
+
let k = y;
|
|
2255
|
+
const I = +c.getAttribute("radius"), E = 1e-6;
|
|
2256
|
+
(f.connectionPoint.x - (y.x - r) > E || f.connectionPoint.y - (y.y - a) > E) && (k = ee(m, y, I)), Nt(s, d, k.x, k.y);
|
|
2257
2257
|
});
|
|
2258
2258
|
}), this.arrows.refreshLayer();
|
|
2259
2259
|
}
|
|
2260
2260
|
_snapToText(t, r, a) {
|
|
2261
|
-
const
|
|
2262
|
-
if (this.links.remove(t, r), !
|
|
2261
|
+
const c = this.texts.detect(a, this.options.detectMargin);
|
|
2262
|
+
if (this.links.remove(t, r), !c)
|
|
2263
2263
|
return !1;
|
|
2264
|
-
this.textToMagnet =
|
|
2265
|
-
const p = this.findMagnetPoint(Ce,
|
|
2266
|
-
return p ? (Nt(t, r, p.point.x, p.point.y), this.links.add(t, r,
|
|
2264
|
+
this.textToMagnet = c;
|
|
2265
|
+
const p = this.findMagnetPoint(Ce, c, a);
|
|
2266
|
+
return p ? (Nt(t, r, p.point.x, p.point.y), this.links.add(t, r, c.id, "text", p.magnet), !0) : !1;
|
|
2267
2267
|
}
|
|
2268
2268
|
_findAndSnapToNode(t, r, a) {
|
|
2269
|
-
const
|
|
2270
|
-
this.links.remove(t, r), p && p.isNode ? (this.hoveredNode = p, this.hoveredNode.setSelected(!0), this._snapToNode(t, r, p,
|
|
2269
|
+
const c = this.ogma.view.graphToScreenCoordinates(a), p = this.ogma.view.getElementAt(c);
|
|
2270
|
+
this.links.remove(t, r), p && p.isNode ? (this.hoveredNode = p, this.hoveredNode.setSelected(!0), this._snapToNode(t, r, p, c)) : (this.hoveredNode && this.hoveredNode.setSelected(!1), this.hoveredNode = null);
|
|
2271
2271
|
}
|
|
2272
|
-
_snapToNode(t, r, a,
|
|
2273
|
-
const p = a.getPositionOnScreen(), y = +a.getAttribute("radius"), f = y * this.ogma.view.getZoom(), s =
|
|
2272
|
+
_snapToNode(t, r, a, c) {
|
|
2273
|
+
const p = a.getPositionOnScreen(), y = +a.getAttribute("radius"), f = y * this.ogma.view.getZoom(), s = c.x - p.x, d = c.y - p.y, m = Math.sqrt(s * s + d * d), k = a.getPosition();
|
|
2274
2274
|
if (m < f + this.options.detectMargin) {
|
|
2275
|
-
let I =
|
|
2275
|
+
let I = k;
|
|
2276
2276
|
if (m > f / 2) {
|
|
2277
|
-
const
|
|
2278
|
-
I = ee(
|
|
2277
|
+
const E = te(t, r === "end" ? "start" : "end");
|
|
2278
|
+
I = ee(E, I, y);
|
|
2279
2279
|
}
|
|
2280
2280
|
Nt(t, r, I.x, I.y), this.links.add(t, r, a.getId(), "node", I);
|
|
2281
2281
|
}
|
|
@@ -2287,18 +2287,18 @@ class Gn extends qe {
|
|
|
2287
2287
|
return this.selected;
|
|
2288
2288
|
}
|
|
2289
2289
|
findMagnetPoint(t, r, a) {
|
|
2290
|
-
let
|
|
2290
|
+
let c;
|
|
2291
2291
|
for (const p of t) {
|
|
2292
2292
|
const y = dt(r), f = yt(r), s = new rt(p.x, p.y).mul({ x: y.width, y: y.height }).add(f), d = s.sub(a).length(), m = this.options.magnetRadius * this.ogma.view.getZoom();
|
|
2293
2293
|
if (d < Math.max(m, this.options.magnetHandleRadius)) {
|
|
2294
|
-
|
|
2294
|
+
c = {
|
|
2295
2295
|
point: s,
|
|
2296
2296
|
magnet: p
|
|
2297
2297
|
};
|
|
2298
2298
|
break;
|
|
2299
2299
|
}
|
|
2300
2300
|
}
|
|
2301
|
-
return
|
|
2301
|
+
return c;
|
|
2302
2302
|
}
|
|
2303
2303
|
/**
|
|
2304
2304
|
* Set the options for the controller
|
|
@@ -2390,7 +2390,7 @@ class Gn extends qe {
|
|
|
2390
2390
|
* Cancel drawing on the current frame
|
|
2391
2391
|
*/
|
|
2392
2392
|
cancelDrawing() {
|
|
2393
|
-
this.annotations.forEach((t) => t.cancelDrawing()), this.emit(
|
|
2393
|
+
this.annotations.forEach((t) => t.cancelDrawing()), this.emit($n);
|
|
2394
2394
|
}
|
|
2395
2395
|
/**
|
|
2396
2396
|
* Update the style of the annotation with the given id
|
|
@@ -2398,7 +2398,7 @@ class Gn extends qe {
|
|
|
2398
2398
|
* @param style The new style
|
|
2399
2399
|
*/
|
|
2400
2400
|
updateStyle(t, r) {
|
|
2401
|
-
const a = this.getAnnotations().features.find((
|
|
2401
|
+
const a = this.getAnnotations().features.find((c) => c.id === t);
|
|
2402
2402
|
return a ? (ht(a) ? this.arrows.updateStyle(a, r) : wt(a) && this.texts.updateStyle(a, r), this.onUpdate(a), this) : this;
|
|
2403
2403
|
}
|
|
2404
2404
|
/**
|
|
@@ -2448,7 +2448,7 @@ export {
|
|
|
2448
2448
|
_t as getArrowStart,
|
|
2449
2449
|
ee as getAttachmentPointOnNode,
|
|
2450
2450
|
Re as getHandleId,
|
|
2451
|
-
|
|
2451
|
+
$e as getTextBbox,
|
|
2452
2452
|
yt as getTextPosition,
|
|
2453
2453
|
dt as getTextSize,
|
|
2454
2454
|
ze as isAnnotationCollection,
|
|
@@ -2458,6 +2458,6 @@ export {
|
|
|
2458
2458
|
Nt as setArrowEndPoint,
|
|
2459
2459
|
Ne as setArrowStart,
|
|
2460
2460
|
zn as setTextBbox,
|
|
2461
|
-
|
|
2461
|
+
Mn as updateTextBbox
|
|
2462
2462
|
};
|
|
2463
2463
|
//# sourceMappingURL=index.mjs.map
|