@soomo/text-annotator 3.0.0-staging.49 → 3.0.0-staging.50
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.
|
@@ -65,19 +65,19 @@ const _t = /* @__PURE__ */ Ee(Se), Ce = (t) => {
|
|
|
65
65
|
t.addEventListener("pointermove", c);
|
|
66
66
|
const p = (O = !1) => {
|
|
67
67
|
f && f.clear();
|
|
68
|
-
const B = Ce(t), { minX: m, minY: w, maxX: E, maxY: L } = B, T = l ? i.getIntersecting(m, w, E, L).filter(({ annotation:
|
|
69
|
-
const
|
|
70
|
-
return { annotation:
|
|
68
|
+
const B = Ce(t), { minX: m, minY: w, maxX: E, maxY: L } = B, T = l ? i.getIntersecting(m, w, E, L).filter(({ annotation: X }) => l(X)) : i.getIntersecting(m, w, E, L), N = r.selected.map(({ id: X }) => X), K = T.map(({ annotation: X, rects: lt }) => {
|
|
69
|
+
const xe = N.includes(X.id), ve = X.id === a.current;
|
|
70
|
+
return { annotation: X, rects: lt, state: { selected: xe, hover: ve } };
|
|
71
71
|
});
|
|
72
|
-
o.redraw(K, B, s, f, O), setTimeout(() => g(T.map(({ annotation:
|
|
72
|
+
o.redraw(K, B, s, f, O), setTimeout(() => g(T.map(({ annotation: X }) => X)), 1);
|
|
73
73
|
}, u = (O) => {
|
|
74
74
|
f = O, p();
|
|
75
|
-
},
|
|
75
|
+
}, v = (O) => {
|
|
76
76
|
s = O, p();
|
|
77
77
|
}, b = (O) => {
|
|
78
78
|
l = O, p(!1);
|
|
79
|
-
},
|
|
80
|
-
i.observe(
|
|
79
|
+
}, x = () => p();
|
|
80
|
+
i.observe(x);
|
|
81
81
|
const h = r.subscribe(() => p()), d = () => p(!0);
|
|
82
82
|
document.addEventListener("scroll", d, { capture: !0, passive: !0 });
|
|
83
83
|
const y = _t(() => {
|
|
@@ -91,10 +91,10 @@ const _t = /* @__PURE__ */ Ee(Se), Ce = (t) => {
|
|
|
91
91
|
});
|
|
92
92
|
return S.observe(document.body, C), {
|
|
93
93
|
destroy: () => {
|
|
94
|
-
t.removeEventListener("pointermove", c), o.destroy(), i.unobserve(
|
|
94
|
+
t.removeEventListener("pointermove", c), o.destroy(), i.unobserve(x), h(), document.removeEventListener("scroll", d), y.clear(), window.removeEventListener("resize", y), A.disconnect(), S.disconnect();
|
|
95
95
|
},
|
|
96
96
|
redraw: p,
|
|
97
|
-
setStyle:
|
|
97
|
+
setStyle: v,
|
|
98
98
|
setFilter: b,
|
|
99
99
|
setPainter: u,
|
|
100
100
|
setVisible: o.setVisible
|
|
@@ -111,14 +111,14 @@ const _t = /* @__PURE__ */ Ee(Se), Ce = (t) => {
|
|
|
111
111
|
const o = (s, l, f, g) => requestAnimationFrame(() => {
|
|
112
112
|
const { width: c, height: p } = e;
|
|
113
113
|
n.clearRect(-0.5, -0.5, c + 1, p + 1), g && g.clear();
|
|
114
|
-
const { top: u, left:
|
|
115
|
-
[...s].sort((
|
|
116
|
-
const { annotation: { target: { created: d } } } =
|
|
114
|
+
const { top: u, left: v } = l;
|
|
115
|
+
[...s].sort((x, h) => {
|
|
116
|
+
const { annotation: { target: { created: d } } } = x, { annotation: { target: { created: y } } } = h;
|
|
117
117
|
return d.getTime() - y.getTime();
|
|
118
|
-
}).forEach((
|
|
118
|
+
}).forEach((x) => {
|
|
119
119
|
var A;
|
|
120
|
-
const h = f ? typeof f == "function" ? f(
|
|
121
|
-
x: C +
|
|
120
|
+
const h = f ? typeof f == "function" ? f(x.annotation, x.state) : f : (A = x.state) != null && A.selected ? mt : q, d = g && g.paint(x, l) || h, y = x.rects.map(({ x: C, y: S, width: R, height: O }) => ({
|
|
121
|
+
x: C + v,
|
|
122
122
|
y: S + u,
|
|
123
123
|
width: R,
|
|
124
124
|
height: O
|
|
@@ -214,7 +214,7 @@ var Me = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, z = function(t) {
|
|
|
214
214
|
}, wt = function(t, e) {
|
|
215
215
|
var n = it(t);
|
|
216
216
|
return { h: n.h, s: Y(n.s + 100 * e, 0, 100), l: n.l, a: n.a };
|
|
217
|
-
},
|
|
217
|
+
}, xt = function(t) {
|
|
218
218
|
return (299 * t.r + 587 * t.g + 114 * t.b) / 1e3 / 255;
|
|
219
219
|
}, jt = function(t, e) {
|
|
220
220
|
var n = it(t);
|
|
@@ -226,11 +226,11 @@ var Me = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, z = function(t) {
|
|
|
226
226
|
return t.prototype.isValid = function() {
|
|
227
227
|
return this.parsed !== null;
|
|
228
228
|
}, t.prototype.brightness = function() {
|
|
229
|
-
return _(
|
|
229
|
+
return _(xt(this.rgba), 2);
|
|
230
230
|
}, t.prototype.isDark = function() {
|
|
231
|
-
return
|
|
231
|
+
return xt(this.rgba) < 0.5;
|
|
232
232
|
}, t.prototype.isLight = function() {
|
|
233
|
-
return
|
|
233
|
+
return xt(this.rgba) >= 0.5;
|
|
234
234
|
}, t.prototype.toHex = function() {
|
|
235
235
|
return e = bt(this.rgba), n = e.r, o = e.g, i = e.b, a = (r = e.a) < 1 ? dt(_(255 * r)) : "", "#" + dt(n) + dt(o) + dt(i) + a;
|
|
236
236
|
var e, n, o, i, r, a;
|
|
@@ -248,34 +248,34 @@ var Me = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, z = function(t) {
|
|
|
248
248
|
return e = se(this.rgba), { h: _(e.h), s: _(e.s), v: _(e.v), a: _(e.a, 3) };
|
|
249
249
|
var e;
|
|
250
250
|
}, t.prototype.invert = function() {
|
|
251
|
-
return
|
|
251
|
+
return P({ r: 255 - (e = this.rgba).r, g: 255 - e.g, b: 255 - e.b, a: e.a });
|
|
252
252
|
var e;
|
|
253
253
|
}, t.prototype.saturate = function(e) {
|
|
254
|
-
return e === void 0 && (e = 0.1),
|
|
254
|
+
return e === void 0 && (e = 0.1), P(wt(this.rgba, e));
|
|
255
255
|
}, t.prototype.desaturate = function(e) {
|
|
256
|
-
return e === void 0 && (e = 0.1),
|
|
256
|
+
return e === void 0 && (e = 0.1), P(wt(this.rgba, -e));
|
|
257
257
|
}, t.prototype.grayscale = function() {
|
|
258
|
-
return
|
|
258
|
+
return P(wt(this.rgba, -1));
|
|
259
259
|
}, t.prototype.lighten = function(e) {
|
|
260
|
-
return e === void 0 && (e = 0.1),
|
|
260
|
+
return e === void 0 && (e = 0.1), P(jt(this.rgba, e));
|
|
261
261
|
}, t.prototype.darken = function(e) {
|
|
262
|
-
return e === void 0 && (e = 0.1),
|
|
262
|
+
return e === void 0 && (e = 0.1), P(jt(this.rgba, -e));
|
|
263
263
|
}, t.prototype.rotate = function(e) {
|
|
264
264
|
return e === void 0 && (e = 15), this.hue(this.hue() + e);
|
|
265
265
|
}, t.prototype.alpha = function(e) {
|
|
266
|
-
return typeof e == "number" ?
|
|
266
|
+
return typeof e == "number" ? P({ r: (n = this.rgba).r, g: n.g, b: n.b, a: e }) : _(this.rgba.a, 3);
|
|
267
267
|
var n;
|
|
268
268
|
}, t.prototype.hue = function(e) {
|
|
269
269
|
var n = it(this.rgba);
|
|
270
|
-
return typeof e == "number" ?
|
|
270
|
+
return typeof e == "number" ? P({ h: e, s: n.s, l: n.l, a: n.a }) : _(n.h);
|
|
271
271
|
}, t.prototype.isEqual = function(e) {
|
|
272
|
-
return this.toHex() ===
|
|
272
|
+
return this.toHex() === P(e).toHex();
|
|
273
273
|
}, t;
|
|
274
|
-
}(),
|
|
274
|
+
}(), P = function(t) {
|
|
275
275
|
return t instanceof zt ? t : new zt(t);
|
|
276
276
|
};
|
|
277
277
|
const De = (t) => [
|
|
278
|
-
`background-color:${
|
|
278
|
+
`background-color:${P((t == null ? void 0 : t.fill) || q.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? q.fillOpacity : t.fillOpacity).toHex()}`,
|
|
279
279
|
t != null && t.underlineThickness ? "text-decoration:underline" : void 0,
|
|
280
280
|
t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
|
|
281
281
|
t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
|
|
@@ -296,13 +296,13 @@ const De = (t) => [
|
|
|
296
296
|
const f = new Set(r.map((c) => c.annotation.id));
|
|
297
297
|
Array.from(e).filter((c) => !f.has(c));
|
|
298
298
|
const g = r.map((c) => {
|
|
299
|
-
var
|
|
300
|
-
const p = s ? typeof s == "function" ? s(c.annotation, c.state) : s : (
|
|
299
|
+
var v;
|
|
300
|
+
const p = s ? typeof s == "function" ? s(c.annotation, c.state) : s : (v = c.state) != null && v.selected ? mt : q, u = l && l.paint(c, a) || p;
|
|
301
301
|
return `::highlight(_${c.annotation.id}) { ${De(u)} }`;
|
|
302
302
|
});
|
|
303
303
|
t.innerHTML = g.join(`
|
|
304
304
|
`), CSS.highlights.clear(), r.forEach(({ annotation: c }) => {
|
|
305
|
-
const p = c.target.selector.map((
|
|
305
|
+
const p = c.target.selector.map((v) => v.range), u = new Highlight(...p);
|
|
306
306
|
CSS.highlights.set(`_${c.id}`, u);
|
|
307
307
|
}), e = f;
|
|
308
308
|
}
|
|
@@ -344,15 +344,15 @@ const Xe = (t, e) => {
|
|
|
344
344
|
redraw: (a, s, l, f, g) => {
|
|
345
345
|
const p = !(Mt(n, a) && g);
|
|
346
346
|
if (!f && !p) return;
|
|
347
|
-
p && (e.innerHTML = ""), [...a].sort((
|
|
348
|
-
const { annotation: { target: { created:
|
|
349
|
-
return
|
|
350
|
-
}).forEach((
|
|
351
|
-
|
|
352
|
-
const
|
|
347
|
+
p && (e.innerHTML = ""), [...a].sort((v, b) => {
|
|
348
|
+
const { annotation: { target: { created: x } } } = v, { annotation: { target: { created: h } } } = b;
|
|
349
|
+
return x.getTime() - h.getTime();
|
|
350
|
+
}).forEach((v) => {
|
|
351
|
+
v.rects.map((b) => {
|
|
352
|
+
const x = Xe(b, a), h = Ae(v, s, l, f, x);
|
|
353
353
|
if (p) {
|
|
354
354
|
const d = document.createElement("span");
|
|
355
|
-
d.className = "r6o-annotation", d.dataset.annotation =
|
|
355
|
+
d.className = "r6o-annotation", d.dataset.annotation = v.annotation.id, d.style.left = `${b.x}px`, d.style.top = `${b.y}px`, d.style.width = `${b.width}px`, d.style.height = `${b.height}px`, d.style.backgroundColor = P((h == null ? void 0 : h.fill) || q.fill).alpha((h == null ? void 0 : h.fillOpacity) === void 0 ? q.fillOpacity : h.fillOpacity).toHex(), h.underlineStyle && (d.style.borderStyle = h.underlineStyle), h.underlineColor && (d.style.borderColor = h.underlineColor), h.underlineThickness && (d.style.borderBottomWidth = `${h.underlineThickness}px`), h.underlineOffset && (d.style.paddingBottom = `${h.underlineOffset}px`), e.appendChild(d);
|
|
356
356
|
}
|
|
357
357
|
});
|
|
358
358
|
}), n = a;
|
|
@@ -363,8 +363,8 @@ const Xe = (t, e) => {
|
|
|
363
363
|
};
|
|
364
364
|
}, $e = (t, e, n) => Ut(t, e, n, Pe(t));
|
|
365
365
|
var U = [];
|
|
366
|
-
for (var
|
|
367
|
-
U.push((
|
|
366
|
+
for (var vt = 0; vt < 256; ++vt)
|
|
367
|
+
U.push((vt + 256).toString(16).slice(1));
|
|
368
368
|
function He(t, e = 0) {
|
|
369
369
|
return (U[t[e + 0]] + U[t[e + 1]] + U[t[e + 2]] + U[t[e + 3]] + "-" + U[t[e + 4]] + U[t[e + 5]] + "-" + U[t[e + 6]] + U[t[e + 7]] + "-" + U[t[e + 8]] + U[t[e + 9]] + "-" + U[t[e + 10]] + U[t[e + 11]] + U[t[e + 12]] + U[t[e + 13]] + U[t[e + 14]] + U[t[e + 15]]).toLowerCase();
|
|
370
370
|
}
|
|
@@ -466,9 +466,9 @@ const Et = { selected: [] }, Qe = (t, e = "EDIT") => {
|
|
|
466
466
|
}, l = (u) => {
|
|
467
467
|
if (s())
|
|
468
468
|
return !1;
|
|
469
|
-
const
|
|
470
|
-
return r.selected.some((b) => b.id ===
|
|
471
|
-
}, f = (u,
|
|
469
|
+
const v = typeof u == "string" ? u : u.id;
|
|
470
|
+
return r.selected.some((b) => b.id === v);
|
|
471
|
+
}, f = (u, v) => {
|
|
472
472
|
const b = t.getAnnotation(u);
|
|
473
473
|
if (!b) {
|
|
474
474
|
console.warn("Invalid selection: " + u);
|
|
@@ -476,30 +476,30 @@ const Et = { selected: [] }, Qe = (t, e = "EDIT") => {
|
|
|
476
476
|
}
|
|
477
477
|
switch (Gt(b, i)) {
|
|
478
478
|
case "EDIT":
|
|
479
|
-
o({ selected: [{ id: u, editable: !0 }], event:
|
|
479
|
+
o({ selected: [{ id: u, editable: !0 }], event: v });
|
|
480
480
|
break;
|
|
481
481
|
case "SELECT":
|
|
482
|
-
o({ selected: [{ id: u }], event:
|
|
482
|
+
o({ selected: [{ id: u }], event: v });
|
|
483
483
|
break;
|
|
484
484
|
default:
|
|
485
|
-
o({ selected: [], event:
|
|
485
|
+
o({ selected: [], event: v });
|
|
486
486
|
}
|
|
487
|
-
}, g = (u,
|
|
488
|
-
const b = Array.isArray(u) ? u : [u],
|
|
487
|
+
}, g = (u, v) => {
|
|
488
|
+
const b = Array.isArray(u) ? u : [u], x = b.map((h) => t.getAnnotation(h)).filter((h) => !!h);
|
|
489
489
|
o({
|
|
490
|
-
selected:
|
|
491
|
-
const d =
|
|
490
|
+
selected: x.map((h) => {
|
|
491
|
+
const d = v === void 0 ? Gt(h, i) === "EDIT" : v;
|
|
492
492
|
return { id: h.id, editable: d };
|
|
493
493
|
})
|
|
494
|
-
}),
|
|
494
|
+
}), x.length !== b.length && console.warn("Invalid selection", u);
|
|
495
495
|
}, c = (u) => {
|
|
496
496
|
if (s())
|
|
497
497
|
return !1;
|
|
498
|
-
const { selected:
|
|
499
|
-
|
|
498
|
+
const { selected: v } = r;
|
|
499
|
+
v.some(({ id: b }) => u.includes(b)) && o({ selected: v.filter(({ id: b }) => !u.includes(b)) });
|
|
500
500
|
}, p = (u) => i = u;
|
|
501
501
|
return t.observe(
|
|
502
|
-
({ changes: u }) => c((u.deleted || []).map((
|
|
502
|
+
({ changes: u }) => c((u.deleted || []).map((v) => v.id))
|
|
503
503
|
), {
|
|
504
504
|
get event() {
|
|
505
505
|
return r ? r.event : null;
|
|
@@ -599,8 +599,8 @@ const cn = (t, e) => {
|
|
|
599
599
|
...(t.updated || []).filter(({ newValue: c }) => !r.has(c.id)).map((c) => {
|
|
600
600
|
const { oldValue: p, newValue: u } = c;
|
|
601
601
|
if (a.has(u.id)) {
|
|
602
|
-
const
|
|
603
|
-
return le(p,
|
|
602
|
+
const v = e.updated.find((b) => b.oldValue.id === u.id).newValue;
|
|
603
|
+
return le(p, v);
|
|
604
604
|
} else
|
|
605
605
|
return c;
|
|
606
606
|
}),
|
|
@@ -678,17 +678,17 @@ const cn = (t, e) => {
|
|
|
678
678
|
t.set(T.id, T), T.bodies.forEach((N) => e.set(N.id, T.id));
|
|
679
679
|
}), r(E, { created: m });
|
|
680
680
|
}
|
|
681
|
-
},
|
|
681
|
+
}, v = (m) => {
|
|
682
682
|
const w = typeof m == "string" ? m : m.id, E = t.get(w);
|
|
683
683
|
if (E)
|
|
684
684
|
return t.delete(w), E.bodies.forEach((L) => e.delete(L.id)), E;
|
|
685
685
|
console.warn(`Attempt to delete missing annotation: ${w}`);
|
|
686
686
|
}, b = (m, w = M.LOCAL) => {
|
|
687
|
-
const E =
|
|
687
|
+
const E = v(m);
|
|
688
688
|
E && r(w, { deleted: [E] });
|
|
689
|
-
},
|
|
689
|
+
}, x = (m, w = M.LOCAL) => {
|
|
690
690
|
const E = m.reduce((L, T) => {
|
|
691
|
-
const N =
|
|
691
|
+
const N = v(T);
|
|
692
692
|
return N ? [...L, N] : L;
|
|
693
693
|
}, []);
|
|
694
694
|
E.length > 0 && r(w, { deleted: E });
|
|
@@ -777,7 +777,7 @@ const cn = (t, e) => {
|
|
|
777
777
|
addBody: g,
|
|
778
778
|
all: c,
|
|
779
779
|
bulkAddAnnotation: u,
|
|
780
|
-
bulkDeleteAnnotation:
|
|
780
|
+
bulkDeleteAnnotation: x,
|
|
781
781
|
bulkDeleteBodies: y,
|
|
782
782
|
bulkUpdateAnnotation: f,
|
|
783
783
|
bulkUpdateBodies: O,
|
|
@@ -819,36 +819,36 @@ const hn = 250, pn = (t) => {
|
|
|
819
819
|
let o = -1, i = !1, r = 0;
|
|
820
820
|
const a = (u) => {
|
|
821
821
|
if (!i) {
|
|
822
|
-
const { changes:
|
|
822
|
+
const { changes: v } = u, b = performance.now();
|
|
823
823
|
if (b - r > hn)
|
|
824
|
-
n.splice(o + 1), n.push(
|
|
824
|
+
n.splice(o + 1), n.push(v), o = n.length - 1;
|
|
825
825
|
else {
|
|
826
|
-
const
|
|
827
|
-
n[
|
|
826
|
+
const x = n.length - 1;
|
|
827
|
+
n[x] = ln(n[x], v);
|
|
828
828
|
}
|
|
829
829
|
r = b;
|
|
830
830
|
}
|
|
831
831
|
i = !1;
|
|
832
832
|
};
|
|
833
833
|
t.observe(a, { origin: M.LOCAL });
|
|
834
|
-
const s = (u) => u && u.length > 0 && t.bulkDeleteAnnotation(u), l = (u) => u && u.length > 0 && t.bulkAddAnnotation(u, !1), f = (u) => u && u.length > 0 && t.bulkUpdateAnnotation(u.map(({ oldValue:
|
|
834
|
+
const s = (u) => u && u.length > 0 && t.bulkDeleteAnnotation(u), l = (u) => u && u.length > 0 && t.bulkAddAnnotation(u, !1), f = (u) => u && u.length > 0 && t.bulkUpdateAnnotation(u.map(({ oldValue: v }) => v)), g = (u) => u && u.length > 0 && t.bulkUpdateAnnotation(u.map(({ newValue: v }) => v)), c = (u) => u && u.length > 0 && t.bulkAddAnnotation(u, !1), p = (u) => u && u.length > 0 && t.bulkDeleteAnnotation(u);
|
|
835
835
|
return {
|
|
836
836
|
canRedo: () => n.length - 1 > o,
|
|
837
837
|
canUndo: () => o > -1,
|
|
838
838
|
destroy: () => t.unobserve(a),
|
|
839
|
-
on: (u,
|
|
839
|
+
on: (u, v) => e.on(u, v),
|
|
840
840
|
redo: () => {
|
|
841
841
|
if (n.length - 1 > o) {
|
|
842
842
|
i = !0;
|
|
843
|
-
const { created: u, updated:
|
|
844
|
-
l(u), g(
|
|
843
|
+
const { created: u, updated: v, deleted: b } = n[o + 1];
|
|
844
|
+
l(u), g(v), p(b), e.emit("redo", n[o + 1]), o += 1;
|
|
845
845
|
}
|
|
846
846
|
},
|
|
847
847
|
undo: () => {
|
|
848
848
|
if (o > -1) {
|
|
849
849
|
i = !0;
|
|
850
|
-
const { created: u, updated:
|
|
851
|
-
s(u), f(
|
|
850
|
+
const { created: u, updated: v, deleted: b } = n[o];
|
|
851
|
+
s(u), f(v), c(b), e.emit("undo", n[o]), o -= 1;
|
|
852
852
|
}
|
|
853
853
|
}
|
|
854
854
|
};
|
|
@@ -861,36 +861,36 @@ const hn = 250, pn = (t) => {
|
|
|
861
861
|
}, mn = (t, e, n, o) => {
|
|
862
862
|
const { store: i, selection: r, hover: a, viewport: s } = t, l = /* @__PURE__ */ new Map();
|
|
863
863
|
let f = [], g;
|
|
864
|
-
const c = (b,
|
|
865
|
-
l.has(b) ? l.get(b).push(
|
|
866
|
-
}, p = (b,
|
|
864
|
+
const c = (b, x) => {
|
|
865
|
+
l.has(b) ? l.get(b).push(x) : l.set(b, [x]);
|
|
866
|
+
}, p = (b, x) => {
|
|
867
867
|
const h = l.get(b);
|
|
868
868
|
if (h) {
|
|
869
|
-
const d = h.indexOf(
|
|
869
|
+
const d = h.indexOf(x);
|
|
870
870
|
d !== -1 && h.splice(d, 1);
|
|
871
871
|
}
|
|
872
|
-
}, u = (b,
|
|
872
|
+
}, u = (b, x, h) => {
|
|
873
873
|
l.has(b) && setTimeout(() => {
|
|
874
874
|
l.get(b).forEach((d) => {
|
|
875
875
|
if (n) {
|
|
876
|
-
const y = Array.isArray(
|
|
876
|
+
const y = Array.isArray(x) ? x.map((C) => n.serialize(C)) : n.serialize(x), A = h ? h instanceof PointerEvent ? h : n.serialize(h) : void 0;
|
|
877
877
|
d(y, A);
|
|
878
878
|
} else
|
|
879
|
-
d(
|
|
879
|
+
d(x, h);
|
|
880
880
|
});
|
|
881
881
|
}, 1);
|
|
882
882
|
};
|
|
883
883
|
r.subscribe(({ selected: b }) => {
|
|
884
884
|
if (!(f.length === 0 && b.length === 0)) {
|
|
885
885
|
if (f.length === 0 && b.length > 0)
|
|
886
|
-
f = b.map(({ id:
|
|
886
|
+
f = b.map(({ id: x }) => i.getAnnotation(x));
|
|
887
887
|
else if (f.length > 0 && b.length === 0)
|
|
888
|
-
f.forEach((
|
|
889
|
-
const h = i.getAnnotation(
|
|
890
|
-
h && !Z(h,
|
|
888
|
+
f.forEach((x) => {
|
|
889
|
+
const h = i.getAnnotation(x.id);
|
|
890
|
+
h && !Z(h, x) && u("updateAnnotation", h, x);
|
|
891
891
|
}), f = [];
|
|
892
892
|
else {
|
|
893
|
-
const
|
|
893
|
+
const x = new Set(f.map((d) => d.id)), h = new Set(b.map(({ id: d }) => d));
|
|
894
894
|
f.filter((d) => !h.has(d.id)).forEach((d) => {
|
|
895
895
|
const y = i.getAnnotation(d.id);
|
|
896
896
|
y && !Z(y, d) && u("updateAnnotation", y, d);
|
|
@@ -898,16 +898,16 @@ const hn = 250, pn = (t) => {
|
|
|
898
898
|
// Remove annotations that were deselected
|
|
899
899
|
...f.filter((d) => h.has(d.id)),
|
|
900
900
|
// Add editable annotations that were selected
|
|
901
|
-
...b.filter(({ id: d }) => !
|
|
901
|
+
...b.filter(({ id: d }) => !x.has(d)).map(({ id: d }) => i.getAnnotation(d))
|
|
902
902
|
];
|
|
903
903
|
}
|
|
904
904
|
u("selectionChanged", f);
|
|
905
905
|
}
|
|
906
906
|
}), a.subscribe((b) => {
|
|
907
907
|
!g && b ? u("mouseEnterAnnotation", i.getAnnotation(b)) : g && !b ? u("mouseLeaveAnnotation", i.getAnnotation(g)) : g && b && (u("mouseLeaveAnnotation", i.getAnnotation(g)), u("mouseEnterAnnotation", i.getAnnotation(b))), g = b;
|
|
908
|
-
}), s == null || s.subscribe((b) => u("viewportIntersect", b.map((
|
|
909
|
-
const { created:
|
|
910
|
-
(
|
|
908
|
+
}), s == null || s.subscribe((b) => u("viewportIntersect", b.map((x) => i.getAnnotation(x)))), i.observe((b) => {
|
|
909
|
+
const { created: x, deleted: h } = b.changes;
|
|
910
|
+
(x || []).forEach((d) => u("createAnnotation", d)), (h || []).forEach((d) => u("deleteAnnotation", d)), (b.changes.updated || []).filter((d) => [
|
|
911
911
|
...d.bodiesCreated || [],
|
|
912
912
|
...d.bodiesDeleted || [],
|
|
913
913
|
...d.bodiesUpdated || []
|
|
@@ -917,15 +917,15 @@ const hn = 250, pn = (t) => {
|
|
|
917
917
|
});
|
|
918
918
|
}, { origin: M.LOCAL }), i.observe((b) => {
|
|
919
919
|
if (f) {
|
|
920
|
-
const
|
|
920
|
+
const x = new Set(f.map((d) => d.id)), h = (b.changes.updated || []).filter(({ newValue: d }) => x.has(d.id)).map(({ newValue: d }) => d);
|
|
921
921
|
h.length > 0 && (f = f.map((d) => h.find((A) => A.id === d.id) || d));
|
|
922
922
|
}
|
|
923
923
|
}, { origin: M.REMOTE });
|
|
924
|
-
const
|
|
925
|
-
const { updated: h } =
|
|
924
|
+
const v = (b) => (x) => {
|
|
925
|
+
const { updated: h } = x;
|
|
926
926
|
b ? (h || []).forEach((d) => u("updateAnnotation", d.oldValue, d.newValue)) : (h || []).forEach((d) => u("updateAnnotation", d.newValue, d.oldValue));
|
|
927
927
|
};
|
|
928
|
-
return e.on("undo",
|
|
928
|
+
return e.on("undo", v(!0)), e.on("redo", v(!1)), { on: c, off: p, emit: u };
|
|
929
929
|
}, yn = (t) => (e) => e.reduce((n, o) => {
|
|
930
930
|
const { parsed: i, error: r } = t.parse(o);
|
|
931
931
|
return r ? {
|
|
@@ -967,11 +967,11 @@ const hn = 250, pn = (t) => {
|
|
|
967
967
|
A.length > 0 && console.warn(`Discarded ${A.length} invalid annotations`, A), o.bulkAddAnnotation(y, d, M.REMOTE);
|
|
968
968
|
} else
|
|
969
969
|
o.bulkAddAnnotation(h, d, M.REMOTE);
|
|
970
|
-
},
|
|
970
|
+
}, v = (h, d) => {
|
|
971
971
|
h ? i.setSelected(h, d) : i.clear();
|
|
972
972
|
}, b = (h) => {
|
|
973
973
|
i.clear(), i.setUserSelectAction(h);
|
|
974
|
-
},
|
|
974
|
+
}, x = (h) => {
|
|
975
975
|
if (n) {
|
|
976
976
|
const d = n.parse(h).parsed, y = n.serialize(o.getAnnotation(d.id));
|
|
977
977
|
return o.updateAnnotation(d), y;
|
|
@@ -993,13 +993,13 @@ const hn = 250, pn = (t) => {
|
|
|
993
993
|
redo: e.redo,
|
|
994
994
|
removeAnnotation: p,
|
|
995
995
|
setAnnotations: u,
|
|
996
|
-
setSelected:
|
|
996
|
+
setSelected: v,
|
|
997
997
|
setUserSelectAction: b,
|
|
998
998
|
undo: e.undo,
|
|
999
|
-
updateAnnotation:
|
|
999
|
+
updateAnnotation: x
|
|
1000
1000
|
};
|
|
1001
1001
|
}, wn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
1002
|
-
let
|
|
1002
|
+
let xn = (t) => crypto.getRandomValues(new Uint8Array(t)), vn = (t, e, n) => {
|
|
1003
1003
|
let o = (2 << Math.log(t.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * e / t.length);
|
|
1004
1004
|
return (r = e) => {
|
|
1005
1005
|
let a = "";
|
|
@@ -1009,7 +1009,7 @@ let vn = (t) => crypto.getRandomValues(new Uint8Array(t)), xn = (t, e, n) => {
|
|
|
1009
1009
|
if (a += t[s[l] & o] || "", a.length === r) return a;
|
|
1010
1010
|
}
|
|
1011
1011
|
};
|
|
1012
|
-
}, An = (t, e = 21) =>
|
|
1012
|
+
}, An = (t, e = 21) => vn(t, e, xn), En = (t = 21) => {
|
|
1013
1013
|
let e = "", n = crypto.getRandomValues(new Uint8Array(t));
|
|
1014
1014
|
for (; t--; )
|
|
1015
1015
|
e += wn[n[t] & 63];
|
|
@@ -1123,12 +1123,12 @@ const ue = "not-annotatable", H = `.${ue}`, Tn = (t) => {
|
|
|
1123
1123
|
c.selectNodeContents(n), c.setStart(n, o);
|
|
1124
1124
|
const p = g(c), u = document.createRange();
|
|
1125
1125
|
u.selectNode(i), u.setEnd(i, r);
|
|
1126
|
-
const
|
|
1126
|
+
const v = g(u), x = In(t).reverse().map((h) => {
|
|
1127
1127
|
var y;
|
|
1128
1128
|
const d = document.createElement("SPAN");
|
|
1129
1129
|
return (y = h.parentNode) == null || y.insertBefore(d, h), d.appendChild(h), d;
|
|
1130
1130
|
});
|
|
1131
|
-
return { unwrap: f, nodes: [p, ...
|
|
1131
|
+
return { unwrap: f, nodes: [p, ...x, v] };
|
|
1132
1132
|
}
|
|
1133
1133
|
}, In = (t) => {
|
|
1134
1134
|
const {
|
|
@@ -1379,14 +1379,14 @@ const ue = "not-annotatable", H = `.${ue}`, Tn = (t) => {
|
|
|
1379
1379
|
updated: f,
|
|
1380
1380
|
...g
|
|
1381
1381
|
} = i, c = a.map((p) => {
|
|
1382
|
-
const { quote: u, start:
|
|
1382
|
+
const { quote: u, start: v, end: b, range: x } = p, { prefix: h, suffix: d } = _n(x, n), y = [{
|
|
1383
1383
|
type: "TextQuoteSelector",
|
|
1384
1384
|
exact: u,
|
|
1385
1385
|
prefix: h,
|
|
1386
1386
|
suffix: d
|
|
1387
1387
|
}, {
|
|
1388
1388
|
type: "TextPositionSelector",
|
|
1389
|
-
start:
|
|
1389
|
+
start: v,
|
|
1390
1390
|
end: b
|
|
1391
1391
|
}];
|
|
1392
1392
|
return {
|
|
@@ -1411,8 +1411,8 @@ const ue = "not-annotatable", H = `.${ue}`, Tn = (t) => {
|
|
|
1411
1411
|
function he(t, e, n = 0, o = t.length - 1, i = Gn) {
|
|
1412
1412
|
for (; o > n; ) {
|
|
1413
1413
|
if (o - n > 600) {
|
|
1414
|
-
const l = o - n + 1, f = e - n + 1, g = Math.log(l), c = 0.5 * Math.exp(2 * g / 3), p = 0.5 * Math.sqrt(g * c * (l - c) / l) * (f - l / 2 < 0 ? -1 : 1), u = Math.max(n, Math.floor(e - f * c / l + p)),
|
|
1415
|
-
he(t, e, u,
|
|
1414
|
+
const l = o - n + 1, f = e - n + 1, g = Math.log(l), c = 0.5 * Math.exp(2 * g / 3), p = 0.5 * Math.sqrt(g * c * (l - c) / l) * (f - l / 2 < 0 ? -1 : 1), u = Math.max(n, Math.floor(e - f * c / l + p)), v = Math.min(o, Math.floor(e + (l - f) * c / l + p));
|
|
1415
|
+
he(t, e, u, v, i);
|
|
1416
1416
|
}
|
|
1417
1417
|
const r = t[e];
|
|
1418
1418
|
let a = n, s = o;
|
|
@@ -1734,7 +1734,7 @@ const io = (t, e) => {
|
|
|
1734
1734
|
}), R = (O) => O.annotation.rects.reduce((B, m) => B + m.width * m.height, 0);
|
|
1735
1735
|
return S.length > 0 ? (S.sort((O, B) => R(O) - R(B)), C ? S.map((O) => O.annotation.id) : [S[0].annotation.id]) : [];
|
|
1736
1736
|
}, u = (y) => {
|
|
1737
|
-
const A =
|
|
1737
|
+
const A = v(y);
|
|
1738
1738
|
if (A.length === 0)
|
|
1739
1739
|
return;
|
|
1740
1740
|
let C = A[0].left, S = A[0].top, R = A[0].right, O = A[0].bottom;
|
|
@@ -1743,7 +1743,7 @@ const io = (t, e) => {
|
|
|
1743
1743
|
C = Math.min(C, m.left), S = Math.min(S, m.top), R = Math.max(R, m.right), O = Math.max(O, m.bottom);
|
|
1744
1744
|
}
|
|
1745
1745
|
return new DOMRect(C, S, R - C, O - S);
|
|
1746
|
-
},
|
|
1746
|
+
}, v = (y) => {
|
|
1747
1747
|
const A = o.get(y);
|
|
1748
1748
|
return A ? A[0].annotation.rects : [];
|
|
1749
1749
|
};
|
|
@@ -1752,12 +1752,12 @@ const io = (t, e) => {
|
|
|
1752
1752
|
clear: s,
|
|
1753
1753
|
getAt: p,
|
|
1754
1754
|
getAnnotationBounds: u,
|
|
1755
|
-
getAnnotationRects:
|
|
1755
|
+
getAnnotationRects: v,
|
|
1756
1756
|
getIntersecting: (y, A, C, S) => {
|
|
1757
1757
|
const R = n.search({ minX: y, minY: A, maxX: C, maxY: S }), O = new Set(R.map((B) => B.annotation.id));
|
|
1758
1758
|
return Array.from(O).map((B) => ({
|
|
1759
1759
|
annotation: t.getAnnotation(B),
|
|
1760
|
-
rects:
|
|
1760
|
+
rects: v(B)
|
|
1761
1761
|
})).filter((B) => !!B.annotation);
|
|
1762
1762
|
},
|
|
1763
1763
|
insert: l,
|
|
@@ -1771,38 +1771,38 @@ const io = (t, e) => {
|
|
|
1771
1771
|
on: (y, A) => i.on(y, A)
|
|
1772
1772
|
};
|
|
1773
1773
|
}, ro = (t, e) => {
|
|
1774
|
-
const n = un(), o = io(n, t), i = Qe(n, e), r = qe(n), a = gn(), s = (
|
|
1775
|
-
const d = Ct(
|
|
1774
|
+
const n = un(), o = io(n, t), i = Qe(n, e), r = qe(n), a = gn(), s = (x, h = M.LOCAL) => {
|
|
1775
|
+
const d = Ct(x, t), y = W(d.target.selector);
|
|
1776
1776
|
return y && n.addAnnotation(d, h), y;
|
|
1777
|
-
}, l = (
|
|
1778
|
-
const y =
|
|
1777
|
+
}, l = (x, h = !0, d = M.LOCAL) => {
|
|
1778
|
+
const y = x.map((C) => Ct(C, t)), A = y.filter((C) => !W(C.target.selector));
|
|
1779
1779
|
return A.length > 0 ? (console.warn("Could not revive all targets for these annotations:", A), n.bulkAddAnnotation(y, h, d), A) : (n.bulkAddAnnotation(y, h, d), []);
|
|
1780
|
-
}, f = (
|
|
1781
|
-
const d =
|
|
1780
|
+
}, f = (x, h = M.LOCAL) => {
|
|
1781
|
+
const d = x.map((A) => Ct(A, t)), y = d.filter((A) => !W(A.target.selector));
|
|
1782
1782
|
return y.length > 0 && console.warn("Could not revive all targets for these annotations:", y), d.forEach((A) => {
|
|
1783
1783
|
n.getAnnotation(A.id) ? n.updateAnnotation(A, h) : n.addAnnotation(A, h);
|
|
1784
1784
|
}), y;
|
|
1785
|
-
}, g = (
|
|
1786
|
-
const d = yt(
|
|
1785
|
+
}, g = (x, h = M.LOCAL) => {
|
|
1786
|
+
const d = yt(x, t);
|
|
1787
1787
|
n.updateTarget(d, h);
|
|
1788
|
-
}, c = (
|
|
1789
|
-
const d =
|
|
1788
|
+
}, c = (x, h = M.LOCAL) => {
|
|
1789
|
+
const d = x.map((y) => yt(y, t));
|
|
1790
1790
|
n.bulkUpdateTargets(d, h);
|
|
1791
|
-
}, p = (
|
|
1792
|
-
const y = o.getAt(
|
|
1791
|
+
}, p = (x, h, d) => {
|
|
1792
|
+
const y = o.getAt(x, h, !!d).map((C) => n.getAnnotation(C)), A = d ? y.filter(d) : y;
|
|
1793
1793
|
return A.length > 0 ? A[0] : void 0;
|
|
1794
|
-
}, u = (
|
|
1795
|
-
const A = o.getAnnotationRects(
|
|
1794
|
+
}, u = (x, h, d, y = 5) => {
|
|
1795
|
+
const A = o.getAnnotationRects(x);
|
|
1796
1796
|
if (A.length !== 0) {
|
|
1797
1797
|
if (h && d) {
|
|
1798
1798
|
const C = A.find(({ top: S, right: R, bottom: O, left: B }) => h >= B - y && h <= R + y && d >= S - y && d <= O + y);
|
|
1799
1799
|
if (C) return C;
|
|
1800
1800
|
}
|
|
1801
|
-
return o.getAnnotationBounds(
|
|
1801
|
+
return o.getAnnotationBounds(x);
|
|
1802
1802
|
}
|
|
1803
|
-
},
|
|
1804
|
-
return n.observe(({ changes:
|
|
1805
|
-
const h = (
|
|
1803
|
+
}, v = () => o.recalculate(), b = (x) => o.on("recalculate", x);
|
|
1804
|
+
return n.observe(({ changes: x }) => {
|
|
1805
|
+
const h = (x.deleted || []).filter((A) => W(A.target.selector)), d = (x.created || []).filter((A) => W(A.target.selector)), y = (x.updated || []).filter((A) => W(A.newValue.target.selector));
|
|
1806
1806
|
(h == null ? void 0 : h.length) > 0 && h.forEach((A) => o.remove(A.target)), d.length > 0 && o.set(d.map((A) => A.target), !1), (y == null ? void 0 : y.length) > 0 && y.forEach(({ newValue: A }) => o.update(A.target));
|
|
1807
1807
|
}), {
|
|
1808
1808
|
store: {
|
|
@@ -1815,7 +1815,7 @@ const io = (t, e) => {
|
|
|
1815
1815
|
getAt: p,
|
|
1816
1816
|
getIntersecting: o.getIntersecting.bind(o),
|
|
1817
1817
|
getAnnotationRects: o.getAnnotationRects.bind(o),
|
|
1818
|
-
recalculatePositions:
|
|
1818
|
+
recalculatePositions: v,
|
|
1819
1819
|
onRecalculatePositions: b,
|
|
1820
1820
|
updateTarget: g
|
|
1821
1821
|
},
|
|
@@ -1833,7 +1833,7 @@ const io = (t, e) => {
|
|
|
1833
1833
|
document.body.appendChild(o);
|
|
1834
1834
|
const r = /* @__PURE__ */ new Map(), a = (c) => Array.from(r.entries()).filter(([p, u]) => u.presenceKey === c.presenceKey).map(([p, u]) => p);
|
|
1835
1835
|
return e.on("selectionChange", (c, p) => {
|
|
1836
|
-
a(c).forEach((
|
|
1836
|
+
a(c).forEach((v) => r.delete(v)), p && p.forEach((v) => r.set(v, c));
|
|
1837
1837
|
}), {
|
|
1838
1838
|
clear: () => {
|
|
1839
1839
|
const { width: c, height: p } = o;
|
|
@@ -1844,13 +1844,13 @@ const io = (t, e) => {
|
|
|
1844
1844
|
},
|
|
1845
1845
|
paint: (c, p, u) => {
|
|
1846
1846
|
n.font && (i.font = n.font);
|
|
1847
|
-
const
|
|
1848
|
-
if (
|
|
1849
|
-
const { height: b } = c.rects[0],
|
|
1850
|
-
i.fillStyle =
|
|
1851
|
-
const d = i.measureText(
|
|
1852
|
-
return i.fillRect(
|
|
1853
|
-
fill:
|
|
1847
|
+
const v = r.get(c.annotation.id);
|
|
1848
|
+
if (v) {
|
|
1849
|
+
const { height: b } = c.rects[0], x = c.rects[0].x + p.left, h = c.rects[0].y + p.top;
|
|
1850
|
+
i.fillStyle = v.appearance.color, i.fillRect(x - 2, h - 2.5, 2, b + 5);
|
|
1851
|
+
const d = i.measureText(v.appearance.label), y = d.width + 6, A = d.actualBoundingBoxAscent + d.actualBoundingBoxDescent + 8, C = d.fontBoundingBoxAscent ? 8 : 6.5;
|
|
1852
|
+
return i.fillRect(x - 2, h - 2.5 - A, y, A), i.fillStyle = "#fff", i.fillText(v.appearance.label, x + 1, h - C), {
|
|
1853
|
+
fill: v.appearance.color,
|
|
1854
1854
|
fillOpacity: u ? 0.45 : 0.18
|
|
1855
1855
|
};
|
|
1856
1856
|
}
|
|
@@ -1868,7 +1868,7 @@ const io = (t, e) => {
|
|
|
1868
1868
|
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : pe(t.parentElement);
|
|
1869
1869
|
}, co = (t, e) => (n) => {
|
|
1870
1870
|
const o = typeof n == "string" ? n : n.id, i = (a) => {
|
|
1871
|
-
const s = r.getBoundingClientRect(), l = r.clientHeight, f = r.clientWidth, g = a.selector[0].range.getBoundingClientRect(), { width: c, height: p } = e.getAnnotationBounds(o), u = g.top - s.top,
|
|
1871
|
+
const s = r.getBoundingClientRect(), l = r.clientHeight, f = r.clientWidth, g = a.selector[0].range.getBoundingClientRect(), { width: c, height: p } = e.getAnnotationBounds(o), u = g.top - s.top, v = g.left - s.left, b = r.parentElement ? r.scrollTop : 0, x = r.parentElement ? r.scrollLeft : 0, h = u + b - (l - p) / 2, d = v + x - (f - c) / 2;
|
|
1872
1872
|
r.scroll({ top: h, left: d, behavior: "smooth" });
|
|
1873
1873
|
}, r = pe(t);
|
|
1874
1874
|
if (r) {
|
|
@@ -2056,12 +2056,12 @@ function wo(t, e) {
|
|
|
2056
2056
|
}) : o++;
|
|
2057
2057
|
at() === t && be(e || "all");
|
|
2058
2058
|
}
|
|
2059
|
-
function
|
|
2059
|
+
function xo(t) {
|
|
2060
2060
|
let e = t.keyCode || t.which || t.charCode;
|
|
2061
2061
|
const n = k.indexOf(e);
|
|
2062
2062
|
if (n >= 0 && k.splice(n, 1), t.key && t.key.toLowerCase() === "meta" && k.splice(0, k.length), (e === 93 || e === 224) && (e = 91), e in D) {
|
|
2063
2063
|
D[e] = !1;
|
|
2064
|
-
for (const o in j) j[o] === e && (
|
|
2064
|
+
for (const o in j) j[o] === e && ($[o] = !1);
|
|
2065
2065
|
}
|
|
2066
2066
|
}
|
|
2067
2067
|
function we(t) {
|
|
@@ -2119,14 +2119,14 @@ function ee(t, e, n, o) {
|
|
|
2119
2119
|
function ne(t, e) {
|
|
2120
2120
|
const n = I["*"];
|
|
2121
2121
|
let o = t.keyCode || t.which || t.charCode;
|
|
2122
|
-
if (
|
|
2122
|
+
if (!$.filter.call(this, t)) return;
|
|
2123
2123
|
if ((o === 93 || o === 224) && (o = 91), k.indexOf(o) === -1 && o !== 229 && k.push(o), ["ctrlKey", "altKey", "shiftKey", "metaKey"].forEach((s) => {
|
|
2124
2124
|
const l = Nt[s];
|
|
2125
2125
|
t[s] && k.indexOf(l) === -1 ? k.push(l) : !t[s] && k.indexOf(l) > -1 ? k.splice(k.indexOf(l), 1) : s === "metaKey" && t[s] && k.length === 3 && (t.ctrlKey || t.shiftKey || t.altKey || (k = k.slice(k.indexOf(l))));
|
|
2126
2126
|
}), o in D) {
|
|
2127
2127
|
D[o] = !0;
|
|
2128
2128
|
for (const s in j)
|
|
2129
|
-
j[s] === o && (
|
|
2129
|
+
j[s] === o && ($[s] = !0);
|
|
2130
2130
|
if (!n) return;
|
|
2131
2131
|
}
|
|
2132
2132
|
for (const s in D)
|
|
@@ -2148,7 +2148,7 @@ function ne(t, e) {
|
|
|
2148
2148
|
c.sort().join("") === k.sort().join("") && ee(t, l, i, e);
|
|
2149
2149
|
}
|
|
2150
2150
|
}
|
|
2151
|
-
function
|
|
2151
|
+
function $(t, e, n) {
|
|
2152
2152
|
k = [];
|
|
2153
2153
|
const o = me(t);
|
|
2154
2154
|
let i = [], r = "all", a = document, s = 0, l = !1, f = !0, g = "+", c = !1, p = !1;
|
|
@@ -2169,15 +2169,15 @@ function X(t, e, n) {
|
|
|
2169
2169
|
const u = function() {
|
|
2170
2170
|
let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2171
2171
|
return ne(b, a);
|
|
2172
|
-
},
|
|
2172
|
+
}, v = function() {
|
|
2173
2173
|
let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2174
|
-
ne(b, a),
|
|
2174
|
+
ne(b, a), xo(b);
|
|
2175
2175
|
};
|
|
2176
2176
|
F.set(a, {
|
|
2177
2177
|
keydownListener: u,
|
|
2178
|
-
keyupListenr:
|
|
2178
|
+
keyupListenr: v,
|
|
2179
2179
|
capture: c
|
|
2180
|
-
}), Rt(a, "keydown", u, c), Rt(a, "keyup",
|
|
2180
|
+
}), Rt(a, "keydown", u, c), Rt(a, "keyup", v, c);
|
|
2181
2181
|
}
|
|
2182
2182
|
if (!rt) {
|
|
2183
2183
|
const u = () => {
|
|
@@ -2190,7 +2190,7 @@ function X(t, e, n) {
|
|
|
2190
2190
|
}
|
|
2191
2191
|
}
|
|
2192
2192
|
}
|
|
2193
|
-
function
|
|
2193
|
+
function vo(t) {
|
|
2194
2194
|
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "all";
|
|
2195
2195
|
Object.keys(I).forEach((n) => {
|
|
2196
2196
|
I[n].filter((i) => i.scope === e && i.shortcut === t).forEach((i) => {
|
|
@@ -2237,17 +2237,17 @@ const Bt = {
|
|
|
2237
2237
|
getAllKeyCodes: mo,
|
|
2238
2238
|
isPressed: bo,
|
|
2239
2239
|
filter: yo,
|
|
2240
|
-
trigger:
|
|
2240
|
+
trigger: vo,
|
|
2241
2241
|
unbind: we,
|
|
2242
2242
|
keyMap: st,
|
|
2243
2243
|
modifier: j,
|
|
2244
2244
|
modifierMap: Nt
|
|
2245
2245
|
};
|
|
2246
2246
|
for (const t in Bt)
|
|
2247
|
-
Object.prototype.hasOwnProperty.call(Bt, t) && (
|
|
2247
|
+
Object.prototype.hasOwnProperty.call(Bt, t) && ($[t] = Bt[t]);
|
|
2248
2248
|
if (typeof window < "u") {
|
|
2249
2249
|
const t = window.hotkeys;
|
|
2250
|
-
|
|
2250
|
+
$.noConflict = (e) => (e && window.hotkeys === $ && (window.hotkeys = t), $), window.hotkeys = $;
|
|
2251
2251
|
}
|
|
2252
2252
|
const Ao = (t, e, n) => {
|
|
2253
2253
|
let o;
|
|
@@ -2259,7 +2259,7 @@ const Ao = (t, e, n) => {
|
|
|
2259
2259
|
s = S, b.clear(), S || (c = void 0, p = void 0, u = void 0);
|
|
2260
2260
|
}, { store: f, selection: g } = e;
|
|
2261
2261
|
let c, p, u;
|
|
2262
|
-
const
|
|
2262
|
+
const v = (S) => {
|
|
2263
2263
|
var O;
|
|
2264
2264
|
if (!s || p === !1)
|
|
2265
2265
|
return;
|
|
@@ -2270,7 +2270,7 @@ const Ao = (t, e, n) => {
|
|
|
2270
2270
|
created: /* @__PURE__ */ new Date()
|
|
2271
2271
|
} : void 0;
|
|
2272
2272
|
};
|
|
2273
|
-
t.addEventListener("selectstart",
|
|
2273
|
+
t.addEventListener("selectstart", v);
|
|
2274
2274
|
const b = _t((S) => {
|
|
2275
2275
|
var T, N;
|
|
2276
2276
|
if (!s) return;
|
|
@@ -2279,7 +2279,7 @@ const Ao = (t, e, n) => {
|
|
|
2279
2279
|
c = void 0;
|
|
2280
2280
|
return;
|
|
2281
2281
|
}
|
|
2282
|
-
if (S.timeStamp - ((u == null ? void 0 : u.timeStamp) || S.timeStamp) < 1e3 && !c &&
|
|
2282
|
+
if (S.timeStamp - ((u == null ? void 0 : u.timeStamp) || S.timeStamp) < 1e3 && !c && v(u || S), !c) return;
|
|
2283
2283
|
if (R.isCollapsed) {
|
|
2284
2284
|
f.getAnnotation(c.annotation) && (g.clear(), f.deleteAnnotation(c.annotation));
|
|
2285
2285
|
return;
|
|
@@ -2287,9 +2287,9 @@ const Ao = (t, e, n) => {
|
|
|
2287
2287
|
const m = R.getRangeAt(0), w = Pn(m, t);
|
|
2288
2288
|
if (Vn(w)) return;
|
|
2289
2289
|
const E = Bn(w.cloneRange());
|
|
2290
|
-
(E.length !== c.selector.length || E.some((K,
|
|
2290
|
+
(E.length !== c.selector.length || E.some((K, X) => {
|
|
2291
2291
|
var lt;
|
|
2292
|
-
return K.toString() !== ((lt = c.selector[
|
|
2292
|
+
return K.toString() !== ((lt = c.selector[X]) == null ? void 0 : lt.quote);
|
|
2293
2293
|
})) && (c = {
|
|
2294
2294
|
...c,
|
|
2295
2295
|
selector: E.map((K) => Xn(K, t, n)),
|
|
@@ -2301,10 +2301,10 @@ const Ao = (t, e, n) => {
|
|
|
2301
2301
|
}, M.LOCAL), g.userSelect(c.annotation, u)));
|
|
2302
2302
|
}, 10);
|
|
2303
2303
|
document.addEventListener("selectionchange", b);
|
|
2304
|
-
const
|
|
2304
|
+
const x = (S) => {
|
|
2305
2305
|
u = Hn(S), p = u.button === 0, c = void 0;
|
|
2306
2306
|
};
|
|
2307
|
-
document.addEventListener("pointerdown",
|
|
2307
|
+
document.addEventListener("pointerdown", x);
|
|
2308
2308
|
const h = (S) => {
|
|
2309
2309
|
var m;
|
|
2310
2310
|
if (!!((m = S.target.parentElement) != null && m.closest(H)) || !p)
|
|
@@ -2327,15 +2327,15 @@ const Ao = (t, e, n) => {
|
|
|
2327
2327
|
"ctrl+a",
|
|
2328
2328
|
"⌘+a"
|
|
2329
2329
|
];
|
|
2330
|
-
|
|
2330
|
+
$(y.join(","), { element: t, keydown: !0, keyup: !1 }, (S) => {
|
|
2331
2331
|
S.repeat || (u = jn(S));
|
|
2332
2332
|
});
|
|
2333
2333
|
const A = (S) => {
|
|
2334
|
-
S.repeat || (c = void 0, g.clear());
|
|
2334
|
+
S.repeat || S.target !== t && S.target !== document.body || (c = void 0, g.clear());
|
|
2335
2335
|
};
|
|
2336
|
-
return
|
|
2336
|
+
return $(d.join(","), { keydown: !0, keyup: !1 }, A), {
|
|
2337
2337
|
destroy: () => {
|
|
2338
|
-
c = void 0, p = void 0, u = void 0, b.clear(), t.removeEventListener("selectstart",
|
|
2338
|
+
c = void 0, p = void 0, u = void 0, b.clear(), t.removeEventListener("selectstart", v), document.removeEventListener("selectionchange", b), document.removeEventListener("pointerdown", x), document.removeEventListener("pointerup", h), $.unbind();
|
|
2339
2339
|
},
|
|
2340
2340
|
setFilter: a,
|
|
2341
2341
|
setUser: i,
|
|
@@ -2354,11 +2354,11 @@ const Ao = (t, e, n) => {
|
|
|
2354
2354
|
console.debug(`Using ${g} renderer`), n.style && c.setStyle(n.style);
|
|
2355
2355
|
const p = Ao(t, o, n.offsetReferenceSelector);
|
|
2356
2356
|
p.setUser(f), p.setAnnotatingEnabled(n.annotatingEnabled);
|
|
2357
|
-
const u = bn(o, s, n.adapter),
|
|
2357
|
+
const u = bn(o, s, n.adapter), v = () => f, b = (C) => {
|
|
2358
2358
|
p.setAnnotatingEnabled(
|
|
2359
2359
|
C === void 0 ? !0 : C
|
|
2360
2360
|
);
|
|
2361
|
-
},
|
|
2361
|
+
}, x = (C) => {
|
|
2362
2362
|
c.setFilter(C), p.setFilter(C);
|
|
2363
2363
|
}, h = (C) => {
|
|
2364
2364
|
f = C, p.setUser(C);
|
|
@@ -2373,9 +2373,9 @@ const Ao = (t, e, n) => {
|
|
|
2373
2373
|
c.destroy(), p.destroy(), s.destroy();
|
|
2374
2374
|
},
|
|
2375
2375
|
element: t,
|
|
2376
|
-
getUser:
|
|
2376
|
+
getUser: v,
|
|
2377
2377
|
setAnnotatingEnabled: b,
|
|
2378
|
-
setFilter:
|
|
2378
|
+
setFilter: x,
|
|
2379
2379
|
setStyle: c.setStyle.bind(c),
|
|
2380
2380
|
redraw: c.redraw.bind(c),
|
|
2381
2381
|
setUser: h,
|