@linkurious/ogma-annotations 1.1.7 → 1.1.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 +169 -165
- package/dist/index.umd.js +6 -6
- package/dist/style.css +1 -0
- package/package.json +2 -1
package/dist/index.mjs
CHANGED
|
@@ -12,7 +12,7 @@ var $e = { exports: {} };
|
|
|
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 h(s) {
|
|
16
16
|
return Math.round(s * 1e8) / 1e8;
|
|
17
17
|
}
|
|
18
18
|
function d(s, f) {
|
|
@@ -192,7 +192,7 @@ var $e = { exports: {} };
|
|
|
192
192
|
// @return self.
|
|
193
193
|
rotateRadiansSelf: function(s) {
|
|
194
194
|
var f = Math.cos(s), m = Math.sin(s), A = this.x * f - this.y * m, T = this.x * m + this.y * f;
|
|
195
|
-
return this.x =
|
|
195
|
+
return this.x = h(A), this.y = h(T), this;
|
|
196
196
|
},
|
|
197
197
|
// [API]
|
|
198
198
|
// [chainable]
|
|
@@ -609,7 +609,7 @@ function Bt(u) {
|
|
|
609
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
611
|
}, []) : u.type == "MultiPolygon" ? l = u.coordinates.reduce(
|
|
612
|
-
(t, r) => t.concat(r.reduce((a,
|
|
612
|
+
(t, r) => t.concat(r.reduce((a, h) => a.concat(h), [])),
|
|
613
613
|
[]
|
|
614
614
|
) : u.type == "Feature" ? l = Bt(u.geometry) : u.type == "GeometryCollection" ? l = u.geometries.reduce(
|
|
615
615
|
(t, r) => t.concat(Bt(r)),
|
|
@@ -628,18 +628,18 @@ function Ft(u, l, t) {
|
|
|
628
628
|
}
|
|
629
629
|
function je(u, l = 5, t = 30) {
|
|
630
630
|
var s;
|
|
631
|
-
const { start: r, end: a } = Vt(u),
|
|
631
|
+
const { start: r, end: a } = Vt(u), h = new U(r.x, r.y), g = new U(a.x, a.y).sub(h), p = 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 * p, g.length() * 0.1, l));
|
|
633
633
|
}
|
|
634
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 h = u.clone().add(a.rotateRadians(Math.PI / 8)), d = u.clone().add(a.rotateRadians(-Math.PI / 8)), g = `${u.x} ${u.y}`;
|
|
639
|
+
return `M ${h.x} ${h.y} L ${g} ${d.x} ${d.y} ${t === "arrow" ? "" : `${h.x} ${h.y}`}`;
|
|
640
640
|
}
|
|
641
641
|
function Ln(u, l, t, r, a) {
|
|
642
|
-
const { start:
|
|
642
|
+
const { start: h, end: d } = Vt(u), { tail: g, head: p, strokeColor: s, strokeWidth: f } = u.properties.style || t, m = new U(h.x, h.y), A = new U(d.x, d.y), T = A.clone().sub(m), S = je(u, r, a), C = Mt("path");
|
|
643
643
|
C.setAttribute("data-annotation", `${u.id}`), C.setAttribute("data-annotation-type", "arrow");
|
|
644
644
|
const k = p === "arrow-plain" || g === "arrow";
|
|
645
645
|
C.setAttribute("stroke", s || "none"), C.setAttribute("stroke-width", `${f}`), C.setAttribute("fill", k ? s || "" : "none"), C.setAttribute("stroke-linecap", "round"), C.setAttribute("stroke-linejoin", "round");
|
|
@@ -656,7 +656,7 @@ var Fe = { exports: {} };
|
|
|
656
656
|
function a(p, s, f) {
|
|
657
657
|
this.fn = p, this.context = s, this.once = f || !1;
|
|
658
658
|
}
|
|
659
|
-
function
|
|
659
|
+
function h(p, s, f, m, A) {
|
|
660
660
|
if (typeof f != "function")
|
|
661
661
|
throw new TypeError("The listener must be a function");
|
|
662
662
|
var T = new a(f, m || p, A), S = t ? t + s : s;
|
|
@@ -735,9 +735,9 @@ var Fe = { exports: {} };
|
|
|
735
735
|
}
|
|
736
736
|
return !0;
|
|
737
737
|
}, g.prototype.on = function(s, f, m) {
|
|
738
|
-
return
|
|
738
|
+
return h(this, s, f, m, !1);
|
|
739
739
|
}, g.prototype.once = function(s, f, m) {
|
|
740
|
-
return
|
|
740
|
+
return h(this, s, f, m, !0);
|
|
741
741
|
}, g.prototype.removeListener = function(s, f, m, A) {
|
|
742
742
|
var T = t ? t + s : s;
|
|
743
743
|
if (!this._events[T])
|
|
@@ -842,9 +842,9 @@ class qe extends Be {
|
|
|
842
842
|
if (!t)
|
|
843
843
|
return;
|
|
844
844
|
const a = t.id;
|
|
845
|
-
Object.keys(r).forEach((
|
|
846
|
-
if (
|
|
847
|
-
if (
|
|
845
|
+
Object.keys(r).forEach((h) => {
|
|
846
|
+
if (h !== "id")
|
|
847
|
+
if (h === "properties") {
|
|
848
848
|
const d = r.properties || { style: {} };
|
|
849
849
|
t.properties = {
|
|
850
850
|
...t.properties || {},
|
|
@@ -855,17 +855,18 @@ class qe extends Be {
|
|
|
855
855
|
}
|
|
856
856
|
};
|
|
857
857
|
} else
|
|
858
|
-
|
|
858
|
+
h === "geometry" ? t.geometry = {
|
|
859
859
|
...t.geometry,
|
|
860
860
|
...r.geometry
|
|
861
|
-
} : t[
|
|
861
|
+
} : t[h] = r[h];
|
|
862
862
|
}), a === this.selectedId && this.refreshEditor(), this.layer.refresh();
|
|
863
863
|
}
|
|
864
864
|
getById(t) {
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
865
|
+
const r = Number(t);
|
|
866
|
+
for (let a = 0; a < this.elements.length; a++) {
|
|
867
|
+
const h = this.elements[a];
|
|
868
|
+
if (!(h.id !== t && h.id !== r))
|
|
869
|
+
return h;
|
|
869
870
|
}
|
|
870
871
|
}
|
|
871
872
|
/**
|
|
@@ -982,8 +983,8 @@ class Hn extends qe {
|
|
|
982
983
|
v(this, "onMouseMove", (t) => {
|
|
983
984
|
if (!this.isDragging || this.draggedHandle === q)
|
|
984
985
|
return;
|
|
985
|
-
const r = this.handles[this.draggedHandle], a = this.ogma.view.getAngle(), { x:
|
|
986
|
-
(g || p) && Ne(this.arrow, this.start.x +
|
|
986
|
+
const r = this.handles[this.draggedHandle], a = this.ogma.view.getAngle(), { x: h, y: d } = new U(t.clientX - this.startX, t.clientY - this.startY).divScalar(this.ogma.view.getZoom()).rotateRadians(a), g = r.id === Te, p = r.id === Ie, s = r.id === _e;
|
|
987
|
+
(g || p) && Ne(this.arrow, this.start.x + h, this.start.y + d), (g || s) && Re(this.arrow, this.end.x + h, this.end.y + d), this.emit(
|
|
987
988
|
Ut,
|
|
988
989
|
this.arrow,
|
|
989
990
|
g ? "line" : p ? "start" : "end"
|
|
@@ -1004,8 +1005,8 @@ class Hn extends qe {
|
|
|
1004
1005
|
startDrawing(t, r, a = Dn(t, r, t, r, Lt)) {
|
|
1005
1006
|
var g;
|
|
1006
1007
|
this.add(a), this.hoveredId = a.id;
|
|
1007
|
-
const
|
|
1008
|
-
this.startDragging(this.getById(a.id),
|
|
1008
|
+
const h = this.ogma.view.graphToScreenCoordinates({ x: t, y: r }), d = ((g = this.ogma.getContainer()) == null ? void 0 : g.getBoundingClientRect()) || { left: 0, top: 0 };
|
|
1009
|
+
this.startDragging(this.getById(a.id), h.x + (d == null ? void 0 : d.left), h.y + d.top), this.draggedHandle = 2;
|
|
1009
1010
|
}
|
|
1010
1011
|
cancelDrawing() {
|
|
1011
1012
|
this.isDragging && (this.remove(this.arrow.id), this.emit(St, this.arrow), this.restoreDragging(), this.isDragging = !1, this.draggedHandle = q);
|
|
@@ -1015,23 +1016,23 @@ class Hn extends qe {
|
|
|
1015
1016
|
}
|
|
1016
1017
|
detect(t, r = 0) {
|
|
1017
1018
|
return this.elements.find((a) => {
|
|
1018
|
-
const { start:
|
|
1019
|
-
new U((
|
|
1020
|
-
), p = new U(d.x, d.y).sub(new U(
|
|
1019
|
+
const { start: h, end: d } = Vt(a), g = new U(t.x, t.y).sub(
|
|
1020
|
+
new U((h.x + d.x) / 2, (h.y + d.y) / 2)
|
|
1021
|
+
), p = new U(d.x, d.y).sub(new U(h.x, h.y)), s = p.length(), f = p.normalize(), m = je(a);
|
|
1021
1022
|
return Math.abs(f.dot(g)) < s / 2 + r && Math.abs(f.rotateRadians(Math.PI / 2).dot(g)) < m / 2 + r;
|
|
1022
1023
|
});
|
|
1023
1024
|
}
|
|
1024
1025
|
refreshEditor() {
|
|
1025
1026
|
if (+this.selectedId < 0 && +this.hoveredId < 0)
|
|
1026
1027
|
return;
|
|
1027
|
-
const t = this.selectedId !== q ? this.getById(this.selectedId) : this.getById(this.hoveredId), r = Vt(t), a = this.ogma.view.graphToScreenCoordinates(r.start),
|
|
1028
|
+
const t = this.selectedId !== q ? this.getById(this.selectedId) : this.getById(this.hoveredId), r = Vt(t), a = this.ogma.view.graphToScreenCoordinates(r.start), h = this.ogma.view.graphToScreenCoordinates(r.end), d = Math.min(this.ogma.view.getZoom(), this.maxHandleScale), [g, p, s] = Array.prototype.slice.call(
|
|
1028
1029
|
this.editor.element.querySelectorAll(".handle")
|
|
1029
1030
|
);
|
|
1030
|
-
p.style.transform = `translate(${a.x}px, ${a.y}px) translate(-50%, -50%) scale(${d})`, s.style.transform = `translate(${
|
|
1031
|
+
p.style.transform = `translate(${a.x}px, ${a.y}px) translate(-50%, -50%) scale(${d})`, s.style.transform = `translate(${h.x}px, ${h.y}px) translate(-50%, -50%) scale(${d}`;
|
|
1031
1032
|
const f = {
|
|
1032
|
-
x: (
|
|
1033
|
-
y: (
|
|
1034
|
-
}, m = new U(
|
|
1033
|
+
x: (h.x + a.x) / 2,
|
|
1034
|
+
y: (h.y + a.y) / 2
|
|
1035
|
+
}, m = new U(h.x - a.x, h.y - a.y), A = m.mul(1 / m.length()), T = Math.atan2(A.y, A.x);
|
|
1035
1036
|
g.style.width = `${m.length()}px`, g.style.left = `${f.x}px`, g.style.top = `${f.y}px`, g.style.transform = `translate(-50%, -50%) rotate(${T}rad)`;
|
|
1036
1037
|
}
|
|
1037
1038
|
getDefaultOptions() {
|
|
@@ -1041,7 +1042,7 @@ class Hn extends qe {
|
|
|
1041
1042
|
t.innerHTML = "";
|
|
1042
1043
|
const r = Mt("g"), a = this.ogma.view.getAngle();
|
|
1043
1044
|
r.setAttribute("transform", `rotate(${-a * (180 / Math.PI)})`), this.elements.forEach(
|
|
1044
|
-
(
|
|
1045
|
+
(h) => Ln(h, r, Lt, this.minArrowHeight, this.maxArrowHeight)
|
|
1045
1046
|
), t.appendChild(r);
|
|
1046
1047
|
}
|
|
1047
1048
|
refreshDrawing() {
|
|
@@ -1085,13 +1086,13 @@ const At = {
|
|
|
1085
1086
|
}, De = {
|
|
1086
1087
|
handleSize: 3.5,
|
|
1087
1088
|
placeholder: "Your text..."
|
|
1088
|
-
}, jn = (u = 0, l = 0, t = 100, r = 50, a = "",
|
|
1089
|
+
}, jn = (u = 0, l = 0, t = 100, r = 50, a = "", h = { ...At }) => ({
|
|
1089
1090
|
id: Xt(),
|
|
1090
1091
|
type: "Feature",
|
|
1091
1092
|
properties: {
|
|
1092
1093
|
type: "text",
|
|
1093
1094
|
content: a,
|
|
1094
|
-
style: { ...At, ...
|
|
1095
|
+
style: { ...At, ...h }
|
|
1095
1096
|
},
|
|
1096
1097
|
geometry: {
|
|
1097
1098
|
type: "Polygon",
|
|
@@ -1123,19 +1124,19 @@ var Ve = { exports: {} };
|
|
|
1123
1124
|
}, a(e);
|
|
1124
1125
|
}
|
|
1125
1126
|
t.d(r, { default: () => Sn });
|
|
1126
|
-
var
|
|
1127
|
+
var h = /^((?:[a-z\d-]+\s+)*)([\d.]+(%|em|px)|(?:x+-)?large|(?:x+-)?small|medium)(?:\s*\/\s*(normal|[\d.]+(%|px|em)?))?(\s.+)?$/, d = /\bsmall-caps\b/, g = /\b(?:italic|oblique)\b/, p = /\bbold(?:er)?\b/, s = 13.3333333, f = { "xx-small": 9, "x-small": 10, smaller: 13.3333, small: 13, medium: 16, large: 18, larger: 19.2, "x-large": 24, "xx-large": 32 };
|
|
1127
1128
|
function m(e) {
|
|
1128
1129
|
var n = "", o = this;
|
|
1129
1130
|
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;
|
|
1130
1131
|
}
|
|
1131
1132
|
var A = { id: "", family: "sans-serif", height: 14, size: 12, variant: "", style: "", weight: "", baseline: "", color: null, toString: m, valueOf: m };
|
|
1132
1133
|
function T(e) {
|
|
1133
|
-
var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, o =
|
|
1134
|
+
var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, o = h.exec(e);
|
|
1134
1135
|
n.family = (o[6] || "").trim();
|
|
1135
1136
|
var i = f[o[2]] || parseFloat(o[2]);
|
|
1136
1137
|
o[3] === "%" ? i *= 0.16 : o[3] === "em" ? i *= 16 : o[3] === "pt" && (i *= s), n.size = i;
|
|
1137
|
-
var
|
|
1138
|
-
if (
|
|
1138
|
+
var c = parseFloat(o[4]);
|
|
1139
|
+
if (c !== "normal" && c !== "inherit" && c ? o[5] && o[5] !== "em" ? o[5] === "pt" ? n.height = c * s : o[5] === "%" ? n.height = 0.01 * i : n.height = c : n.height = c * i : n.height = Math.round(i * (7 / 6)), d.test(o[1]) && (n.variant = "small-caps"), g.test(o[1]) && (n.style = "italic"), p.test(o[1]))
|
|
1139
1140
|
n.weight = "bold";
|
|
1140
1141
|
else {
|
|
1141
1142
|
var y = parseInt(/\b(\d+)\b/.exec(o[1]), 10);
|
|
@@ -1144,7 +1145,7 @@ var Ve = { exports: {} };
|
|
|
1144
1145
|
return n;
|
|
1145
1146
|
}
|
|
1146
1147
|
function S() {
|
|
1147
|
-
var e, n, o, i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "12px/14px sans-serif",
|
|
1148
|
+
var e, n, o, i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "12px/14px sans-serif", c = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, y = 14, w = 12, x = null, b = null, E = "";
|
|
1148
1149
|
if (i && i.nodeType) {
|
|
1149
1150
|
var O = i && (i.ownerDocument && i.ownerDocument.defaultView || i.document && i || i.defaultView), M = O.getComputedStyle(i, null);
|
|
1150
1151
|
e = M.getPropertyValue("font-family") || "", w = parseFloat(M.getPropertyValue("font-size")), y = M.getPropertyValue("line-height"), x = M.getPropertyValue("font-weight"), b = M.getPropertyValue("font-style"), E = M.getPropertyValue("font-variant") || "";
|
|
@@ -1153,9 +1154,9 @@ var Ve = { exports: {} };
|
|
|
1153
1154
|
e = I.family, w = I.size, y = I.height, E = I.variant, b = I.style, x = I.weight;
|
|
1154
1155
|
} else
|
|
1155
1156
|
a(i) === "object" && (e = i.family, w = i.size, y = i.height, E = i.variant, x = i.weight, b = i.style, n = i.baseline, o = i.color);
|
|
1156
|
-
|
|
1157
|
+
c.size && c.size < 3 && (w *= c.size), y = y !== "normal" && y ? parseFloat(y) : w * (7 / 6), c.height && c.height < 3 && (y *= c.height);
|
|
1157
1158
|
var z = Object.create(A);
|
|
1158
|
-
return z.family =
|
|
1159
|
+
return z.family = c.family || e || "sans-serif", z.height = y ?? 14, z.size = w ?? 12, z.variant = c.variant || E || "", z.style = c.style || b || "", z.weight = c.weight || x || "", z.baseline = n || 0, c.baseline != null && (z.baseline = c.baseline), z.color = c.color || o || "", z.id = m.call(z, !0), z;
|
|
1159
1160
|
}
|
|
1160
1161
|
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 };
|
|
1161
1162
|
var k, F = function(e) {
|
|
@@ -1163,8 +1164,8 @@ var Ve = { exports: {} };
|
|
|
1163
1164
|
if (n && n.getContext) {
|
|
1164
1165
|
var o = n.getContext("2d");
|
|
1165
1166
|
if (o && typeof o.measureText == "function")
|
|
1166
|
-
return function(i,
|
|
1167
|
-
return o.font = String(
|
|
1167
|
+
return function(i, c) {
|
|
1168
|
+
return o.font = String(c), o.measureText(i).width;
|
|
1168
1169
|
};
|
|
1169
1170
|
}
|
|
1170
1171
|
}(typeof document < "u" ? document : null) || (k = {}, function(e, n) {
|
|
@@ -1175,14 +1176,14 @@ var Ve = { exports: {} };
|
|
|
1175
1176
|
return e.length * k[n].size;
|
|
1176
1177
|
}), X = {}, D = { trim: !0, collapse: !0 };
|
|
1177
1178
|
function Y(e, n, o) {
|
|
1178
|
-
var i = Object.assign({}, D, o),
|
|
1179
|
-
if (!
|
|
1179
|
+
var i = Object.assign({}, D, o), c = String(e);
|
|
1180
|
+
if (!c)
|
|
1180
1181
|
return 0;
|
|
1181
|
-
if (
|
|
1182
|
-
var y = n.id + "/" +
|
|
1183
|
-
return y in X || (X[y] = F("_".concat(
|
|
1182
|
+
if (c in C) {
|
|
1183
|
+
var y = n.id + "/" + c;
|
|
1184
|
+
return y in X || (X[y] = F("_".concat(c, "_"), n) - F("__", n)), X[y];
|
|
1184
1185
|
}
|
|
1185
|
-
return i.trim && i.collapse ? i.trim ?
|
|
1186
|
+
return i.trim && i.collapse ? i.trim ? c = c.trim() : i.collapse && (c = c.replace(/\s+/g, " ")) : c = c.replace(/\n/g, " "), F(c, n) + n.size * (e.tracking || 0);
|
|
1186
1187
|
}
|
|
1187
1188
|
function G(e) {
|
|
1188
1189
|
return G = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
|
|
@@ -1217,8 +1218,8 @@ var Ve = { exports: {} };
|
|
|
1217
1218
|
return function() {
|
|
1218
1219
|
var o, i = Ct(e);
|
|
1219
1220
|
if (n) {
|
|
1220
|
-
var
|
|
1221
|
-
o = Reflect.construct(i, arguments,
|
|
1221
|
+
var c = Ct(this).constructor;
|
|
1222
|
+
o = Reflect.construct(i, arguments, c);
|
|
1222
1223
|
} else
|
|
1223
1224
|
o = i.apply(this, arguments);
|
|
1224
1225
|
return Ue(this, o);
|
|
@@ -1247,7 +1248,7 @@ var Ve = { exports: {} };
|
|
|
1247
1248
|
function ue(e, n) {
|
|
1248
1249
|
for (var o = 0; o < n.length; o++) {
|
|
1249
1250
|
var i = n[o];
|
|
1250
|
-
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, (
|
|
1251
|
+
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, (c = function(y, w) {
|
|
1251
1252
|
if (G(y) !== "object" || y === null)
|
|
1252
1253
|
return y;
|
|
1253
1254
|
var x = y[Symbol.toPrimitive];
|
|
@@ -1258,9 +1259,9 @@ var Ve = { exports: {} };
|
|
|
1258
1259
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1259
1260
|
}
|
|
1260
1261
|
return String(y);
|
|
1261
|
-
}(i.key, "string"), G(
|
|
1262
|
+
}(i.key, "string"), G(c) === "symbol" ? c : String(c)), i);
|
|
1262
1263
|
}
|
|
1263
|
-
var
|
|
1264
|
+
var c;
|
|
1264
1265
|
}
|
|
1265
1266
|
function Pt(e, n, o) {
|
|
1266
1267
|
return n && ue(e.prototype, n), o && ue(e, o), Object.defineProperty(e, "prototype", { writable: !1 }), e;
|
|
@@ -1302,16 +1303,16 @@ var Ve = { exports: {} };
|
|
|
1302
1303
|
}(N), Zt = /^[\n\r\t\x20\xA0\u2000-\u200B\u205F\u3000]/, Ye = /^[^\n\r\t\u0020\u2000-\u200B\u205F\u3000]{2,}/, de = /^[\xA0\u2011\u202F\u2060\uFEFF]/, Xe = /^(?:[;\xAD%?…]|,(?!\d))/, Ge = /^[´±°¢£¤$¥\u2212]/;
|
|
1303
1304
|
function Nt(e, n) {
|
|
1304
1305
|
n !== !1 && (e = e.trim());
|
|
1305
|
-
for (var o, i,
|
|
1306
|
+
for (var o, i, c = [], y = e.charAt(0), w = 0, x = 1, b = e.length; x < b; x++) {
|
|
1306
1307
|
o = e.charAt(x), i = e.charAt(x + 1);
|
|
1307
1308
|
var E = Zt.test(y), O = Zt.test(o), M = O || E, I = void 0;
|
|
1308
1309
|
if ((Ge.test(o) && !de.test(y) || Xe.test(y + i) && !de.test(o)) && (M = !0), y !== "-" && y !== "‐" && y !== "–" && y !== "—" || ((I = Zt.test(e.charAt(x - 2))) && !O && (M = !1), !I && Ye.test(o + i) && (M = !0)), M) {
|
|
1309
1310
|
var z = e.slice(w, x);
|
|
1310
|
-
/\u00AD$/.test(z) ? (
|
|
1311
|
+
/\u00AD$/.test(z) ? (c.push(new N(z.slice(0, -1))), c.push(new pt())) : (c.push(new N(z)), c.push(new Tt())), w = x;
|
|
1311
1312
|
}
|
|
1312
1313
|
y = o;
|
|
1313
1314
|
}
|
|
1314
|
-
return
|
|
1315
|
+
return c.push(new N(e.slice(w))), c;
|
|
1315
1316
|
}
|
|
1316
1317
|
const fe = { nbsp: " ", iexcl: "¡", cent: "¢", pound: "£", curren: "¤", yen: "¥", brvbar: "¦", sect: "§", uml: "¨", copy: "©", ordf: "ª", laquo: "«", not: "¬", shy: "", reg: "®", macr: "¯", deg: "°", plusmn: "±", sup2: "²", sup3: "³", acute: "´", micro: "µ", para: "¶", middot: "·", cedil: "¸", sup1: "¹", ordm: "º", raquo: "»", frac14: "¼", frac12: "½", frac34: "¾", iquest: "¿", Agrave: "À", Aacute: "Á", Acirc: "Â", Atilde: "Ã", Auml: "Ä", Aring: "Å", AElig: "Æ", Ccedil: "Ç", Egrave: "È", Eacute: "É", Ecirc: "Ê", Euml: "Ë", Igrave: "Ì", Iacute: "Í", Icirc: "Î", Iuml: "Ï", ETH: "Ð", Ntilde: "Ñ", Ograve: "Ò", Oacute: "Ó", Ocirc: "Ô", Otilde: "Õ", Ouml: "Ö", times: "×", Oslash: "Ø", Ugrave: "Ù", Uacute: "Ú", Ucirc: "Û", Uuml: "Ü", Yacute: "Ý", THORN: "Þ", szlig: "ß", agrave: "à", aacute: "á", acirc: "â", atilde: "ã", auml: "ä", aring: "å", aelig: "æ", ccedil: "ç", egrave: "è", eacute: "é", ecirc: "ê", euml: "ë", igrave: "ì", iacute: "í", icirc: "î", iuml: "ï", eth: "ð", ntilde: "ñ", ograve: "ò", oacute: "ó", ocirc: "ô", otilde: "õ", ouml: "ö", divide: "÷", oslash: "ø", ugrave: "ù", uacute: "ú", ucirc: "û", uuml: "ü", yacute: "ý", thorn: "þ", yuml: "ÿ", fnof: "ƒ", Alpha: "Α", Beta: "Β", Gamma: "Γ", Delta: "Δ", Epsilon: "Ε", Zeta: "Ζ", Eta: "Η", Theta: "Θ", Iota: "Ι", Kappa: "Κ", Lambda: "Λ", Mu: "Μ", Nu: "Ν", Xi: "Ξ", Omicron: "Ο", Pi: "Π", Rho: "Ρ", Sigma: "Σ", Tau: "Τ", Upsilon: "Υ", Phi: "Φ", Chi: "Χ", Psi: "Ψ", Omega: "Ω", alpha: "α", beta: "β", gamma: "γ", delta: "δ", epsilon: "ε", zeta: "ζ", eta: "η", theta: "θ", iota: "ι", kappa: "κ", lambda: "λ", mu: "μ", nu: "ν", xi: "ξ", omicron: "ο", pi: "π", rho: "ρ", sigmaf: "ς", sigma: "σ", tau: "τ", upsilon: "υ", phi: "φ", chi: "χ", psi: "ψ", omega: "ω", thetasym: "ϑ", upsih: "ϒ", piv: "ϖ", bull: "•", hellip: "…", prime: "′", Prime: "″", oline: "‾", frasl: "⁄", weierp: "℘", image: "ℑ", real: "ℜ", trade: "™", alefsym: "ℵ", larr: "←", uarr: "↑", rarr: "→", darr: "↓", harr: "↔", crarr: "↵", lArr: "⇐", uArr: "⇑", rArr: "⇒", dArr: "⇓", hArr: "⇔", forall: "∀", part: "∂", exist: "∃", empty: "∅", nabla: "∇", isin: "∈", notin: "∉", ni: "∋", prod: "∏", sum: "∑", minus: "−", lowast: "∗", radic: "√", prop: "∝", infin: "∞", ang: "∠", and: "⊥", or: "⊦", cap: "∩", cup: "∪", int: "∫", there4: "∴", sim: "∼", cong: "≅", asymp: "≈", ne: "≠", equiv: "≡", le: "≤", ge: "≥", sub: "⊂", sup: "⊃", nsub: "⊄", sube: "⊆", supe: "⊇", oplus: "⊕", otimes: "⊗", perp: "⊥", sdot: "⋅", lceil: "⌈", rceil: "⌉", lfloor: "⌊", rfloor: "⌋", lang: "〈", rang: "〉", loz: "◊", spades: "♠", clubs: "♣", hearts: "♥", diams: "♦", quot: '"', amp: "&", lt: "<", gt: ">", OElig: "Œ", oelig: "œ", Scaron: "Š", scaron: "š", Yuml: "Ÿ", circ: "ˆ", tilde: "˜", ensp: " ", emsp: " ", thinsp: " ", zwnj: "", zwj: "", lrm: "", rlm: "", ndash: "–", mdash: "—", lsquo: "‘", rsquo: "’", sbquo: "‚", ldquo: "“", rdquo: "”", bdquo: "„", dagger: "†", Dagger: "‡", permil: "‰", lsaquo: "‹", rsaquo: "›" };
|
|
1317
1318
|
var Ze = /^[\n\r\x20\u2000-\u200B\u205F\u3000]/, We = /^<\/([a-zA-Z0-9]+)([^>]*)>/, Ke = /^<([a-zA-Z0-9]+)((?:\s[^=\s/]+(?:\s*=\s*(?:"[^"]+"|'[^']+'|[^>\\s]+))?)+)?\s*(\/?)>(\n*)/, Je = /^<!--(.+?)-->/, Qe = /&(?:#(\d\d{2,})|#x([\da-fA-F]{2,})|([a-zA-Z][a-zA-Z1-4]{1,8}));/g, pe = { b: function(e) {
|
|
@@ -1342,12 +1343,12 @@ var Ve = { exports: {} };
|
|
|
1342
1343
|
e.sup = !0;
|
|
1343
1344
|
} }, tn = { div: 1, li: 1, blockquote: 2, h1: 2, h2: 2, h3: 2, h4: 2, h5: 2, h6: 2, ul: 2, ol: 2, hr: 2, p: 2 };
|
|
1344
1345
|
function ge(e) {
|
|
1345
|
-
return e.replace(Qe, function(n, o, i,
|
|
1346
|
+
return e.replace(Qe, function(n, o, i, c) {
|
|
1346
1347
|
if (o || i) {
|
|
1347
1348
|
var y = o ? 10 : 16;
|
|
1348
1349
|
return String.fromCharCode(parseInt(o || i, y));
|
|
1349
1350
|
}
|
|
1350
|
-
return
|
|
1351
|
+
return c in fe ? fe[c] : n;
|
|
1351
1352
|
});
|
|
1352
1353
|
}
|
|
1353
1354
|
function en(e) {
|
|
@@ -1399,8 +1400,8 @@ var Ve = { exports: {} };
|
|
|
1399
1400
|
return (e.style || e.weight || e.baseline || e.color || e.size || e.family) && (o = S(n, e)), o;
|
|
1400
1401
|
}
|
|
1401
1402
|
function me(e, n, o) {
|
|
1402
|
-
for (var i,
|
|
1403
|
-
|
|
1403
|
+
for (var i, c, y = e.width; y + o.width > n && e.length; )
|
|
1404
|
+
c = (i = e[e.length - 1]).width, i.width > o.width ? (i.value = i.value.slice(0, -1), i.width = Y(i, i.font), y += i.width) : e.pop(), y -= c;
|
|
1404
1405
|
e[e.length - 1] instanceof pt && e.pop(), i = e[e.length - 1] || i || {}, o.font = S(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);
|
|
1405
1406
|
}
|
|
1406
1407
|
function vt(e) {
|
|
@@ -1435,12 +1436,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1435
1436
|
return !e && !n || e === n;
|
|
1436
1437
|
};
|
|
1437
1438
|
function gn(e, n) {
|
|
1438
|
-
var o = [], i = n.font(),
|
|
1439
|
+
var o = [], i = n.font(), c = i.size, y = i.family, w = n.align(), x = n.createElement();
|
|
1439
1440
|
if (e.length) {
|
|
1440
|
-
var b = i.height, E = n.valign(), O = n.height()(), M = n.width()(0), I = !isFinite(M) && e.length === 1, z = I ? null : n.x(), R = vt(b /
|
|
1441
|
+
var b = i.height, E = n.valign(), O = n.height()(), M = n.width()(0), I = !isFinite(M) && e.length === 1, z = I ? null : n.x(), R = vt(b / c), Q = I ? null : vt(b / (1.15 * c + (b - c) / 2));
|
|
1441
1442
|
if (pn[E] && isFinite(O)) {
|
|
1442
1443
|
var $ = E === "bottom" ? 1 : 0.5;
|
|
1443
|
-
Q += (O * $ - b * e.length * $) /
|
|
1444
|
+
Q += (O * $ - b * e.length * $) / c;
|
|
1444
1445
|
}
|
|
1445
1446
|
var L = w === "justify", H = 0;
|
|
1446
1447
|
w === "right" ? H = M : w === "center" && (H = M / 2);
|
|
@@ -1456,7 +1457,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1456
1457
|
P = [];
|
|
1457
1458
|
for (var xt = 0, Dt = 0, ht = void 0, W = 0, Rt = lt.length; W < Rt; W++) {
|
|
1458
1459
|
var B = lt[W], K = B.font;
|
|
1459
|
-
B.whitespace && xt++, Dt += B.width, W && !B.tracking && !st && Kt(K.id, at) && Kt(B.class, dt) && Kt(ht, B.href) ? j += B.value : (_(), j = B.value, Z = { fontFamily: K.family !== y ? K.family : null, fontSize: K.size !==
|
|
1460
|
+
B.whitespace && xt++, Dt += B.width, W && !B.tracking && !st && Kt(K.id, at) && Kt(B.class, dt) && Kt(ht, B.href) ? j += B.value : (_(), j = B.value, Z = { fontFamily: K.family !== y ? K.family : null, fontSize: K.size !== c ? K.size : null, fontWeight: K.weight || null, fontStyle: K.style || null, fontVariant: K.variant !== "normal" && K.variant || null, fill: K.color || null, baselineShift: K.baseline ? 100 * K.baseline + "%" : null, className: B.class || null }, st && (Z.dx = vt(st), st = 0), B.tracking && (st = K.size * B.tracking), B.href && !ht ? (ht = B.href, tt = "a", Z.href = ht, Z.rel = B.rel, Z.target = B.target) : ht = null, at = K.id, dt = B.class);
|
|
1460
1461
|
}
|
|
1461
1462
|
if (_(), I)
|
|
1462
1463
|
o.push.apply(o, ve(P));
|
|
@@ -1468,19 +1469,19 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1468
1469
|
o.push(x("tspan", { x: z(it), dy: vt(it ? R : Q) + "em" }, " "));
|
|
1469
1470
|
}
|
|
1470
1471
|
}
|
|
1471
|
-
return x.apply(void 0, ["text", { fontFamily: y, fontSize:
|
|
1472
|
+
return x.apply(void 0, ["text", { fontFamily: y, fontSize: c, textAnchor: fn[w] || "start" }].concat(o));
|
|
1472
1473
|
}
|
|
1473
1474
|
var yn = { middle: 0.5, center: 0.5, bottom: 1, end: 1 };
|
|
1474
1475
|
function mn(e, n, o) {
|
|
1475
1476
|
if (e.length) {
|
|
1476
1477
|
o.textBaseline = "middle";
|
|
1477
|
-
var i = n.font(),
|
|
1478
|
+
var i = n.font(), c = i.height, y = i.size, w = n.valign(), x = n.height()(), b = n.width()(0), E = n.align(), O = E === "justify", M = 0.5 * c, I = yn[w];
|
|
1478
1479
|
if (I && isFinite(x)) {
|
|
1479
|
-
var z = e.length *
|
|
1480
|
+
var z = e.length * c;
|
|
1480
1481
|
M += x * I - z * I;
|
|
1481
1482
|
}
|
|
1482
1483
|
e.forEach(function(R, Q) {
|
|
1483
|
-
var $ = n.x()(Q), L = Q *
|
|
1484
|
+
var $ = n.x()(Q), L = Q * c + M, H = 0, P = 0;
|
|
1484
1485
|
R.forEach(function(j) {
|
|
1485
1486
|
j.whitespace && H++, P += j.width;
|
|
1486
1487
|
});
|
|
@@ -1526,7 +1527,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1526
1527
|
function vn(e, n) {
|
|
1527
1528
|
for (var o = 0; o < n.length; o++) {
|
|
1528
1529
|
var i = n[o];
|
|
1529
|
-
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, (
|
|
1530
|
+
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, (c = function(y, w) {
|
|
1530
1531
|
if (It(y) !== "object" || y === null)
|
|
1531
1532
|
return y;
|
|
1532
1533
|
var x = y[Symbol.toPrimitive];
|
|
@@ -1537,9 +1538,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1537
1538
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1538
1539
|
}
|
|
1539
1540
|
return String(y);
|
|
1540
|
-
}(i.key, "string"), It(
|
|
1541
|
+
}(i.key, "string"), It(c) === "symbol" ? c : String(c)), i);
|
|
1541
1542
|
}
|
|
1542
|
-
var
|
|
1543
|
+
var c;
|
|
1543
1544
|
}
|
|
1544
1545
|
var xn = S(), Qt = function(e) {
|
|
1545
1546
|
return typeof e == "function" ? e : function() {
|
|
@@ -1557,12 +1558,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1557
1558
|
}, x: function() {
|
|
1558
1559
|
return 0;
|
|
1559
1560
|
}, font: null, tAnchor: 0, parser: e.defaultparser }, i)
|
|
1560
|
-
for (var
|
|
1561
|
-
typeof this[
|
|
1561
|
+
for (var c in i)
|
|
1562
|
+
typeof this[c] == "function" && this[c](i[c]);
|
|
1562
1563
|
}
|
|
1563
1564
|
var n, o;
|
|
1564
1565
|
return n = e, o = [{ key: "linebreak", value: function(i) {
|
|
1565
|
-
var
|
|
1566
|
+
var c = this, y = this.props.parser(String(i)), w = this.font(), x = function(b, E, O) {
|
|
1566
1567
|
if (!b.length)
|
|
1567
1568
|
return [];
|
|
1568
1569
|
var M = E.height(), I = E.width(), z = E.overflowLine(), R = E.overflowWrap(), Q = S(O, !0, !1), $ = isFinite(M()) ? Math.floor(M() / O.height) : 1 / 0;
|
|
@@ -1632,7 +1633,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1632
1633
|
return W.font = O, W.width = ht, W;
|
|
1633
1634
|
}(y, this, w);
|
|
1634
1635
|
return x.height = x.length * w.height, x.render = function(b) {
|
|
1635
|
-
return
|
|
1636
|
+
return c.render(x, b);
|
|
1636
1637
|
}, x.svg = x.render, x.draw = x.render, x;
|
|
1637
1638
|
} }, { key: "font", value: function(i) {
|
|
1638
1639
|
return arguments.length ? (this.props.font = S(i), this) : this.props.font || S(xn);
|
|
@@ -1645,13 +1646,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1645
1646
|
} }, { key: "align", value: function(i) {
|
|
1646
1647
|
if (!arguments.length)
|
|
1647
1648
|
return this.props.align;
|
|
1648
|
-
var
|
|
1649
|
-
return
|
|
1649
|
+
var c = String(i).toLowerCase();
|
|
1650
|
+
return c === "left" || c === "start" ? (this.props.align = "left", this.props.tAnchor = 0) : c === "center" || c === "middle" ? (this.props.align = "center", this.props.tAnchor = -0.5) : c === "end" || c === "right" ? (this.props.align = "right", this.props.tAnchor = -1) : c === "justify" && (this.props.align = i, this.props.tAnchor = 0), this;
|
|
1650
1651
|
} }, { key: "overflowWrap", value: function(i) {
|
|
1651
1652
|
if (!arguments.length)
|
|
1652
1653
|
return this.props.overflowWrap || "normal";
|
|
1653
|
-
var
|
|
1654
|
-
return
|
|
1654
|
+
var c = String(i).toLowerCase();
|
|
1655
|
+
return c === "break-word" ? this.props.overflowWrap = "break-word" : c !== "normal" && i != null || (this.props.overflowWrap = null), this;
|
|
1655
1656
|
} }, { key: "width", value: function(i) {
|
|
1656
1657
|
return arguments.length ? (this.props.width = Qt(i), this) : this.props.width;
|
|
1657
1658
|
} }, { key: "height", value: function(i) {
|
|
@@ -1662,8 +1663,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1662
1663
|
if (!arguments.length)
|
|
1663
1664
|
return this.props.parser;
|
|
1664
1665
|
if (typeof i == "string") {
|
|
1665
|
-
var
|
|
1666
|
-
typeof
|
|
1666
|
+
var c = e[i] || e[i + "parser"];
|
|
1667
|
+
typeof c == "function" && (i = c);
|
|
1667
1668
|
}
|
|
1668
1669
|
if (typeof i != "function")
|
|
1669
1670
|
throw new Error("Unknown parser: " + i);
|
|
@@ -1691,7 +1692,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1691
1692
|
function wn(e, n) {
|
|
1692
1693
|
for (var o = 0; o < n.length; o++) {
|
|
1693
1694
|
var i = n[o];
|
|
1694
|
-
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, (
|
|
1695
|
+
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, (c = function(y, w) {
|
|
1695
1696
|
if (_t(y) !== "object" || y === null)
|
|
1696
1697
|
return y;
|
|
1697
1698
|
var x = y[Symbol.toPrimitive];
|
|
@@ -1702,9 +1703,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1702
1703
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1703
1704
|
}
|
|
1704
1705
|
return String(y);
|
|
1705
|
-
}(i.key, "string"), _t(
|
|
1706
|
+
}(i.key, "string"), _t(c) === "symbol" ? c : String(c)), i);
|
|
1706
1707
|
}
|
|
1707
|
-
var
|
|
1708
|
+
var c;
|
|
1708
1709
|
}
|
|
1709
1710
|
var we = function(e) {
|
|
1710
1711
|
return typeof e == "function" ? e : function() {
|
|
@@ -1720,13 +1721,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1720
1721
|
}, height: function() {
|
|
1721
1722
|
return 1 / 0;
|
|
1722
1723
|
}, rotation: 0, vAnchor: 0, hAnchor: 0 }, i)
|
|
1723
|
-
for (var
|
|
1724
|
-
typeof this[
|
|
1724
|
+
for (var c in i)
|
|
1725
|
+
typeof this[c] == "function" && this[c](i[c]);
|
|
1725
1726
|
this.render = this.render.bind(this);
|
|
1726
1727
|
}
|
|
1727
1728
|
var n, o;
|
|
1728
1729
|
return n = e, o = [{ key: "anchor", value: function(i) {
|
|
1729
|
-
var
|
|
1730
|
+
var c = this.props, y = c.hAnchor, w = c.vAnchor, x = c.width, b = c.height;
|
|
1730
1731
|
if (!arguments.length)
|
|
1731
1732
|
return [y * x(0), w * b(0)];
|
|
1732
1733
|
if (typeof i == "string") {
|
|
@@ -1744,7 +1745,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1744
1745
|
return arguments.length ? (this.props.rotation = i, this) : this.props.rotation;
|
|
1745
1746
|
} }, { key: "createElement", value: function(i) {
|
|
1746
1747
|
return arguments.length ? (this.props.createElement = i, this) : this.props.createElement || e.createElement;
|
|
1747
|
-
} }, { key: "canvas", value: function(i,
|
|
1748
|
+
} }, { key: "canvas", value: function(i, c) {
|
|
1748
1749
|
var y, w = i.getContext ? i.getContext("2d") : i;
|
|
1749
1750
|
return w.save(), w.rotate(this.rotate() * Math.PI / 180), w.translate.apply(w, function(x) {
|
|
1750
1751
|
if (Array.isArray(x))
|
|
@@ -1762,7 +1763,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1762
1763
|
}(y) || function() {
|
|
1763
1764
|
throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
1764
1765
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
|
|
1765
|
-
}()),
|
|
1766
|
+
}()), c(w), w.restore(), w;
|
|
1766
1767
|
} }, { key: "render", value: function() {
|
|
1767
1768
|
var i = xe(arguments);
|
|
1768
1769
|
if (i.d3)
|
|
@@ -1770,8 +1771,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1770
1771
|
if (i.ctx)
|
|
1771
1772
|
return this.canvas(i.ctx, i.fn);
|
|
1772
1773
|
if (i.text) {
|
|
1773
|
-
var
|
|
1774
|
-
return this.createElement()("g", { transform: "rotate(".concat(this.rotate(), ") translate(").concat(this.anchor(), ")") },
|
|
1774
|
+
var c = typeof i.text.render == "function" ? i.text.render() : i.text;
|
|
1775
|
+
return this.createElement()("g", { transform: "rotate(".concat(this.rotate(), ") translate(").concat(this.anchor(), ")") }, c);
|
|
1775
1776
|
}
|
|
1776
1777
|
} }], o && wn(n.prototype, o), Object.defineProperty(n, "prototype", { writable: !1 }), e;
|
|
1777
1778
|
}(), bn = Object.prototype.hasOwnProperty, ee = {};
|
|
@@ -1793,7 +1794,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1793
1794
|
if (n && o.setAttribute)
|
|
1794
1795
|
for (var i in n)
|
|
1795
1796
|
bn.call(n, i) && n[i] != null && o.setAttribute(i === "className" ? "class" : An(i), n[i]);
|
|
1796
|
-
for (var
|
|
1797
|
+
for (var c = arguments.length, y = new Array(c > 2 ? c - 2 : 0), w = 2; w < c; w++)
|
|
1797
1798
|
y[w - 2] = arguments[w];
|
|
1798
1799
|
return y != null && y.length && y.forEach(function(x) {
|
|
1799
1800
|
Ae(o, x);
|
|
@@ -1802,19 +1803,19 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1802
1803
|
}
|
|
1803
1804
|
rt.createElement = Se, rt.textparser = Nt, rt.defaultparser = Nt, rt.htmlparser = function(e) {
|
|
1804
1805
|
e = String(e || "").trim();
|
|
1805
|
-
for (var n, o, i = { weight: null, style: null, sub: !1, sup: !1, href: null, color: null, rel: null, target: null },
|
|
1806
|
+
for (var n, o, i = { weight: null, style: null, sub: !1, sup: !1, href: null, color: null, rel: null, target: null }, c = [], y = [], w = function(M) {
|
|
1806
1807
|
for (var I in i)
|
|
1807
1808
|
i[I] && (M[I] = i[I]);
|
|
1808
|
-
|
|
1809
|
+
c.push(M);
|
|
1809
1810
|
}, x = function(M) {
|
|
1810
|
-
var I =
|
|
1811
|
+
var I = c.length, z = tn[M];
|
|
1811
1812
|
if (I && z) {
|
|
1812
|
-
for (var R = I - 1;
|
|
1813
|
+
for (var R = I - 1; c[R] && (c[R] instanceof Tt || Ze.test(c[R].value)); )
|
|
1813
1814
|
R--;
|
|
1814
|
-
for (; z &&
|
|
1815
|
+
for (; z && c[R] && c[R] instanceof nt; )
|
|
1815
1816
|
R--, z--;
|
|
1816
1817
|
for (; z-- > 0; )
|
|
1817
|
-
|
|
1818
|
+
c.push(new nt());
|
|
1818
1819
|
}
|
|
1819
1820
|
}; e.length; ) {
|
|
1820
1821
|
if (n = /^[^<]+/.exec(e))
|
|
@@ -1826,14 +1827,14 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1826
1827
|
var b = n[1];
|
|
1827
1828
|
x(b), y.push(i), i = Object.create(i), pe[b] && pe[b](i, "");
|
|
1828
1829
|
var E = rn(n[2]);
|
|
1829
|
-
b === "a" && (E.href && (i.href = E.href), E.rel && (i.rel = E.rel), E.target && (i.target = E.target)), E.class && (i.class = i.class ? i.class + " " + E.class : E.class), E.style && (o = /(?:^|\s|;)color\s*:\s*([^;\s"']+)/.exec(E.style)) && o[1] && (i.color = o[1]), b === "br" &&
|
|
1830
|
+
b === "a" && (E.href && (i.href = E.href), E.rel && (i.rel = E.rel), E.target && (i.target = E.target)), E.class && (i.class = i.class ? i.class + " " + E.class : E.class), E.style && (o = /(?:^|\s|;)color\s*:\s*([^;\s"']+)/.exec(E.style)) && o[1] && (i.color = o[1]), b === "br" && c.push(new nt());
|
|
1830
1831
|
} else
|
|
1831
1832
|
n = [e.slice(0, 1)], w(new N(n[0]));
|
|
1832
1833
|
e = e.slice(n[0].length);
|
|
1833
1834
|
}
|
|
1834
|
-
for (var O =
|
|
1835
|
-
|
|
1836
|
-
return
|
|
1835
|
+
for (var O = c[c.length - 1]; O instanceof nt; )
|
|
1836
|
+
c.pop(), O = c[c.length - 1];
|
|
1837
|
+
return c;
|
|
1837
1838
|
}, rt.latexparser = function(e) {
|
|
1838
1839
|
e = String(e || "").trim();
|
|
1839
1840
|
var n = [0];
|
|
@@ -1852,17 +1853,17 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1852
1853
|
}).replace(/\\verb,(.*?),/, function($, L) {
|
|
1853
1854
|
return "\\verb,".concat(n[+L], ",");
|
|
1854
1855
|
});
|
|
1855
|
-
for (var o, i = { weight: null, italic: null, variant: null, sub: !1, sup: !1, href: null },
|
|
1856
|
+
for (var o, i = { weight: null, italic: null, variant: null, sub: !1, sup: !1, href: null }, c = [], y = [], w = function($) {
|
|
1856
1857
|
for (var L in i)
|
|
1857
1858
|
i[L] && ($[L] = i[L]);
|
|
1858
|
-
return
|
|
1859
|
+
return c.push($), $;
|
|
1859
1860
|
}, x = function() {
|
|
1860
1861
|
y.push(i), i = Object.create(i);
|
|
1861
1862
|
}, b = function() {
|
|
1862
1863
|
if (!y.length)
|
|
1863
1864
|
throw new Error("Unexpected }");
|
|
1864
1865
|
i = y.pop();
|
|
1865
|
-
}, E = { tokens:
|
|
1866
|
+
}, E = { tokens: c, open_context: x, close_context: b, add_token: w }; e.length; ) {
|
|
1866
1867
|
if (o = an.exec(e))
|
|
1867
1868
|
Nt(o[0], !1).forEach(w);
|
|
1868
1869
|
else if (o = ln.exec(e))
|
|
@@ -1901,7 +1902,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1901
1902
|
}
|
|
1902
1903
|
e = e.slice(o[0].length);
|
|
1903
1904
|
}
|
|
1904
|
-
return
|
|
1905
|
+
return c;
|
|
1905
1906
|
}, rt.measureText = function(e, n, o) {
|
|
1906
1907
|
return Y(e, S(n), o);
|
|
1907
1908
|
}, rt.Token = N, rt.Break = Tt, rt.LineBreak = nt, rt.SoftHyphen = pt, rt.Rotator = be, be.createElement = Se;
|
|
@@ -1912,13 +1913,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1912
1913
|
var Fn = Ve.exports;
|
|
1913
1914
|
const Oe = /* @__PURE__ */ ce(Fn);
|
|
1914
1915
|
function Bn(u, l) {
|
|
1915
|
-
const t = ut(u), { fontSize: r, font: a, padding:
|
|
1916
|
+
const t = ut(u), { fontSize: r, font: a, padding: h = 0 } = u.properties.style || {};
|
|
1916
1917
|
if (t.width === t.height && t.width === 0)
|
|
1917
1918
|
return;
|
|
1918
1919
|
const p = new Oe({
|
|
1919
1920
|
font: `${r}px/${r}px ${a}`.replace(/(px)+/g, "px"),
|
|
1920
|
-
width: t.width -
|
|
1921
|
-
height: t.height -
|
|
1921
|
+
width: t.width - h * 2,
|
|
1922
|
+
height: t.height - h * 2,
|
|
1922
1923
|
align: "left",
|
|
1923
1924
|
valign: "top",
|
|
1924
1925
|
x: 0,
|
|
@@ -1929,7 +1930,7 @@ function Bn(u, l) {
|
|
|
1929
1930
|
u.properties.content.replaceAll(`
|
|
1930
1931
|
`, "<br>")
|
|
1931
1932
|
).render();
|
|
1932
|
-
p.setAttribute("transform", `translate(${
|
|
1933
|
+
p.setAttribute("transform", `translate(${h}, ${h})`), l.appendChild(p);
|
|
1933
1934
|
}
|
|
1934
1935
|
const Me = 20;
|
|
1935
1936
|
class qn extends qe {
|
|
@@ -1968,16 +1969,16 @@ class qn extends qe {
|
|
|
1968
1969
|
});
|
|
1969
1970
|
v(this, "startDrawing", (t, r, a = jn(t, r, 0, 0, "", At)) => {
|
|
1970
1971
|
this.add(a);
|
|
1971
|
-
const
|
|
1972
|
-
this.select(a.id), this.startDragging(this.getById(a.id),
|
|
1972
|
+
const h = this.ogma.view.graphToScreenCoordinates({ x: t, y: r });
|
|
1973
|
+
this.select(a.id), this.startDragging(this.getById(a.id), h.x, h.y), this.draggedHandle = 6;
|
|
1973
1974
|
});
|
|
1974
1975
|
v(this, "cancelDrawing", () => {
|
|
1975
1976
|
this.isDragging && (this.remove(this.annotation.id), this.annotation = { ...re }, this.draggedHandle = q, this.isDragging = !1, this.emit(St, this.annotation));
|
|
1976
1977
|
});
|
|
1977
1978
|
v(this, "startDragging", (t, r, a) => {
|
|
1978
1979
|
this.annotation = t;
|
|
1979
|
-
const
|
|
1980
|
-
this.rect.x =
|
|
1980
|
+
const h = ct(this.annotation), d = ut(this.annotation);
|
|
1981
|
+
this.rect.x = h.x, this.rect.y = h.y, this.rect.width = d.width, this.rect.height = d.height, this.startX = r, this.startY = a, this.disableDragging(), this.textArea.classList.add("noevents"), this.textArea.setAttribute("disabled", "disabled"), this.emit(Yt, this.annotation), this.isDragging = !0;
|
|
1981
1982
|
});
|
|
1982
1983
|
v(this, "onHandleMouseDown", (t) => {
|
|
1983
1984
|
const r = this.getById(this.selectedId) || this.getById(this.hoveredId);
|
|
@@ -1990,10 +1991,10 @@ class qn extends qe {
|
|
|
1990
1991
|
if (!this.isDragging)
|
|
1991
1992
|
return;
|
|
1992
1993
|
t.stopPropagation(), t.preventDefault();
|
|
1993
|
-
const r = this.handles[this.draggedHandle], a = r.classList.contains("top"),
|
|
1994
|
-
(g &&
|
|
1995
|
-
const S =
|
|
1996
|
-
this.rect.width + f * (p ||
|
|
1994
|
+
const r = this.handles[this.draggedHandle], a = r.classList.contains("top"), h = r.classList.contains("left"), d = r.classList.contains("right"), g = r.classList.contains("bottom"), p = r.classList.contains("line-handle"), s = this.ogma.view.getZoom(), f = (t.clientX - this.startX) / s, m = (t.clientY - this.startY) / s, A = this.ogma.view.getAngle(), T = new U(f, m).rotateRadians(A);
|
|
1995
|
+
(g && h || a && d) && (T.y = 0, T.x = 0);
|
|
1996
|
+
const S = h || p ? this.rect.x + T.x : this.rect.x, C = a || p ? this.rect.y + T.y : this.rect.y, k = Math.max(
|
|
1997
|
+
this.rect.width + f * (p || h ? 0 : 1),
|
|
1997
1998
|
Me
|
|
1998
1999
|
), F = Math.max(
|
|
1999
2000
|
this.rect.height + m * (p || a ? 0 : 1),
|
|
@@ -2017,16 +2018,16 @@ class qn extends qe {
|
|
|
2017
2018
|
a.addEventListener("input", this._onInput), a.addEventListener("focus", this._onFocus), a.addEventListener("blur", this._onBlur), a.spellcheck = !1, this.handles = Array.prototype.slice.call(
|
|
2018
2019
|
this.editor.element.querySelectorAll(".annotation-text-handle > .handle")
|
|
2019
2020
|
), this.handles.forEach(
|
|
2020
|
-
(
|
|
2021
|
+
(h) => h.addEventListener("mousedown", this.onHandleMouseDown)
|
|
2021
2022
|
), document.addEventListener("mouseup", this.onMouseUp), document.addEventListener("mousemove", this.onMouseMove, !0), t.events.on(["viewChanged", "zoom"], this.onViewChanged);
|
|
2022
2023
|
}
|
|
2023
2024
|
_canRemove() {
|
|
2024
2025
|
return !this.isFocused;
|
|
2025
2026
|
}
|
|
2026
2027
|
detect({ x: t, y: r }, a = 0) {
|
|
2027
|
-
const
|
|
2028
|
+
const h = new U(t, r), d = this.ogma.view.getAngle();
|
|
2028
2029
|
return this.elements.find((g) => {
|
|
2029
|
-
const { x: p, y: s } = ct(g), { width: f, height: m } = ut(g), A = new U(p, s), { x: T, y: S } =
|
|
2030
|
+
const { x: p, y: s } = ct(g), { width: f, height: m } = ut(g), A = new U(p, s), { x: T, y: S } = h.sub(A).rotateRadians(-d);
|
|
2030
2031
|
return T > -a && T < f + a && S > -a && S < m + a;
|
|
2031
2032
|
});
|
|
2032
2033
|
}
|
|
@@ -2053,14 +2054,17 @@ class qn extends qe {
|
|
|
2053
2054
|
const { x: Et, y: kt } = new U(f.x, f.y).rotateRadians(-a);
|
|
2054
2055
|
D.setAttribute("transform", `translate(${Et},${kt})`), D.classList.add(p), D.setAttribute("data-annotation", `${d.id}`), D.setAttribute("data-annotation-type", "text"), t.appendChild(D);
|
|
2055
2056
|
});
|
|
2056
|
-
const
|
|
2057
|
-
|
|
2057
|
+
const h = Mt("style");
|
|
2058
|
+
h.innerHTML = r, t.firstChild && t.insertBefore(h, t.firstChild);
|
|
2058
2059
|
}
|
|
2059
2060
|
refreshDrawing() {
|
|
2060
2061
|
const t = this.ogma.view.getAngle();
|
|
2061
2062
|
[...this.layer.element.children].forEach((r) => {
|
|
2062
|
-
const a =
|
|
2063
|
-
|
|
2063
|
+
const a = r.getAttribute("data-annotation");
|
|
2064
|
+
if (!a)
|
|
2065
|
+
return;
|
|
2066
|
+
const h = ct(this.getById(a)), { x: d, y: g } = new U(h.x, h.y).rotateRadians(-t);
|
|
2067
|
+
r.setAttribute("transform", `translate(${d},${g})`);
|
|
2064
2068
|
});
|
|
2065
2069
|
}
|
|
2066
2070
|
getDefaultOptions() {
|
|
@@ -2069,14 +2073,14 @@ class qn extends qe {
|
|
|
2069
2073
|
refreshEditor() {
|
|
2070
2074
|
if (+this.selectedId < 0 && +this.hoveredId < 0)
|
|
2071
2075
|
return;
|
|
2072
|
-
const t = this.getById(this.selectedId) || this.getById(this.hoveredId), r = ut(t), a = this.ogma.view.graphToScreenCoordinates(ct(t)),
|
|
2076
|
+
const t = this.getById(this.selectedId) || this.getById(this.hoveredId), r = ut(t), a = this.ogma.view.graphToScreenCoordinates(ct(t)), h = this.ogma.view.getZoom(), {
|
|
2073
2077
|
font: d,
|
|
2074
2078
|
fontSize: g,
|
|
2075
2079
|
color: p,
|
|
2076
2080
|
background: s,
|
|
2077
2081
|
padding: f = 0
|
|
2078
|
-
} = t.properties.style || At, m = (g || 1) *
|
|
2079
|
-
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 *
|
|
2082
|
+
} = t.properties.style || At, m = (g || 1) * h;
|
|
2083
|
+
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 * h}px, ${r.height / 2 * h}px)`, this.editor.element.style.width = `${r.width * h}px`, this.editor.element.style.height = `${r.height * h}px`, this.textArea.style.font = `${m} ${d}`, this.textArea.style.fontFamily = d || "sans-serif", this.textArea.style.fontSize = `${m}px`, this.textArea.style.padding = `${h * f}px`, this.textArea.style.lineHeight = `${m}px`, this.textArea.style.boxSizing = "border-box", this.textArea.style.color = p || "black", this.textArea.style.background = s || "transparent", this.textArea.placeholder = this.placeholder, this.layer.refresh();
|
|
2080
2084
|
}
|
|
2081
2085
|
select(t) {
|
|
2082
2086
|
super.select(t), this.textArea.focus();
|
|
@@ -2091,20 +2095,20 @@ class Vn {
|
|
|
2091
2095
|
v(this, "linksByTargetId", {});
|
|
2092
2096
|
v(this, "linksByArrowId", {});
|
|
2093
2097
|
}
|
|
2094
|
-
add(l, t, r, a,
|
|
2098
|
+
add(l, t, r, a, h) {
|
|
2095
2099
|
const d = Xt(), g = l.id, p = {
|
|
2096
2100
|
id: d,
|
|
2097
2101
|
arrow: g,
|
|
2098
2102
|
target: r,
|
|
2099
2103
|
targetType: a,
|
|
2100
|
-
connectionPoint:
|
|
2104
|
+
connectionPoint: h,
|
|
2101
2105
|
side: t
|
|
2102
2106
|
};
|
|
2103
2107
|
return this.links[d] = p, this.linksByTargetId[r] || (this.linksByTargetId[r] = []), this.linksByTargetId[r].push(d), this.linksByArrowId[g] || (this.linksByArrowId[g] = {}), this.linksByArrowId[g][t] = d, l.properties.link = l.properties.link || {}, l.properties.link[t] = {
|
|
2104
2108
|
id: r,
|
|
2105
2109
|
side: t,
|
|
2106
2110
|
type: a,
|
|
2107
|
-
magnet:
|
|
2111
|
+
magnet: h
|
|
2108
2112
|
}, this;
|
|
2109
2113
|
}
|
|
2110
2114
|
arrowIsLinked(l, t) {
|
|
@@ -2117,9 +2121,9 @@ class Vn {
|
|
|
2117
2121
|
const r = l.id, a = (g = this.linksByArrowId[r]) == null ? void 0 : g[t];
|
|
2118
2122
|
if ((p = l.properties.link) == null || delete p[t], !a)
|
|
2119
2123
|
return this;
|
|
2120
|
-
const
|
|
2124
|
+
const h = this.links[a];
|
|
2121
2125
|
delete this.links[a];
|
|
2122
|
-
const d = this.linksByTargetId[
|
|
2126
|
+
const d = this.linksByTargetId[h.target];
|
|
2123
2127
|
for (let s = 0; s < d.length; s++)
|
|
2124
2128
|
if (d[s] === a) {
|
|
2125
2129
|
d.splice(s, 1);
|
|
@@ -2184,23 +2188,23 @@ class Gn extends Be {
|
|
|
2184
2188
|
Ce.forEach((a) => {
|
|
2185
2189
|
if (!this.textToMagnet)
|
|
2186
2190
|
return;
|
|
2187
|
-
const
|
|
2191
|
+
const h = ut(this.textToMagnet), d = ct(this.textToMagnet), { x: g, y: p } = new U(a.x, a.y).mul({ x: h.width, y: h.height }).rotateRadians(this.ogma.view.getAngle()).add(d);
|
|
2188
2192
|
t.moveTo(g, p), t.arc(g, p, this.options.magnetHandleRadius / r, 0, Math.PI * 2);
|
|
2189
2193
|
}), t.fill(), t.closePath();
|
|
2190
2194
|
});
|
|
2191
2195
|
v(this, "_onFeatureDrag", (t, r) => {
|
|
2192
2196
|
const a = r;
|
|
2193
2197
|
if (ot(t) && a === "line")
|
|
2194
|
-
["start", "end"].find((
|
|
2195
|
-
const d =
|
|
2196
|
-
return this._snapToText(t, a, d) || this._findAndSnapToNode(t,
|
|
2198
|
+
["start", "end"].find((h) => {
|
|
2199
|
+
const d = h === "start" ? zt(t) : qt(t);
|
|
2200
|
+
return this._snapToText(t, a, d) || this._findAndSnapToNode(t, h, d);
|
|
2197
2201
|
});
|
|
2198
2202
|
else if (ot(t) && a !== "line") {
|
|
2199
|
-
const
|
|
2200
|
-
this._snapToText(t, a,
|
|
2203
|
+
const h = a === "start" ? zt(t) : qt(t);
|
|
2204
|
+
this._snapToText(t, a, h) || this._findAndSnapToNode(t, a, h);
|
|
2201
2205
|
} else
|
|
2202
|
-
mt(t) && (this.activeLinks.forEach(({ arrow:
|
|
2203
|
-
const p = this.getAnnotation(
|
|
2206
|
+
mt(t) && (this.activeLinks.forEach(({ arrow: h, side: d, connectionPoint: g }) => {
|
|
2207
|
+
const p = this.getAnnotation(h), s = ut(t), f = ct(t), m = new U(g.x, g.y).mul({ x: s.width, y: s.height }).rotateRadians(this.ogma.view.getAngle()).add(f);
|
|
2204
2208
|
p.geometry.coordinates[d === "start" ? 0 : 1] = [m.x, m.y];
|
|
2205
2209
|
}), this.activeLinks.length && this.arrows.refreshLayer());
|
|
2206
2210
|
this.layer.refresh(), this.emit(Ut, t, r);
|
|
@@ -2268,33 +2272,33 @@ class Gn extends Be {
|
|
|
2268
2272
|
}), this.layer = t.layers.addCanvasLayer(this._render), this.layer.moveToBottom();
|
|
2269
2273
|
}
|
|
2270
2274
|
_moveNodes(t, r, a) {
|
|
2271
|
-
t.forEach((
|
|
2272
|
-
const d = this.links.getTargetLinks(
|
|
2275
|
+
t.forEach((h) => {
|
|
2276
|
+
const d = this.links.getTargetLinks(h.getId(), "node"), g = h.getPosition();
|
|
2273
2277
|
d.forEach((p) => {
|
|
2274
2278
|
const s = this.getAnnotation(p.arrow), f = p.side, m = jt(
|
|
2275
2279
|
s,
|
|
2276
2280
|
f === "start" ? "end" : "start"
|
|
2277
2281
|
);
|
|
2278
2282
|
let A = g;
|
|
2279
|
-
const T = +
|
|
2283
|
+
const T = +h.getAttribute("radius"), S = 1e-6;
|
|
2280
2284
|
(p.connectionPoint.x - (g.x - r) > S || p.connectionPoint.y - (g.y - a) > S) && (A = Ft(m, g, T)), bt(s, f, A.x, A.y);
|
|
2281
2285
|
});
|
|
2282
2286
|
}), this.arrows.refreshLayer();
|
|
2283
2287
|
}
|
|
2284
2288
|
_snapToText(t, r, a) {
|
|
2285
|
-
const
|
|
2286
|
-
if (this.links.remove(t, r), !
|
|
2289
|
+
const h = this.texts.detect(a, this.options.detectMargin);
|
|
2290
|
+
if (this.links.remove(t, r), !h)
|
|
2287
2291
|
return !1;
|
|
2288
|
-
this.textToMagnet =
|
|
2289
|
-
const d = this.findMagnetPoint(Ce,
|
|
2290
|
-
return d ? (bt(t, r, d.point.x, d.point.y), this.links.add(t, r,
|
|
2292
|
+
this.textToMagnet = h;
|
|
2293
|
+
const d = this.findMagnetPoint(Ce, h, a);
|
|
2294
|
+
return d ? (bt(t, r, d.point.x, d.point.y), this.links.add(t, r, h.id, "text", d.magnet), !0) : !1;
|
|
2291
2295
|
}
|
|
2292
2296
|
_findAndSnapToNode(t, r, a) {
|
|
2293
|
-
const
|
|
2294
|
-
this.links.remove(t, r), d && d.isNode ? (this.hoveredNode = d, this.hoveredNode.setSelected(!0), this._snapToNode(t, r, d,
|
|
2297
|
+
const h = this.ogma.view.graphToScreenCoordinates(a), d = this.ogma.view.getElementAt(h);
|
|
2298
|
+
this.links.remove(t, r), d && d.isNode ? (this.hoveredNode = d, this.hoveredNode.setSelected(!0), this._snapToNode(t, r, d, h)) : (this.hoveredNode && this.hoveredNode.setSelected(!1), this.hoveredNode = null);
|
|
2295
2299
|
}
|
|
2296
|
-
_snapToNode(t, r, a,
|
|
2297
|
-
const d = a.getPositionOnScreen(), g = +a.getAttribute("radius"), p = g * this.ogma.view.getZoom(), s =
|
|
2300
|
+
_snapToNode(t, r, a, h) {
|
|
2301
|
+
const d = a.getPositionOnScreen(), g = +a.getAttribute("radius"), p = g * this.ogma.view.getZoom(), s = h.x - d.x, f = h.y - d.y, m = Math.sqrt(s * s + f * f), A = a.getPosition();
|
|
2298
2302
|
if (m < p + this.options.detectMargin) {
|
|
2299
2303
|
let T = A;
|
|
2300
2304
|
if (m > p / 2) {
|
|
@@ -2306,11 +2310,11 @@ class Gn extends Be {
|
|
|
2306
2310
|
}
|
|
2307
2311
|
refreshTextLinks() {
|
|
2308
2312
|
let t = !1;
|
|
2309
|
-
this.links.forEach(({ connectionPoint: r, targetType: a, target:
|
|
2313
|
+
this.links.forEach(({ connectionPoint: r, targetType: a, target: h, arrow: d, side: g }) => {
|
|
2310
2314
|
if (a !== "text")
|
|
2311
2315
|
return;
|
|
2312
2316
|
t = !0;
|
|
2313
|
-
const p = this.getAnnotation(
|
|
2317
|
+
const p = this.getAnnotation(h), s = this.getAnnotation(d), f = ut(p), m = ct(p), A = new U(r.x, r.y).mul({ x: f.width, y: f.height }).rotateRadians(this.ogma.view.getAngle()).add(m);
|
|
2314
2318
|
bt(s, g, A.x, A.y);
|
|
2315
2319
|
}), t && this.arrows.refreshLayer();
|
|
2316
2320
|
}
|
|
@@ -2321,7 +2325,7 @@ class Gn extends Be {
|
|
|
2321
2325
|
return this.selected;
|
|
2322
2326
|
}
|
|
2323
2327
|
findMagnetPoint(t, r, a) {
|
|
2324
|
-
let
|
|
2328
|
+
let h;
|
|
2325
2329
|
for (const d of t) {
|
|
2326
2330
|
const g = ut(r), p = ct(r), s = new U(d.x, d.y).mul({ x: g.width, y: g.height }).rotateRadians(this.ogma.view.getAngle()).add(p), f = s.sub(a).length(), m = Math.min(
|
|
2327
2331
|
this.options.magnetRadius * this.ogma.view.getZoom(),
|
|
@@ -2330,14 +2334,14 @@ class Gn extends Be {
|
|
|
2330
2334
|
g.height / 2
|
|
2331
2335
|
);
|
|
2332
2336
|
if (f < Math.max(m, this.options.magnetHandleRadius)) {
|
|
2333
|
-
|
|
2337
|
+
h = {
|
|
2334
2338
|
point: s,
|
|
2335
2339
|
magnet: d
|
|
2336
2340
|
};
|
|
2337
2341
|
break;
|
|
2338
2342
|
}
|
|
2339
2343
|
}
|
|
2340
|
-
return
|
|
2344
|
+
return h;
|
|
2341
2345
|
}
|
|
2342
2346
|
/**
|
|
2343
2347
|
* Set the options for the controller
|
|
@@ -2370,11 +2374,11 @@ class Gn extends Be {
|
|
|
2370
2374
|
*/
|
|
2371
2375
|
add(t) {
|
|
2372
2376
|
if (ze(t)) {
|
|
2373
|
-
const [r, a] = t.features.reduce((
|
|
2377
|
+
const [r, a] = t.features.reduce((h, d) => (ot(d) ? h[1].push(d) : mt(d) && h[0].push(d), h), [[], []]);
|
|
2374
2378
|
return r.forEach(
|
|
2375
|
-
(
|
|
2379
|
+
(h) => this.add(h)
|
|
2376
2380
|
), a.forEach(
|
|
2377
|
-
(
|
|
2381
|
+
(h) => this.add(h)
|
|
2378
2382
|
), this.arrows.refreshLayer(), this;
|
|
2379
2383
|
}
|
|
2380
2384
|
switch (t.properties.type) {
|
|
@@ -2402,8 +2406,8 @@ class Gn extends Be {
|
|
|
2402
2406
|
const a = t.properties.link[r];
|
|
2403
2407
|
if (!a)
|
|
2404
2408
|
continue;
|
|
2405
|
-
const
|
|
2406
|
-
if (a.type === "text" &&
|
|
2409
|
+
const h = this.getAnnotation(a.id);
|
|
2410
|
+
if (a.type === "text" && h)
|
|
2407
2411
|
this.links.add(t, r, a.id, a.type, a.magnet);
|
|
2408
2412
|
else if (a.type === "node") {
|
|
2409
2413
|
const d = this.ogma.getNode(a.id);
|
|
@@ -2445,7 +2449,7 @@ class Gn extends Be {
|
|
|
2445
2449
|
* @param style The new style
|
|
2446
2450
|
*/
|
|
2447
2451
|
updateStyle(t, r) {
|
|
2448
|
-
const a = this.getAnnotations().features.find((
|
|
2452
|
+
const a = this.getAnnotations().features.find((h) => h.id === t);
|
|
2449
2453
|
return a ? (ot(a) ? this.arrows.updateStyle(a, r) : mt(a) && this.texts.updateStyle(a, r), this.onUpdate(a), this) : this;
|
|
2450
2454
|
}
|
|
2451
2455
|
/**
|