@recogito/text-annotator 3.0.1 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -33,7 +33,7 @@ const re = "not-annotatable", et = `.${re}`, it = (t) => {
|
|
|
33
33
|
pointerId: t.pointerId,
|
|
34
34
|
pointerType: t.pointerType,
|
|
35
35
|
timeStamp: t.timeStamp
|
|
36
|
-
}),
|
|
36
|
+
}), ht = (t) => ({
|
|
37
37
|
...t,
|
|
38
38
|
type: t.type,
|
|
39
39
|
key: t.key,
|
|
@@ -92,7 +92,7 @@ const re = "not-annotatable", et = `.${re}`, it = (t) => {
|
|
|
92
92
|
prefix: a.substring(a.length - n),
|
|
93
93
|
suffix: l.substring(0, n)
|
|
94
94
|
};
|
|
95
|
-
}, q = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), ke = /^\s*$/, Ie = (t) => ke.test(t.toString()),
|
|
95
|
+
}, q = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), ke = /^\s*$/, Ie = (t) => ke.test(t.toString()), _e = (t, e) => {
|
|
96
96
|
const n = (s) => Math.round(s * 10) / 10, o = {
|
|
97
97
|
top: n(t.top),
|
|
98
98
|
bottom: n(t.bottom),
|
|
@@ -116,7 +116,7 @@ const re = "not-annotatable", et = `.${re}`, it = (t) => {
|
|
|
116
116
|
return "block-contains";
|
|
117
117
|
} else if (o.top >= i.top && o.bottom <= i.bottom && o.left >= i.left && o.right <= i.right)
|
|
118
118
|
return "block-is-contained";
|
|
119
|
-
},
|
|
119
|
+
}, Ue = (t, e) => {
|
|
120
120
|
const n = Math.min(t.left, e.left), o = Math.max(t.right, e.right), i = Math.min(t.top, e.top), s = Math.max(t.bottom, e.bottom);
|
|
121
121
|
return new DOMRect(n, i, o - n, s - i);
|
|
122
122
|
}, Ne = (t) => t.reduce((e, n) => {
|
|
@@ -124,9 +124,9 @@ const re = "not-annotatable", et = `.${re}`, it = (t) => {
|
|
|
124
124
|
return e;
|
|
125
125
|
let o = [...e], i = !1;
|
|
126
126
|
for (const s of e) {
|
|
127
|
-
const a =
|
|
127
|
+
const a = _e(n, s);
|
|
128
128
|
if (a === "inline-adjacent") {
|
|
129
|
-
o = o.map((r) => r === s ?
|
|
129
|
+
o = o.map((r) => r === s ? Ue(n, s) : r), i = !0;
|
|
130
130
|
break;
|
|
131
131
|
} else if (a === "inline-contains") {
|
|
132
132
|
o = o.map((r) => r === s ? n : r), i = !0;
|
|
@@ -202,21 +202,20 @@ const re = "not-annotatable", et = `.${re}`, it = (t) => {
|
|
|
202
202
|
const { overflowY: e } = window.getComputedStyle(t);
|
|
203
203
|
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : ce(t.parentElement);
|
|
204
204
|
}, Ye = (t, e) => (n) => {
|
|
205
|
-
const o = typeof n == "string" ? n : n.id, i = (
|
|
206
|
-
const
|
|
207
|
-
s.scroll({ top:
|
|
205
|
+
const o = typeof n == "string" ? n : n.id, i = (h) => {
|
|
206
|
+
const u = s.getBoundingClientRect(), p = s.clientHeight, v = s.clientWidth, g = h.selector[0].range.getBoundingClientRect(), { width: m, height: A } = e.getAnnotationBounds(o), d = g.top - u.top, c = g.left - u.left, y = s.parentElement ? s.scrollTop : 0, S = s.parentElement ? s.scrollLeft : 0, E = d + y - (p - A) / 2, C = c + S - (v - m) / 2;
|
|
207
|
+
s.scroll({ top: E, left: C, behavior: "smooth" });
|
|
208
208
|
}, s = ce(t);
|
|
209
|
-
if (s)
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
{
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
return !1;
|
|
209
|
+
if (!s)
|
|
210
|
+
return console.warn(`The scroll parent is missing for the annotation: ${o}`, { container: t }), !1;
|
|
211
|
+
const a = e.getAnnotation(o);
|
|
212
|
+
if (!a)
|
|
213
|
+
return console.warn(`The annotation is missing in the store: ${o}`), !1;
|
|
214
|
+
const { range: r } = a.target.selector[0];
|
|
215
|
+
if (r && !r.collapsed)
|
|
216
|
+
return i(a.target), !0;
|
|
217
|
+
const l = At(a.target, t), { range: f } = l.selector[0];
|
|
218
|
+
return f && !f.collapsed ? (i(l), !0) : !1;
|
|
220
219
|
}, G = {
|
|
221
220
|
fill: "rgb(0, 128, 255)",
|
|
222
221
|
fillOpacity: 0.18
|
|
@@ -246,9 +245,9 @@ const re = "not-annotatable", et = `.${re}`, it = (t) => {
|
|
|
246
245
|
t.addEventListener("pointermove", u);
|
|
247
246
|
const p = (M = !1) => {
|
|
248
247
|
f && f.clear();
|
|
249
|
-
const T = Xe(t), { minX: I, minY: D, maxX:
|
|
248
|
+
const T = Xe(t), { minX: I, minY: D, maxX: b, maxY: x } = T, w = l ? i.getIntersecting(I, D, b, x).filter(({ annotation: O }) => l(O)) : i.getIntersecting(I, D, b, x), L = s.selected.map(({ id: O }) => O), B = w.map(({ annotation: O, rects: _ }) => {
|
|
250
249
|
const P = L.includes(O.id), Se = O.id === a.current;
|
|
251
|
-
return { annotation: O, rects:
|
|
250
|
+
return { annotation: O, rects: _, state: { selected: P, hover: Se } };
|
|
252
251
|
});
|
|
253
252
|
o.redraw(B, T, r, f, M), setTimeout(() => h(w.map(({ annotation: O }) => O)), 1);
|
|
254
253
|
}, v = (M) => {
|
|
@@ -261,18 +260,18 @@ const re = "not-annotatable", et = `.${re}`, it = (t) => {
|
|
|
261
260
|
i.observe(A);
|
|
262
261
|
const d = s.subscribe(() => p()), c = () => p(!0);
|
|
263
262
|
document.addEventListener("scroll", c, { capture: !0, passive: !0 });
|
|
264
|
-
const
|
|
263
|
+
const y = Dt(() => {
|
|
265
264
|
i.recalculatePositions(), f && f.reset(), p();
|
|
266
265
|
});
|
|
267
|
-
window.addEventListener("resize",
|
|
268
|
-
const S = new ResizeObserver(
|
|
266
|
+
window.addEventListener("resize", y);
|
|
267
|
+
const S = new ResizeObserver(y);
|
|
269
268
|
S.observe(t);
|
|
270
269
|
const E = { attributes: !0, childList: !0, subtree: !0 }, C = new MutationObserver((M) => {
|
|
271
270
|
M.every((I) => I.target === t || t.contains(I.target)) || p(!0);
|
|
272
271
|
});
|
|
273
272
|
return C.observe(document.body, E), {
|
|
274
273
|
destroy: () => {
|
|
275
|
-
t.removeEventListener("pointermove", u), o.destroy(), i.unobserve(A), d(), document.removeEventListener("scroll", c), window.removeEventListener("resize",
|
|
274
|
+
t.removeEventListener("pointermove", u), o.destroy(), i.unobserve(A), d(), document.removeEventListener("scroll", c), window.removeEventListener("resize", y), S.disconnect(), C.disconnect();
|
|
276
275
|
},
|
|
277
276
|
redraw: p,
|
|
278
277
|
setStyle: g,
|
|
@@ -294,22 +293,22 @@ const re = "not-annotatable", et = `.${re}`, it = (t) => {
|
|
|
294
293
|
n.clearRect(-0.5, -0.5, u + 1, p + 1), h && h.clear();
|
|
295
294
|
const { top: v, left: g } = l;
|
|
296
295
|
[...r].sort((A, d) => {
|
|
297
|
-
const { annotation: { target: { created: c } } } = A, { annotation: { target: { created:
|
|
298
|
-
return c.getTime() -
|
|
296
|
+
const { annotation: { target: { created: c } } } = A, { annotation: { target: { created: y } } } = d;
|
|
297
|
+
return c.getTime() - y.getTime();
|
|
299
298
|
}).forEach((A) => {
|
|
300
299
|
var S;
|
|
301
|
-
const d = f ? typeof f == "function" ? f(A.annotation, A.state) : f : (S = A.state) != null && S.selected ? xt : G, c = h && h.paint(A, l) || d,
|
|
300
|
+
const d = f ? typeof f == "function" ? f(A.annotation, A.state) : f : (S = A.state) != null && S.selected ? xt : G, c = h && h.paint(A, l) || d, y = A.rects.map(({ x: E, y: C, width: R, height: M }) => ({
|
|
302
301
|
x: E + g,
|
|
303
302
|
y: C + v,
|
|
304
303
|
width: R,
|
|
305
304
|
height: M
|
|
306
305
|
}));
|
|
307
|
-
if (n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1,
|
|
306
|
+
if (n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1, y.forEach(
|
|
308
307
|
({ x: E, y: C, width: R, height: M }) => n.fillRect(E, C, R, M)
|
|
309
308
|
), c.underlineColor) {
|
|
310
309
|
n.globalAlpha = 1, n.strokeStyle = c.underlineColor, n.lineWidth = c.underlineThickness ?? 1;
|
|
311
310
|
const E = c.underlineOffset ?? 0;
|
|
312
|
-
|
|
311
|
+
y.forEach(({ x: C, y: R, width: M, height: T }) => {
|
|
313
312
|
n.beginPath(), n.moveTo(C, R + T + E), n.lineTo(C + M, R + T + E), n.stroke();
|
|
314
313
|
});
|
|
315
314
|
}
|
|
@@ -339,7 +338,7 @@ var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, F = function(t) {
|
|
|
339
338
|
return { r: $(t.r, 0, 255), g: $(t.g, 0, 255), b: $(t.b, 0, 255), a: $(t.a) };
|
|
340
339
|
}, St = function(t) {
|
|
341
340
|
return { r: V(t.r), g: V(t.g), b: V(t.b), a: V(t.a, 3) };
|
|
342
|
-
}, We = /^#([0-9a-f]{3,8})$/i,
|
|
341
|
+
}, We = /^#([0-9a-f]{3,8})$/i, pt = function(t) {
|
|
343
342
|
var e = t.toString(16);
|
|
344
343
|
return e.length < 2 ? "0" + e : e;
|
|
345
344
|
}, de = function(t) {
|
|
@@ -357,7 +356,7 @@ var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, F = function(t) {
|
|
|
357
356
|
}, jt = function(t) {
|
|
358
357
|
return ue((n = (e = t).s, { h: e.h, s: (n *= ((o = e.l) < 50 ? o : 100 - o) / 100) > 0 ? 2 * n / (o + n) * 100 : 0, v: o + n, a: e.a }));
|
|
359
358
|
var e, n, o;
|
|
360
|
-
},
|
|
359
|
+
}, ct = function(t) {
|
|
361
360
|
return { h: (e = de(t)).h, s: (i = (200 - (n = e.s)) * (o = e.v) / 100) > 0 && i < 200 ? n * o / 100 / (i <= 100 ? i : 200 - i) * 100 : 0, l: i / 2, a: e.a };
|
|
362
361
|
var e, n, o, i;
|
|
363
362
|
}, qe = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Ge = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Qe = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Je = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, zt = { string: [[function(t) {
|
|
@@ -395,12 +394,12 @@ var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, F = function(t) {
|
|
|
395
394
|
}, Ze = function(t) {
|
|
396
395
|
return typeof t == "string" ? Ft(t.trim(), zt.string) : typeof t == "object" && t !== null ? Ft(t, zt.object) : [null, void 0];
|
|
397
396
|
}, Ct = function(t, e) {
|
|
398
|
-
var n =
|
|
397
|
+
var n = ct(t);
|
|
399
398
|
return { h: n.h, s: $(n.s + 100 * e, 0, 100), l: n.l, a: n.a };
|
|
400
399
|
}, Lt = function(t) {
|
|
401
400
|
return (299 * t.r + 587 * t.g + 114 * t.b) / 1e3 / 255;
|
|
402
401
|
}, Wt = function(t, e) {
|
|
403
|
-
var n =
|
|
402
|
+
var n = ct(t);
|
|
404
403
|
return { h: n.h, s: n.s, l: $(n.l + 100 * e, 0, 100), a: n.a };
|
|
405
404
|
}, qt = function() {
|
|
406
405
|
function t(e) {
|
|
@@ -415,7 +414,7 @@ var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, F = function(t) {
|
|
|
415
414
|
}, t.prototype.isLight = function() {
|
|
416
415
|
return Lt(this.rgba) >= 0.5;
|
|
417
416
|
}, t.prototype.toHex = function() {
|
|
418
|
-
return e = St(this.rgba), n = e.r, o = e.g, i = e.b, a = (s = e.a) < 1 ?
|
|
417
|
+
return e = St(this.rgba), n = e.r, o = e.g, i = e.b, a = (s = e.a) < 1 ? pt(V(255 * s)) : "", "#" + pt(n) + pt(o) + pt(i) + a;
|
|
419
418
|
var e, n, o, i, s, a;
|
|
420
419
|
}, t.prototype.toRgb = function() {
|
|
421
420
|
return St(this.rgba);
|
|
@@ -423,9 +422,9 @@ var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, F = function(t) {
|
|
|
423
422
|
return e = St(this.rgba), n = e.r, o = e.g, i = e.b, (s = e.a) < 1 ? "rgba(" + n + ", " + o + ", " + i + ", " + s + ")" : "rgb(" + n + ", " + o + ", " + i + ")";
|
|
424
423
|
var e, n, o, i, s;
|
|
425
424
|
}, t.prototype.toHsl = function() {
|
|
426
|
-
return Ht(
|
|
425
|
+
return Ht(ct(this.rgba));
|
|
427
426
|
}, t.prototype.toHslString = function() {
|
|
428
|
-
return e = Ht(
|
|
427
|
+
return e = Ht(ct(this.rgba)), n = e.h, o = e.s, i = e.l, (s = e.a) < 1 ? "hsla(" + n + ", " + o + "%, " + i + "%, " + s + ")" : "hsl(" + n + ", " + o + "%, " + i + "%)";
|
|
429
428
|
var e, n, o, i, s;
|
|
430
429
|
}, t.prototype.toHsv = function() {
|
|
431
430
|
return e = de(this.rgba), { h: V(e.h), s: V(e.s), v: V(e.v), a: V(e.a, 3) };
|
|
@@ -449,7 +448,7 @@ var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, F = function(t) {
|
|
|
449
448
|
return typeof e == "number" ? j({ r: (n = this.rgba).r, g: n.g, b: n.b, a: e }) : V(this.rgba.a, 3);
|
|
450
449
|
var n;
|
|
451
450
|
}, t.prototype.hue = function(e) {
|
|
452
|
-
var n =
|
|
451
|
+
var n = ct(this.rgba);
|
|
453
452
|
return typeof e == "number" ? j({ h: e, s: n.s, l: n.l, a: n.a }) : V(n.h);
|
|
454
453
|
}, t.prototype.isEqual = function(e) {
|
|
455
454
|
return this.toHex() === j(e).toHex();
|
|
@@ -642,12 +641,12 @@ const fn = (t) => {
|
|
|
642
641
|
};
|
|
643
642
|
};
|
|
644
643
|
var hn = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(hn || {});
|
|
645
|
-
const
|
|
646
|
-
const { subscribe: o, set: i } = Kt(
|
|
647
|
-
let s = e, a =
|
|
644
|
+
const gt = { selected: [] }, pn = (t, e, n) => {
|
|
645
|
+
const { subscribe: o, set: i } = Kt(gt);
|
|
646
|
+
let s = e, a = gt;
|
|
648
647
|
o((g) => a = g);
|
|
649
648
|
const r = () => {
|
|
650
|
-
Q(a,
|
|
649
|
+
Q(a, gt) || i(gt);
|
|
651
650
|
}, l = () => {
|
|
652
651
|
var g;
|
|
653
652
|
return ((g = a.selected) == null ? void 0 : g.length) === 0;
|
|
@@ -660,7 +659,7 @@ const pt = { selected: [] }, pn = (t, e, n) => {
|
|
|
660
659
|
let A;
|
|
661
660
|
if (Array.isArray(g)) {
|
|
662
661
|
if (A = g.map((c) => t.getAnnotation(c)).filter(Boolean), A.length < g.length) {
|
|
663
|
-
console.warn("Invalid selection: " + g.filter((c) => !A.some((
|
|
662
|
+
console.warn("Invalid selection: " + g.filter((c) => !A.some((y) => y.id === c)));
|
|
664
663
|
return;
|
|
665
664
|
}
|
|
666
665
|
} else {
|
|
@@ -671,17 +670,17 @@ const pt = { selected: [] }, pn = (t, e, n) => {
|
|
|
671
670
|
}
|
|
672
671
|
A = [c];
|
|
673
672
|
}
|
|
674
|
-
const d = A.reduce((c,
|
|
675
|
-
const S = Zt(
|
|
676
|
-
return S === "EDIT" ? [...c, { id:
|
|
673
|
+
const d = A.reduce((c, y) => {
|
|
674
|
+
const S = Zt(y, s, n);
|
|
675
|
+
return S === "EDIT" ? [...c, { id: y.id, editable: !0 }] : S === "SELECT" ? [...c, { id: y.id }] : c;
|
|
677
676
|
}, []);
|
|
678
677
|
i({ selected: d, event: m });
|
|
679
678
|
}, u = (g, m) => {
|
|
680
679
|
const A = Array.isArray(g) ? g : [g], d = A.map((c) => t.getAnnotation(c)).filter((c) => !!c);
|
|
681
680
|
i({
|
|
682
681
|
selected: d.map((c) => {
|
|
683
|
-
const
|
|
684
|
-
return { id: c.id, editable:
|
|
682
|
+
const y = m === void 0 ? Zt(c, s, n) === "EDIT" : m;
|
|
683
|
+
return { id: c.id, editable: y };
|
|
685
684
|
})
|
|
686
685
|
}), d.length !== A.length && console.warn("Invalid selection", g);
|
|
687
686
|
}, p = (g) => {
|
|
@@ -712,7 +711,10 @@ const pt = { selected: [] }, pn = (t, e, n) => {
|
|
|
712
711
|
subscribe: o,
|
|
713
712
|
userSelect: h
|
|
714
713
|
};
|
|
715
|
-
}, Zt = (t, e, n) =>
|
|
714
|
+
}, Zt = (t, e, n) => {
|
|
715
|
+
const o = n ? n.serialize(t) : t;
|
|
716
|
+
return typeof e == "function" ? e(o) : e || "EDIT";
|
|
717
|
+
}, K = [];
|
|
716
718
|
for (let t = 0; t < 256; ++t)
|
|
717
719
|
K.push((t + 256).toString(16).slice(1));
|
|
718
720
|
function gn(t, e = 0) {
|
|
@@ -817,7 +819,7 @@ const En = (t, e) => {
|
|
|
817
819
|
...(e.updated || []).filter(({ oldValue: u }) => !r.has(u.id))
|
|
818
820
|
];
|
|
819
821
|
return { created: l, deleted: f, updated: h };
|
|
820
|
-
},
|
|
822
|
+
}, mt = (t) => {
|
|
821
823
|
const e = t.id === void 0 ? he() : t.id;
|
|
822
824
|
return {
|
|
823
825
|
...t,
|
|
@@ -832,14 +834,14 @@ const En = (t, e) => {
|
|
|
832
834
|
}
|
|
833
835
|
};
|
|
834
836
|
}, Cn = (t) => t.id !== void 0, Ln = () => {
|
|
835
|
-
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (
|
|
836
|
-
n.push({ onChange:
|
|
837
|
-
}, i = (
|
|
838
|
-
const x = n.findIndex((w) => w.onChange ==
|
|
837
|
+
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (b, x = {}) => {
|
|
838
|
+
n.push({ onChange: b, options: x });
|
|
839
|
+
}, i = (b) => {
|
|
840
|
+
const x = n.findIndex((w) => w.onChange == b);
|
|
839
841
|
x > -1 && n.splice(x, 1);
|
|
840
|
-
}, s = (
|
|
842
|
+
}, s = (b, x) => {
|
|
841
843
|
const w = {
|
|
842
|
-
origin:
|
|
844
|
+
origin: b,
|
|
843
845
|
changes: {
|
|
844
846
|
created: x.created || [],
|
|
845
847
|
updated: x.updated || [],
|
|
@@ -850,94 +852,94 @@ const En = (t, e) => {
|
|
|
850
852
|
n.forEach((L) => {
|
|
851
853
|
En(L, w) && L.onChange(w);
|
|
852
854
|
});
|
|
853
|
-
}, a = (
|
|
854
|
-
if (
|
|
855
|
-
throw Error(`Cannot add annotation ${
|
|
855
|
+
}, a = (b, x = k.LOCAL) => {
|
|
856
|
+
if (b.id && t.get(b.id))
|
|
857
|
+
throw Error(`Cannot add annotation ${b.id} - exists already`);
|
|
856
858
|
{
|
|
857
|
-
const w =
|
|
859
|
+
const w = mt(b);
|
|
858
860
|
t.set(w.id, w), w.bodies.forEach((L) => e.set(L.id, w.id)), s(x, { created: [w] });
|
|
859
861
|
}
|
|
860
|
-
}, r = (
|
|
861
|
-
const w =
|
|
862
|
+
}, r = (b, x) => {
|
|
863
|
+
const w = mt(typeof b == "string" ? x : b), L = typeof b == "string" ? b : b.id, B = L && t.get(L);
|
|
862
864
|
if (B) {
|
|
863
865
|
const O = pe(B, w);
|
|
864
|
-
return L === w.id ? t.set(L, w) : (t.delete(L), t.set(w.id, w)), B.bodies.forEach((
|
|
866
|
+
return L === w.id ? t.set(L, w) : (t.delete(L), t.set(w.id, w)), B.bodies.forEach((_) => e.delete(_.id)), w.bodies.forEach((_) => e.set(_.id, w.id)), O;
|
|
865
867
|
} else
|
|
866
868
|
console.warn(`Cannot update annotation ${L} - does not exist`);
|
|
867
|
-
}, l = (
|
|
868
|
-
const L = Cn(x) ? w : x, B = r(
|
|
869
|
+
}, l = (b, x = k.LOCAL, w = k.LOCAL) => {
|
|
870
|
+
const L = Cn(x) ? w : x, B = r(b, x);
|
|
869
871
|
B && s(L, { updated: [B] });
|
|
870
|
-
}, f = (
|
|
871
|
-
t.get(
|
|
872
|
-
}, h = (
|
|
873
|
-
const w =
|
|
872
|
+
}, f = (b, x = k.LOCAL) => {
|
|
873
|
+
t.get(b.id) ? l(b, x) : a(b, x);
|
|
874
|
+
}, h = (b, x = k.LOCAL) => {
|
|
875
|
+
const w = b.reduce((L, B) => {
|
|
874
876
|
const O = r(B);
|
|
875
877
|
return O ? [...L, O] : L;
|
|
876
878
|
}, []);
|
|
877
879
|
w.length > 0 && s(x, { updated: w });
|
|
878
|
-
}, u = (
|
|
879
|
-
const w =
|
|
880
|
-
L.forEach((
|
|
881
|
-
t.set(
|
|
880
|
+
}, u = (b, x = k.LOCAL) => {
|
|
881
|
+
const w = b.map(mt), { toAdd: L, toUpdate: B } = w.reduce((_, P) => t.get(P.id) ? { ..._, toUpdate: [..._.toUpdate, P] } : { ..._, toAdd: [..._.toAdd, P] }, { toAdd: [], toUpdate: [] }), O = B.map((_) => r(_, x)).filter(Boolean);
|
|
882
|
+
L.forEach((_) => {
|
|
883
|
+
t.set(_.id, _), _.bodies.forEach((P) => e.set(P.id, _.id));
|
|
882
884
|
}), s(x, { created: L, updated: O });
|
|
883
|
-
}, p = (
|
|
884
|
-
const w = t.get(
|
|
885
|
+
}, p = (b, x = k.LOCAL) => {
|
|
886
|
+
const w = t.get(b.annotation);
|
|
885
887
|
if (w) {
|
|
886
888
|
const L = {
|
|
887
889
|
...w,
|
|
888
|
-
bodies: [...w.bodies,
|
|
890
|
+
bodies: [...w.bodies, b]
|
|
889
891
|
};
|
|
890
|
-
t.set(w.id, L), e.set(
|
|
892
|
+
t.set(w.id, L), e.set(b.id, L.id), s(x, { updated: [{
|
|
891
893
|
oldValue: w,
|
|
892
894
|
newValue: L,
|
|
893
|
-
bodiesCreated: [
|
|
895
|
+
bodiesCreated: [b]
|
|
894
896
|
}] });
|
|
895
897
|
} else
|
|
896
|
-
console.warn(`Attempt to add body to missing annotation: ${
|
|
897
|
-
}, v = () => [...t.values()], g = (
|
|
898
|
+
console.warn(`Attempt to add body to missing annotation: ${b.annotation}`);
|
|
899
|
+
}, v = () => [...t.values()], g = (b = k.LOCAL) => {
|
|
898
900
|
const x = [...t.values()];
|
|
899
|
-
t.clear(), e.clear(), s(
|
|
900
|
-
}, m = (
|
|
901
|
-
const L =
|
|
901
|
+
t.clear(), e.clear(), s(b, { deleted: x });
|
|
902
|
+
}, m = (b, x = !0, w = k.LOCAL) => {
|
|
903
|
+
const L = b.map(mt);
|
|
902
904
|
if (x) {
|
|
903
905
|
const B = [...t.values()];
|
|
904
906
|
t.clear(), e.clear(), L.forEach((O) => {
|
|
905
|
-
t.set(O.id, O), O.bodies.forEach((
|
|
907
|
+
t.set(O.id, O), O.bodies.forEach((_) => e.set(_.id, O.id));
|
|
906
908
|
}), s(w, { created: L, deleted: B });
|
|
907
909
|
} else {
|
|
908
|
-
const B =
|
|
909
|
-
const P =
|
|
910
|
+
const B = b.reduce((O, _) => {
|
|
911
|
+
const P = _.id && t.get(_.id);
|
|
910
912
|
return P ? [...O, P] : O;
|
|
911
913
|
}, []);
|
|
912
914
|
if (B.length > 0)
|
|
913
915
|
throw Error(`Bulk insert would overwrite the following annotations: ${B.map((O) => O.id).join(", ")}`);
|
|
914
916
|
L.forEach((O) => {
|
|
915
|
-
t.set(O.id, O), O.bodies.forEach((
|
|
917
|
+
t.set(O.id, O), O.bodies.forEach((_) => e.set(_.id, O.id));
|
|
916
918
|
}), s(w, { created: L });
|
|
917
919
|
}
|
|
918
|
-
}, A = (
|
|
919
|
-
const x = typeof
|
|
920
|
+
}, A = (b) => {
|
|
921
|
+
const x = typeof b == "string" ? b : b.id, w = t.get(x);
|
|
920
922
|
if (w)
|
|
921
923
|
return t.delete(x), w.bodies.forEach((L) => e.delete(L.id)), w;
|
|
922
924
|
console.warn(`Attempt to delete missing annotation: ${x}`);
|
|
923
|
-
}, d = (
|
|
924
|
-
const w = A(
|
|
925
|
+
}, d = (b, x = k.LOCAL) => {
|
|
926
|
+
const w = A(b);
|
|
925
927
|
w && s(x, { deleted: [w] });
|
|
926
|
-
}, c = (
|
|
927
|
-
const w =
|
|
928
|
+
}, c = (b, x = k.LOCAL) => {
|
|
929
|
+
const w = b.reduce((L, B) => {
|
|
928
930
|
const O = A(B);
|
|
929
931
|
return O ? [...L, O] : L;
|
|
930
932
|
}, []);
|
|
931
933
|
w.length > 0 && s(x, { deleted: w });
|
|
932
|
-
},
|
|
933
|
-
const x = t.get(
|
|
934
|
+
}, y = (b) => {
|
|
935
|
+
const x = t.get(b.annotation);
|
|
934
936
|
if (x) {
|
|
935
|
-
const w = x.bodies.find((L) => L.id ===
|
|
937
|
+
const w = x.bodies.find((L) => L.id === b.id);
|
|
936
938
|
if (w) {
|
|
937
939
|
e.delete(w.id);
|
|
938
940
|
const L = {
|
|
939
941
|
...x,
|
|
940
|
-
bodies: x.bodies.filter((B) => B.id !==
|
|
942
|
+
bodies: x.bodies.filter((B) => B.id !== b.id)
|
|
941
943
|
};
|
|
942
944
|
return t.set(x.id, L), {
|
|
943
945
|
oldValue: x,
|
|
@@ -945,33 +947,33 @@ const En = (t, e) => {
|
|
|
945
947
|
bodiesDeleted: [w]
|
|
946
948
|
};
|
|
947
949
|
} else
|
|
948
|
-
console.warn(`Attempt to delete missing body ${
|
|
950
|
+
console.warn(`Attempt to delete missing body ${b.id} from annotation ${b.annotation}`);
|
|
949
951
|
} else
|
|
950
|
-
console.warn(`Attempt to delete body from missing annotation ${
|
|
951
|
-
}, S = (
|
|
952
|
-
const w = b
|
|
952
|
+
console.warn(`Attempt to delete body from missing annotation ${b.annotation}`);
|
|
953
|
+
}, S = (b, x = k.LOCAL) => {
|
|
954
|
+
const w = y(b);
|
|
953
955
|
w && s(x, { updated: [w] });
|
|
954
|
-
}, E = (
|
|
955
|
-
const w =
|
|
956
|
+
}, E = (b, x = k.LOCAL) => {
|
|
957
|
+
const w = b.map((L) => y(L)).filter(Boolean);
|
|
956
958
|
w.length > 0 && s(x, { updated: w });
|
|
957
|
-
}, C = (
|
|
958
|
-
const x = t.get(
|
|
959
|
+
}, C = (b) => {
|
|
960
|
+
const x = t.get(b);
|
|
959
961
|
return x ? { ...x } : void 0;
|
|
960
|
-
}, R = (
|
|
961
|
-
const x = e.get(
|
|
962
|
+
}, R = (b) => {
|
|
963
|
+
const x = e.get(b);
|
|
962
964
|
if (x) {
|
|
963
|
-
const w = C(x).bodies.find((L) => L.id ===
|
|
965
|
+
const w = C(x).bodies.find((L) => L.id === b);
|
|
964
966
|
if (w)
|
|
965
967
|
return w;
|
|
966
|
-
console.error(`Store integrity error: body ${
|
|
968
|
+
console.error(`Store integrity error: body ${b} in index, but not in annotation`);
|
|
967
969
|
} else
|
|
968
|
-
console.warn(`Attempt to retrieve missing body: ${
|
|
969
|
-
}, M = (
|
|
970
|
-
if (
|
|
970
|
+
console.warn(`Attempt to retrieve missing body: ${b}`);
|
|
971
|
+
}, M = (b, x) => {
|
|
972
|
+
if (b.annotation !== x.annotation)
|
|
971
973
|
throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
|
|
972
|
-
const w = t.get(
|
|
974
|
+
const w = t.get(b.annotation);
|
|
973
975
|
if (w) {
|
|
974
|
-
const L = w.bodies.find((O) => O.id ===
|
|
976
|
+
const L = w.bodies.find((O) => O.id === b.id), B = {
|
|
975
977
|
...w,
|
|
976
978
|
bodies: w.bodies.map((O) => O.id === L.id ? x : O)
|
|
977
979
|
};
|
|
@@ -981,21 +983,21 @@ const En = (t, e) => {
|
|
|
981
983
|
bodiesUpdated: [{ oldBody: L, newBody: x }]
|
|
982
984
|
};
|
|
983
985
|
} else
|
|
984
|
-
console.warn(`Attempt to add body to missing annotation ${
|
|
985
|
-
}, T = (
|
|
986
|
-
const L = M(
|
|
986
|
+
console.warn(`Attempt to add body to missing annotation ${b.annotation}`);
|
|
987
|
+
}, T = (b, x, w = k.LOCAL) => {
|
|
988
|
+
const L = M(b, x);
|
|
987
989
|
L && s(w, { updated: [L] });
|
|
988
|
-
}, I = (
|
|
989
|
-
const w =
|
|
990
|
+
}, I = (b, x = k.LOCAL) => {
|
|
991
|
+
const w = b.map((L) => M({ id: L.id, annotation: L.annotation }, L)).filter(Boolean);
|
|
990
992
|
s(x, { updated: w });
|
|
991
|
-
}, D = (
|
|
992
|
-
const x = t.get(
|
|
993
|
+
}, D = (b) => {
|
|
994
|
+
const x = t.get(b.annotation);
|
|
993
995
|
if (x) {
|
|
994
996
|
const w = {
|
|
995
997
|
...x,
|
|
996
998
|
target: {
|
|
997
999
|
...x.target,
|
|
998
|
-
...
|
|
1000
|
+
...b
|
|
999
1001
|
}
|
|
1000
1002
|
};
|
|
1001
1003
|
return t.set(x.id, w), {
|
|
@@ -1003,11 +1005,11 @@ const En = (t, e) => {
|
|
|
1003
1005
|
newValue: w,
|
|
1004
1006
|
targetUpdated: {
|
|
1005
1007
|
oldTarget: x.target,
|
|
1006
|
-
newTarget:
|
|
1008
|
+
newTarget: b
|
|
1007
1009
|
}
|
|
1008
1010
|
};
|
|
1009
1011
|
} else
|
|
1010
|
-
console.warn(`Attempt to update target on missing annotation: ${
|
|
1012
|
+
console.warn(`Attempt to update target on missing annotation: ${b.annotation}`);
|
|
1011
1013
|
};
|
|
1012
1014
|
return {
|
|
1013
1015
|
addAnnotation: a,
|
|
@@ -1018,8 +1020,8 @@ const En = (t, e) => {
|
|
|
1018
1020
|
bulkDeleteBodies: E,
|
|
1019
1021
|
bulkUpdateAnnotations: h,
|
|
1020
1022
|
bulkUpdateBodies: I,
|
|
1021
|
-
bulkUpdateTargets: (
|
|
1022
|
-
const w =
|
|
1023
|
+
bulkUpdateTargets: (b, x = k.LOCAL) => {
|
|
1024
|
+
const w = b.map((L) => D(L)).filter(Boolean);
|
|
1023
1025
|
w.length > 0 && s(x, { updated: w });
|
|
1024
1026
|
},
|
|
1025
1027
|
bulkUpsertAnnotations: u,
|
|
@@ -1032,8 +1034,8 @@ const En = (t, e) => {
|
|
|
1032
1034
|
unobserve: i,
|
|
1033
1035
|
updateAnnotation: l,
|
|
1034
1036
|
updateBody: T,
|
|
1035
|
-
updateTarget: (
|
|
1036
|
-
const w = D(
|
|
1037
|
+
updateTarget: (b, x = k.LOCAL) => {
|
|
1038
|
+
const w = D(b);
|
|
1037
1039
|
w && s(x, { updated: [w] });
|
|
1038
1040
|
},
|
|
1039
1041
|
upsertAnnotation: f
|
|
@@ -1113,8 +1115,8 @@ const On = 250, Rn = (t, e) => {
|
|
|
1113
1115
|
l.has(m) && setTimeout(() => {
|
|
1114
1116
|
l.get(m).forEach((c) => {
|
|
1115
1117
|
if (n) {
|
|
1116
|
-
const
|
|
1117
|
-
c(
|
|
1118
|
+
const y = Array.isArray(A) ? A.map((E) => n.serialize(E)) : n.serialize(A), S = d ? d instanceof PointerEvent ? d : n.serialize(d) : void 0;
|
|
1119
|
+
c(y, S);
|
|
1118
1120
|
} else
|
|
1119
1121
|
c(A, d);
|
|
1120
1122
|
});
|
|
@@ -1132,8 +1134,8 @@ const On = 250, Rn = (t, e) => {
|
|
|
1132
1134
|
else {
|
|
1133
1135
|
const A = new Set(f.map((c) => c.id)), d = new Set(m.map(({ id: c }) => c));
|
|
1134
1136
|
f.filter((c) => !d.has(c.id)).forEach((c) => {
|
|
1135
|
-
const
|
|
1136
|
-
|
|
1137
|
+
const y = a.getAnnotation(c.id);
|
|
1138
|
+
y && !Q(y, c) && v("updateAnnotation", y, c);
|
|
1137
1139
|
}), f = [
|
|
1138
1140
|
// Remove annotations that were deselected
|
|
1139
1141
|
...f.filter((c) => d.has(c.id)),
|
|
@@ -1151,9 +1153,9 @@ const On = 250, Rn = (t, e) => {
|
|
|
1151
1153
|
...c.bodiesCreated || [],
|
|
1152
1154
|
...c.bodiesDeleted || [],
|
|
1153
1155
|
...c.bodiesUpdated || []
|
|
1154
|
-
].length > 0).forEach(({ oldValue: c, newValue:
|
|
1156
|
+
].length > 0).forEach(({ oldValue: c, newValue: y }) => {
|
|
1155
1157
|
const S = f.find((E) => E.id === c.id) || c;
|
|
1156
|
-
f = f.map((E) => E.id === c.id ?
|
|
1158
|
+
f = f.map((E) => E.id === c.id ? y : E), v("updateAnnotation", y, S);
|
|
1157
1159
|
});
|
|
1158
1160
|
}, { origin: k.LOCAL }), a.observe((m) => {
|
|
1159
1161
|
if (f) {
|
|
@@ -1180,8 +1182,8 @@ const On = 250, Rn = (t, e) => {
|
|
|
1180
1182
|
}, { parsed: [], failed: [] }), In = (t, e, n) => {
|
|
1181
1183
|
const { store: o, selection: i } = t, s = (d) => {
|
|
1182
1184
|
if (n) {
|
|
1183
|
-
const { parsed: c, error:
|
|
1184
|
-
c ? o.addAnnotation(c, k.REMOTE) : console.error(
|
|
1185
|
+
const { parsed: c, error: y } = n.parse(d);
|
|
1186
|
+
c ? o.addAnnotation(c, k.REMOTE) : console.error(y);
|
|
1185
1187
|
} else
|
|
1186
1188
|
o.addAnnotation(Mt(d), k.REMOTE);
|
|
1187
1189
|
}, a = () => i.clear(), r = () => o.clear(), l = (d) => {
|
|
@@ -1189,9 +1191,9 @@ const On = 250, Rn = (t, e) => {
|
|
|
1189
1191
|
return n && c ? n.serialize(c) : c;
|
|
1190
1192
|
}, f = () => n ? o.all().map(n.serialize) : o.all(), h = () => {
|
|
1191
1193
|
var d;
|
|
1192
|
-
const c = (((d = i.selected) == null ? void 0 : d.map((
|
|
1194
|
+
const c = (((d = i.selected) == null ? void 0 : d.map((y) => y.id)) || []).map((y) => o.getAnnotation(y)).filter(Boolean);
|
|
1193
1195
|
return n ? c.map(n.serialize) : c;
|
|
1194
|
-
}, u = (d, c = !0) => fetch(d).then((
|
|
1196
|
+
}, u = (d, c = !0) => fetch(d).then((y) => y.json()).then((y) => (v(y, c), y)), p = (d) => {
|
|
1195
1197
|
if (typeof d == "string") {
|
|
1196
1198
|
const c = o.getAnnotation(d);
|
|
1197
1199
|
if (o.deleteAnnotation(d), c)
|
|
@@ -1203,7 +1205,7 @@ const On = 250, Rn = (t, e) => {
|
|
|
1203
1205
|
}
|
|
1204
1206
|
}, v = (d, c = !0) => {
|
|
1205
1207
|
if (n) {
|
|
1206
|
-
const
|
|
1208
|
+
const y = n.parseAll || kn(n), { parsed: S, failed: E } = y(d);
|
|
1207
1209
|
E.length > 0 && console.warn(`Discarded ${E.length} invalid annotations`, E), o.bulkAddAnnotations(S, c, k.REMOTE);
|
|
1208
1210
|
} else
|
|
1209
1211
|
o.bulkAddAnnotations(d.map(Mt), c, k.REMOTE);
|
|
@@ -1213,8 +1215,8 @@ const On = 250, Rn = (t, e) => {
|
|
|
1213
1215
|
i.clear(), i.setUserSelectAction(d);
|
|
1214
1216
|
}, A = (d) => {
|
|
1215
1217
|
if (n) {
|
|
1216
|
-
const c = n.parse(d).parsed,
|
|
1217
|
-
return o.updateAnnotation(c),
|
|
1218
|
+
const c = n.parse(d).parsed, y = n.serialize(o.getAnnotation(c.id));
|
|
1219
|
+
return o.updateAnnotation(c), y;
|
|
1218
1220
|
} else {
|
|
1219
1221
|
const c = o.getAnnotation(d.id);
|
|
1220
1222
|
return o.updateAnnotation(Mt(d)), c;
|
|
@@ -1239,8 +1241,8 @@ const On = 250, Rn = (t, e) => {
|
|
|
1239
1241
|
undo: e.undo,
|
|
1240
1242
|
updateAnnotation: A
|
|
1241
1243
|
};
|
|
1242
|
-
},
|
|
1243
|
-
let
|
|
1244
|
+
}, _n = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
1245
|
+
let Un = (t) => crypto.getRandomValues(new Uint8Array(t)), Nn = (t, e, n) => {
|
|
1244
1246
|
let o = (2 << Math.log2(t.length - 1)) - 1, i = -~(1.6 * o * e / t.length);
|
|
1245
1247
|
return (s = e) => {
|
|
1246
1248
|
let a = "";
|
|
@@ -1250,10 +1252,10 @@ let _n = (t) => crypto.getRandomValues(new Uint8Array(t)), Nn = (t, e, n) => {
|
|
|
1250
1252
|
if (a += t[r[l] & o] || "", a.length >= s) return a;
|
|
1251
1253
|
}
|
|
1252
1254
|
};
|
|
1253
|
-
}, Vn = (t, e = 21) => Nn(t, e | 0,
|
|
1255
|
+
}, Vn = (t, e = 21) => Nn(t, e | 0, Un), Dn = (t = 21) => {
|
|
1254
1256
|
let e = "", n = crypto.getRandomValues(new Uint8Array(t |= 0));
|
|
1255
1257
|
for (; t--; )
|
|
1256
|
-
e +=
|
|
1258
|
+
e += _n[n[t] & 63];
|
|
1257
1259
|
return e;
|
|
1258
1260
|
};
|
|
1259
1261
|
const Yn = () => ({ isGuest: !0, id: Vn("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), Kn = (t) => {
|
|
@@ -1371,7 +1373,7 @@ const xo = (t, e) => ({
|
|
|
1371
1373
|
const { prefix: S, suffix: E } = Be(d, n);
|
|
1372
1374
|
c.prefix = S, c.suffix = E;
|
|
1373
1375
|
}
|
|
1374
|
-
const
|
|
1376
|
+
const y = {
|
|
1375
1377
|
type: "TextPositionSelector",
|
|
1376
1378
|
start: m,
|
|
1377
1379
|
end: A
|
|
@@ -1382,7 +1384,7 @@ const xo = (t, e) => ({
|
|
|
1382
1384
|
// @ts-expect-error: `scope` is not part of the core `TextSelector` type
|
|
1383
1385
|
scope: "scope" in p ? p.scope : void 0,
|
|
1384
1386
|
source: e,
|
|
1385
|
-
selector: [c,
|
|
1387
|
+
selector: [c, y]
|
|
1386
1388
|
};
|
|
1387
1389
|
});
|
|
1388
1390
|
return {
|
|
@@ -1429,12 +1431,12 @@ class Wn {
|
|
|
1429
1431
|
search(e) {
|
|
1430
1432
|
let n = this.data;
|
|
1431
1433
|
const o = [];
|
|
1432
|
-
if (!
|
|
1434
|
+
if (!bt(e, n)) return o;
|
|
1433
1435
|
const i = this.toBBox, s = [];
|
|
1434
1436
|
for (; n; ) {
|
|
1435
1437
|
for (let a = 0; a < n.children.length; a++) {
|
|
1436
1438
|
const r = n.children[a], l = n.leaf ? i(r) : r;
|
|
1437
|
-
|
|
1439
|
+
bt(e, l) && (n.leaf ? o.push(r) : kt(e, l) ? this._all(r, o) : s.push(r));
|
|
1438
1440
|
}
|
|
1439
1441
|
n = s.pop();
|
|
1440
1442
|
}
|
|
@@ -1442,12 +1444,12 @@ class Wn {
|
|
|
1442
1444
|
}
|
|
1443
1445
|
collides(e) {
|
|
1444
1446
|
let n = this.data;
|
|
1445
|
-
if (!
|
|
1447
|
+
if (!bt(e, n)) return !1;
|
|
1446
1448
|
const o = [];
|
|
1447
1449
|
for (; n; ) {
|
|
1448
1450
|
for (let i = 0; i < n.children.length; i++) {
|
|
1449
1451
|
const s = n.children[i], a = n.leaf ? this.toBBox(s) : s;
|
|
1450
|
-
if (
|
|
1452
|
+
if (bt(e, a)) {
|
|
1451
1453
|
if (n.leaf || kt(e, a)) return !0;
|
|
1452
1454
|
o.push(s);
|
|
1453
1455
|
}
|
|
@@ -1581,14 +1583,14 @@ class Wn {
|
|
|
1581
1583
|
_allDistMargin(e, n, o, i) {
|
|
1582
1584
|
e.children.sort(i);
|
|
1583
1585
|
const s = this.toBBox, a = st(e, 0, n, s), r = st(e, o - n, o, s);
|
|
1584
|
-
let l =
|
|
1586
|
+
let l = yt(a) + yt(r);
|
|
1585
1587
|
for (let f = n; f < o - n; f++) {
|
|
1586
1588
|
const h = e.children[f];
|
|
1587
|
-
rt(a, e.leaf ? s(h) : h), l +=
|
|
1589
|
+
rt(a, e.leaf ? s(h) : h), l += yt(a);
|
|
1588
1590
|
}
|
|
1589
1591
|
for (let f = o - n - 1; f >= n; f--) {
|
|
1590
1592
|
const h = e.children[f];
|
|
1591
|
-
rt(r, e.leaf ? s(h) : h), l +=
|
|
1593
|
+
rt(r, e.leaf ? s(h) : h), l += yt(r);
|
|
1592
1594
|
}
|
|
1593
1595
|
return l;
|
|
1594
1596
|
}
|
|
@@ -1630,7 +1632,7 @@ function Qn(t, e) {
|
|
|
1630
1632
|
function Bt(t) {
|
|
1631
1633
|
return (t.maxX - t.minX) * (t.maxY - t.minY);
|
|
1632
1634
|
}
|
|
1633
|
-
function
|
|
1635
|
+
function yt(t) {
|
|
1634
1636
|
return t.maxX - t.minX + (t.maxY - t.minY);
|
|
1635
1637
|
}
|
|
1636
1638
|
function Jn(t, e) {
|
|
@@ -1643,7 +1645,7 @@ function Zn(t, e) {
|
|
|
1643
1645
|
function kt(t, e) {
|
|
1644
1646
|
return t.minX <= e.minX && t.minY <= e.minY && e.maxX <= t.maxX && e.maxY <= t.maxY;
|
|
1645
1647
|
}
|
|
1646
|
-
function
|
|
1648
|
+
function bt(t, e) {
|
|
1647
1649
|
return e.minX <= t.maxX && e.minY <= t.maxY && e.maxX >= t.minX && e.maxY >= t.minY;
|
|
1648
1650
|
}
|
|
1649
1651
|
function tt(t) {
|
|
@@ -1667,10 +1669,10 @@ function ee(t, e, n, o, i) {
|
|
|
1667
1669
|
}
|
|
1668
1670
|
const to = (t, e) => {
|
|
1669
1671
|
const n = new Wn(), o = /* @__PURE__ */ new Map(), i = (d, c) => {
|
|
1670
|
-
const
|
|
1672
|
+
const y = d.selector.flatMap((E) => {
|
|
1671
1673
|
const C = q([E]) ? E.range : ae(E, e).range;
|
|
1672
1674
|
return Array.from(C.getClientRects());
|
|
1673
|
-
}), S = Ne(
|
|
1675
|
+
}), S = Ne(y).map(({ left: E, top: C, right: R, bottom: M }) => new DOMRect(E - c.left, C - c.top, R - E, M - C));
|
|
1674
1676
|
return S.map((E) => {
|
|
1675
1677
|
const { x: C, y: R, width: M, height: T } = E;
|
|
1676
1678
|
return {
|
|
@@ -1688,38 +1690,38 @@ const to = (t, e) => {
|
|
|
1688
1690
|
n.clear(), o.clear();
|
|
1689
1691
|
}, r = (d) => {
|
|
1690
1692
|
const c = i(d, e.getBoundingClientRect());
|
|
1691
|
-
c.length !== 0 && (c.forEach((
|
|
1693
|
+
c.length !== 0 && (c.forEach((y) => n.insert(y)), o.set(d.annotation, c));
|
|
1692
1694
|
}, l = (d) => {
|
|
1693
1695
|
const c = o.get(d.annotation);
|
|
1694
|
-
c && (c.forEach((
|
|
1696
|
+
c && (c.forEach((y) => n.remove(y)), o.delete(d.annotation));
|
|
1695
1697
|
}, f = (d) => {
|
|
1696
1698
|
l(d), r(d);
|
|
1697
1699
|
}, h = (d, c = !0) => {
|
|
1698
1700
|
c && a();
|
|
1699
|
-
const
|
|
1701
|
+
const y = e.getBoundingClientRect(), S = d.map((C) => ({ target: C, rects: i(C, y) }));
|
|
1700
1702
|
S.forEach(({ target: C, rects: R }) => {
|
|
1701
1703
|
R.length > 0 && o.set(C.annotation, R);
|
|
1702
1704
|
});
|
|
1703
1705
|
const E = S.flatMap(({ rects: C }) => C);
|
|
1704
1706
|
n.load(E);
|
|
1705
|
-
}, u = (d, c,
|
|
1707
|
+
}, u = (d, c, y = !1) => {
|
|
1706
1708
|
const S = n.search({
|
|
1707
1709
|
minX: d,
|
|
1708
1710
|
minY: c,
|
|
1709
1711
|
maxX: d,
|
|
1710
1712
|
maxY: c
|
|
1711
1713
|
}), E = (C) => C.annotation.rects.reduce((R, M) => R + M.width * M.height, 0);
|
|
1712
|
-
return S.length > 0 ? (S.sort((C, R) => E(C) - E(R)),
|
|
1714
|
+
return S.length > 0 ? (S.sort((C, R) => E(C) - E(R)), y ? S.map((C) => C.annotation.id) : [S[0].annotation.id]) : [];
|
|
1713
1715
|
}, p = (d) => {
|
|
1714
1716
|
const c = v(d);
|
|
1715
1717
|
if (c.length === 0)
|
|
1716
1718
|
return;
|
|
1717
|
-
let
|
|
1719
|
+
let y = c[0].left, S = c[0].top, E = c[0].right, C = c[0].bottom;
|
|
1718
1720
|
for (let R = 1; R < c.length; R++) {
|
|
1719
1721
|
const M = c[R];
|
|
1720
|
-
|
|
1722
|
+
y = Math.min(y, M.left), S = Math.min(S, M.top), E = Math.max(E, M.right), C = Math.max(C, M.bottom);
|
|
1721
1723
|
}
|
|
1722
|
-
return new DOMRect(
|
|
1724
|
+
return new DOMRect(y, S, E - y, C - S);
|
|
1723
1725
|
}, v = (d) => {
|
|
1724
1726
|
const c = o.get(d);
|
|
1725
1727
|
return c ? c[0].annotation.rects : [];
|
|
@@ -1730,8 +1732,8 @@ const to = (t, e) => {
|
|
|
1730
1732
|
getAt: u,
|
|
1731
1733
|
getAnnotationBounds: p,
|
|
1732
1734
|
getAnnotationRects: v,
|
|
1733
|
-
getIntersecting: (d, c,
|
|
1734
|
-
const E = n.search({ minX: d, minY: c, maxX:
|
|
1735
|
+
getIntersecting: (d, c, y, S) => {
|
|
1736
|
+
const E = n.search({ minX: d, minY: c, maxX: y, maxY: S }), C = new Set(E.map((R) => R.annotation.id));
|
|
1735
1737
|
return Array.from(C).map((R) => ({
|
|
1736
1738
|
annotation: t.getAnnotation(R),
|
|
1737
1739
|
rects: v(R)
|
|
@@ -1745,38 +1747,36 @@ const to = (t, e) => {
|
|
|
1745
1747
|
update: f
|
|
1746
1748
|
};
|
|
1747
1749
|
}, eo = (t, e) => {
|
|
1748
|
-
const n = Ln(), o = to(n, t), i = pn(n)
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
return S && n.addAnnotation(b, c), S;
|
|
1753
|
-
}, l = (d, c = !0, b = k.LOCAL) => {
|
|
1750
|
+
const n = Ln(), o = to(n, t), i = pn(n, e.userSelectAction, e.adapter), s = fn(n), a = Mn(), r = (d, c = k.LOCAL) => {
|
|
1751
|
+
const y = Et(d, t), S = q(y.target.selector);
|
|
1752
|
+
return S && n.addAnnotation(y, c), S;
|
|
1753
|
+
}, l = (d, c = !0, y = k.LOCAL) => {
|
|
1754
1754
|
const S = d.map((C) => Et(C, t)), E = S.filter((C) => !q(C.target.selector));
|
|
1755
|
-
return n.bulkAddAnnotations(S, c,
|
|
1755
|
+
return n.bulkAddAnnotations(S, c, y), E;
|
|
1756
1756
|
}, f = (d, c = k.LOCAL) => {
|
|
1757
|
-
const
|
|
1758
|
-
return
|
|
1757
|
+
const y = d.map((E) => Et(E, t)), S = y.filter((E) => !q(E.target.selector));
|
|
1758
|
+
return y.forEach((E) => {
|
|
1759
1759
|
n.getAnnotation(E.id) ? n.updateAnnotation(E, c) : n.addAnnotation(E, c);
|
|
1760
1760
|
}), S;
|
|
1761
1761
|
}, h = (d, c = k.LOCAL) => {
|
|
1762
|
-
const
|
|
1763
|
-
n.updateTarget(
|
|
1762
|
+
const y = At(d, t);
|
|
1763
|
+
n.updateTarget(y, c);
|
|
1764
1764
|
}, u = (d, c = k.LOCAL) => {
|
|
1765
|
-
const
|
|
1766
|
-
n.bulkUpdateTargets(
|
|
1765
|
+
const y = d.map((S) => At(S, t));
|
|
1766
|
+
n.bulkUpdateTargets(y, c);
|
|
1767
1767
|
};
|
|
1768
|
-
function p(d, c,
|
|
1769
|
-
const E =
|
|
1768
|
+
function p(d, c, y, S) {
|
|
1769
|
+
const E = y || !!S, C = o.getAt(d, c, E).map((M) => n.getAnnotation(M)), R = S ? C.filter(S) : C;
|
|
1770
1770
|
if (R.length !== 0)
|
|
1771
|
-
return
|
|
1771
|
+
return y ? R : R[0];
|
|
1772
1772
|
}
|
|
1773
1773
|
const v = (d) => {
|
|
1774
1774
|
if (o.getAnnotationRects(d).length !== 0)
|
|
1775
1775
|
return o.getAnnotationBounds(d);
|
|
1776
|
-
}, g = (d, c,
|
|
1776
|
+
}, g = (d, c, y, S) => o.getIntersecting(d, c, y, S), m = (d) => o.getAnnotationRects(d), A = () => o.recalculate();
|
|
1777
1777
|
return n.observe(({ changes: d }) => {
|
|
1778
|
-
const c = (d.deleted || []).filter((E) => q(E.target.selector)),
|
|
1779
|
-
(c == null ? void 0 : c.length) > 0 && c.forEach((E) => o.remove(E.target)),
|
|
1778
|
+
const c = (d.deleted || []).filter((E) => q(E.target.selector)), y = (d.created || []).filter((E) => q(E.target.selector)), S = (d.updated || []).filter((E) => q(E.newValue.target.selector));
|
|
1779
|
+
(c == null ? void 0 : c.length) > 0 && c.forEach((E) => o.remove(E.target)), y.length > 0 && o.set(y.map((E) => E.target), !1), (S == null ? void 0 : S.length) > 0 && S.forEach(({ newValue: E }) => o.update(E.target));
|
|
1780
1780
|
}), {
|
|
1781
1781
|
store: {
|
|
1782
1782
|
...n,
|
|
@@ -1820,8 +1820,8 @@ const to = (t, e) => {
|
|
|
1820
1820
|
if (v) {
|
|
1821
1821
|
const { height: g } = h.rects[0], m = h.rects[0].x + u.left, A = h.rects[0].y + u.top;
|
|
1822
1822
|
o.fillStyle = v.appearance.color, o.fillRect(m - 2, A - 2.5, 2, g + 5);
|
|
1823
|
-
const d = o.measureText(v.appearance.label), c = d.width + 6,
|
|
1824
|
-
return o.fillRect(m - 2, A - 2.5 -
|
|
1823
|
+
const d = o.measureText(v.appearance.label), c = d.width + 6, y = d.actualBoundingBoxAscent + d.actualBoundingBoxDescent + 8, S = d.fontBoundingBoxAscent ? 8 : 6.5;
|
|
1824
|
+
return o.fillRect(m - 2, A - 2.5 - y, c, y), o.fillStyle = "#fff", o.fillText(v.appearance.label, m + 1, A - S), {
|
|
1825
1825
|
fill: v.appearance.color,
|
|
1826
1826
|
fillOpacity: p ? 0.45 : 0.18
|
|
1827
1827
|
};
|
|
@@ -1834,7 +1834,7 @@ const to = (t, e) => {
|
|
|
1834
1834
|
}
|
|
1835
1835
|
};
|
|
1836
1836
|
}, It = typeof navigator < "u" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : !1;
|
|
1837
|
-
function
|
|
1837
|
+
function _t(t, e, n, o) {
|
|
1838
1838
|
t.addEventListener ? t.addEventListener(e, n, o) : t.attachEvent && t.attachEvent("on".concat(e), n);
|
|
1839
1839
|
}
|
|
1840
1840
|
function ot(t, e, n, o) {
|
|
@@ -1860,7 +1860,7 @@ function io(t, e) {
|
|
|
1860
1860
|
o.indexOf(n[s]) === -1 && (i = !1);
|
|
1861
1861
|
return i;
|
|
1862
1862
|
}
|
|
1863
|
-
const
|
|
1863
|
+
const dt = {
|
|
1864
1864
|
backspace: 8,
|
|
1865
1865
|
"⌫": 8,
|
|
1866
1866
|
tab: 9,
|
|
@@ -1928,7 +1928,7 @@ const lt = {
|
|
|
1928
1928
|
"⌘": 91,
|
|
1929
1929
|
cmd: 91,
|
|
1930
1930
|
command: 91
|
|
1931
|
-
},
|
|
1931
|
+
}, at = {
|
|
1932
1932
|
16: "shiftKey",
|
|
1933
1933
|
18: "altKey",
|
|
1934
1934
|
17: "ctrlKey",
|
|
@@ -1944,20 +1944,20 @@ const lt = {
|
|
|
1944
1944
|
91: !1
|
|
1945
1945
|
}, N = {};
|
|
1946
1946
|
for (let t = 1; t < 20; t++)
|
|
1947
|
-
|
|
1948
|
-
let
|
|
1949
|
-
const W = /* @__PURE__ */ new Map(),
|
|
1947
|
+
dt["f".concat(t)] = 111 + t;
|
|
1948
|
+
let U = [], lt = null, we = "all";
|
|
1949
|
+
const W = /* @__PURE__ */ new Map(), ft = (t) => dt[t.toLowerCase()] || z[t.toLowerCase()] || t.toUpperCase().charCodeAt(0), so = (t) => Object.keys(dt).find((e) => dt[e] === t), ro = (t) => Object.keys(z).find((e) => z[e] === t);
|
|
1950
1950
|
function Ae(t) {
|
|
1951
1951
|
we = t || "all";
|
|
1952
1952
|
}
|
|
1953
|
-
function
|
|
1953
|
+
function ut() {
|
|
1954
1954
|
return we || "all";
|
|
1955
1955
|
}
|
|
1956
1956
|
function ao() {
|
|
1957
|
-
return
|
|
1957
|
+
return U.slice(0);
|
|
1958
1958
|
}
|
|
1959
1959
|
function co() {
|
|
1960
|
-
return
|
|
1960
|
+
return U.map((t) => so(t) || ro(t) || String.fromCharCode(t));
|
|
1961
1961
|
}
|
|
1962
1962
|
function lo() {
|
|
1963
1963
|
const t = [];
|
|
@@ -1973,7 +1973,7 @@ function lo() {
|
|
|
1973
1973
|
scope: i,
|
|
1974
1974
|
shortcut: a,
|
|
1975
1975
|
mods: s,
|
|
1976
|
-
keys: o.split("+").map((r) =>
|
|
1976
|
+
keys: o.split("+").map((r) => ft(r))
|
|
1977
1977
|
});
|
|
1978
1978
|
});
|
|
1979
1979
|
}), t;
|
|
@@ -1987,11 +1987,11 @@ function uo(t) {
|
|
|
1987
1987
|
return (e.isContentEditable || (i || n === "TEXTAREA" || n === "SELECT") && !e.readOnly) && (o = !1), o;
|
|
1988
1988
|
}
|
|
1989
1989
|
function fo(t) {
|
|
1990
|
-
return typeof t == "string" && (t =
|
|
1990
|
+
return typeof t == "string" && (t = ft(t)), U.indexOf(t) !== -1;
|
|
1991
1991
|
}
|
|
1992
1992
|
function ho(t, e) {
|
|
1993
1993
|
let n, o;
|
|
1994
|
-
t || (t =
|
|
1994
|
+
t || (t = ut());
|
|
1995
1995
|
for (const i in N)
|
|
1996
1996
|
if (Object.prototype.hasOwnProperty.call(N, i))
|
|
1997
1997
|
for (n = N[i], o = 0; o < n.length; )
|
|
@@ -2001,12 +2001,12 @@ function ho(t, e) {
|
|
|
2001
2001
|
} = a;
|
|
2002
2002
|
return Xt(r);
|
|
2003
2003
|
}) : o++;
|
|
2004
|
-
|
|
2004
|
+
ut() === t && Ae(e || "all");
|
|
2005
2005
|
}
|
|
2006
2006
|
function po(t) {
|
|
2007
2007
|
let e = t.keyCode || t.which || t.charCode;
|
|
2008
|
-
const n =
|
|
2009
|
-
if (n >= 0 &&
|
|
2008
|
+
const n = U.indexOf(e);
|
|
2009
|
+
if (n >= 0 && U.splice(n, 1), t.key && t.key.toLowerCase() === "meta" && U.splice(0, U.length), (e === 93 || e === 224) && (e = 91), e in X) {
|
|
2010
2010
|
X[e] = !1;
|
|
2011
2011
|
for (const o in z) z[o] === e && (H[o] = !1);
|
|
2012
2012
|
}
|
|
@@ -2014,19 +2014,19 @@ function po(t) {
|
|
|
2014
2014
|
function xe(t) {
|
|
2015
2015
|
if (typeof t > "u")
|
|
2016
2016
|
Object.keys(N).forEach((i) => {
|
|
2017
|
-
Array.isArray(N[i]) && N[i].forEach((s) =>
|
|
2017
|
+
Array.isArray(N[i]) && N[i].forEach((s) => wt(s)), delete N[i];
|
|
2018
2018
|
}), Xt(null);
|
|
2019
2019
|
else if (Array.isArray(t))
|
|
2020
2020
|
t.forEach((i) => {
|
|
2021
|
-
i.key &&
|
|
2021
|
+
i.key && wt(i);
|
|
2022
2022
|
});
|
|
2023
2023
|
else if (typeof t == "object")
|
|
2024
|
-
t.key &&
|
|
2024
|
+
t.key && wt(t);
|
|
2025
2025
|
else if (typeof t == "string") {
|
|
2026
2026
|
for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), o = 1; o < e; o++)
|
|
2027
2027
|
n[o - 1] = arguments[o];
|
|
2028
2028
|
let [i, s] = n;
|
|
2029
|
-
typeof i == "function" && (s = i, i = ""),
|
|
2029
|
+
typeof i == "function" && (s = i, i = ""), wt({
|
|
2030
2030
|
key: t,
|
|
2031
2031
|
scope: i,
|
|
2032
2032
|
method: s,
|
|
@@ -2034,7 +2034,7 @@ function xe(t) {
|
|
|
2034
2034
|
});
|
|
2035
2035
|
}
|
|
2036
2036
|
}
|
|
2037
|
-
const
|
|
2037
|
+
const wt = (t) => {
|
|
2038
2038
|
let {
|
|
2039
2039
|
key: e,
|
|
2040
2040
|
scope: n,
|
|
@@ -2042,9 +2042,9 @@ const bt = (t) => {
|
|
|
2042
2042
|
splitKey: i = "+"
|
|
2043
2043
|
} = t;
|
|
2044
2044
|
be(e).forEach((a) => {
|
|
2045
|
-
const r = a.split(i), l = r.length, f = r[l - 1], h = f === "*" ? "*" :
|
|
2045
|
+
const r = a.split(i), l = r.length, f = r[l - 1], h = f === "*" ? "*" : ft(f);
|
|
2046
2046
|
if (!N[h]) return;
|
|
2047
|
-
n || (n =
|
|
2047
|
+
n || (n = ut());
|
|
2048
2048
|
const u = l > 1 ? ye(z, r) : [], p = [];
|
|
2049
2049
|
N[h] = N[h].filter((v) => {
|
|
2050
2050
|
const m = (o ? v.method === o : !0) && v.scope === n && io(v.mods, u);
|
|
@@ -2060,26 +2060,29 @@ function ne(t, e, n, o) {
|
|
|
2060
2060
|
i = e.mods.length > 0;
|
|
2061
2061
|
for (const s in X)
|
|
2062
2062
|
Object.prototype.hasOwnProperty.call(X, s) && (!X[s] && e.mods.indexOf(+s) > -1 || X[s] && e.mods.indexOf(+s) === -1) && (i = !1);
|
|
2063
|
-
(e.mods.length === 0 && !X[16] && !X[18] && !X[17] && !X[91] || i || e.shortcut === "*") && (e.keys = [], e.keys = e.keys.concat(
|
|
2063
|
+
(e.mods.length === 0 && !X[16] && !X[18] && !X[17] && !X[91] || i || e.shortcut === "*") && (e.keys = [], e.keys = e.keys.concat(U), e.method(t, e) === !1 && (t.preventDefault ? t.preventDefault() : t.returnValue = !1, t.stopPropagation && t.stopPropagation(), t.cancelBubble && (t.cancelBubble = !0)));
|
|
2064
2064
|
}
|
|
2065
2065
|
}
|
|
2066
2066
|
function oe(t, e) {
|
|
2067
2067
|
const n = N["*"];
|
|
2068
2068
|
let o = t.keyCode || t.which || t.charCode;
|
|
2069
2069
|
if (!H.filter.call(this, t)) return;
|
|
2070
|
-
if ((o === 93 || o === 224) && (o = 91),
|
|
2071
|
-
const l =
|
|
2072
|
-
t[r] &&
|
|
2070
|
+
if ((o === 93 || o === 224) && (o = 91), U.indexOf(o) === -1 && o !== 229 && U.push(o), ["metaKey", "ctrlKey", "altKey", "shiftKey"].forEach((r) => {
|
|
2071
|
+
const l = at[r];
|
|
2072
|
+
t[r] && U.indexOf(l) === -1 ? U.push(l) : !t[r] && U.indexOf(l) > -1 ? U.splice(U.indexOf(l), 1) : r === "metaKey" && t[r] && (U = U.filter((f) => f in at || f === o));
|
|
2073
2073
|
}), o in X) {
|
|
2074
2074
|
X[o] = !0;
|
|
2075
2075
|
for (const r in z)
|
|
2076
|
-
z
|
|
2076
|
+
if (Object.prototype.hasOwnProperty.call(z, r)) {
|
|
2077
|
+
const l = at[z[r]];
|
|
2078
|
+
H[r] = t[l];
|
|
2079
|
+
}
|
|
2077
2080
|
if (!n) return;
|
|
2078
2081
|
}
|
|
2079
2082
|
for (const r in X)
|
|
2080
|
-
Object.prototype.hasOwnProperty.call(X, r) && (X[r] = t[
|
|
2081
|
-
t.getModifierState && !(t.altKey && !t.ctrlKey) && t.getModifierState("AltGraph") && (
|
|
2082
|
-
const i =
|
|
2083
|
+
Object.prototype.hasOwnProperty.call(X, r) && (X[r] = t[at[r]]);
|
|
2084
|
+
t.getModifierState && !(t.altKey && !t.ctrlKey) && t.getModifierState("AltGraph") && (U.indexOf(17) === -1 && U.push(17), U.indexOf(18) === -1 && U.push(18), X[17] = !0, X[18] = !0);
|
|
2085
|
+
const i = ut();
|
|
2083
2086
|
if (n)
|
|
2084
2087
|
for (let r = 0; r < n.length; r++)
|
|
2085
2088
|
n[r].scope === i && (t.type === "keydown" && n[r].keydown || t.type === "keyup" && n[r].keyup) && ne(t, n[r], i, e);
|
|
@@ -2091,16 +2094,16 @@ function oe(t, e) {
|
|
|
2091
2094
|
splitKey: f
|
|
2092
2095
|
} = l, h = l.key.split(f), u = [];
|
|
2093
2096
|
for (let p = 0; p < h.length; p++)
|
|
2094
|
-
u.push(
|
|
2095
|
-
u.sort().join("") ===
|
|
2097
|
+
u.push(ft(h[p]));
|
|
2098
|
+
u.sort().join("") === U.sort().join("") && ne(t, l, i, e);
|
|
2096
2099
|
}
|
|
2097
2100
|
}
|
|
2098
2101
|
function H(t, e, n) {
|
|
2099
|
-
|
|
2102
|
+
U = [];
|
|
2100
2103
|
const o = be(t);
|
|
2101
2104
|
let i = [], s = "all", a = document, r = 0, l = !1, f = !0, h = "+", u = !1, p = !1;
|
|
2102
2105
|
for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (s = e.scope), e.element && (a = e.element), e.keyup && (l = e.keyup), e.keydown !== void 0 && (f = e.keydown), e.capture !== void 0 && (u = e.capture), typeof e.splitKey == "string" && (h = e.splitKey), e.single === !0 && (p = !0)), typeof e == "string" && (s = e), p && xe(t, s); r < o.length; r++)
|
|
2103
|
-
t = o[r].split(h), i = [], t.length > 1 && (i = ye(z, t)), t = t[t.length - 1], t = t === "*" ? "*" :
|
|
2106
|
+
t = o[r].split(h), i = [], t.length > 1 && (i = ye(z, t)), t = t[t.length - 1], t = t === "*" ? "*" : ft(t), t in N || (N[t] = []), N[t].push({
|
|
2104
2107
|
keyup: l,
|
|
2105
2108
|
keydown: f,
|
|
2106
2109
|
scope: s,
|
|
@@ -2124,16 +2127,16 @@ function H(t, e, n) {
|
|
|
2124
2127
|
keydownListener: v,
|
|
2125
2128
|
keyupListenr: g,
|
|
2126
2129
|
capture: u
|
|
2127
|
-
}),
|
|
2130
|
+
}), _t(a, "keydown", v, u), _t(a, "keyup", g, u);
|
|
2128
2131
|
}
|
|
2129
|
-
if (!
|
|
2132
|
+
if (!lt) {
|
|
2130
2133
|
const v = () => {
|
|
2131
|
-
|
|
2134
|
+
U = [];
|
|
2132
2135
|
};
|
|
2133
|
-
|
|
2136
|
+
lt = {
|
|
2134
2137
|
listener: v,
|
|
2135
2138
|
capture: u
|
|
2136
|
-
},
|
|
2139
|
+
}, _t(window, "focus", v, u);
|
|
2137
2140
|
}
|
|
2138
2141
|
}
|
|
2139
2142
|
}
|
|
@@ -2167,18 +2170,18 @@ function Xt(t) {
|
|
|
2167
2170
|
capture: r
|
|
2168
2171
|
} = W.get(i) || {};
|
|
2169
2172
|
s && a && (ot(i, "keyup", a, r), ot(i, "keydown", s, r), W.delete(i));
|
|
2170
|
-
}), W.clear(), Object.keys(N).forEach((i) => delete N[i]),
|
|
2173
|
+
}), W.clear(), Object.keys(N).forEach((i) => delete N[i]), lt)) {
|
|
2171
2174
|
const {
|
|
2172
2175
|
listener: i,
|
|
2173
2176
|
capture: s
|
|
2174
|
-
} =
|
|
2175
|
-
ot(window, "focus", i, s),
|
|
2177
|
+
} = lt;
|
|
2178
|
+
ot(window, "focus", i, s), lt = null;
|
|
2176
2179
|
}
|
|
2177
2180
|
}
|
|
2178
|
-
const
|
|
2181
|
+
const Ut = {
|
|
2179
2182
|
getPressedKeyString: co,
|
|
2180
2183
|
setScope: Ae,
|
|
2181
|
-
getScope:
|
|
2184
|
+
getScope: ut,
|
|
2182
2185
|
deleteScope: ho,
|
|
2183
2186
|
getPressedKeyCodes: ao,
|
|
2184
2187
|
getAllKeyCodes: lo,
|
|
@@ -2186,12 +2189,12 @@ const _t = {
|
|
|
2186
2189
|
filter: uo,
|
|
2187
2190
|
trigger: go,
|
|
2188
2191
|
unbind: xe,
|
|
2189
|
-
keyMap:
|
|
2192
|
+
keyMap: dt,
|
|
2190
2193
|
modifier: z,
|
|
2191
|
-
modifierMap:
|
|
2194
|
+
modifierMap: at
|
|
2192
2195
|
};
|
|
2193
|
-
for (const t in
|
|
2194
|
-
Object.prototype.hasOwnProperty.call(
|
|
2196
|
+
for (const t in Ut)
|
|
2197
|
+
Object.prototype.hasOwnProperty.call(Ut, t) && (H[t] = Ut[t]);
|
|
2195
2198
|
if (typeof window < "u") {
|
|
2196
2199
|
const t = window.hotkeys;
|
|
2197
2200
|
H.noConflict = (e) => (e && window.hotkeys === H && (window.hotkeys = t), H), window.hotkeys = H;
|
|
@@ -2226,12 +2229,12 @@ const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+
|
|
|
2226
2229
|
h.getAnnotation(p.annotation) && (u.clear(), h.deleteAnnotation(p.annotation));
|
|
2227
2230
|
return;
|
|
2228
2231
|
}
|
|
2229
|
-
const
|
|
2232
|
+
const b = I.getRangeAt(0), x = De(b, t);
|
|
2230
2233
|
if (Ie(x)) return;
|
|
2231
2234
|
const w = Me(x.cloneRange());
|
|
2232
2235
|
(w.length !== p.selector.length || w.some((B, O) => {
|
|
2233
|
-
var
|
|
2234
|
-
return B.toString() !== ((
|
|
2236
|
+
var _;
|
|
2237
|
+
return B.toString() !== ((_ = p.selector[O]) == null ? void 0 : _.quote);
|
|
2235
2238
|
})) && (p = {
|
|
2236
2239
|
...p,
|
|
2237
2240
|
selector: w.map((B) => Ve(B, t, s)),
|
|
@@ -2242,7 +2245,7 @@ const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+
|
|
|
2242
2245
|
}, c = (T) => {
|
|
2243
2246
|
if (it(T.target) || !v) return;
|
|
2244
2247
|
const I = () => {
|
|
2245
|
-
const { x:
|
|
2248
|
+
const { x: b, y: x } = t.getBoundingClientRect(), w = T.target instanceof Node && t.contains(T.target) && h.getAt(T.clientX - b, T.clientY - x, a === "all", l);
|
|
2246
2249
|
if (w) {
|
|
2247
2250
|
const { selected: L } = u, B = new Set(L.map((P) => P.id)), O = Array.isArray(w) ? w.map((P) => P.id) : [w.id];
|
|
2248
2251
|
(B.size !== O.length || !O.every((P) => B.has(P))) && u.userSelect(O, T);
|
|
@@ -2250,28 +2253,28 @@ const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+
|
|
|
2250
2253
|
u.clear();
|
|
2251
2254
|
}, D = T.timeStamp - g.timeStamp;
|
|
2252
2255
|
setTimeout(() => {
|
|
2253
|
-
const
|
|
2254
|
-
|
|
2256
|
+
const b = document.getSelection();
|
|
2257
|
+
b != null && b.isCollapsed && D < ie ? (p = void 0, I()) : p && p.selector.length > 0 && (R(), u.userSelect(p.annotation, vt(T)));
|
|
2255
2258
|
});
|
|
2256
|
-
},
|
|
2259
|
+
}, y = (T) => {
|
|
2257
2260
|
const I = document.getSelection();
|
|
2258
|
-
I != null && I.isCollapsed || ((!p || p.selector.length === 0) && A(T), R(), u.userSelect(p.annotation, vt(T)));
|
|
2261
|
+
I != null && I.isCollapsed || ((!p || p.selector.length === 0) && A(T), p && (R(), u.userSelect(p.annotation, vt(T))));
|
|
2259
2262
|
}, S = (T) => {
|
|
2260
|
-
T.key === "Shift" && p && (document.getSelection().isCollapsed || (R(), u.userSelect(p.annotation,
|
|
2263
|
+
T.key === "Shift" && p && (document.getSelection().isCollapsed || (R(), u.userSelect(p.annotation, ht(T))));
|
|
2261
2264
|
}, E = (T) => {
|
|
2262
2265
|
const I = () => setTimeout(() => {
|
|
2263
2266
|
(p == null ? void 0 : p.selector.length) > 0 && (u.clear(), h.addAnnotation({
|
|
2264
2267
|
id: p.annotation,
|
|
2265
2268
|
bodies: [],
|
|
2266
2269
|
target: p
|
|
2267
|
-
}), u.userSelect(p.annotation,
|
|
2270
|
+
}), u.userSelect(p.annotation, ht(T))), document.removeEventListener("selectionchange", I);
|
|
2268
2271
|
}, 100);
|
|
2269
2272
|
document.addEventListener("selectionchange", I), m(T);
|
|
2270
2273
|
};
|
|
2271
2274
|
H(mo.join(","), { element: t, keydown: !0, keyup: !1 }, (T) => {
|
|
2272
|
-
T.repeat || (g =
|
|
2275
|
+
T.repeat || (g = ht(T));
|
|
2273
2276
|
}), H(Ee, { keydown: !0, keyup: !1 }, (T) => {
|
|
2274
|
-
g =
|
|
2277
|
+
g = ht(T), E(T);
|
|
2275
2278
|
});
|
|
2276
2279
|
const C = (T) => {
|
|
2277
2280
|
T.repeat || T.target !== t && T.target !== document.body || (p = void 0, u.clear());
|
|
@@ -2290,9 +2293,9 @@ const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+
|
|
|
2290
2293
|
const { target: { updated: I } } = T, { updated: D } = p;
|
|
2291
2294
|
(!I || !D || I < D) && h.updateTarget(p);
|
|
2292
2295
|
};
|
|
2293
|
-
return t.addEventListener("pointerdown", d), document.addEventListener("pointerup", c), document.addEventListener("contextmenu",
|
|
2296
|
+
return t.addEventListener("pointerdown", d), document.addEventListener("pointerup", c), document.addEventListener("contextmenu", y), i && (t.addEventListener("keyup", S), t.addEventListener("selectstart", m), document.addEventListener("selectionchange", A)), {
|
|
2294
2297
|
destroy: () => {
|
|
2295
|
-
t.removeEventListener("pointerdown", d), document.removeEventListener("pointerup", c), document.removeEventListener("contextmenu",
|
|
2298
|
+
t.removeEventListener("pointerdown", d), document.removeEventListener("pointerup", c), document.removeEventListener("contextmenu", y), t.removeEventListener("keyup", S), t.removeEventListener("selectstart", m), document.removeEventListener("selectionchange", A), H.unbind();
|
|
2296
2299
|
},
|
|
2297
2300
|
setFilter: f,
|
|
2298
2301
|
setUser: r
|
|
@@ -2306,7 +2309,7 @@ const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+
|
|
|
2306
2309
|
const n = bo(e, {
|
|
2307
2310
|
annotatingEnabled: !0,
|
|
2308
2311
|
user: Yn()
|
|
2309
|
-
}), o = eo(t, n
|
|
2312
|
+
}), o = eo(t, n), { selection: i, viewport: s } = o, a = o.store, r = Rn(a), l = Bn(o, r, n.adapter);
|
|
2310
2313
|
let f = n.user;
|
|
2311
2314
|
const h = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : se : n.renderer || se, u = h === "SPANS" ? rn(t, o, s) : h === "CSS_HIGHLIGHTS" ? nn(t, o, s) : h === "CANVAS" ? ze(t, o, s) : void 0;
|
|
2312
2315
|
if (!u)
|
|
@@ -2350,7 +2353,7 @@ export {
|
|
|
2350
2353
|
hn as UserSelectAction,
|
|
2351
2354
|
xo as W3CTextFormat,
|
|
2352
2355
|
Le as cancelSingleClickEvents,
|
|
2353
|
-
|
|
2356
|
+
ht as cloneKeyboardEvent,
|
|
2354
2357
|
vt as clonePointerEvent,
|
|
2355
2358
|
Ao as createBody,
|
|
2356
2359
|
ze as createCanvasRenderer,
|