@linkurious/ogma-annotations 1.1.14 → 1.1.15
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.js +9 -9
- package/dist/index.mjs +316 -289
- package/dist/types/Control.d.ts +1 -0
- package/dist/types/Editor/base.d.ts +1 -0
- package/dist/types/types.d.ts +1 -1
- package/dist/types/utils.d.ts +2 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var $n = Object.defineProperty;
|
|
2
|
-
var zn = (a,
|
|
3
|
-
var m = (a,
|
|
4
|
-
let Kt = (a = 21) => crypto.getRandomValues(new Uint8Array(a)).reduce((
|
|
2
|
+
var zn = (a, h, t) => h in a ? $n(a, h, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[h] = t;
|
|
3
|
+
var m = (a, h, t) => (zn(a, typeof h != "symbol" ? h + "" : h, t), t);
|
|
4
|
+
let Kt = (a = 21) => crypto.getRandomValues(new Uint8Array(a)).reduce((h, t) => (t &= 63, t < 36 ? h += t.toString(36) : t < 62 ? h += (t - 26).toString(36).toUpperCase() : t > 62 ? h += "-" : h += "_", h), "");
|
|
5
5
|
const zt = {
|
|
6
6
|
strokeType: "plain",
|
|
7
7
|
strokeColor: "black",
|
|
@@ -34,7 +34,7 @@ const zt = {
|
|
|
34
34
|
// tail: 'arrow-plain',
|
|
35
35
|
// start: { x: 0, y: 0 },
|
|
36
36
|
// end: { x: 100, y: 100 }
|
|
37
|
-
}, Nn = (a = 0,
|
|
37
|
+
}, Nn = (a = 0, h = 0, t = 0, r = 0, o = { ...zt }) => ({
|
|
38
38
|
id: Kt(),
|
|
39
39
|
type: "Feature",
|
|
40
40
|
properties: {
|
|
@@ -47,7 +47,7 @@ const zt = {
|
|
|
47
47
|
geometry: {
|
|
48
48
|
type: "LineString",
|
|
49
49
|
coordinates: [
|
|
50
|
-
[a,
|
|
50
|
+
[a, h],
|
|
51
51
|
[t, r]
|
|
52
52
|
]
|
|
53
53
|
}
|
|
@@ -59,59 +59,59 @@ function qe(a) {
|
|
|
59
59
|
return a.geometry.bbox || Fn(a), a.geometry.bbox;
|
|
60
60
|
}
|
|
61
61
|
function ut(a) {
|
|
62
|
-
const
|
|
62
|
+
const h = qe(a);
|
|
63
63
|
return {
|
|
64
|
-
width:
|
|
65
|
-
height:
|
|
64
|
+
width: h[2] - h[0],
|
|
65
|
+
height: h[3] - h[1]
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
function ct(a) {
|
|
69
|
-
const
|
|
70
|
-
return { x:
|
|
69
|
+
const h = qe(a);
|
|
70
|
+
return { x: h[0], y: h[1] };
|
|
71
71
|
}
|
|
72
72
|
function Fn(a) {
|
|
73
|
-
const [
|
|
74
|
-
a.geometry.bbox = [
|
|
73
|
+
const [h, t] = a.geometry.coordinates[0][0], [r, o] = a.geometry.coordinates[0][2];
|
|
74
|
+
a.geometry.bbox = [h, t, r, o];
|
|
75
75
|
}
|
|
76
|
-
function Bn(a,
|
|
77
|
-
a.geometry.bbox = [
|
|
76
|
+
function Bn(a, h, t, r, o) {
|
|
77
|
+
a.geometry.bbox = [h, t, h + r, t + o], a.geometry.coordinates = [
|
|
78
78
|
[
|
|
79
|
-
[
|
|
80
|
-
[
|
|
81
|
-
[
|
|
82
|
-
[
|
|
83
|
-
[
|
|
79
|
+
[h, t],
|
|
80
|
+
[h + r, t],
|
|
81
|
+
[h + r, t + o],
|
|
82
|
+
[h, t + o],
|
|
83
|
+
[h, t]
|
|
84
84
|
]
|
|
85
85
|
];
|
|
86
86
|
}
|
|
87
87
|
function $t(a) {
|
|
88
|
-
const [
|
|
89
|
-
return { x:
|
|
88
|
+
const [h, t] = a.geometry.coordinates[0];
|
|
89
|
+
return { x: h, y: t };
|
|
90
90
|
}
|
|
91
|
-
function Rt(a,
|
|
92
|
-
const [t, r] = a.geometry.coordinates[
|
|
91
|
+
function Rt(a, h) {
|
|
92
|
+
const [t, r] = a.geometry.coordinates[h === "start" ? 0 : 1];
|
|
93
93
|
return { x: t, y: r };
|
|
94
94
|
}
|
|
95
|
-
function
|
|
96
|
-
const [
|
|
97
|
-
return { x:
|
|
95
|
+
function Wt(a) {
|
|
96
|
+
const [h, t] = a.geometry.coordinates[1];
|
|
97
|
+
return { x: h, y: t };
|
|
98
98
|
}
|
|
99
|
-
function Re(a,
|
|
100
|
-
a.geometry.coordinates[0] = [
|
|
99
|
+
function Re(a, h, t) {
|
|
100
|
+
a.geometry.coordinates[0] = [h, t];
|
|
101
101
|
}
|
|
102
|
-
function Ve(a,
|
|
103
|
-
a.geometry.coordinates[1] = [
|
|
102
|
+
function Ve(a, h, t) {
|
|
103
|
+
a.geometry.coordinates[1] = [h, t];
|
|
104
104
|
}
|
|
105
105
|
function Yt(a) {
|
|
106
|
-
return { start: $t(a), end:
|
|
106
|
+
return { start: $t(a), end: Wt(a) };
|
|
107
107
|
}
|
|
108
|
-
function At(a,
|
|
109
|
-
|
|
108
|
+
function At(a, h, t, r) {
|
|
109
|
+
h === "start" ? Re(a, t, r) : Ve(a, t, r);
|
|
110
110
|
}
|
|
111
111
|
const Ue = (a) => parseInt(a.getAttribute("data-handle-id") || "-1");
|
|
112
|
-
function
|
|
113
|
-
return
|
|
114
|
-
(
|
|
112
|
+
function si(a) {
|
|
113
|
+
return Gt(a).reduce(
|
|
114
|
+
(h, t) => (h[0] = Math.min(t[0], h[0]), h[1] = Math.min(t[1], h[1]), h[2] = Math.max(t[0], h[2]), h[3] = Math.max(t[1], h[3]), h),
|
|
115
115
|
[
|
|
116
116
|
Number.POSITIVE_INFINITY,
|
|
117
117
|
Number.POSITIVE_INFINITY,
|
|
@@ -120,103 +120,119 @@ function ii(a) {
|
|
|
120
120
|
]
|
|
121
121
|
);
|
|
122
122
|
}
|
|
123
|
-
function
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
function jn(a) {
|
|
124
|
+
return Array.isArray(a) && a.length === 2 && a.every(isFinite);
|
|
125
|
+
}
|
|
126
|
+
function qn(a, h, t, r) {
|
|
127
|
+
for (let o = 0; o < a.coordinates.length; o++) {
|
|
128
|
+
const l = a.coordinates[o];
|
|
129
|
+
if (jn(l))
|
|
130
|
+
l[0] = t + (l[0] - t) * h, l[1] = r + (l[1] - r) * h;
|
|
131
|
+
else
|
|
132
|
+
for (let u = 0; u < l.length; u++) {
|
|
133
|
+
const d = l[u];
|
|
134
|
+
d[0] = t + (d[0] - t) * h, d[1] = r + (d[1] - r) * h;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return a;
|
|
138
|
+
}
|
|
139
|
+
function Gt(a) {
|
|
140
|
+
let h = [];
|
|
141
|
+
return a.type == "Point" ? h = [a.coordinates] : a.type == "LineString" || a.type == "MultiPoint" ? h = a.coordinates : a.type == "Polygon" || a.type == "MultiLineString" ? h = a.coordinates.reduce(function(t, r) {
|
|
126
142
|
return t.concat(r);
|
|
127
|
-
}, []) : a.type == "MultiPolygon" ?
|
|
128
|
-
(t, r) => t.concat(r.reduce((o,
|
|
143
|
+
}, []) : a.type == "MultiPolygon" ? h = a.coordinates.reduce(
|
|
144
|
+
(t, r) => t.concat(r.reduce((o, l) => o.concat(l), [])),
|
|
129
145
|
[]
|
|
130
|
-
) : a.type == "Feature" ?
|
|
131
|
-
(t, r) => t.concat(
|
|
146
|
+
) : a.type == "Feature" ? h = Gt(a.geometry) : a.type == "GeometryCollection" ? h = a.geometries.reduce(
|
|
147
|
+
(t, r) => t.concat(Gt(r)),
|
|
132
148
|
[]
|
|
133
|
-
) : a.type == "FeatureCollection" && (
|
|
134
|
-
(t, r) => t.concat(
|
|
149
|
+
) : a.type == "FeatureCollection" && (h = a.features.reduce(
|
|
150
|
+
(t, r) => t.concat(Gt(r)),
|
|
135
151
|
[]
|
|
136
|
-
)),
|
|
152
|
+
)), h;
|
|
137
153
|
}
|
|
138
|
-
function Vt(a,
|
|
139
|
-
const r = Math.atan2(a.y -
|
|
154
|
+
function Vt(a, h, t) {
|
|
155
|
+
const r = Math.atan2(a.y - h.y, a.x - h.x);
|
|
140
156
|
return {
|
|
141
|
-
x:
|
|
142
|
-
y:
|
|
157
|
+
x: h.x + t * Math.cos(r),
|
|
158
|
+
y: h.y + t * Math.sin(r)
|
|
143
159
|
};
|
|
144
160
|
}
|
|
145
|
-
function ue(a,
|
|
146
|
-
if (!
|
|
161
|
+
function ue(a, h) {
|
|
162
|
+
if (!h)
|
|
147
163
|
return { x: a.clientX, y: a.clientY };
|
|
148
|
-
const t =
|
|
164
|
+
const t = h.getBoundingClientRect();
|
|
149
165
|
return {
|
|
150
|
-
x: a.clientX - t.left -
|
|
151
|
-
y: a.clientY - t.top -
|
|
166
|
+
x: a.clientX - t.left - h.clientLeft,
|
|
167
|
+
y: a.clientY - t.top - h.clientTop
|
|
152
168
|
};
|
|
153
169
|
}
|
|
154
|
-
const vt = (a,
|
|
155
|
-
x: a.x -
|
|
156
|
-
y: a.y -
|
|
157
|
-
}), kt = (a) => Math.sqrt(a.x * a.x + a.y * a.y),
|
|
170
|
+
const vt = (a, h) => ({
|
|
171
|
+
x: a.x - h.x,
|
|
172
|
+
y: a.y - h.y
|
|
173
|
+
}), kt = (a) => Math.sqrt(a.x * a.x + a.y * a.y), Ge = (a) => ({
|
|
158
174
|
x: -a.x,
|
|
159
175
|
y: -a.y
|
|
160
|
-
}),
|
|
161
|
-
const
|
|
162
|
-
return
|
|
163
|
-
x: a.x /
|
|
164
|
-
y: a.y /
|
|
176
|
+
}), We = (a) => {
|
|
177
|
+
const h = kt(a);
|
|
178
|
+
return h === 0 ? { x: 0, y: 0 } : {
|
|
179
|
+
x: a.x / h,
|
|
180
|
+
y: a.y / h
|
|
165
181
|
};
|
|
166
|
-
}, Et = (a,
|
|
167
|
-
x: a.x +
|
|
168
|
-
y: a.y +
|
|
169
|
-
}), Ye = (a,
|
|
170
|
-
x: a.x *
|
|
171
|
-
y: a.y *
|
|
172
|
-
}), Ut = (a,
|
|
173
|
-
x: a.x *
|
|
174
|
-
y: a.y *
|
|
175
|
-
}), rt = (a,
|
|
176
|
-
const t = Math.sin(
|
|
182
|
+
}, Et = (a, h) => ({
|
|
183
|
+
x: a.x + h.x,
|
|
184
|
+
y: a.y + h.y
|
|
185
|
+
}), Ye = (a, h) => ({
|
|
186
|
+
x: a.x * h,
|
|
187
|
+
y: a.y * h
|
|
188
|
+
}), Ut = (a, h) => ({
|
|
189
|
+
x: a.x * h.x,
|
|
190
|
+
y: a.y * h.y
|
|
191
|
+
}), rt = (a, h) => {
|
|
192
|
+
const t = Math.sin(h), r = Math.cos(h);
|
|
177
193
|
return {
|
|
178
194
|
x: a.x * r - a.y * t,
|
|
179
195
|
y: a.x * t + a.y * r
|
|
180
196
|
};
|
|
181
|
-
},
|
|
182
|
-
x: a.x /
|
|
183
|
-
y: a.y /
|
|
184
|
-
}), Oe = (a,
|
|
185
|
-
function Xe(a,
|
|
197
|
+
}, Rn = (a, h) => ({
|
|
198
|
+
x: a.x / h,
|
|
199
|
+
y: a.y / h
|
|
200
|
+
}), Oe = (a, h) => a.x * h.x + a.y * h.y;
|
|
201
|
+
function Xe(a, h = 5, t = 30) {
|
|
186
202
|
var d;
|
|
187
|
-
const { start: r, end: o } = Yt(a),
|
|
188
|
-
return Math.min(t, Math.max(3 * u, kt(
|
|
203
|
+
const { start: r, end: o } = Yt(a), l = vt(o, r), u = a.properties.style && a.properties.style.strokeWidth ? (d = a.properties.style) == null ? void 0 : d.strokeWidth : 0;
|
|
204
|
+
return Math.min(t, Math.max(3 * u, kt(l) * 0.1, h));
|
|
189
205
|
}
|
|
190
|
-
function Le(a,
|
|
191
|
-
const o = Ye(We(
|
|
206
|
+
function Le(a, h, t, r) {
|
|
207
|
+
const o = Ye(Ge(We(h)), r);
|
|
192
208
|
if (!t || t === "none")
|
|
193
209
|
return "";
|
|
194
|
-
const
|
|
195
|
-
return `M ${
|
|
210
|
+
const l = Et(a, rt(o, Math.PI / 8)), u = Et(a, rt(o, -Math.PI / 8)), d = `${a.x} ${a.y}`;
|
|
211
|
+
return `M ${l.x} ${l.y} L ${d} ${u.x} ${u.y} ${t === "arrow" ? "" : `${l.x} ${l.y}`}`;
|
|
196
212
|
}
|
|
197
|
-
function
|
|
198
|
-
const { start:
|
|
213
|
+
function Vn(a, h, t, r, o) {
|
|
214
|
+
const { start: l, end: u } = Yt(a), { tail: d, head: g, strokeColor: f, strokeWidth: y } = a.properties.style || t, v = vt(u, l), T = Xe(a, r, o), A = Pt("path");
|
|
199
215
|
A.setAttribute("data-annotation", `${a.id}`), A.setAttribute("data-annotation-type", "arrow");
|
|
200
216
|
const b = g === "arrow-plain" || d === "arrow";
|
|
201
217
|
A.setAttribute("stroke", f || "none"), A.setAttribute("stroke-width", `${y}`), A.setAttribute("fill", b ? f || "" : "none"), A.setAttribute("stroke-linecap", "round"), A.setAttribute("stroke-linejoin", "round");
|
|
202
|
-
const C = Le(
|
|
203
|
-
A.setAttribute("d", $),
|
|
218
|
+
const C = Le(l, Ge(v), d, T), E = Le(u, v, g, T), $ = C + `M ${l.x} ${l.y} ${u.x} ${u.y}` + E;
|
|
219
|
+
A.setAttribute("d", $), h.appendChild(A);
|
|
204
220
|
}
|
|
205
|
-
const V = -1, Xt = "dragging", Zt = "dragstart", Tt = "dragend", de = "select", fe = "unselect",
|
|
206
|
-
var
|
|
221
|
+
const V = -1, Xt = "dragging", Zt = "dragstart", Tt = "dragend", de = "select", fe = "unselect", Un = "hover", Gn = "unhover", pe = "remove", ge = "add", Wn = "cancelDrawing", ye = "update", Yn = "link";
|
|
222
|
+
var Xn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
207
223
|
function Ze(a) {
|
|
208
224
|
return a && a.__esModule && Object.prototype.hasOwnProperty.call(a, "default") ? a.default : a;
|
|
209
225
|
}
|
|
210
226
|
var Ke = { exports: {} };
|
|
211
227
|
(function(a) {
|
|
212
|
-
var
|
|
228
|
+
var h = Object.prototype.hasOwnProperty, t = "~";
|
|
213
229
|
function r() {
|
|
214
230
|
}
|
|
215
231
|
Object.create && (r.prototype = /* @__PURE__ */ Object.create(null), new r().__proto__ || (t = !1));
|
|
216
232
|
function o(g, f, y) {
|
|
217
233
|
this.fn = g, this.context = f, this.once = y || !1;
|
|
218
234
|
}
|
|
219
|
-
function
|
|
235
|
+
function l(g, f, y, v, T) {
|
|
220
236
|
if (typeof y != "function")
|
|
221
237
|
throw new TypeError("The listener must be a function");
|
|
222
238
|
var A = new o(y, v || g, T), b = t ? t + f : f;
|
|
@@ -233,7 +249,7 @@ var Ke = { exports: {} };
|
|
|
233
249
|
if (this._eventsCount === 0)
|
|
234
250
|
return f;
|
|
235
251
|
for (v in y = this._events)
|
|
236
|
-
|
|
252
|
+
h.call(y, v) && f.push(t ? v.slice(1) : v);
|
|
237
253
|
return Object.getOwnPropertySymbols ? f.concat(Object.getOwnPropertySymbols(y)) : f;
|
|
238
254
|
}, d.prototype.listeners = function(f) {
|
|
239
255
|
var y = t ? t + f : f, v = this._events[y];
|
|
@@ -271,8 +287,8 @@ var Ke = { exports: {} };
|
|
|
271
287
|
N[_ - 1] = arguments[_];
|
|
272
288
|
E.fn.apply(E.context, N);
|
|
273
289
|
} else {
|
|
274
|
-
var
|
|
275
|
-
for (_ = 0; _ <
|
|
290
|
+
var G = E.length, W;
|
|
291
|
+
for (_ = 0; _ < G; _++)
|
|
276
292
|
switch (E[_].once && this.removeListener(f, E[_].fn, void 0, !0), $) {
|
|
277
293
|
case 1:
|
|
278
294
|
E[_].fn.call(E[_].context);
|
|
@@ -288,16 +304,16 @@ var Ke = { exports: {} };
|
|
|
288
304
|
break;
|
|
289
305
|
default:
|
|
290
306
|
if (!N)
|
|
291
|
-
for (
|
|
292
|
-
N[
|
|
307
|
+
for (W = 1, N = new Array($ - 1); W < $; W++)
|
|
308
|
+
N[W - 1] = arguments[W];
|
|
293
309
|
E[_].fn.apply(E[_].context, N);
|
|
294
310
|
}
|
|
295
311
|
}
|
|
296
312
|
return !0;
|
|
297
313
|
}, d.prototype.on = function(f, y, v) {
|
|
298
|
-
return
|
|
314
|
+
return l(this, f, y, v, !1);
|
|
299
315
|
}, d.prototype.once = function(f, y, v) {
|
|
300
|
-
return
|
|
316
|
+
return l(this, f, y, v, !0);
|
|
301
317
|
}, d.prototype.removeListener = function(f, y, v, T) {
|
|
302
318
|
var A = t ? t + f : f;
|
|
303
319
|
if (!this._events[A])
|
|
@@ -318,8 +334,8 @@ var Ke = { exports: {} };
|
|
|
318
334
|
return f ? (y = t ? t + f : f, this._events[y] && u(this, y)) : (this._events = new r(), this._eventsCount = 0), this;
|
|
319
335
|
}, d.prototype.off = d.prototype.removeListener, d.prototype.addListener = d.prototype.on, d.prefixed = t, d.EventEmitter = d, a.exports = d;
|
|
320
336
|
})(Ke);
|
|
321
|
-
var
|
|
322
|
-
const Je = /* @__PURE__ */ Ze(
|
|
337
|
+
var Zn = Ke.exports;
|
|
338
|
+
const Je = /* @__PURE__ */ Ze(Zn);
|
|
323
339
|
class Qe extends Je {
|
|
324
340
|
constructor(t, r) {
|
|
325
341
|
super();
|
|
@@ -387,6 +403,12 @@ class Qe extends Je {
|
|
|
387
403
|
geometry: r
|
|
388
404
|
});
|
|
389
405
|
}
|
|
406
|
+
scale(t, r, o, l) {
|
|
407
|
+
this.updateGeometry(
|
|
408
|
+
t,
|
|
409
|
+
qn(t.geometry, r, o, l)
|
|
410
|
+
);
|
|
411
|
+
}
|
|
390
412
|
/**
|
|
391
413
|
* @method update
|
|
392
414
|
* Updates an annotation (position, color etc)
|
|
@@ -401,9 +423,9 @@ class Qe extends Je {
|
|
|
401
423
|
if (!t)
|
|
402
424
|
return;
|
|
403
425
|
const o = t.id;
|
|
404
|
-
Object.keys(r).forEach((
|
|
405
|
-
if (
|
|
406
|
-
if (
|
|
426
|
+
Object.keys(r).forEach((l) => {
|
|
427
|
+
if (l !== "id")
|
|
428
|
+
if (l === "properties") {
|
|
407
429
|
const u = r.properties || { style: {} };
|
|
408
430
|
t.properties = {
|
|
409
431
|
...t.properties || {},
|
|
@@ -414,18 +436,18 @@ class Qe extends Je {
|
|
|
414
436
|
}
|
|
415
437
|
};
|
|
416
438
|
} else
|
|
417
|
-
|
|
439
|
+
l === "geometry" ? t.geometry = {
|
|
418
440
|
...t.geometry,
|
|
419
441
|
...r.geometry
|
|
420
|
-
} : t[
|
|
442
|
+
} : t[l] = r[l];
|
|
421
443
|
}), o === this.selectedId && this.refreshEditor(), this.layer.refresh();
|
|
422
444
|
}
|
|
423
445
|
getById(t) {
|
|
424
446
|
const r = Number(t);
|
|
425
447
|
for (let o = 0; o < this.elements.length; o++) {
|
|
426
|
-
const
|
|
427
|
-
if (!(
|
|
428
|
-
return
|
|
448
|
+
const l = this.elements[o];
|
|
449
|
+
if (!(l.id !== t && l.id !== r))
|
|
450
|
+
return l;
|
|
429
451
|
}
|
|
430
452
|
}
|
|
431
453
|
/**
|
|
@@ -439,7 +461,7 @@ class Qe extends Je {
|
|
|
439
461
|
}
|
|
440
462
|
hover(t) {
|
|
441
463
|
const r = this.getById(t);
|
|
442
|
-
r && (this.showeditorOnHover && this.editor.show(), this.hoveredId = t, this.refreshEditor(), this.layer.refresh(), this.emit(
|
|
464
|
+
r && (this.showeditorOnHover && this.editor.show(), this.hoveredId = t, this.refreshEditor(), this.layer.refresh(), this.emit(Un, r));
|
|
443
465
|
}
|
|
444
466
|
getSelectedFeature() {
|
|
445
467
|
return this.selectedId === V ? null : this.getById(this.selectedId);
|
|
@@ -450,7 +472,7 @@ class Qe extends Je {
|
|
|
450
472
|
}
|
|
451
473
|
unhover() {
|
|
452
474
|
const t = this.getById(this.hoveredId);
|
|
453
|
-
return this.emit(
|
|
475
|
+
return this.emit(Gn, t), this.hoveredId = V, this.selectedId === V && this.editor.hide(), this.layer.refresh(), this;
|
|
454
476
|
}
|
|
455
477
|
/**
|
|
456
478
|
* @method remove
|
|
@@ -510,7 +532,7 @@ class Qe extends Je {
|
|
|
510
532
|
}
|
|
511
533
|
}
|
|
512
534
|
const Ce = "handle-line", Pe = "handle-start", $e = "handle-end";
|
|
513
|
-
class
|
|
535
|
+
class Kn extends Qe {
|
|
514
536
|
constructor(t, r = {}) {
|
|
515
537
|
super(
|
|
516
538
|
t,
|
|
@@ -536,8 +558,8 @@ class Xn extends Qe {
|
|
|
536
558
|
const r = this.getById(this.selectedId) || this.getById(this.hoveredId);
|
|
537
559
|
if (!r)
|
|
538
560
|
return;
|
|
539
|
-
const { x: o, y:
|
|
540
|
-
this.startDragging(r, o,
|
|
561
|
+
const { x: o, y: l } = ue(t, this.ogma.getContainer());
|
|
562
|
+
this.startDragging(r, o, l), this.draggedHandle = Ue(t.target);
|
|
541
563
|
});
|
|
542
564
|
m(this, "onMouseUp", () => {
|
|
543
565
|
this.draggedHandle !== -1 && (this.restoreDragging(), this.isDragging = !1, this.draggedHandle = V, this.emit(Tt, this.arrow));
|
|
@@ -545,14 +567,14 @@ class Xn extends Qe {
|
|
|
545
567
|
m(this, "onMouseMove", (t) => {
|
|
546
568
|
if (!this.isDragging || this.draggedHandle === V)
|
|
547
569
|
return;
|
|
548
|
-
const r = this.handles[this.draggedHandle], o = this.ogma.view.getAngle(), { x:
|
|
549
|
-
|
|
570
|
+
const r = this.handles[this.draggedHandle], o = this.ogma.view.getAngle(), { x: l, y: u } = rt(
|
|
571
|
+
Rn(
|
|
550
572
|
{ x: t.clientX - this.startX, y: t.clientY - this.startY },
|
|
551
573
|
this.ogma.view.getZoom()
|
|
552
574
|
),
|
|
553
575
|
o
|
|
554
576
|
), d = r.id === Ce, g = r.id === Pe, f = r.id === $e;
|
|
555
|
-
(d || g) && Re(this.arrow, this.start.x +
|
|
577
|
+
(d || g) && Re(this.arrow, this.start.x + l, this.start.y + u), (d || f) && Ve(this.arrow, this.end.x + l, this.end.y + u), this.emit(
|
|
556
578
|
Xt,
|
|
557
579
|
this.arrow,
|
|
558
580
|
d ? "line" : g ? "start" : "end"
|
|
@@ -573,42 +595,42 @@ class Xn extends Qe {
|
|
|
573
595
|
startDrawing(t, r, o = Nn(t, r, t, r, zt)) {
|
|
574
596
|
var d;
|
|
575
597
|
this.disableDragging(), this.add(o), this.hoveredId = o.id;
|
|
576
|
-
const
|
|
598
|
+
const l = this.ogma.view.graphToScreenCoordinates({ x: t, y: r }), u = ((d = this.ogma.getContainer()) == null ? void 0 : d.getBoundingClientRect()) || {
|
|
577
599
|
left: 0,
|
|
578
600
|
top: 0
|
|
579
601
|
};
|
|
580
602
|
this.startDragging(
|
|
581
603
|
this.getById(o.id),
|
|
582
|
-
|
|
583
|
-
|
|
604
|
+
l.x + (u == null ? void 0 : u.left),
|
|
605
|
+
l.y + u.top
|
|
584
606
|
), this.draggedHandle = 2;
|
|
585
607
|
}
|
|
586
608
|
cancelDrawing() {
|
|
587
609
|
this.isDragging && (this.remove(this.arrow.id), this.emit(Tt, this.arrow), this.restoreDragging(), this.isDragging = !1, this.draggedHandle = V);
|
|
588
610
|
}
|
|
589
611
|
startDragging(t, r, o) {
|
|
590
|
-
this.selectedId !== t.id && this.select(this.hoveredId), this.arrow = t, this.startX = r, this.startY = o, this.start = $t(this.arrow), this.end =
|
|
612
|
+
this.selectedId !== t.id && this.select(this.hoveredId), this.arrow = t, this.startX = r, this.startY = o, this.start = $t(this.arrow), this.end = Wt(this.arrow), this.disableDragging(), this.emit(Zt, this.arrow), this.isDragging = !0;
|
|
591
613
|
}
|
|
592
614
|
detect(t, r = 0) {
|
|
593
615
|
return this.elements.find((o) => {
|
|
594
|
-
const { start:
|
|
595
|
-
x: (
|
|
596
|
-
y: (
|
|
597
|
-
}), g = vt(u,
|
|
616
|
+
const { start: l, end: u } = Yt(o), d = vt(t, {
|
|
617
|
+
x: (l.x + u.x) / 2,
|
|
618
|
+
y: (l.y + u.y) / 2
|
|
619
|
+
}), g = vt(u, l), f = kt(g), y = We(g), v = Xe(o);
|
|
598
620
|
return Math.abs(Oe(y, d)) < f / 2 + r && Math.abs(Oe(rt(y, Math.PI / 2), d)) < v / 2 + r;
|
|
599
621
|
});
|
|
600
622
|
}
|
|
601
623
|
refreshEditor() {
|
|
602
624
|
if (+this.selectedId < 0 && +this.hoveredId < 0)
|
|
603
625
|
return;
|
|
604
|
-
const t = this.selectedId !== V ? this.getById(this.selectedId) : this.getById(this.hoveredId), r = Yt(t), o = this.ogma.view.graphToScreenCoordinates(r.start),
|
|
626
|
+
const t = this.selectedId !== V ? this.getById(this.selectedId) : this.getById(this.hoveredId), r = Yt(t), o = this.ogma.view.graphToScreenCoordinates(r.start), l = this.ogma.view.graphToScreenCoordinates(r.end), [u, d, g] = Array.prototype.slice.call(
|
|
605
627
|
this.editor.element.querySelectorAll(".handle")
|
|
606
628
|
);
|
|
607
|
-
d.style.transform = `translate(${o.x}px, ${o.y}px) translate(-50%, -50%)`, g.style.transform = `translate(${
|
|
629
|
+
d.style.transform = `translate(${o.x}px, ${o.y}px) translate(-50%, -50%)`, g.style.transform = `translate(${l.x}px, ${l.y}px) translate(-50%, -50%)`;
|
|
608
630
|
const f = {
|
|
609
|
-
x: (
|
|
610
|
-
y: (
|
|
611
|
-
}, y = vt(
|
|
631
|
+
x: (l.x + o.x) / 2,
|
|
632
|
+
y: (l.y + o.y) / 2
|
|
633
|
+
}, y = vt(l, o), v = Ye(y, 1 / kt(y)), T = Math.atan2(v.y, v.x);
|
|
612
634
|
u.style.width = `${kt(y)}px`, u.style.left = `${f.x}px`, u.style.top = `${f.y}px`, u.style.transform = `translate(-50%, -50%) rotate(${T}rad)`;
|
|
613
635
|
}
|
|
614
636
|
getDefaultOptions() {
|
|
@@ -618,12 +640,12 @@ class Xn extends Qe {
|
|
|
618
640
|
t.innerHTML = "";
|
|
619
641
|
const r = Pt("g"), o = this.ogma.view.getAngle();
|
|
620
642
|
r.setAttribute("transform", `rotate(${-o * (180 / Math.PI)})`), this.elements.forEach(
|
|
621
|
-
(
|
|
643
|
+
(l) => Vn(l, r, zt, this.minArrowHeight, this.maxArrowHeight)
|
|
622
644
|
), t.appendChild(r);
|
|
623
645
|
}
|
|
624
646
|
refreshDrawing() {
|
|
625
647
|
const t = this.ogma.view.getAngle();
|
|
626
|
-
this.layer.element.children[0].setAttribute(
|
|
648
|
+
this.layer.element !== null && this.layer.element.children[0].setAttribute(
|
|
627
649
|
"transform",
|
|
628
650
|
`rotate(${-t * (180 / Math.PI)})`
|
|
629
651
|
);
|
|
@@ -665,32 +687,32 @@ const St = {
|
|
|
665
687
|
}, ze = {
|
|
666
688
|
handleSize: 3.5,
|
|
667
689
|
placeholder: "Your text..."
|
|
668
|
-
},
|
|
690
|
+
}, Jn = (a = 0, h = 0, t = 100, r = 50, o = "", l = { ...St }) => ({
|
|
669
691
|
id: Kt(),
|
|
670
692
|
type: "Feature",
|
|
671
693
|
properties: {
|
|
672
694
|
type: "text",
|
|
673
695
|
content: o,
|
|
674
|
-
style: { ...St, ...
|
|
696
|
+
style: { ...St, ...l }
|
|
675
697
|
},
|
|
676
698
|
geometry: {
|
|
677
699
|
type: "Polygon",
|
|
678
700
|
coordinates: [
|
|
679
701
|
[
|
|
680
|
-
[a,
|
|
681
|
-
[a + t,
|
|
682
|
-
[a + t,
|
|
683
|
-
[a,
|
|
684
|
-
[a,
|
|
702
|
+
[a, h],
|
|
703
|
+
[a + t, h],
|
|
704
|
+
[a + t, h + r],
|
|
705
|
+
[a, h + r],
|
|
706
|
+
[a, h]
|
|
685
707
|
]
|
|
686
708
|
]
|
|
687
709
|
}
|
|
688
710
|
});
|
|
689
711
|
var tn = { exports: {} };
|
|
690
|
-
(function(a,
|
|
712
|
+
(function(a, h) {
|
|
691
713
|
(function(t, r) {
|
|
692
714
|
a.exports = r();
|
|
693
|
-
})(
|
|
715
|
+
})(Xn, () => (() => {
|
|
694
716
|
var t = { d: (e, n) => {
|
|
695
717
|
for (var s in n)
|
|
696
718
|
t.o(n, s) && !t.o(e, s) && Object.defineProperty(e, s, { enumerable: !0, get: n[s] });
|
|
@@ -703,14 +725,14 @@ var tn = { exports: {} };
|
|
|
703
725
|
}, o(e);
|
|
704
726
|
}
|
|
705
727
|
t.d(r, { default: () => Cn });
|
|
706
|
-
var
|
|
728
|
+
var l = /^((?:[a-z\d-]+\s+)*)([\d.]+(%|em|px)|(?:x+-)?large|(?:x+-)?small|medium)(?:\s*\/\s*(normal|[\d.]+(%|px|em)?))?(\s.+)?$/, u = /\bsmall-caps\b/, d = /\b(?:italic|oblique)\b/, g = /\bbold(?:er)?\b/, f = 13.3333333, y = { "xx-small": 9, "x-small": 10, smaller: 13.3333, small: 13, medium: 16, large: 18, larger: 19.2, "x-large": 24, "xx-large": 32 };
|
|
707
729
|
function v(e) {
|
|
708
730
|
var n = "", s = this;
|
|
709
731
|
return s.style && s.style !== "normal" && (n += s.style), s.variant && s.variant !== "normal" && (n += (n ? " " : "") + s.variant), s.weight && s.weight !== "normal" && (n += (n ? " " : "") + s.weight), s.size && (n += (n ? " " : "") + s.size + "px", s.height !== s.size && (n += "/" + s.height + "px")), s.family && (n += (n ? " " : "") + s.family), e && (n += "::" + s.baseline), e && (n += "::" + s.color), n;
|
|
710
732
|
}
|
|
711
733
|
var T = { id: "", family: "sans-serif", height: 14, size: 12, variant: "", style: "", weight: "", baseline: "", color: null, toString: v, valueOf: v };
|
|
712
734
|
function A(e) {
|
|
713
|
-
var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, s =
|
|
735
|
+
var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, s = l.exec(e);
|
|
714
736
|
n.family = (s[6] || "").trim();
|
|
715
737
|
var i = y[s[2]] || parseFloat(s[2]);
|
|
716
738
|
s[3] === "%" ? i *= 0.16 : s[3] === "em" ? i *= 16 : s[3] === "pt" && (i *= f), n.size = i;
|
|
@@ -754,7 +776,7 @@ var tn = { exports: {} };
|
|
|
754
776
|
}
|
|
755
777
|
return e.length * E[n].size;
|
|
756
778
|
}), N = {}, _ = { trim: !0, collapse: !0 };
|
|
757
|
-
function
|
|
779
|
+
function G(e, n, s) {
|
|
758
780
|
var i = Object.assign({}, _, s), c = String(e);
|
|
759
781
|
if (!c)
|
|
760
782
|
return 0;
|
|
@@ -764,12 +786,12 @@ var tn = { exports: {} };
|
|
|
764
786
|
}
|
|
765
787
|
return i.trim && i.collapse ? i.trim ? c = c.trim() : i.collapse && (c = c.replace(/\s+/g, " ")) : c = c.replace(/\n/g, " "), $(c, n) + n.size * (e.tracking || 0);
|
|
766
788
|
}
|
|
767
|
-
function
|
|
768
|
-
return
|
|
789
|
+
function W(e) {
|
|
790
|
+
return W = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
|
|
769
791
|
return typeof n;
|
|
770
792
|
} : function(n) {
|
|
771
793
|
return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
|
|
772
|
-
},
|
|
794
|
+
}, W(e);
|
|
773
795
|
}
|
|
774
796
|
function _t(e, n) {
|
|
775
797
|
if (typeof n != "function" && n !== null)
|
|
@@ -805,7 +827,7 @@ var tn = { exports: {} };
|
|
|
805
827
|
};
|
|
806
828
|
}
|
|
807
829
|
function en(e, n) {
|
|
808
|
-
if (n && (
|
|
830
|
+
if (n && (W(n) === "object" || typeof n == "function"))
|
|
809
831
|
return n;
|
|
810
832
|
if (n !== void 0)
|
|
811
833
|
throw new TypeError("Derived constructors may only return object or undefined");
|
|
@@ -828,17 +850,17 @@ var tn = { exports: {} };
|
|
|
828
850
|
for (var s = 0; s < n.length; s++) {
|
|
829
851
|
var i = n[s];
|
|
830
852
|
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, (c = function(p, w) {
|
|
831
|
-
if (
|
|
853
|
+
if (W(p) !== "object" || p === null)
|
|
832
854
|
return p;
|
|
833
855
|
var x = p[Symbol.toPrimitive];
|
|
834
856
|
if (x !== void 0) {
|
|
835
857
|
var k = x.call(p, w);
|
|
836
|
-
if (
|
|
858
|
+
if (W(k) !== "object")
|
|
837
859
|
return k;
|
|
838
860
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
839
861
|
}
|
|
840
862
|
return String(p);
|
|
841
|
-
}(i.key, "string"),
|
|
863
|
+
}(i.key, "string"), W(c) === "symbol" ? c : String(c)), i);
|
|
842
864
|
}
|
|
843
865
|
var c;
|
|
844
866
|
}
|
|
@@ -872,7 +894,7 @@ var tn = { exports: {} };
|
|
|
872
894
|
return Ht(this, s), n.apply(this, arguments);
|
|
873
895
|
}
|
|
874
896
|
return Ft(s);
|
|
875
|
-
}(F),
|
|
897
|
+
}(F), gt = function(e) {
|
|
876
898
|
_t(s, e);
|
|
877
899
|
var n = Jt(s);
|
|
878
900
|
function s() {
|
|
@@ -887,7 +909,7 @@ var tn = { exports: {} };
|
|
|
887
909
|
var S = Qt.test(p), M = Qt.test(s), O = M || S, I = void 0;
|
|
888
910
|
if ((sn.test(s) && !ve.test(p) || rn.test(p + i) && !ve.test(s)) && (O = !0), p !== "-" && p !== "‐" && p !== "–" && p !== "—" || ((I = Qt.test(e.charAt(x - 2))) && !M && (O = !1), !I && nn.test(s + i) && (O = !0)), O) {
|
|
889
911
|
var L = e.slice(w, x);
|
|
890
|
-
/\u00AD$/.test(L) ? (c.push(new F(L.slice(0, -1))), c.push(new
|
|
912
|
+
/\u00AD$/.test(L) ? (c.push(new F(L.slice(0, -1))), c.push(new gt())) : (c.push(new F(L)), c.push(new Dt())), w = x;
|
|
891
913
|
}
|
|
892
914
|
p = s;
|
|
893
915
|
}
|
|
@@ -980,8 +1002,8 @@ var tn = { exports: {} };
|
|
|
980
1002
|
}
|
|
981
1003
|
function Ee(e, n, s) {
|
|
982
1004
|
for (var i, c, p = e.width; p + s.width > n && e.length; )
|
|
983
|
-
c = (i = e[e.length - 1]).width, i.width > s.width ? (i.value = i.value.slice(0, -1), i.width =
|
|
984
|
-
e[e.length - 1] instanceof
|
|
1005
|
+
c = (i = e[e.length - 1]).width, i.width > s.width ? (i.value = i.value.slice(0, -1), i.width = G(i, i.font), p += i.width) : e.pop(), p -= c;
|
|
1006
|
+
e[e.length - 1] instanceof gt && e.pop(), i = e[e.length - 1] || i || {}, s.font = b(s.font, i.bold, i.italic, ""), s.href = e.length ? i.href : null, s.rel = e.length ? i.rel : null, s.target = e.length ? i.target : null, e.push(s);
|
|
985
1007
|
}
|
|
986
1008
|
function xt(e) {
|
|
987
1009
|
return Math.round(1e6 * e) / 1e6;
|
|
@@ -1026,17 +1048,17 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1026
1048
|
w === "right" ? j = O : w === "center" && (j = O / 2);
|
|
1027
1049
|
for (var H = [], Q = "tspan", Y = null, q = "", D = function() {
|
|
1028
1050
|
if (q) {
|
|
1029
|
-
var
|
|
1030
|
-
H.push(
|
|
1051
|
+
var yt = x(Q, Y, q);
|
|
1052
|
+
H.push(yt);
|
|
1031
1053
|
}
|
|
1032
1054
|
Q = "tspan", Y = null, q = "";
|
|
1033
1055
|
}, nt = 0, tt = e.length; nt < tt; nt++) {
|
|
1034
|
-
var at = "", dt = "",
|
|
1056
|
+
var at = "", dt = "", ot = 0, lt = e[nt];
|
|
1035
1057
|
if (lt.length) {
|
|
1036
1058
|
H = [];
|
|
1037
1059
|
for (var wt = 0, Lt = 0, ht = void 0, X = 0, jt = lt.length; X < jt; X++) {
|
|
1038
1060
|
var R = lt[X], Z = R.font;
|
|
1039
|
-
R.whitespace && wt++, Lt += R.width, X && !R.tracking && !
|
|
1061
|
+
R.whitespace && wt++, Lt += R.width, X && !R.tracking && !ot && ee(Z.id, at) && ee(R.class, dt) && ee(ht, R.href) ? q += R.value : (D(), q = R.value, Y = { fontFamily: Z.family !== p ? Z.family : null, fontSize: Z.size !== c ? Z.size : null, fontWeight: Z.weight || null, fontStyle: Z.style || null, fontVariant: Z.variant !== "normal" && Z.variant || null, fill: Z.color || null, baselineShift: Z.baseline ? 100 * Z.baseline + "%" : null, className: R.class || null }, ot && (Y.dx = xt(ot), ot = 0), R.tracking && (ot = Z.size * R.tracking), R.href && !ht ? (ht = R.href, Q = "a", Y.href = ht, Y.rel = R.rel, Y.target = R.target) : ht = null, at = Z.id, dt = R.class);
|
|
1040
1062
|
}
|
|
1041
1063
|
if (D(), I)
|
|
1042
1064
|
s.push.apply(s, ke(H));
|
|
@@ -1068,8 +1090,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1068
1090
|
M && B.length > 1 && !Y && (Q = (k - H) / j), B.forEach(function(q) {
|
|
1069
1091
|
s.font = q.font;
|
|
1070
1092
|
var D = q.font, nt = D.baseline ? p * -D.baseline + 0.15 * p : 0;
|
|
1071
|
-
s.fillStyle = function(dt,
|
|
1072
|
-
return dt.color ? dt.color :
|
|
1093
|
+
s.fillStyle = function(dt, ot) {
|
|
1094
|
+
return dt.color ? dt.color : ot.href ? "#00C" : "#000";
|
|
1073
1095
|
}(D, q);
|
|
1074
1096
|
var tt = 0;
|
|
1075
1097
|
if (S === "right" ? tt += k - H : S === "center" ? tt += k / 2 - H / 2 : S === "justify" && (q.whitespace || q instanceof et) && (z += Q), s.fillText(q.value, z + tt, P + nt), q.href) {
|
|
@@ -1150,10 +1172,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1150
1172
|
return [];
|
|
1151
1173
|
for (var P = 0, j = 0, H = 0, Q = [], Y = [], q = !1; P < k.length && j < z; ) {
|
|
1152
1174
|
var D = k[P], nt = An(D, M);
|
|
1153
|
-
if (D.width =
|
|
1175
|
+
if (D.width = G(D, nt), D.font = nt, D.line = j, D.whitespace = D.value in C, D.value && (D.value = D.value.replace(bn, " ")), !(!H && D.whitespace || q && D.whitespace))
|
|
1154
1176
|
if (D instanceof et)
|
|
1155
1177
|
H = 0, Y = [], Q.push(P + 1), j++;
|
|
1156
|
-
else if (D instanceof Dt || D instanceof
|
|
1178
|
+
else if (D instanceof Dt || D instanceof gt)
|
|
1157
1179
|
Y.push({ index: P, width: H });
|
|
1158
1180
|
else if (D.whitespace || H + D.width < I(j))
|
|
1159
1181
|
H += D.width;
|
|
@@ -1161,8 +1183,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1161
1183
|
var tt = void 0, at = void 0;
|
|
1162
1184
|
do {
|
|
1163
1185
|
at = !0, tt = Y.pop();
|
|
1164
|
-
var dt = k[tt.index],
|
|
1165
|
-
dt instanceof
|
|
1186
|
+
var dt = k[tt.index], ot = void 0;
|
|
1187
|
+
dt instanceof gt && (ot = G("-", dt.font), tt.width + ot > I(j) && (at = !Y.length));
|
|
1166
1188
|
} while (!at);
|
|
1167
1189
|
Q.push(tt.index + 1), H = 0, j++, P = tt.index, Y = [];
|
|
1168
1190
|
} else if (B === "break-word") {
|
|
@@ -1170,7 +1192,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1170
1192
|
if (H + D.width > lt) {
|
|
1171
1193
|
var wt = D.clone();
|
|
1172
1194
|
do
|
|
1173
|
-
D.value = D.value.slice(0, -1), D.width =
|
|
1195
|
+
D.value = D.value.slice(0, -1), D.width = G(D, D.font), H += D.width;
|
|
1174
1196
|
while (D.value && D.width > lt);
|
|
1175
1197
|
wt.value = wt.value.slice(D.value.length), k.splice(P + 1, 0, new Dt(), wt);
|
|
1176
1198
|
}
|
|
@@ -1180,13 +1202,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1180
1202
|
P++, q = D.whitespace;
|
|
1181
1203
|
}
|
|
1182
1204
|
P !== Q[Q.length - 1] && Q.push(P);
|
|
1183
|
-
var Lt = 0, ht = 0, X = Q.map(function(
|
|
1184
|
-
for (var K,
|
|
1185
|
-
|
|
1186
|
-
for (var ft =
|
|
1205
|
+
var Lt = 0, ht = 0, X = Q.map(function(yt) {
|
|
1206
|
+
for (var K, mt = Lt; (K = k[mt]) && (K.whitespace || !K.value); )
|
|
1207
|
+
mt++;
|
|
1208
|
+
for (var ft = yt, oe = null; ft > mt && (K = k[ft - 1]) && (K.whitespace || !(K.value || K instanceof gt)); )
|
|
1187
1209
|
K instanceof et && (oe = K), ft--;
|
|
1188
|
-
K instanceof
|
|
1189
|
-
var bt = k.slice(
|
|
1210
|
+
K instanceof gt && (K.value = "-", K.width = G("-", K.font)), Lt = yt;
|
|
1211
|
+
var bt = k.slice(mt, ft).filter(function(ae) {
|
|
1190
1212
|
return ae.value;
|
|
1191
1213
|
});
|
|
1192
1214
|
return oe && bt.push(oe), bt.width = bt.reduce(function(ae, Pn) {
|
|
@@ -1195,18 +1217,18 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1195
1217
|
});
|
|
1196
1218
|
if (X.hasLineOverflow = !1, L) {
|
|
1197
1219
|
var jt = L === "ellipsis" ? "…" : L;
|
|
1198
|
-
X.forEach(function(
|
|
1199
|
-
var
|
|
1200
|
-
if (
|
|
1220
|
+
X.forEach(function(yt, K) {
|
|
1221
|
+
var mt = I(K);
|
|
1222
|
+
if (yt.width > mt) {
|
|
1201
1223
|
var ft = new F(jt);
|
|
1202
|
-
ft.font = M, ft.width =
|
|
1224
|
+
ft.font = M, ft.width = G(jt, J), Ee(yt, mt, ft), X.hasLineOverflow = !0;
|
|
1203
1225
|
}
|
|
1204
1226
|
});
|
|
1205
1227
|
}
|
|
1206
1228
|
var R = S.overflow() === "ellipsis" ? "…" : S.overflow();
|
|
1207
1229
|
if (R && P !== k.length) {
|
|
1208
1230
|
var Z = I(X.length - 1), qt = X[X.length - 1], Ct = new F(R);
|
|
1209
|
-
Ct.font = M, Ct.width =
|
|
1231
|
+
Ct.font = M, Ct.width = G(R, J), Ee(qt, Z, Ct), X.hasOverflow = !0;
|
|
1210
1232
|
} else
|
|
1211
1233
|
X.hasOverflow = !1;
|
|
1212
1234
|
return X.font = M, X.width = ht, X;
|
|
@@ -1483,28 +1505,28 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1483
1505
|
}
|
|
1484
1506
|
return c;
|
|
1485
1507
|
}, it.measureText = function(e, n, s) {
|
|
1486
|
-
return
|
|
1487
|
-
}, it.Token = F, it.Break = Dt, it.LineBreak = et, it.SoftHyphen =
|
|
1508
|
+
return G(e, b(n), s);
|
|
1509
|
+
}, it.Token = F, it.Break = Dt, it.LineBreak = et, it.SoftHyphen = gt, it.Rotator = _e, _e.createElement = De;
|
|
1488
1510
|
const Cn = it;
|
|
1489
1511
|
return r.default;
|
|
1490
1512
|
})());
|
|
1491
1513
|
})(tn);
|
|
1492
|
-
var
|
|
1493
|
-
const Ne = /* @__PURE__ */ Ze(
|
|
1514
|
+
var Qn = tn.exports;
|
|
1515
|
+
const Ne = /* @__PURE__ */ Ze(Qn);
|
|
1494
1516
|
function he(a) {
|
|
1495
1517
|
return a.replace(/…$/, "");
|
|
1496
1518
|
}
|
|
1497
1519
|
function ce(a) {
|
|
1498
1520
|
return a.children[0].innerHTML;
|
|
1499
1521
|
}
|
|
1500
|
-
function
|
|
1501
|
-
const t = ut(a), { fontSize: r, font: o, padding:
|
|
1522
|
+
function ti(a, h) {
|
|
1523
|
+
const t = ut(a), { fontSize: r, font: o, padding: l = 0 } = a.properties.style || {};
|
|
1502
1524
|
if (t.width === t.height && t.width === 0)
|
|
1503
1525
|
return;
|
|
1504
1526
|
const u = new Ne({
|
|
1505
1527
|
font: `${r}px/${r}px ${o}`.replace(/(px)+/g, "px"),
|
|
1506
|
-
width: t.width -
|
|
1507
|
-
height: t.height -
|
|
1528
|
+
width: t.width - l * 2,
|
|
1529
|
+
height: t.height - l * 2,
|
|
1508
1530
|
align: "left",
|
|
1509
1531
|
valign: "top",
|
|
1510
1532
|
x: 0,
|
|
@@ -1533,7 +1555,7 @@ function Jn(a, l) {
|
|
|
1533
1555
|
}
|
|
1534
1556
|
}), v.forEach((b) => g.removeChild(f[b]));
|
|
1535
1557
|
const T = a.properties.content.match(/(https?:\/\/.*)/gm), A = T ? T.map((b) => b.split(" ")[0]) : [];
|
|
1536
|
-
g.setAttribute("transform", `translate(${
|
|
1558
|
+
g.setAttribute("transform", `translate(${l}, ${l})`), A.forEach((b) => {
|
|
1537
1559
|
let C = b;
|
|
1538
1560
|
const E = [];
|
|
1539
1561
|
for (; C.length > 0; ) {
|
|
@@ -1550,10 +1572,10 @@ function Jn(a, l) {
|
|
|
1550
1572
|
const N = document.createElementNS("http://www.w3.org/2000/svg", "a");
|
|
1551
1573
|
N.setAttribute("href", b), N.setAttribute("target", "_blank"), N.innerHTML = ce($), $.children[0].innerHTML = "", $.children[0].appendChild(N);
|
|
1552
1574
|
});
|
|
1553
|
-
}),
|
|
1575
|
+
}), h.appendChild(g);
|
|
1554
1576
|
}
|
|
1555
1577
|
const He = 20;
|
|
1556
|
-
class
|
|
1578
|
+
class ei extends Qe {
|
|
1557
1579
|
constructor(t, r = {}) {
|
|
1558
1580
|
super(
|
|
1559
1581
|
t,
|
|
@@ -1587,26 +1609,26 @@ class Qn extends Qe {
|
|
|
1587
1609
|
m(this, "_onBlur", () => {
|
|
1588
1610
|
this.isFocused = !1;
|
|
1589
1611
|
});
|
|
1590
|
-
m(this, "startDrawing", (t, r, o =
|
|
1612
|
+
m(this, "startDrawing", (t, r, o = Jn(t, r, 0, 0, "", St)) => {
|
|
1591
1613
|
this.add(o);
|
|
1592
|
-
const
|
|
1593
|
-
this.select(o.id), this.startDragging(this.getById(o.id),
|
|
1614
|
+
const l = this.ogma.view.graphToScreenCoordinates({ x: t, y: r });
|
|
1615
|
+
this.select(o.id), this.startDragging(this.getById(o.id), l.x, l.y), this.draggedHandle = 6;
|
|
1594
1616
|
});
|
|
1595
1617
|
m(this, "cancelDrawing", () => {
|
|
1596
1618
|
this.isDragging && (this.remove(this.annotation.id), this.annotation = { ...le }, this.draggedHandle = V, this.isDragging = !1, this.emit(Tt, this.annotation));
|
|
1597
1619
|
});
|
|
1598
1620
|
m(this, "startDragging", (t, r, o) => {
|
|
1599
1621
|
this.annotation = t;
|
|
1600
|
-
const
|
|
1601
|
-
this.rect.x =
|
|
1622
|
+
const l = ct(this.annotation), u = ut(this.annotation);
|
|
1623
|
+
this.rect.x = l.x, this.rect.y = l.y, this.rect.width = u.width, this.rect.height = u.height, this.startX = r, this.startY = o, this.disableDragging(), this.textArea.classList.add("noevents"), this.textArea.setAttribute("disabled", "disabled"), this.emit(Zt, this.annotation), this.isDragging = !0;
|
|
1602
1624
|
});
|
|
1603
1625
|
m(this, "onHandleMouseDown", (t) => {
|
|
1604
1626
|
const r = this.getById(this.selectedId) || this.getById(this.hoveredId);
|
|
1605
1627
|
if (!r)
|
|
1606
1628
|
return;
|
|
1607
1629
|
this.selectedId !== r.id && this.select(this.hoveredId);
|
|
1608
|
-
const { x: o, y:
|
|
1609
|
-
this.startDragging(r, o,
|
|
1630
|
+
const { x: o, y: l } = ue(t, this.ogma.getContainer());
|
|
1631
|
+
this.startDragging(r, o, l), this.draggedHandle = Ue(t.target);
|
|
1610
1632
|
});
|
|
1611
1633
|
m(this, "onMouseMove", (t) => {
|
|
1612
1634
|
requestAnimationFrame(() => this._onMouseMove(t));
|
|
@@ -1615,13 +1637,13 @@ class Qn extends Qe {
|
|
|
1615
1637
|
if (!this.isDragging)
|
|
1616
1638
|
return;
|
|
1617
1639
|
t.stopPropagation(), t.preventDefault();
|
|
1618
|
-
const r = this.handles[this.draggedHandle], o = r.classList.contains("top"),
|
|
1640
|
+
const r = this.handles[this.draggedHandle], o = r.classList.contains("top"), l = r.classList.contains("left"), u = r.classList.contains("right"), d = r.classList.contains("bottom"), g = r.classList.contains("line-handle"), { x: f, y } = ue(
|
|
1619
1641
|
t,
|
|
1620
1642
|
this.ogma.getContainer()
|
|
1621
1643
|
), v = this.ogma.view.getZoom(), T = (f - this.startX) / v, A = (y - this.startY) / v, b = this.ogma.view.getAngle(), C = rt({ x: T, y: A }, b);
|
|
1622
|
-
(d &&
|
|
1623
|
-
const E =
|
|
1624
|
-
this.rect.width + T * (g ||
|
|
1644
|
+
(d && l || o && u) && (C.y = 0, C.x = 0);
|
|
1645
|
+
const E = l || g ? this.rect.x + C.x : this.rect.x, $ = o || g ? this.rect.y + C.y : this.rect.y, N = Math.max(
|
|
1646
|
+
this.rect.width + T * (g || l ? 0 : 1),
|
|
1625
1647
|
He
|
|
1626
1648
|
), _ = Math.max(
|
|
1627
1649
|
this.rect.height + A * (g || o ? 0 : 1),
|
|
@@ -1648,16 +1670,16 @@ class Qn extends Qe {
|
|
|
1648
1670
|
o.addEventListener("input", this._onInput), o.addEventListener("focus", this._onFocus), o.addEventListener("blur", this._onBlur), o.addEventListener("mousedown", this._onMousedown), o.spellcheck = !1, this.handles = Array.prototype.slice.call(
|
|
1649
1671
|
this.editor.element.querySelectorAll(".annotation-text-handle > .handle")
|
|
1650
1672
|
), this.handles.forEach(
|
|
1651
|
-
(
|
|
1673
|
+
(l) => l.addEventListener("mousedown", this.onHandleMouseDown)
|
|
1652
1674
|
), document.addEventListener("mouseup", this.onMouseUp), document.addEventListener("mousemove", this.onMouseMove, !0), t.events.on(["viewChanged", "zoom"], this.onViewChanged);
|
|
1653
1675
|
}
|
|
1654
1676
|
_canRemove() {
|
|
1655
1677
|
return !this.isFocused;
|
|
1656
1678
|
}
|
|
1657
1679
|
detect({ x: t, y: r }, o = 0) {
|
|
1658
|
-
const
|
|
1680
|
+
const l = { x: t, y: r }, u = this.ogma.view.getAngle();
|
|
1659
1681
|
return this.elements.find((d) => {
|
|
1660
|
-
const { x: g, y: f } = ct(d), { width: y, height: v } = ut(d), T = { x: g, y: f }, { x: A, y: b } = rt(vt(
|
|
1682
|
+
const { x: g, y: f } = ct(d), { width: y, height: v } = ut(d), T = { x: g, y: f }, { x: A, y: b } = rt(vt(l, T), -u);
|
|
1661
1683
|
return A > -o && A < y + o && b > -o && b < v + o;
|
|
1662
1684
|
});
|
|
1663
1685
|
}
|
|
@@ -1678,14 +1700,14 @@ class Qn extends Qe {
|
|
|
1678
1700
|
return;
|
|
1679
1701
|
const _ = Pt("g");
|
|
1680
1702
|
_.classList.add("annotation-text"), _.setAttribute("fill", `${T}`), _.setAttribute("font-size", `${A}px`), _.setAttribute("font-family", `${b}`);
|
|
1681
|
-
const
|
|
1682
|
-
let
|
|
1683
|
-
$ && $ !== "none" && (
|
|
1703
|
+
const G = Pt("rect");
|
|
1704
|
+
let W = !1;
|
|
1705
|
+
$ && $ !== "none" && (W = !0, G.setAttribute("stroke", C || "black"), G.setAttribute("stroke-width", `${E}`), $ === "dashed" && G.setAttribute("stroke-dasharray", "5,5")), (N && N.length || W) && (W = !0, G.setAttribute("fill", N || "transparent")), W && (G.setAttribute("width", `${f.width}`), G.setAttribute("height", `${f.height}`)), _.appendChild(G), ti(u, _);
|
|
1684
1706
|
const { x: _t, y: It } = rt(y, -o);
|
|
1685
1707
|
_.setAttribute("transform", `translate(${_t},${It})`), _.classList.add(g), _.setAttribute("data-annotation", `${u.id}`), _.setAttribute("data-annotation-type", "text"), t.appendChild(_);
|
|
1686
1708
|
});
|
|
1687
|
-
const
|
|
1688
|
-
|
|
1709
|
+
const l = Pt("style");
|
|
1710
|
+
l.innerHTML = r, t.firstChild && t.insertBefore(l, t.firstChild);
|
|
1689
1711
|
}
|
|
1690
1712
|
refreshDrawing() {
|
|
1691
1713
|
const t = this.ogma.view.getAngle();
|
|
@@ -1693,7 +1715,7 @@ class Qn extends Qe {
|
|
|
1693
1715
|
const o = r.getAttribute("data-annotation");
|
|
1694
1716
|
if (!o)
|
|
1695
1717
|
return;
|
|
1696
|
-
const
|
|
1718
|
+
const l = ct(this.getById(o)), { x: u, y: d } = rt(l, -t);
|
|
1697
1719
|
r.setAttribute("transform", `translate(${u},${d})`);
|
|
1698
1720
|
});
|
|
1699
1721
|
}
|
|
@@ -1705,14 +1727,14 @@ class Qn extends Qe {
|
|
|
1705
1727
|
return;
|
|
1706
1728
|
const t = this.getById(this.selectedId) || this.getById(this.hoveredId), r = ut(t), o = this.ogma.view.graphToScreenCoordinates(
|
|
1707
1729
|
ct(t)
|
|
1708
|
-
),
|
|
1730
|
+
), l = this.ogma.view.getZoom(), {
|
|
1709
1731
|
font: u,
|
|
1710
1732
|
fontSize: d,
|
|
1711
1733
|
color: g,
|
|
1712
1734
|
background: f,
|
|
1713
1735
|
padding: y = 0
|
|
1714
|
-
} = t.properties.style || St, v = (d || 1) *
|
|
1715
|
-
this.textArea.value = t.properties.content, this.editor.element.style.transform = `translate(${o.x}px, ${o.y}px)translate(-50%, -50%)translate(${r.width / 2 *
|
|
1736
|
+
} = t.properties.style || St, v = (d || 1) * l;
|
|
1737
|
+
this.textArea.value = t.properties.content, this.editor.element.style.transform = `translate(${o.x}px, ${o.y}px)translate(-50%, -50%)translate(${r.width / 2 * l}px, ${r.height / 2 * l}px)`, this.editor.element.style.width = `${r.width * l}px`, this.editor.element.style.height = `${r.height * l}px`, this.textArea.style.font = `${v} ${u}`, this.textArea.style.fontFamily = u || "sans-serif", this.textArea.style.fontSize = `${v}px`, this.textArea.style.padding = `${l * y}px`, this.textArea.style.lineHeight = `${v}px`, this.textArea.style.boxSizing = "border-box", this.textArea.style.color = g || "black", this.textArea.style.background = f || "transparent", this.textArea.placeholder = this.placeholder, this.layer.refresh();
|
|
1716
1738
|
}
|
|
1717
1739
|
select(t) {
|
|
1718
1740
|
super.select(t), this.textArea.focus();
|
|
@@ -1721,41 +1743,41 @@ class Qn extends Qe {
|
|
|
1721
1743
|
super.destroy(), document.removeEventListener("mouseup", this.onMouseUp), document.removeEventListener("mousemove", this.onMouseMove, !0), this.ogma.events.off(this.onViewChanged);
|
|
1722
1744
|
}
|
|
1723
1745
|
}
|
|
1724
|
-
class
|
|
1746
|
+
class ni {
|
|
1725
1747
|
constructor() {
|
|
1726
1748
|
m(this, "links", {});
|
|
1727
1749
|
m(this, "linksByTargetId", {});
|
|
1728
1750
|
m(this, "linksByArrowId", {});
|
|
1729
1751
|
}
|
|
1730
|
-
add(
|
|
1731
|
-
const u = Kt(), d =
|
|
1752
|
+
add(h, t, r, o, l) {
|
|
1753
|
+
const u = Kt(), d = h.id, g = {
|
|
1732
1754
|
id: u,
|
|
1733
1755
|
arrow: d,
|
|
1734
1756
|
target: r,
|
|
1735
1757
|
targetType: o,
|
|
1736
|
-
connectionPoint:
|
|
1758
|
+
connectionPoint: l,
|
|
1737
1759
|
side: t
|
|
1738
1760
|
};
|
|
1739
|
-
return this.links[u] = g, this.linksByTargetId[r] || (this.linksByTargetId[r] = []), this.linksByTargetId[r].push(u), this.linksByArrowId[d] || (this.linksByArrowId[d] = {}), this.linksByArrowId[d][t] = u,
|
|
1761
|
+
return this.links[u] = g, this.linksByTargetId[r] || (this.linksByTargetId[r] = []), this.linksByTargetId[r].push(u), this.linksByArrowId[d] || (this.linksByArrowId[d] = {}), this.linksByArrowId[d][t] = u, h.properties.link = h.properties.link || {}, h.properties.link[t] = {
|
|
1740
1762
|
id: r,
|
|
1741
1763
|
side: t,
|
|
1742
1764
|
type: o,
|
|
1743
|
-
magnet:
|
|
1765
|
+
magnet: l
|
|
1744
1766
|
}, this;
|
|
1745
1767
|
}
|
|
1746
|
-
arrowIsLinked(
|
|
1768
|
+
arrowIsLinked(h, t) {
|
|
1747
1769
|
var r;
|
|
1748
|
-
return !!((r = this.linksByArrowId[
|
|
1770
|
+
return !!((r = this.linksByArrowId[h]) != null && r[t]);
|
|
1749
1771
|
}
|
|
1750
1772
|
// remove the link between the arrow and the target by arrow id and side
|
|
1751
|
-
remove(
|
|
1773
|
+
remove(h, t) {
|
|
1752
1774
|
var d, g;
|
|
1753
|
-
const r =
|
|
1754
|
-
if ((g =
|
|
1775
|
+
const r = h.id, o = (d = this.linksByArrowId[r]) == null ? void 0 : d[t];
|
|
1776
|
+
if ((g = h.properties.link) == null || delete g[t], !o)
|
|
1755
1777
|
return this;
|
|
1756
|
-
const
|
|
1778
|
+
const l = this.links[o];
|
|
1757
1779
|
delete this.links[o];
|
|
1758
|
-
const u = this.linksByTargetId[
|
|
1780
|
+
const u = this.linksByTargetId[l.target];
|
|
1759
1781
|
for (let f = 0; f < u.length; f++)
|
|
1760
1782
|
if (u[f] === o) {
|
|
1761
1783
|
u.splice(f, 1);
|
|
@@ -1763,20 +1785,20 @@ class ti {
|
|
|
1763
1785
|
}
|
|
1764
1786
|
return delete this.linksByArrowId[r][t], this;
|
|
1765
1787
|
}
|
|
1766
|
-
getArrowLink(
|
|
1788
|
+
getArrowLink(h, t) {
|
|
1767
1789
|
var o;
|
|
1768
|
-
const r = (o = this.linksByArrowId[
|
|
1790
|
+
const r = (o = this.linksByArrowId[h]) == null ? void 0 : o[t];
|
|
1769
1791
|
return r ? this.links[r] : null;
|
|
1770
1792
|
}
|
|
1771
|
-
getTargetLinks(
|
|
1793
|
+
getTargetLinks(h, t) {
|
|
1772
1794
|
var r;
|
|
1773
|
-
return ((r = this.linksByTargetId[
|
|
1795
|
+
return ((r = this.linksByTargetId[h]) == null ? void 0 : r.map((o) => this.links[o]).filter((o) => o.targetType === t)) ?? [];
|
|
1774
1796
|
}
|
|
1775
|
-
forEach(
|
|
1776
|
-
Object.values(this.links).forEach(
|
|
1797
|
+
forEach(h) {
|
|
1798
|
+
Object.values(this.links).forEach(h);
|
|
1777
1799
|
}
|
|
1778
1800
|
}
|
|
1779
|
-
const
|
|
1801
|
+
const st = (a) => a.properties.type === "arrow", pt = (a) => a.properties.type === "text", Fe = (a) => a.type === "FeatureCollection", ii = {
|
|
1780
1802
|
magnetColor: "#3e8",
|
|
1781
1803
|
detectMargin: 20,
|
|
1782
1804
|
magnetHandleRadius: 5,
|
|
@@ -1796,12 +1818,12 @@ const ot = (a) => a.properties.type === "arrow", mt = (a) => a.properties.type =
|
|
|
1796
1818
|
{ x: 0.5, y: 1 },
|
|
1797
1819
|
{ x: 1, y: 1 }
|
|
1798
1820
|
];
|
|
1799
|
-
class
|
|
1821
|
+
class oi extends Je {
|
|
1800
1822
|
constructor(t, r = {}) {
|
|
1801
1823
|
super();
|
|
1802
1824
|
m(this, "arrows");
|
|
1803
1825
|
m(this, "texts");
|
|
1804
|
-
m(this, "links", new
|
|
1826
|
+
m(this, "links", new ni());
|
|
1805
1827
|
m(this, "layer");
|
|
1806
1828
|
m(this, "annotations");
|
|
1807
1829
|
m(this, "ogma");
|
|
@@ -1820,37 +1842,37 @@ class ri extends Je {
|
|
|
1820
1842
|
je.forEach((o) => {
|
|
1821
1843
|
if (!this.textToMagnet)
|
|
1822
1844
|
return;
|
|
1823
|
-
const
|
|
1845
|
+
const l = ut(this.textToMagnet), u = ct(this.textToMagnet), d = Ut(o, { x: l.width, y: l.height }), g = rt(d, this.ogma.view.getAngle()), { x: f, y } = Et(g, u);
|
|
1824
1846
|
t.moveTo(f, y), t.arc(f, y, this.options.magnetHandleRadius / r, 0, Math.PI * 2);
|
|
1825
1847
|
}), t.fill(), t.closePath();
|
|
1826
1848
|
});
|
|
1827
1849
|
m(this, "_onFeatureDrag", (t, r) => {
|
|
1828
1850
|
const o = r;
|
|
1829
|
-
if (
|
|
1830
|
-
["start", "end"].find((
|
|
1831
|
-
const u =
|
|
1832
|
-
return this._snapToText(t, o, u) || this._findAndSnapToNode(t,
|
|
1851
|
+
if (st(t) && o === "line")
|
|
1852
|
+
["start", "end"].find((l) => {
|
|
1853
|
+
const u = l === "start" ? $t(t) : Wt(t);
|
|
1854
|
+
return this._snapToText(t, o, u) || this._findAndSnapToNode(t, l, u);
|
|
1833
1855
|
});
|
|
1834
|
-
else if (
|
|
1835
|
-
const
|
|
1836
|
-
this._snapToText(t, o,
|
|
1856
|
+
else if (st(t) && o !== "line") {
|
|
1857
|
+
const l = o === "start" ? $t(t) : Wt(t);
|
|
1858
|
+
this._snapToText(t, o, l) || this._findAndSnapToNode(t, o, l);
|
|
1837
1859
|
} else
|
|
1838
|
-
|
|
1839
|
-
const g = this.getAnnotation(
|
|
1860
|
+
pt(t) && (this.activeLinks.forEach(({ arrow: l, side: u, connectionPoint: d }) => {
|
|
1861
|
+
const g = this.getAnnotation(l), f = ut(t), y = ct(t), v = Ut(d, { x: f.width, y: f.height }), T = rt(v, this.ogma.view.getAngle()), A = Et(T, y);
|
|
1840
1862
|
g.geometry.coordinates[u === "start" ? 0 : 1] = [A.x, A.y];
|
|
1841
1863
|
}), this.activeLinks.length && this.arrows.refreshLayer());
|
|
1842
1864
|
this.layer.refresh(), this.emit(Xt, t, r);
|
|
1843
1865
|
});
|
|
1844
1866
|
m(this, "_onFeatureDragEnd", (t) => {
|
|
1845
|
-
this.dragged !== null &&
|
|
1846
|
-
this.links.getArrowLink(t.id, r) && this.emit(
|
|
1867
|
+
this.dragged !== null && st(t) && $t(this.dragged) && Be.forEach((r) => {
|
|
1868
|
+
this.links.getArrowLink(t.id, r) && this.emit(Yn, {
|
|
1847
1869
|
arrow: t,
|
|
1848
1870
|
link: this.links.getArrowLink(t.id, r)
|
|
1849
1871
|
});
|
|
1850
|
-
}), (
|
|
1872
|
+
}), (pt(t) || st(t)) && this.onUpdate(t), this.dragged = null, this.activeLinks = [], this.textToMagnet = void 0, this.annotations.forEach((r) => r.enableDetection()), this.layer.refresh(), this.emit(Tt, t);
|
|
1851
1873
|
});
|
|
1852
1874
|
m(this, "_onFeatureDragStart", (t) => {
|
|
1853
|
-
this.textToMagnet = void 0,
|
|
1875
|
+
this.textToMagnet = void 0, st(t) ? this.dragged = t : pt(t) && this.activeLinks.push(...this.links.getTargetLinks(t.id, "text")), this.annotations.forEach((r) => {
|
|
1854
1876
|
const o = r.getSelectedFeature();
|
|
1855
1877
|
o && o !== t && r.unhover().unselect(), r.disableDetection();
|
|
1856
1878
|
}), this.emit(Zt, t);
|
|
@@ -1897,41 +1919,41 @@ class ri extends Je {
|
|
|
1897
1919
|
m(this, "_onUpdate", (t) => {
|
|
1898
1920
|
this.emit(ye, t);
|
|
1899
1921
|
});
|
|
1900
|
-
this.options = this.setOptions({ ...
|
|
1922
|
+
this.options = this.setOptions({ ...ii, ...r }), this.ogma = t, this.arrows = new Kn(t, this.options), this.texts = new ei(t, this.options), this.annotations = [this.arrows, this.texts], this.annotations.forEach((o) => {
|
|
1901
1923
|
o.on(Zt, this._onFeatureDragStart).on(Xt, this._onFeatureDrag).on(Tt, this._onFeatureDragEnd).on(ye, this.onUpdate).on(fe, this._onUnselect).on(de, this._onSelect).on(ge, this._onAdded).on(pe, this._onRemoved);
|
|
1902
1924
|
}), this.ogma.events.on("nodesDragStart", this._onNodesDragStart).on("nodesDragProgress", this._onNodesDrag).on("layoutEnd", this._onLayoutEnd).on(["viewChanged", "rotate"], () => {
|
|
1903
1925
|
this.refreshTextLinks();
|
|
1904
1926
|
}), this.layer = t.layers.addCanvasLayer(this._render), this.layer.moveToBottom();
|
|
1905
1927
|
}
|
|
1906
1928
|
_moveNodes(t, r, o) {
|
|
1907
|
-
t.forEach((
|
|
1908
|
-
const u = this.links.getTargetLinks(
|
|
1929
|
+
t.forEach((l) => {
|
|
1930
|
+
const u = this.links.getTargetLinks(l.getId(), "node"), d = l.getPosition();
|
|
1909
1931
|
u.forEach((g) => {
|
|
1910
1932
|
const f = this.getAnnotation(g.arrow), y = g.side, v = Rt(
|
|
1911
1933
|
f,
|
|
1912
1934
|
y === "start" ? "end" : "start"
|
|
1913
1935
|
);
|
|
1914
1936
|
let T = d;
|
|
1915
|
-
const A = +
|
|
1937
|
+
const A = +l.getAttribute("radius"), b = 1e-6;
|
|
1916
1938
|
(g.connectionPoint.x - (d.x - r) > b || g.connectionPoint.y - (d.y - o) > b) && (T = Vt(v, d, A)), At(f, y, T.x, T.y);
|
|
1917
1939
|
});
|
|
1918
1940
|
}), this.arrows.refreshLayer();
|
|
1919
1941
|
}
|
|
1920
1942
|
_snapToText(t, r, o) {
|
|
1921
|
-
const
|
|
1922
|
-
if (this.links.remove(t, r), !
|
|
1943
|
+
const l = this.texts.detect(o, this.options.detectMargin);
|
|
1944
|
+
if (this.links.remove(t, r), !l)
|
|
1923
1945
|
return !1;
|
|
1924
|
-
this.textToMagnet =
|
|
1925
|
-
const u = this.findMagnetPoint(je,
|
|
1926
|
-
return u ? (At(t, r, u.point.x, u.point.y), this.links.add(t, r,
|
|
1946
|
+
this.textToMagnet = l;
|
|
1947
|
+
const u = this.findMagnetPoint(je, l, o);
|
|
1948
|
+
return u ? (At(t, r, u.point.x, u.point.y), this.links.add(t, r, l.id, "text", u.magnet), !0) : !1;
|
|
1927
1949
|
}
|
|
1928
1950
|
_findAndSnapToNode(t, r, o) {
|
|
1929
1951
|
var d, g;
|
|
1930
|
-
const
|
|
1931
|
-
this.links.remove(t, r), u && u.isNode ? ((d = this.hoveredNode) == null || d.setSelected(!1), this.hoveredNode = u, u.setSelected(!0), this._snapToNode(t, r, u,
|
|
1952
|
+
const l = this.ogma.view.graphToScreenCoordinates(o), u = this.ogma.view.getElementAt(l);
|
|
1953
|
+
this.links.remove(t, r), u && u.isNode ? ((d = this.hoveredNode) == null || d.setSelected(!1), this.hoveredNode = u, u.setSelected(!0), this._snapToNode(t, r, u, l)) : ((g = this.hoveredNode) == null || g.setSelected(!1), this.hoveredNode = null);
|
|
1932
1954
|
}
|
|
1933
|
-
_snapToNode(t, r, o,
|
|
1934
|
-
const u = o.getPositionOnScreen(), d = +o.getAttribute("radius"), g = d * this.ogma.view.getZoom(), f =
|
|
1955
|
+
_snapToNode(t, r, o, l) {
|
|
1956
|
+
const u = o.getPositionOnScreen(), d = +o.getAttribute("radius"), g = d * this.ogma.view.getZoom(), f = l.x - u.x, y = l.y - u.y, v = Math.sqrt(f * f + y * y), T = o.getPosition();
|
|
1935
1957
|
if (v < g + this.options.detectMargin) {
|
|
1936
1958
|
let A = T;
|
|
1937
1959
|
if (v > g / 2) {
|
|
@@ -1944,11 +1966,11 @@ class ri extends Je {
|
|
|
1944
1966
|
refreshTextLinks() {
|
|
1945
1967
|
let t = !1;
|
|
1946
1968
|
this.links.forEach(
|
|
1947
|
-
({ connectionPoint: r, targetType: o, target:
|
|
1969
|
+
({ connectionPoint: r, targetType: o, target: l, arrow: u, side: d }) => {
|
|
1948
1970
|
if (o !== "text")
|
|
1949
1971
|
return;
|
|
1950
1972
|
t = !0;
|
|
1951
|
-
const g = this.getAnnotation(
|
|
1973
|
+
const g = this.getAnnotation(l), f = this.getAnnotation(u), y = ut(g), v = ct(g), T = Ut(r, { x: y.width, y: y.height }), A = rt(T, this.ogma.view.getAngle()), b = Et(A, v);
|
|
1952
1974
|
At(f, d, b.x, b.y);
|
|
1953
1975
|
}
|
|
1954
1976
|
), t && this.arrows.refreshLayer();
|
|
@@ -1960,7 +1982,7 @@ class ri extends Je {
|
|
|
1960
1982
|
return this.selected;
|
|
1961
1983
|
}
|
|
1962
1984
|
findMagnetPoint(t, r, o) {
|
|
1963
|
-
let
|
|
1985
|
+
let l;
|
|
1964
1986
|
for (const u of t) {
|
|
1965
1987
|
const d = ut(r), g = ct(r), f = Ut(u, { x: d.width, y: d.height }), y = rt(f, this.ogma.view.getAngle()), v = Et(y, g), T = kt(vt(v, o)), A = Math.min(
|
|
1966
1988
|
this.options.magnetRadius * this.ogma.view.getZoom(),
|
|
@@ -1969,14 +1991,14 @@ class ri extends Je {
|
|
|
1969
1991
|
d.height / 2
|
|
1970
1992
|
);
|
|
1971
1993
|
if (T < Math.max(A, this.options.magnetHandleRadius)) {
|
|
1972
|
-
|
|
1994
|
+
l = {
|
|
1973
1995
|
point: v,
|
|
1974
1996
|
magnet: u
|
|
1975
1997
|
};
|
|
1976
1998
|
break;
|
|
1977
1999
|
}
|
|
1978
2000
|
}
|
|
1979
|
-
return
|
|
2001
|
+
return l;
|
|
1980
2002
|
}
|
|
1981
2003
|
/**
|
|
1982
2004
|
* Set the options for the controller
|
|
@@ -1995,13 +2017,13 @@ class ri extends Je {
|
|
|
1995
2017
|
*/
|
|
1996
2018
|
select(t) {
|
|
1997
2019
|
const r = this.getAnnotations().features.find((o) => o.id === t);
|
|
1998
|
-
return r ? (
|
|
2020
|
+
return r ? (st(r) ? this.arrows.select(r.id) : pt(r) && this.texts.select(r.id), this) : this;
|
|
1999
2021
|
}
|
|
2000
2022
|
/**
|
|
2001
2023
|
* Unselects the currently selected annotation
|
|
2002
2024
|
*/
|
|
2003
2025
|
unselect() {
|
|
2004
|
-
return this.selected ? (
|
|
2026
|
+
return this.selected ? (st(this.selected) ? this.arrows.unselect() : pt(this.selected) && this.texts.unselect(), this) : this;
|
|
2005
2027
|
}
|
|
2006
2028
|
/**
|
|
2007
2029
|
* Add an annotation to the controller
|
|
@@ -2010,10 +2032,10 @@ class ri extends Je {
|
|
|
2010
2032
|
add(t) {
|
|
2011
2033
|
if (Fe(t)) {
|
|
2012
2034
|
const [r, o] = t.features.reduce(
|
|
2013
|
-
(
|
|
2035
|
+
(l, u) => (st(u) ? l[1].push(u) : pt(u) && l[0].push(u), l),
|
|
2014
2036
|
[[], []]
|
|
2015
2037
|
);
|
|
2016
|
-
return r.forEach((
|
|
2038
|
+
return r.forEach((l) => this.add(l)), o.forEach((l) => this.add(l)), this.arrows.refreshLayer(), this;
|
|
2017
2039
|
}
|
|
2018
2040
|
switch (t.properties.type) {
|
|
2019
2041
|
case "text":
|
|
@@ -2032,7 +2054,7 @@ class ri extends Je {
|
|
|
2032
2054
|
remove(t) {
|
|
2033
2055
|
return Fe(t) ? (t.features.forEach(
|
|
2034
2056
|
(r) => this.remove(r)
|
|
2035
|
-
), this) : (
|
|
2057
|
+
), this) : (st(t) ? (this.links.remove(t, "start"), this.links.remove(t, "end"), this.arrows.remove(t.id)) : this.texts.remove(t.id), this);
|
|
2036
2058
|
}
|
|
2037
2059
|
loadLink(t) {
|
|
2038
2060
|
if (t.properties.link)
|
|
@@ -2040,8 +2062,8 @@ class ri extends Je {
|
|
|
2040
2062
|
const o = t.properties.link[r];
|
|
2041
2063
|
if (!o)
|
|
2042
2064
|
continue;
|
|
2043
|
-
const
|
|
2044
|
-
if (o.type === "text" &&
|
|
2065
|
+
const l = this.getAnnotation(o.id);
|
|
2066
|
+
if (o.type === "text" && l)
|
|
2045
2067
|
this.links.add(t, r, o.id, o.type, o.magnet);
|
|
2046
2068
|
else if (o.type === "node") {
|
|
2047
2069
|
const u = this.ogma.getNode(o.id);
|
|
@@ -2078,7 +2100,7 @@ class ri extends Je {
|
|
|
2078
2100
|
* Cancel drawing on the current frame
|
|
2079
2101
|
*/
|
|
2080
2102
|
cancelDrawing() {
|
|
2081
|
-
this.annotations.forEach((t) => t.cancelDrawing()), this.emit(
|
|
2103
|
+
this.annotations.forEach((t) => t.cancelDrawing()), this.emit(Wn);
|
|
2082
2104
|
}
|
|
2083
2105
|
/**
|
|
2084
2106
|
* Update the style of the annotation with the given id
|
|
@@ -2086,8 +2108,12 @@ class ri extends Je {
|
|
|
2086
2108
|
* @param style The new style
|
|
2087
2109
|
*/
|
|
2088
2110
|
updateStyle(t, r) {
|
|
2089
|
-
const o = this.getAnnotations().features.find((
|
|
2090
|
-
return o ? (
|
|
2111
|
+
const o = this.getAnnotations().features.find((l) => l.id === t);
|
|
2112
|
+
return o ? (st(o) ? this.arrows.updateStyle(o, r) : pt(o) && this.texts.updateStyle(o, r), this.onUpdate(o), this) : this;
|
|
2113
|
+
}
|
|
2114
|
+
setScale(t, r, o, l) {
|
|
2115
|
+
const u = this.getAnnotations().features.find((d) => d.id === t);
|
|
2116
|
+
return u ? (st(u) ? this.arrows.scale(u, r, o, l) : pt(u) && this.texts.scale(u, r, o, l), this.onUpdate(u), this) : this;
|
|
2091
2117
|
}
|
|
2092
2118
|
/**
|
|
2093
2119
|
*
|
|
@@ -2118,33 +2144,33 @@ class ri extends Je {
|
|
|
2118
2144
|
}
|
|
2119
2145
|
}
|
|
2120
2146
|
export {
|
|
2121
|
-
|
|
2122
|
-
|
|
2147
|
+
Kn as Arrows,
|
|
2148
|
+
oi as Control,
|
|
2123
2149
|
ge as EVT_ADD,
|
|
2124
|
-
|
|
2150
|
+
Wn as EVT_CANCEL_DRAWING,
|
|
2125
2151
|
Xt as EVT_DRAG,
|
|
2126
2152
|
Tt as EVT_DRAG_END,
|
|
2127
2153
|
Zt as EVT_DRAG_START,
|
|
2128
|
-
|
|
2129
|
-
|
|
2154
|
+
Un as EVT_HOVER,
|
|
2155
|
+
Yn as EVT_LINK,
|
|
2130
2156
|
pe as EVT_REMOVE,
|
|
2131
2157
|
de as EVT_SELECT,
|
|
2132
|
-
|
|
2158
|
+
Gn as EVT_UNHOVER,
|
|
2133
2159
|
fe as EVT_UNSELECT,
|
|
2134
2160
|
ye as EVT_UPDATE,
|
|
2135
2161
|
V as NONE,
|
|
2136
|
-
|
|
2162
|
+
ei as Texts,
|
|
2137
2163
|
ue as clientToContainerPosition,
|
|
2138
2164
|
Nn as createArrow,
|
|
2139
2165
|
Pt as createSVGElement,
|
|
2140
|
-
|
|
2166
|
+
Jn as createText,
|
|
2141
2167
|
Me as defaultArrowOptions,
|
|
2142
2168
|
zt as defaultArrowStyle,
|
|
2143
2169
|
ze as defaultControllerOptions,
|
|
2144
2170
|
le as defaultTextOptions,
|
|
2145
2171
|
St as defaultTextStyle,
|
|
2146
|
-
|
|
2147
|
-
|
|
2172
|
+
si as getAnnotationsBounds,
|
|
2173
|
+
Wt as getArrowEnd,
|
|
2148
2174
|
Yt as getArrowEndPoints,
|
|
2149
2175
|
Rt as getArrowSide,
|
|
2150
2176
|
$t as getArrowStart,
|
|
@@ -2154,8 +2180,9 @@ export {
|
|
|
2154
2180
|
ct as getTextPosition,
|
|
2155
2181
|
ut as getTextSize,
|
|
2156
2182
|
Fe as isAnnotationCollection,
|
|
2157
|
-
|
|
2158
|
-
|
|
2183
|
+
st as isArrow,
|
|
2184
|
+
pt as isText,
|
|
2185
|
+
qn as scaleGeometry,
|
|
2159
2186
|
Ve as setArrowEnd,
|
|
2160
2187
|
At as setArrowEndPoint,
|
|
2161
2188
|
Re as setArrowStart,
|