@soomo/text-annotator 3.4.9-staging.0 → 3.4.10-staging.0
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.
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { UAParser as
|
|
2
|
-
import { OS as
|
|
1
|
+
import { UAParser as Ee } from "ua-parser-js";
|
|
2
|
+
import { OS as Ce } from "ua-parser-js/enums";
|
|
3
3
|
import le from "debounce";
|
|
4
|
-
import { UserSelectAction as
|
|
4
|
+
import { UserSelectAction as Se, serializeW3CBodies as Ae, parseW3CBodies as we, parseW3CUser as Re, createStore as ve, createSelectionState as Te, createHoverState as xe, createViewportState as Le, Origin as K, createAnonymousGuest as Ne, createUndoStack as Oe, createLifecycleObserver as Be, createBaseAnnotator as ke } from "@annotorious/core";
|
|
5
5
|
import { Origin as Ft, UserSelectAction as Vt, createBody as Yt } from "@annotorious/core";
|
|
6
6
|
import { colord as ne } from "colord";
|
|
7
|
-
import { dequal as
|
|
7
|
+
import { dequal as Me } from "dequal/lite";
|
|
8
8
|
import { v4 as de } from "uuid";
|
|
9
|
-
import
|
|
10
|
-
import { createNanoEvents as
|
|
9
|
+
import Ie from "rbush";
|
|
10
|
+
import { createNanoEvents as _e } from "nanoevents";
|
|
11
11
|
import q from "hotkeys-js";
|
|
12
|
-
import { poll as
|
|
13
|
-
const ue = "not-annotatable", W = `.${ue}`, G = (e, t) => e.contains(t) ? !!(t instanceof HTMLElement ? t.closest(W) : t.parentElement?.closest(W)) : !0,
|
|
12
|
+
import { poll as He } from "poll";
|
|
13
|
+
const ue = "not-annotatable", W = `.${ue}`, G = (e, t) => e.contains(t) ? !!(t instanceof HTMLElement ? t.closest(W) : t.parentElement?.closest(W)) : !0, fe = (e, t) => {
|
|
14
14
|
const n = t.commonAncestorContainer;
|
|
15
15
|
return !G(e, n);
|
|
16
16
|
}, Pe = (e) => e.addEventListener("click", (t) => {
|
|
@@ -63,7 +63,7 @@ const ue = "not-annotatable", W = `.${ue}`, G = (e, t) => e.contains(t) ? !!(t i
|
|
|
63
63
|
return ((...r) => {
|
|
64
64
|
clearTimeout(n), n = setTimeout(() => e.apply(void 0, r), t);
|
|
65
65
|
});
|
|
66
|
-
}, De =
|
|
66
|
+
}, De = Ee(), ge = De.os.is(Ce.MACOS), Ue = (e) => {
|
|
67
67
|
(!e.hasAttribute("tabindex") || e.tabIndex < -1) && e.setAttribute("tabindex", "-1"), e.classList.add("no-focus-outline");
|
|
68
68
|
}, Ke = (e) => {
|
|
69
69
|
const t = [], n = document.createNodeIterator(
|
|
@@ -110,7 +110,7 @@ const ue = "not-annotatable", W = `.${ue}`, G = (e, t) => e.contains(t) ? !!(t i
|
|
|
110
110
|
for (; n = t.nextNode(); )
|
|
111
111
|
n instanceof HTMLElement && (yield n);
|
|
112
112
|
}, $e = (e, t) => {
|
|
113
|
-
if (!
|
|
113
|
+
if (!fe(e, t)) return [];
|
|
114
114
|
const n = [];
|
|
115
115
|
let r = null;
|
|
116
116
|
for (const s of We(t)) {
|
|
@@ -135,7 +135,7 @@ const ue = "not-annotatable", W = `.${ue}`, G = (e, t) => e.contains(t) ? !!(t i
|
|
|
135
135
|
prefix: i.substring(i.length - n),
|
|
136
136
|
suffix: l.substring(0, n)
|
|
137
137
|
};
|
|
138
|
-
}, I = (e) => e.every((t) => t.range instanceof Range && !t.range.collapsed),
|
|
138
|
+
}, I = (e) => e.every((t) => t.range instanceof Range && !t.range.collapsed), me = /^\s*$/, Ve = (e) => me.test(e.toString()), Ht = (e) => me.test(e.textContent || ""), Ye = (e, t, n, r) => {
|
|
139
139
|
const s = (c) => Math.round(c * 10) / 10, o = {
|
|
140
140
|
top: s(e.top),
|
|
141
141
|
bottom: s(e.bottom),
|
|
@@ -210,7 +210,7 @@ const ue = "not-annotatable", W = `.${ue}`, G = (e, t) => e.contains(t) ? !!(t i
|
|
|
210
210
|
}, Dt = (e, t) => {
|
|
211
211
|
const { left: n, top: r, right: s, bottom: o } = e;
|
|
212
212
|
return new DOMRect(n + t.left, r + t.top, s - n, o - r);
|
|
213
|
-
},
|
|
213
|
+
}, pe = (e, t) => {
|
|
214
214
|
const { start: n, end: r } = e, s = e.offsetReference || t, o = document.createNodeIterator(
|
|
215
215
|
t,
|
|
216
216
|
NodeFilter.SHOW_TEXT,
|
|
@@ -246,20 +246,20 @@ const ue = "not-annotatable", W = `.${ue}`, G = (e, t) => e.contains(t) ? !!(t i
|
|
|
246
246
|
};
|
|
247
247
|
}, Q = (e, t) => I(e.selector) ? e : {
|
|
248
248
|
...e,
|
|
249
|
-
selector: e.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n :
|
|
249
|
+
selector: e.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : pe(n, t))
|
|
250
250
|
}, te = (e, t) => I(e.target.selector) ? e : { ...e, target: Q(e.target, t) }, Qe = (e, t) => {
|
|
251
251
|
const n = e.cloneRange();
|
|
252
252
|
return t.contains(n.startContainer) || n.setStart(t, 0), t.contains(n.endContainer) || n.setEnd(t, t.childNodes.length), n;
|
|
253
|
-
},
|
|
253
|
+
}, he = (e) => {
|
|
254
254
|
if (!e)
|
|
255
255
|
return document.scrollingElement;
|
|
256
256
|
const { overflowY: t } = window.getComputedStyle(e);
|
|
257
|
-
return t !== "visible" && t !== "hidden" && e.scrollHeight > e.clientHeight ? e :
|
|
257
|
+
return t !== "visible" && t !== "hidden" && e.scrollHeight > e.clientHeight ? e : he(e.parentElement);
|
|
258
258
|
}, ie = (e, t, n) => {
|
|
259
259
|
const r = n.getBoundingClientRect(), s = n.clientHeight, o = n.clientWidth, i = t.selector[0].range.getBoundingClientRect(), { width: c, height: l } = e.getAnnotationBounds(t.annotation), g = i.top - r.top, d = i.left - r.left, u = n.parentElement ? n.scrollTop : 0, y = n.parentElement ? n.scrollLeft : 0, w = g + u - (s - l) / 2, f = d + y - (o - c) / 2;
|
|
260
260
|
n.scroll({ top: w, left: f, behavior: "smooth" });
|
|
261
261
|
}, Ze = (e, t) => (n, r) => {
|
|
262
|
-
const s = typeof n == "string" ? n : n.id, o = r ? typeof r == "string" ? document.getElementById(r) : r :
|
|
262
|
+
const s = typeof n == "string" ? n : n.id, o = r ? typeof r == "string" ? document.getElementById(r) : r : he(e);
|
|
263
263
|
if (!o)
|
|
264
264
|
return console.warn(`The scroll parent is missing for the annotation: ${s}`, { container: e }), !1;
|
|
265
265
|
const i = t.getAnnotation(s);
|
|
@@ -289,21 +289,21 @@ const ue = "not-annotatable", W = `.${ue}`, G = (e, t) => e.contains(t) ? !!(t i
|
|
|
289
289
|
const { store: s, selection: o, hover: i } = t;
|
|
290
290
|
let c, l, g;
|
|
291
291
|
const d = et(n), u = (A) => {
|
|
292
|
-
const { x:
|
|
293
|
-
O && t.selection.evalSelectAction(O) !==
|
|
292
|
+
const { x: T, y: N } = e.getBoundingClientRect(), O = s.getAt(A.clientX - T, A.clientY - N, !1, l);
|
|
293
|
+
O && t.selection.evalSelectAction(O) !== Se.NONE ? i.current !== O.id && (e.classList.add("hovered"), i.set(O.id)) : i.current && (e.classList.remove("hovered"), i.set(null));
|
|
294
294
|
};
|
|
295
295
|
e.addEventListener("pointermove", u);
|
|
296
296
|
const y = ee((A = !1) => requestAnimationFrame(() => {
|
|
297
297
|
g && g.clear();
|
|
298
|
-
const
|
|
298
|
+
const T = Je(e), { minX: N, minY: O, maxX: D, maxY: Y } = T, X = l ? s.getIntersecting(N, O, D, Y).filter(({ annotation: h }) => l(h)) : s.getIntersecting(N, O, D, Y), $ = o.selected.map(({ id: h }) => h), re = X.map(({ annotation: h, rects: v }) => {
|
|
299
299
|
const k = $.includes(h.id), U = h.id === i.current;
|
|
300
300
|
return {
|
|
301
301
|
annotation: h,
|
|
302
|
-
rects:
|
|
302
|
+
rects: v,
|
|
303
303
|
state: { selected: k, hovered: U }
|
|
304
304
|
};
|
|
305
305
|
});
|
|
306
|
-
r.redraw(re,
|
|
306
|
+
r.redraw(re, T, c, g, A), setTimeout(() => d(X.map(({ annotation: h }) => h)), 1);
|
|
307
307
|
}), 10), w = (A) => {
|
|
308
308
|
g = A, y();
|
|
309
309
|
}, f = (A) => {
|
|
@@ -424,7 +424,7 @@ const ue = "not-annotatable", W = `.${ue}`, G = (e, t) => e.contains(t) ? !!(t i
|
|
|
424
424
|
t.remove();
|
|
425
425
|
},
|
|
426
426
|
redraw: (i, c, l, g, d) => {
|
|
427
|
-
const y = !(
|
|
427
|
+
const y = !(Me(n, i) && d);
|
|
428
428
|
if (!g && !y) return;
|
|
429
429
|
y && (t.innerHTML = ""), [...i].sort((f, x) => {
|
|
430
430
|
const { annotation: { target: { created: R } } } = f, { annotation: { target: { created: b } } } = x;
|
|
@@ -457,7 +457,7 @@ const ue = "not-annotatable", W = `.${ue}`, G = (e, t) => e.contains(t) ? !!(t i
|
|
|
457
457
|
if (i.length === 0)
|
|
458
458
|
return { error: Error(`No targets found for annotation: ${e.id}`) };
|
|
459
459
|
const c = {
|
|
460
|
-
creator:
|
|
460
|
+
creator: Re(n),
|
|
461
461
|
created: r ? new Date(r) : void 0,
|
|
462
462
|
updated: s ? new Date(s) : void 0,
|
|
463
463
|
annotation: t,
|
|
@@ -502,7 +502,7 @@ const ue = "not-annotatable", W = `.${ue}`, G = (e, t) => e.contains(t) ? !!(t i
|
|
|
502
502
|
modified: s,
|
|
503
503
|
body: o,
|
|
504
504
|
...i
|
|
505
|
-
} = e, c =
|
|
505
|
+
} = e, c = we(o, t), l = mt(e);
|
|
506
506
|
return "error" in l ? { error: l.error } : {
|
|
507
507
|
parsed: {
|
|
508
508
|
...i,
|
|
@@ -546,7 +546,7 @@ const ue = "not-annotatable", W = `.${ue}`, G = (e, t) => e.contains(t) ? !!(t i
|
|
|
546
546
|
"@context": "http://www.w3.org/ns/anno.jsonld",
|
|
547
547
|
id: e.id,
|
|
548
548
|
type: "Annotation",
|
|
549
|
-
body:
|
|
549
|
+
body: Ae(e.bodies),
|
|
550
550
|
creator: c,
|
|
551
551
|
created: l?.toISOString(),
|
|
552
552
|
modified: g?.toISOString(),
|
|
@@ -591,17 +591,17 @@ const ue = "not-annotatable", W = `.${ue}`, G = (e, t) => e.contains(t) ? !!(t i
|
|
|
591
591
|
}
|
|
592
592
|
};
|
|
593
593
|
}, Et = (e, t, n, r) => {
|
|
594
|
-
const s = new
|
|
594
|
+
const s = new Ie(), o = /* @__PURE__ */ new Map(), i = _e(), c = (m, a) => {
|
|
595
595
|
const C = m.selector.flatMap((A) => {
|
|
596
|
-
const
|
|
597
|
-
return Ke(
|
|
596
|
+
const T = I([A]) ? A.range : pe(A, t).range;
|
|
597
|
+
return Ke(T);
|
|
598
598
|
}), L = ze(C, n, r).map((A) => Ge(A, a));
|
|
599
599
|
return L.map((A) => {
|
|
600
|
-
const { x:
|
|
600
|
+
const { x: T, y: N, width: O, height: D } = A;
|
|
601
601
|
return {
|
|
602
|
-
minX:
|
|
602
|
+
minX: T,
|
|
603
603
|
minY: N,
|
|
604
|
-
maxX:
|
|
604
|
+
maxX: T + O,
|
|
605
605
|
maxY: N + D,
|
|
606
606
|
annotation: {
|
|
607
607
|
id: m.annotation,
|
|
@@ -621,11 +621,11 @@ const ue = "not-annotatable", W = `.${ue}`, G = (e, t) => e.contains(t) ? !!(t i
|
|
|
621
621
|
u(m), d(m);
|
|
622
622
|
}, w = (m, a = !0) => {
|
|
623
623
|
a && g();
|
|
624
|
-
const C = t.getBoundingClientRect(), L = m.map((
|
|
625
|
-
L.forEach(({ target:
|
|
626
|
-
N.length > 0 && o.set(
|
|
624
|
+
const C = t.getBoundingClientRect(), L = m.map((T) => ({ target: T, rects: c(T, C) }));
|
|
625
|
+
L.forEach(({ target: T, rects: N }) => {
|
|
626
|
+
N.length > 0 && o.set(T.annotation, N);
|
|
627
627
|
});
|
|
628
|
-
const A = L.flatMap(({ rects:
|
|
628
|
+
const A = L.flatMap(({ rects: T }) => T);
|
|
629
629
|
s.load(A);
|
|
630
630
|
}, f = (m, a, C = !1) => {
|
|
631
631
|
const L = s.search({
|
|
@@ -633,18 +633,18 @@ const ue = "not-annotatable", W = `.${ue}`, G = (e, t) => e.contains(t) ? !!(t i
|
|
|
633
633
|
minY: a,
|
|
634
634
|
maxX: m,
|
|
635
635
|
maxY: a
|
|
636
|
-
}), A = (
|
|
637
|
-
return L.length > 0 ? (L.sort((
|
|
636
|
+
}), A = (T) => T.annotation.rects.reduce((N, O) => N + O.width * O.height, 0);
|
|
637
|
+
return L.length > 0 ? (L.sort((T, N) => A(T) - A(N)), C ? L.map((T) => T.annotation.id) : [L[0].annotation.id]) : [];
|
|
638
638
|
}, x = (m) => {
|
|
639
639
|
const a = R(m);
|
|
640
640
|
if (a.length === 0)
|
|
641
641
|
return;
|
|
642
|
-
let C = a[0].left, L = a[0].top, A = a[0].right,
|
|
642
|
+
let C = a[0].left, L = a[0].top, A = a[0].right, T = a[0].bottom;
|
|
643
643
|
for (let N = 1; N < a.length; N++) {
|
|
644
644
|
const O = a[N];
|
|
645
|
-
C = Math.min(C, O.left), L = Math.min(L, O.top), A = Math.max(A, O.right),
|
|
645
|
+
C = Math.min(C, O.left), L = Math.min(L, O.top), A = Math.max(A, O.right), T = Math.max(T, O.bottom);
|
|
646
646
|
}
|
|
647
|
-
return new DOMRect(C, L, A - C,
|
|
647
|
+
return new DOMRect(C, L, A - C, T - L);
|
|
648
648
|
}, R = (m) => {
|
|
649
649
|
const a = o.get(m);
|
|
650
650
|
return a ? a[0].annotation.rects : [];
|
|
@@ -656,8 +656,8 @@ const ue = "not-annotatable", W = `.${ue}`, G = (e, t) => e.contains(t) ? !!(t i
|
|
|
656
656
|
getAnnotationBounds: x,
|
|
657
657
|
getAnnotationRects: R,
|
|
658
658
|
getIntersecting: (m, a, C, L) => {
|
|
659
|
-
const A = s.search({ minX: m, minY: a, maxX: C, maxY: L }),
|
|
660
|
-
return Array.from(
|
|
659
|
+
const A = s.search({ minX: m, minY: a, maxX: C, maxY: L }), T = new Set(A.map((N) => N.annotation.id));
|
|
660
|
+
return Array.from(T).map((N) => ({
|
|
661
661
|
annotation: e.getAnnotation(N),
|
|
662
662
|
rects: R(N)
|
|
663
663
|
})).filter((N) => !!N.annotation);
|
|
@@ -673,7 +673,7 @@ const ue = "not-annotatable", W = `.${ue}`, G = (e, t) => e.contains(t) ? !!(t i
|
|
|
673
673
|
on: (m, a) => i.on(m, a)
|
|
674
674
|
};
|
|
675
675
|
}, Ct = (e, t) => {
|
|
676
|
-
const n =
|
|
676
|
+
const n = ve(), r = Et(n, e, t.mergeHighlights?.horizontalTolerance, t.mergeHighlights?.verticalTolerance), s = Te(n, t.userSelectAction, t.adapter), o = xe(n), i = Le(), c = (p, S = K.LOCAL) => {
|
|
677
677
|
const E = te(p, e), m = I(E.target.selector);
|
|
678
678
|
return m && n.addAnnotation(E, S), m;
|
|
679
679
|
}, l = (p, S = !0, E = K.LOCAL) => {
|
|
@@ -719,9 +719,9 @@ const ue = "not-annotatable", W = `.${ue}`, G = (e, t) => e.contains(t) ? !!(t i
|
|
|
719
719
|
hover: o,
|
|
720
720
|
viewport: i
|
|
721
721
|
};
|
|
722
|
-
}, ae = 300,
|
|
723
|
-
...
|
|
724
|
-
|
|
722
|
+
}, ae = 300, ye = ["up", "down", "left", "right"], be = ge ? "⌘+a" : "ctrl+a", St = [
|
|
723
|
+
...ye.map((e) => `shift+${e}`),
|
|
724
|
+
be
|
|
725
725
|
], At = (e, t, n, r) => {
|
|
726
726
|
const { store: s, selection: o } = t;
|
|
727
727
|
let i;
|
|
@@ -738,8 +738,8 @@ const ue = "not-annotatable", W = `.${ue}`, G = (e, t) => e.contains(t) ? !!(t i
|
|
|
738
738
|
if (w === "ADD_TO_CURRENT")
|
|
739
739
|
return !0;
|
|
740
740
|
if (r.allowModifierSelect) {
|
|
741
|
-
const
|
|
742
|
-
return
|
|
741
|
+
const v = h;
|
|
742
|
+
return ge ? v.metaKey : v.ctrlKey;
|
|
743
743
|
} else
|
|
744
744
|
return !1;
|
|
745
745
|
}, C = () => {
|
|
@@ -767,17 +767,17 @@ const ue = "not-annotatable", W = `.${ue}`, G = (e, t) => e.contains(t) ? !!(t i
|
|
|
767
767
|
};
|
|
768
768
|
}, L = le((h) => {
|
|
769
769
|
if (!y) return;
|
|
770
|
-
const
|
|
771
|
-
if (!
|
|
772
|
-
const k = Array.from(Array(
|
|
773
|
-
if (
|
|
770
|
+
const v = document.getSelection();
|
|
771
|
+
if (!v?.anchorNode) return;
|
|
772
|
+
const k = Array.from(Array(v.rangeCount).keys()).map((B) => v.getRangeAt(B));
|
|
773
|
+
if (k.every((B) => !fe(e, B))) {
|
|
774
774
|
f = void 0;
|
|
775
775
|
return;
|
|
776
776
|
}
|
|
777
777
|
const U = h.timeStamp - (b?.timeStamp || h.timeStamp);
|
|
778
|
-
if (b?.type === "pointerdown" && (U < 1e3 && !f ||
|
|
778
|
+
if (b?.type === "pointerdown" && (U < 1e3 && !f || v.isCollapsed && U < ae) && C(), !f && (C(), !f))
|
|
779
779
|
return;
|
|
780
|
-
if (
|
|
780
|
+
if (v.isCollapsed) {
|
|
781
781
|
s.getAnnotation(f.annotation) && !(a(b) || w === "REPLACE_CURRENT") && (o.clear(), s.deleteAnnotation(f.annotation));
|
|
782
782
|
return;
|
|
783
783
|
}
|
|
@@ -796,63 +796,63 @@ const ue = "not-annotatable", W = `.${ue}`, G = (e, t) => e.contains(t) ? !!(t i
|
|
|
796
796
|
}, !(a(b) || w === "REPLACE_CURRENT") && (s.getAnnotation(f.annotation) ? s.updateTarget(f, K.LOCAL) : o.clear());
|
|
797
797
|
}, 10), A = (h) => {
|
|
798
798
|
b = J(h), R = b.button === 0;
|
|
799
|
-
},
|
|
799
|
+
}, T = async (h) => {
|
|
800
800
|
if (!R) return;
|
|
801
|
-
const
|
|
801
|
+
const v = J(h), k = () => {
|
|
802
802
|
const { x: H, y: M } = e.getBoundingClientRect();
|
|
803
|
-
if (G(e,
|
|
804
|
-
(typeof d == "function" ? d(
|
|
803
|
+
if (G(e, v.target)) {
|
|
804
|
+
(typeof d == "function" ? d(v, e) : d === "ALWAYS") && o.clear();
|
|
805
805
|
return;
|
|
806
806
|
}
|
|
807
|
-
const P =
|
|
808
|
-
|
|
809
|
-
|
|
807
|
+
const P = v.target instanceof Node && e.contains(v.target) && s.getAt(
|
|
808
|
+
v.clientX - H,
|
|
809
|
+
v.clientY - M,
|
|
810
810
|
g === "all",
|
|
811
811
|
u
|
|
812
812
|
);
|
|
813
813
|
if (P) {
|
|
814
814
|
const { selected: z } = o, B = new Set(z.map((V) => V.id)), F = Array.isArray(P) ? P.map((V) => V.id) : [P.id];
|
|
815
|
-
(B.size !== F.length || !F.every((V) => B.has(V))) && (n.emit("clickAnnotation", P), o.userSelect(F,
|
|
815
|
+
(B.size !== F.length || !F.every((V) => B.has(V))) && (n.emit("clickAnnotation", P), o.userSelect(F, v));
|
|
816
816
|
} else
|
|
817
817
|
o.clear();
|
|
818
818
|
};
|
|
819
|
-
if (
|
|
819
|
+
if (v.timeStamp - b.timeStamp < ae) {
|
|
820
820
|
await N();
|
|
821
|
-
const H = document.getSelection(), M = G(e, b.target), P = G(e,
|
|
821
|
+
const H = document.getSelection(), M = G(e, b.target), P = G(e, v.target);
|
|
822
822
|
if (H?.isCollapsed || M && P) {
|
|
823
823
|
f = void 0, k();
|
|
824
824
|
return;
|
|
825
825
|
}
|
|
826
826
|
}
|
|
827
|
-
f && f.selector.length > 0 && ($(), o.userSelect(f.annotation,
|
|
827
|
+
f && f.selector.length > 0 && ($(), o.userSelect(f.annotation, v));
|
|
828
828
|
}, N = async () => {
|
|
829
829
|
const h = document.getSelection();
|
|
830
|
-
let
|
|
831
|
-
const U = () => k ||
|
|
832
|
-
return setTimeout(() =>
|
|
830
|
+
let v = !1, k = h?.isCollapsed;
|
|
831
|
+
const U = () => k || v, H = 1;
|
|
832
|
+
return setTimeout(() => v = !0, 50), He(() => k = h?.isCollapsed, H, U);
|
|
833
833
|
}, O = (h) => {
|
|
834
834
|
document.getSelection()?.isCollapsed || ((!f || f.selector.length === 0) && L(h), f && ($(), o.userSelect(f.annotation, J(h))));
|
|
835
835
|
}, D = (h) => {
|
|
836
836
|
y && h.key === "Shift" && f && (document.getSelection().isCollapsed || ($(), o.userSelect(f.annotation, j(h))));
|
|
837
837
|
}, Y = (h) => {
|
|
838
|
-
const
|
|
838
|
+
const v = () => setTimeout(() => {
|
|
839
839
|
f?.selector.length > 0 && (o.clear(), s.addAnnotation({
|
|
840
840
|
id: f.annotation,
|
|
841
841
|
bodies: [],
|
|
842
842
|
target: f
|
|
843
|
-
}), o.userSelect(f.annotation, j(h))), document.removeEventListener("selectionchange",
|
|
843
|
+
}), o.userSelect(f.annotation, j(h))), document.removeEventListener("selectionchange", v);
|
|
844
844
|
}, 100);
|
|
845
|
-
document.addEventListener("selectionchange",
|
|
845
|
+
document.addEventListener("selectionchange", v), C();
|
|
846
846
|
};
|
|
847
847
|
q(St.join(","), { element: e, keydown: !0, keyup: !1 }, (h) => {
|
|
848
848
|
h.repeat || (b = j(h));
|
|
849
|
-
}), q(
|
|
849
|
+
}), q(be, { keydown: !0, keyup: !1 }, (h) => {
|
|
850
850
|
b = j(h), Y(h);
|
|
851
851
|
});
|
|
852
852
|
const X = (h) => {
|
|
853
853
|
h.repeat || h.target !== e && h.target !== document.body || (f = void 0, o.clear());
|
|
854
854
|
};
|
|
855
|
-
q(
|
|
855
|
+
q(ye.join(","), { keydown: !0, keyup: !1 }, X);
|
|
856
856
|
const $ = () => {
|
|
857
857
|
const h = s.getAnnotation(f.annotation);
|
|
858
858
|
if (!h)
|
|
@@ -862,13 +862,13 @@ const ue = "not-annotatable", W = `.${ue}`, G = (e, t) => e.contains(t) ? !!(t i
|
|
|
862
862
|
target: f
|
|
863
863
|
});
|
|
864
864
|
else {
|
|
865
|
-
const { target: { updated:
|
|
866
|
-
(!
|
|
865
|
+
const { target: { updated: v } } = h, { updated: k } = f;
|
|
866
|
+
(!v || !k || v < k) && s.updateTarget(f);
|
|
867
867
|
}
|
|
868
868
|
};
|
|
869
|
-
return document.addEventListener("pointerdown", A), document.addEventListener("pointerup",
|
|
869
|
+
return document.addEventListener("pointerdown", A), document.addEventListener("pointerup", T), document.addEventListener("contextmenu", O), e.addEventListener("keyup", D), e.addEventListener("selectstart", C), document.addEventListener("selectionchange", L), {
|
|
870
870
|
destroy: () => {
|
|
871
|
-
f = void 0, x = void 0, R = void 0, b = void 0, L.clear(), document.removeEventListener("pointerdown", A), document.removeEventListener("pointerup",
|
|
871
|
+
f = void 0, x = void 0, R = void 0, b = void 0, L.clear(), document.removeEventListener("pointerdown", A), document.removeEventListener("pointerup", T), document.removeEventListener("contextmenu", O), e.removeEventListener("keyup", D), e.removeEventListener("selectstart", C), document.removeEventListener("selectionchange", L), q.unbind();
|
|
872
872
|
},
|
|
873
873
|
setFilter: E,
|
|
874
874
|
setUser: m,
|
|
@@ -883,8 +883,8 @@ const ue = "not-annotatable", W = `.${ue}`, G = (e, t) => e.contains(t) ? !!(t i
|
|
|
883
883
|
Pe(e), Ue(e);
|
|
884
884
|
const n = wt(t, {
|
|
885
885
|
annotatingEnabled: !0,
|
|
886
|
-
user:
|
|
887
|
-
}), r = Ct(e, n), { selection: s, viewport: o } = r, i = r.store, c =
|
|
886
|
+
user: Ne()
|
|
887
|
+
}), r = Ct(e, n), { selection: s, viewport: o } = r, i = r.store, c = Oe(i), l = Be(r, c, n.adapter);
|
|
888
888
|
let g = n.user;
|
|
889
889
|
const d = typeof n.renderer != "function" ? n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : ce : n.renderer || ce : null, u = d === null ? n.renderer(e, r, o) : d === "SPANS" ? ft(e, r, o) : d === "CSS_HIGHLIGHTS" ? at(e, r, o) : d === "CANVAS" ? st(e, r, o) : void 0;
|
|
890
890
|
if (!u)
|
|
@@ -892,7 +892,7 @@ const ue = "not-annotatable", W = `.${ue}`, G = (e, t) => e.contains(t) ? !!(t i
|
|
|
892
892
|
console.debug(d ? `Using ${d} renderer` : "Using custom renderer implementation"), n.style && u.setStyle(n.style);
|
|
893
893
|
const y = At(e, r, l, n);
|
|
894
894
|
y.setUser(g);
|
|
895
|
-
const w =
|
|
895
|
+
const w = ke(r, c, n.adapter), f = () => g, x = (a) => {
|
|
896
896
|
y.setAnnotatingEnabled(
|
|
897
897
|
a === void 0 ? !0 : a
|
|
898
898
|
);
|
|
@@ -957,10 +957,10 @@ export {
|
|
|
957
957
|
Fe as getQuoteContext,
|
|
958
958
|
oe as getRangeAnnotatableContents,
|
|
959
959
|
Je as getViewportBounds,
|
|
960
|
-
|
|
960
|
+
ge as isMac,
|
|
961
961
|
Ht as isNodeWhitespaceOrEmpty,
|
|
962
962
|
G as isNotAnnotatable,
|
|
963
|
-
|
|
963
|
+
fe as isRangeAnnotatable,
|
|
964
964
|
Ve as isRangeWhitespaceOrEmpty,
|
|
965
965
|
I as isRevived,
|
|
966
966
|
ze as mergeClientRects,
|
|
@@ -970,7 +970,7 @@ export {
|
|
|
970
970
|
Ue as programmaticallyFocusable,
|
|
971
971
|
je as rangeToSelector,
|
|
972
972
|
te as reviveAnnotation,
|
|
973
|
-
|
|
973
|
+
pe as reviveSelector,
|
|
974
974
|
Q as reviveTarget,
|
|
975
975
|
Ze as scrollIntoView,
|
|
976
976
|
ht as serializeW3CTextAnnotation,
|
|
@@ -980,6 +980,6 @@ export {
|
|
|
980
980
|
Dt as toViewportBounds,
|
|
981
981
|
et as trackViewport,
|
|
982
982
|
Qe as trimRangeToContainer,
|
|
983
|
-
|
|
983
|
+
me as whitespaceOrEmptyRegex
|
|
984
984
|
};
|
|
985
985
|
//# sourceMappingURL=text-annotator.es.js.map
|