@recogito/text-annotator 3.4.10 → 4.0.1-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +8 -7
- package/dist/model/core/index.d.ts +1 -1
- package/dist/model/w3c/index.d.ts +2 -2
- package/dist/model/w3c/{W3CTextFormatAdapter.d.ts → w3c-text-format-adapter.d.ts} +2 -2
- package/dist/rendering/base-renderer.d.ts +31 -0
- package/dist/{highlight/HighlightStyle.d.ts → rendering/highlight-style.d.ts} +4 -1
- package/dist/{highlight/Highlight.d.ts → rendering/highlight.d.ts} +2 -1
- package/dist/rendering/index.d.ts +5 -0
- package/dist/rendering/renderer-css-highlight/css-highlight-renderer.d.ts +6 -0
- package/dist/rendering/renderer-css-highlight/index.d.ts +1 -0
- package/dist/rendering/renderer-inline-markup/index.d.ts +0 -0
- package/dist/rendering/renderer-spans/index.d.ts +1 -0
- package/dist/rendering/renderer-spans/spans-renderer.d.ts +3 -0
- package/dist/{SelectionHandler.d.ts → selection-handler.d.ts} +2 -2
- package/dist/state/index.d.ts +2 -2
- package/dist/state/{spatialTree.d.ts → spatial-tree.d.ts} +1 -1
- package/dist/state/{TextAnnotationStore.d.ts → text-annotation-store.d.ts} +1 -1
- package/dist/state/{TextAnnotatorState.d.ts → text-annotator-state.d.ts} +2 -2
- package/dist/{TextAnnotatorOptions.d.ts → text-annotator-options.d.ts} +2 -4
- package/dist/text-annotator.css +1 -1
- package/dist/{TextAnnotator.d.ts → text-annotator.d.ts} +6 -6
- package/dist/text-annotator.es.js +757 -841
- package/dist/text-annotator.es.js.map +1 -1
- package/dist/text-annotator.umd.js +2 -2
- package/dist/text-annotator.umd.js.map +1 -1
- package/dist/utils/annotation/index.d.ts +4 -0
- package/dist/utils/{rangeToSelector.d.ts → annotation/range-to-selector.d.ts} +1 -1
- package/dist/utils/{reviveSelector.d.ts → annotation/revive-annotation.d.ts} +4 -1
- package/dist/{api/scrollIntoView.d.ts → utils/annotation/scroll-into-view.d.ts} +2 -2
- package/dist/utils/dom/index.d.ts +7 -0
- package/dist/utils/events/index.d.ts +3 -0
- package/dist/utils/highlight/compute-z-index.d.ts +3 -0
- package/dist/utils/highlight/index.d.ts +4 -0
- package/package.json +1 -1
- package/dist/api/index.d.ts +0 -1
- package/dist/highlight/HighlightPainter.d.ts +0 -11
- package/dist/highlight/Renderer.d.ts +0 -22
- package/dist/highlight/canvas/canvasRenderer.d.ts +0 -5
- package/dist/highlight/canvas/index.d.ts +0 -1
- package/dist/highlight/highlights/highlightsRenderer.d.ts +0 -6
- package/dist/highlight/highlights/index.d.ts +0 -1
- package/dist/highlight/index.d.ts +0 -8
- package/dist/highlight/span/color.d.ts +0 -2
- package/dist/highlight/span/index.d.ts +0 -2
- package/dist/highlight/span/spansRenderer.d.ts +0 -3
- package/dist/presence/PresencePainter.d.ts +0 -5
- package/dist/presence/PresencePainterOptions.d.ts +0 -3
- package/dist/presence/index.d.ts +0 -2
- package/dist/utils/index.d.ts +0 -19
- package/dist/utils/isRevived.d.ts +0 -2
- package/dist/utils/reviveAnnotation.d.ts +0 -2
- package/dist/utils/reviveTarget.d.ts +0 -2
- /package/dist/model/core/{TextAnnotation.d.ts → text-annotation.d.ts} +0 -0
- /package/dist/model/w3c/{W3CTextAnnotation.d.ts → w3c-text-annotation.d.ts} +0 -0
- /package/dist/{highlight → rendering}/viewport.d.ts +0 -0
- /package/dist/utils/{getQuoteContext.d.ts → annotation/get-quote-context.d.ts} +0 -0
- /package/dist/utils/{device.d.ts → dom/device.d.ts} +0 -0
- /package/dist/utils/{isNotAnnotatable.d.ts → dom/is-not-annotatable.d.ts} +0 -0
- /package/dist/utils/{isWhitespaceOrEmpty.d.ts → dom/is-whitespace-or-empty.d.ts} +0 -0
- /package/dist/utils/{mergeRanges.d.ts → dom/merge-ranges.d.ts} +0 -0
- /package/dist/utils/{programmaticallyFocusable.d.ts → dom/programmatically-focusable.d.ts} +0 -0
- /package/dist/utils/{splitAnnotatableRanges.d.ts → dom/split-annotatable-ranges.d.ts} +0 -0
- /package/dist/utils/{trimRangeToContainer.d.ts → dom/trim-range-to-container.d.ts} +0 -0
- /package/dist/utils/{cancelSingleClickEvents.d.ts → events/cancel-single-click-events.d.ts} +0 -0
- /package/dist/utils/{cloneEvents.d.ts → events/clone-events.d.ts} +0 -0
- /package/dist/utils/{debounce.d.ts → events/debounce.d.ts} +0 -0
- /package/dist/utils/{getHighlightClientRects.d.ts → highlight/get-highlight-client-rects.d.ts} +0 -0
- /package/dist/utils/{mergeClientRects.d.ts → highlight/merge-client-rects.d.ts} +0 -0
- /package/dist/utils/{rectsToBounds.d.ts → highlight/rects-to-bounds.d.ts} +0 -0
|
@@ -1,983 +1,899 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { Origin as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
1
|
+
import { v4 as lt } from "uuid";
|
|
2
|
+
import { parseW3CBodies as Ct, serializeW3CBodies as At, parseW3CUser as Tt, UserSelectAction as Rt, createStore as vt, createSelectionState as wt, createHoverState as xt, createViewportState as Lt, Origin as F, createAnonymousGuest as Nt, createUndoStack as Ot, createLifecycleObserver as kt, createBaseAnnotator as Mt } from "@annotorious/core";
|
|
3
|
+
import { Origin as Be, UserSelectAction as Ie, createBody as _e } from "@annotorious/core";
|
|
4
|
+
import { createNanoEvents as dt } from "nanoevents";
|
|
5
|
+
import { colord as et } from "colord";
|
|
6
|
+
import { dequal as Bt } from "dequal/lite";
|
|
7
|
+
import It from "rbush";
|
|
8
|
+
import _t from "debounce";
|
|
9
9
|
import q from "hotkeys-js";
|
|
10
|
-
import { poll as
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
return
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
x: e.x,
|
|
21
|
-
y: e.y,
|
|
22
|
-
clientX: e.clientX,
|
|
23
|
-
clientY: e.clientY,
|
|
24
|
-
offsetX: e.offsetX,
|
|
25
|
-
offsetY: e.offsetY,
|
|
26
|
-
screenX: e.screenX,
|
|
27
|
-
screenY: e.screenY,
|
|
28
|
-
isPrimary: e.isPrimary,
|
|
29
|
-
altKey: e.altKey,
|
|
30
|
-
ctrlKey: e.ctrlKey,
|
|
31
|
-
metaKey: e.metaKey,
|
|
32
|
-
shiftKey: e.shiftKey,
|
|
33
|
-
button: e.button,
|
|
34
|
-
buttons: e.buttons,
|
|
35
|
-
currentTarget: e.currentTarget,
|
|
36
|
-
target: e.target,
|
|
37
|
-
defaultPrevented: e.defaultPrevented,
|
|
38
|
-
detail: e.detail,
|
|
39
|
-
eventPhase: e.eventPhase,
|
|
40
|
-
pointerId: e.pointerId,
|
|
41
|
-
pointerType: e.pointerType,
|
|
42
|
-
timeStamp: e.timeStamp
|
|
43
|
-
}), G = (e) => ({
|
|
44
|
-
...e,
|
|
45
|
-
type: e.type,
|
|
46
|
-
key: e.key,
|
|
47
|
-
code: e.code,
|
|
48
|
-
location: e.location,
|
|
49
|
-
repeat: e.repeat,
|
|
50
|
-
altKey: e.altKey,
|
|
51
|
-
ctrlKey: e.ctrlKey,
|
|
52
|
-
metaKey: e.metaKey,
|
|
53
|
-
shiftKey: e.shiftKey,
|
|
54
|
-
currentTarget: e.currentTarget,
|
|
55
|
-
target: e.target,
|
|
56
|
-
defaultPrevented: e.defaultPrevented,
|
|
57
|
-
detail: e.detail,
|
|
58
|
-
timeStamp: e.timeStamp
|
|
59
|
-
}), ee = (e, t = 10) => {
|
|
60
|
-
let n;
|
|
61
|
-
return ((...r) => {
|
|
62
|
-
clearTimeout(n), n = setTimeout(() => e.apply(void 0, r), t);
|
|
10
|
+
import { poll as Dt } from "poll";
|
|
11
|
+
const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft = "not-annotatable", Y = `.${ft}`, $ = (t, e) => t.contains(e) ? !!(e instanceof HTMLElement ? e.closest(Y) : e.parentElement?.closest(Y)) : !0, gt = (t, e) => {
|
|
12
|
+
const o = e.commonAncestorContainer;
|
|
13
|
+
return !$(t, o);
|
|
14
|
+
}, mt = /^\s*$/, Ht = (t) => mt.test(t.toString()), we = (t) => mt.test(t.textContent || ""), Pt = (t) => {
|
|
15
|
+
if (t.length === 0) return [];
|
|
16
|
+
if (t.length === 1) return [t[0]];
|
|
17
|
+
t.sort((s, n) => {
|
|
18
|
+
const r = s.compareBoundaryPoints(Range.START_TO_START, n);
|
|
19
|
+
return r !== 0 ? r : s.compareBoundaryPoints(Range.END_TO_END, n);
|
|
63
20
|
});
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
let r;
|
|
72
|
-
for (; r = n.nextNode(); )
|
|
73
|
-
e.intersectsNode(r) && t.push(r);
|
|
74
|
-
if (t.length < 2)
|
|
75
|
-
return Array.from(e.getClientRects());
|
|
76
|
-
{
|
|
77
|
-
const s = t[0], o = t[t.length - 1], i = document.createRange();
|
|
78
|
-
if (i.selectNode(s), e.startContainer.nodeType === Node.TEXT_NODE)
|
|
79
|
-
i.setStart(s, e.startOffset);
|
|
80
|
-
else {
|
|
81
|
-
const f = e.startContainer.childNodes[e.startOffset];
|
|
82
|
-
f ? i.setStartBefore(f) : i.setStartAfter(e.startContainer);
|
|
83
|
-
}
|
|
84
|
-
const c = document.createRange();
|
|
85
|
-
if (c.selectNode(o), e.endContainer.nodeType === Node.TEXT_NODE)
|
|
86
|
-
c.setEnd(o, e.endOffset);
|
|
87
|
-
else {
|
|
88
|
-
const f = e.endContainer.childNodes[e.endOffset];
|
|
89
|
-
f ? c.setEndBefore(f) : c.setEndAfter(e.endContainer);
|
|
90
|
-
}
|
|
91
|
-
const l = (f) => {
|
|
92
|
-
const u = document.createRange();
|
|
93
|
-
return u.selectNode(f), Array.from(u.getClientRects());
|
|
94
|
-
};
|
|
95
|
-
return [
|
|
96
|
-
...Array.from(i.getClientRects()),
|
|
97
|
-
...t.slice(1, -1).flatMap(l),
|
|
98
|
-
...Array.from(c.getClientRects())
|
|
99
|
-
];
|
|
100
|
-
}
|
|
101
|
-
}, Ue = function* (e) {
|
|
102
|
-
const t = document.createNodeIterator(
|
|
103
|
-
e.commonAncestorContainer,
|
|
21
|
+
const [e, ...o] = t, i = o.reduce((s, n) => s.current.compareBoundaryPoints(Range.START_TO_END, n) >= 0 ? (s.current.compareBoundaryPoints(Range.END_TO_END, n) < 0 && s.current.setEnd(n.endContainer, n.endOffset), s) : (s.merged.push(s.current), s.current = n.cloneRange(), s), { merged: [], current: e.cloneRange() });
|
|
22
|
+
return [...i.merged, i.current];
|
|
23
|
+
}, Ut = (t) => {
|
|
24
|
+
(!t.hasAttribute("tabindex") || t.tabIndex < -1) && t.setAttribute("tabindex", "-1"), t.classList.add("no-focus-outline");
|
|
25
|
+
}, Kt = function* (t) {
|
|
26
|
+
const e = document.createNodeIterator(
|
|
27
|
+
t.commonAncestorContainer,
|
|
104
28
|
NodeFilter.SHOW_ELEMENT,
|
|
105
|
-
(
|
|
29
|
+
(i) => i instanceof HTMLElement && i.classList.contains(ft) && !i.parentElement.closest(Y) && t.intersectsNode(i) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
|
|
106
30
|
);
|
|
107
|
-
let
|
|
108
|
-
for (;
|
|
109
|
-
|
|
110
|
-
},
|
|
111
|
-
if (!
|
|
112
|
-
const
|
|
113
|
-
let
|
|
114
|
-
for (const s of
|
|
115
|
-
let
|
|
116
|
-
|
|
31
|
+
let o;
|
|
32
|
+
for (; o = e.nextNode(); )
|
|
33
|
+
o instanceof HTMLElement && (yield o);
|
|
34
|
+
}, Ft = (t, e) => {
|
|
35
|
+
if (!gt(t, e)) return [];
|
|
36
|
+
const o = [];
|
|
37
|
+
let i = null;
|
|
38
|
+
for (const s of Kt(e)) {
|
|
39
|
+
let n;
|
|
40
|
+
i ? (n = document.createRange(), n.setStartAfter(i), n.setEndBefore(s)) : (n = e.cloneRange(), n.setEndBefore(s)), n.collapsed || o.push(n), i = s;
|
|
117
41
|
}
|
|
118
|
-
if (
|
|
119
|
-
const s =
|
|
120
|
-
s.setStartAfter(
|
|
42
|
+
if (i) {
|
|
43
|
+
const s = e.cloneRange();
|
|
44
|
+
s.setStartAfter(i), s.collapsed || o.push(s);
|
|
121
45
|
}
|
|
122
|
-
return
|
|
123
|
-
},
|
|
124
|
-
const
|
|
125
|
-
return
|
|
126
|
-
},
|
|
127
|
-
const
|
|
128
|
-
o.setStart(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
46
|
+
return o.length > 0 ? o : [e];
|
|
47
|
+
}, nt = (t) => {
|
|
48
|
+
const e = t.cloneContents();
|
|
49
|
+
return e.querySelectorAll(Y).forEach((o) => o.remove()), e;
|
|
50
|
+
}, $t = (t, e) => {
|
|
51
|
+
const o = t.cloneRange();
|
|
52
|
+
return e.contains(o.startContainer) || o.setStart(e, 0), e.contains(o.endContainer) || o.setEnd(e, e.childNodes.length), o;
|
|
53
|
+
}, rt = new Intl.Segmenter(void 0, { granularity: "grapheme" }), Yt = (t, e, o = 10, i) => {
|
|
54
|
+
const s = i ? t.startContainer.parentElement.closest(i) : e, n = document.createRange();
|
|
55
|
+
n.setStart(s, 0), n.setEnd(t.startContainer, t.startOffset);
|
|
56
|
+
const r = nt(n).textContent, a = document.createRange();
|
|
57
|
+
a.setStart(t.endContainer, t.endOffset), s === document.body ? a.setEnd(s, s.childNodes.length) : a.setEndAfter(s);
|
|
58
|
+
const d = nt(a).textContent, g = [...rt.segment(r)], m = [...rt.segment(d)];
|
|
132
59
|
return {
|
|
133
|
-
prefix:
|
|
134
|
-
suffix:
|
|
135
|
-
};
|
|
136
|
-
}, I = (e) => e.every((t) => t.range instanceof Range && !t.range.collapsed), pe = /^\s*$/, $e = (e) => pe.test(e.toString()), kt = (e) => pe.test(e.textContent || ""), Fe = (e, t, n, r) => {
|
|
137
|
-
const s = (c) => Math.round(c * 10) / 10, o = {
|
|
138
|
-
top: s(e.top),
|
|
139
|
-
bottom: s(e.bottom),
|
|
140
|
-
left: s(e.left),
|
|
141
|
-
right: s(e.right)
|
|
142
|
-
}, i = {
|
|
143
|
-
top: s(t.top),
|
|
144
|
-
bottom: s(t.bottom),
|
|
145
|
-
left: s(t.left),
|
|
146
|
-
right: s(t.right)
|
|
60
|
+
prefix: g.slice(-o).map((b) => b.segment).join(""),
|
|
61
|
+
suffix: m.slice(0, o).map((b) => b.segment).join("")
|
|
147
62
|
};
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
if (o.left <= i.left && o.right >= i.right)
|
|
157
|
-
return "block-contains";
|
|
158
|
-
} else if (o.top >= i.top && o.bottom <= i.bottom && o.left >= i.left && o.right <= i.right)
|
|
159
|
-
return "block-is-contained";
|
|
160
|
-
}, Ve = (e, t) => {
|
|
161
|
-
const n = Math.min(e.left, t.left), r = Math.max(e.right, t.right), s = Math.min(e.top, t.top), o = Math.max(e.bottom, t.bottom);
|
|
162
|
-
return new DOMRect(n, s, r - n, o - s);
|
|
163
|
-
}, Ye = (e, t = 0.5, n = 0.5) => e.reduce((r, s) => {
|
|
164
|
-
if (s.width === 0 || s.height === 0)
|
|
165
|
-
return r;
|
|
166
|
-
let o = [...r], i = !1;
|
|
167
|
-
for (const c of r) {
|
|
168
|
-
const l = Fe(s, c, t, n);
|
|
169
|
-
if (l === "inline-adjacent") {
|
|
170
|
-
o = o.map((f) => f === c ? Ve(s, c) : f), i = !0;
|
|
171
|
-
break;
|
|
172
|
-
} else if (l === "inline-contains") {
|
|
173
|
-
o = o.map((f) => f === c ? s : f), i = !0;
|
|
174
|
-
break;
|
|
175
|
-
} else if (l === "inline-is-contained") {
|
|
176
|
-
i = !0;
|
|
177
|
-
break;
|
|
178
|
-
} else if (l === "block-contains" || l === "block-is-contained") {
|
|
179
|
-
s.width < c.width && (o = o.map((f) => f === c ? s : f)), s.width === c.width && s.height < c.width && (o = o.map((f) => f === c ? s : f)), i = !0;
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return i ? o : [...o, s];
|
|
184
|
-
}, []), Mt = (e) => ({
|
|
185
|
-
length: e.length,
|
|
186
|
-
item: (t) => e[t],
|
|
187
|
-
[Symbol.iterator]: function* () {
|
|
188
|
-
for (let t = 0; t < this.length; t++)
|
|
189
|
-
yield this.item(t);
|
|
190
|
-
}
|
|
191
|
-
}), Xe = (e) => {
|
|
192
|
-
if (e.length === 0) return [];
|
|
193
|
-
if (e.length === 1) return [e[0]];
|
|
194
|
-
e.sort((s, o) => {
|
|
195
|
-
const i = s.compareBoundaryPoints(Range.START_TO_START, o);
|
|
196
|
-
return i !== 0 ? i : s.compareBoundaryPoints(Range.END_TO_END, o);
|
|
197
|
-
});
|
|
198
|
-
const [t, ...n] = e, r = n.reduce((s, o) => s.current.compareBoundaryPoints(Range.START_TO_END, o) >= 0 ? (s.current.compareBoundaryPoints(Range.END_TO_END, o) < 0 && s.current.setEnd(o.endContainer, o.endOffset), s) : (s.merged.push(s.current), s.current = o.cloneRange(), s), { merged: [], current: t.cloneRange() });
|
|
199
|
-
return [...r.merged, r.current];
|
|
200
|
-
}, ze = (e, t, n) => {
|
|
201
|
-
const r = document.createRange(), s = n ? e.startContainer.parentElement.closest(n) : t;
|
|
202
|
-
r.setStart(s, 0), r.setEnd(e.startContainer, e.startOffset);
|
|
203
|
-
const o = oe(r).textContent, i = e.toString(), c = o.length || 0, l = c + i.length;
|
|
204
|
-
return n ? { quote: i, start: c, end: l, range: e, offsetReference: s } : { quote: i, start: c, end: l, range: e };
|
|
205
|
-
}, je = (e, t) => {
|
|
206
|
-
const { left: n, top: r, right: s, bottom: o } = e;
|
|
207
|
-
return new DOMRect(n - t.left, r - t.top, s - n, o - r);
|
|
208
|
-
}, It = (e, t) => {
|
|
209
|
-
const { left: n, top: r, right: s, bottom: o } = e;
|
|
210
|
-
return new DOMRect(n + t.left, r + t.top, s - n, o - r);
|
|
211
|
-
}, he = (e, t) => {
|
|
212
|
-
const { start: n, end: r } = e, s = e.offsetReference || t, o = document.createNodeIterator(
|
|
213
|
-
t,
|
|
63
|
+
}, Wt = (t, e, o) => {
|
|
64
|
+
const i = document.createRange(), s = o ? t.startContainer.parentElement.closest(o) : e;
|
|
65
|
+
i.setStart(s, 0), i.setEnd(t.startContainer, t.startOffset);
|
|
66
|
+
const n = nt(i).textContent, r = t.toString(), a = n.length || 0, d = a + r.length;
|
|
67
|
+
return o ? { quote: r, start: a, end: d, range: t, offsetReference: s } : { quote: r, start: a, end: d, range: t };
|
|
68
|
+
}, D = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), pt = (t, e) => {
|
|
69
|
+
const { start: o, end: i } = t, s = t.offsetReference || e, n = document.createNodeIterator(
|
|
70
|
+
e,
|
|
214
71
|
NodeFilter.SHOW_TEXT,
|
|
215
|
-
(
|
|
72
|
+
(m) => m.parentElement?.closest(Y) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT
|
|
216
73
|
);
|
|
217
|
-
let
|
|
218
|
-
const
|
|
219
|
-
let
|
|
220
|
-
|
|
221
|
-
let
|
|
222
|
-
for (;
|
|
223
|
-
if (
|
|
224
|
-
const
|
|
225
|
-
if (
|
|
226
|
-
|
|
74
|
+
let r = 0;
|
|
75
|
+
const a = document.createRange();
|
|
76
|
+
let d = n.nextNode();
|
|
77
|
+
d === null && console.error("Could not revive annotation target. Content missing.");
|
|
78
|
+
let g = !s;
|
|
79
|
+
for (; d !== null; ) {
|
|
80
|
+
if (g ||= typeof s?.contains == "function" ? s.contains(d) : !1, g) {
|
|
81
|
+
const m = d.textContent?.length || 0;
|
|
82
|
+
if (r + m > o) {
|
|
83
|
+
a.setStart(d, o - r);
|
|
227
84
|
break;
|
|
228
85
|
}
|
|
229
|
-
|
|
86
|
+
r += m;
|
|
230
87
|
}
|
|
231
|
-
|
|
88
|
+
d = n.nextNode();
|
|
232
89
|
}
|
|
233
|
-
for (;
|
|
234
|
-
const
|
|
235
|
-
if (
|
|
236
|
-
|
|
90
|
+
for (; d !== null; ) {
|
|
91
|
+
const m = d.textContent?.length || 0;
|
|
92
|
+
if (r + m >= i) {
|
|
93
|
+
a.setEnd(d, i - r);
|
|
237
94
|
break;
|
|
238
95
|
}
|
|
239
|
-
|
|
96
|
+
r += m, d = n.nextNode();
|
|
240
97
|
}
|
|
241
98
|
return {
|
|
242
|
-
...
|
|
243
|
-
range:
|
|
99
|
+
...t,
|
|
100
|
+
range: a
|
|
244
101
|
};
|
|
245
|
-
}, Q = (
|
|
246
|
-
...
|
|
247
|
-
selector:
|
|
248
|
-
},
|
|
249
|
-
|
|
250
|
-
return t.contains(n.startContainer) || n.setStart(t, 0), t.contains(n.endContainer) || n.setEnd(t, t.childNodes.length), n;
|
|
251
|
-
}, ye = (e) => {
|
|
252
|
-
if (!e)
|
|
102
|
+
}, Q = (t, e) => D(t.selector) ? t : {
|
|
103
|
+
...t,
|
|
104
|
+
selector: t.selector.map((o) => o.range instanceof Range && !o.range.collapsed ? o : pt(o, e))
|
|
105
|
+
}, Z = (t, e) => D(t.target.selector) ? t : { ...t, target: Q(t.target, e) }, ht = (t) => {
|
|
106
|
+
if (!t)
|
|
253
107
|
return document.scrollingElement;
|
|
254
|
-
const { overflowY:
|
|
255
|
-
return
|
|
256
|
-
},
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
},
|
|
260
|
-
const s = typeof
|
|
261
|
-
if (!
|
|
262
|
-
return console.warn(`The scroll parent is missing for the annotation: ${s}`, { container:
|
|
263
|
-
const
|
|
264
|
-
if (!
|
|
108
|
+
const { overflowY: e } = window.getComputedStyle(t);
|
|
109
|
+
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : ht(t.parentElement);
|
|
110
|
+
}, it = (t, e, o) => {
|
|
111
|
+
const i = o.getBoundingClientRect(), s = o.clientHeight, n = o.clientWidth, r = e.selector[0].range.getBoundingClientRect(), { width: a, height: d } = t.getAnnotationBounds(e.annotation), g = r.top - i.top, m = r.left - i.left, b = o.parentElement ? o.scrollTop : 0, h = o.parentElement ? o.scrollLeft : 0, T = g + b - (s - d) / 2, u = m + h - (n - a) / 2;
|
|
112
|
+
o.scroll({ top: T, left: u, behavior: "smooth" });
|
|
113
|
+
}, Xt = (t, e) => (o, i) => {
|
|
114
|
+
const s = typeof o == "string" ? o : o.id, n = i ? typeof i == "string" ? document.getElementById(i) : i : ht(t);
|
|
115
|
+
if (!n)
|
|
116
|
+
return console.warn(`The scroll parent is missing for the annotation: ${s}`, { container: t }), !1;
|
|
117
|
+
const r = e.getAnnotation(s);
|
|
118
|
+
if (!r)
|
|
265
119
|
return console.warn(`The annotation is missing in the store: ${s}`), !1;
|
|
266
|
-
const { range:
|
|
267
|
-
if (
|
|
268
|
-
return
|
|
269
|
-
const
|
|
270
|
-
return
|
|
271
|
-
},
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
},
|
|
275
|
-
fill: "rgb(0, 128, 255)",
|
|
276
|
-
fillOpacity: 0.45
|
|
277
|
-
}, Qe = (e) => {
|
|
278
|
-
const { top: t, left: n } = e.getBoundingClientRect(), { innerWidth: r, innerHeight: s } = window, o = -n, i = -t, c = r - n, l = s - t;
|
|
279
|
-
return { top: t, left: n, minX: o, minY: i, maxX: c, maxY: l };
|
|
280
|
-
}, Ze = (e) => {
|
|
281
|
-
let t = /* @__PURE__ */ new Set();
|
|
282
|
-
return (r) => {
|
|
283
|
-
const s = r.map((o) => o.id);
|
|
284
|
-
(t.size !== s.length || s.some((o) => !t.has(o))) && e.set(s), t = new Set(s);
|
|
285
|
-
};
|
|
286
|
-
}, se = (e, t, n, r) => {
|
|
287
|
-
const { store: s, selection: o, hover: i } = t;
|
|
288
|
-
let c, l, f;
|
|
289
|
-
const u = Ze(n), d = (A) => {
|
|
290
|
-
const { x: v, y: N } = e.getBoundingClientRect(), O = s.getAt(A.clientX - v, A.clientY - N, !1, l);
|
|
291
|
-
O && t.selection.evalSelectAction(O) !== Ce.NONE ? i.current !== O.id && (e.classList.add("hovered"), i.set(O.id)) : i.current && (e.classList.remove("hovered"), i.set(null));
|
|
292
|
-
};
|
|
293
|
-
e.addEventListener("pointermove", d);
|
|
294
|
-
const y = ee((A = !1) => requestAnimationFrame(() => {
|
|
295
|
-
f && f.clear();
|
|
296
|
-
const v = Qe(e), { minX: N, minY: O, maxX: P, maxY: X } = v, z = l ? s.getIntersecting(N, O, P, X).filter(({ annotation: p }) => l(p)) : s.getIntersecting(N, O, P, X), F = o.selected.map(({ id: p }) => p), re = z.map(({ annotation: p, rects: T }) => {
|
|
297
|
-
const k = F.includes(p.id), U = p.id === i.current;
|
|
298
|
-
return {
|
|
299
|
-
annotation: p,
|
|
300
|
-
rects: T,
|
|
301
|
-
state: { selected: k, hovered: U }
|
|
302
|
-
};
|
|
303
|
-
});
|
|
304
|
-
r.redraw(re, v, c, f, A), setTimeout(() => u(z.map(({ annotation: p }) => p)), 1);
|
|
305
|
-
}), 10), w = (A) => {
|
|
306
|
-
f = A, y();
|
|
307
|
-
}, g = (A) => {
|
|
308
|
-
c = A, y();
|
|
309
|
-
}, x = (A) => {
|
|
310
|
-
l = A, y(!1);
|
|
311
|
-
}, R = () => y();
|
|
312
|
-
s.observe(R);
|
|
313
|
-
const b = o.subscribe(() => y()), h = i.subscribe(() => y()), S = () => y(!0);
|
|
314
|
-
document.addEventListener("scroll", S, { capture: !0, passive: !0 });
|
|
315
|
-
const E = ee(() => {
|
|
316
|
-
s.recalculatePositions(), f?.reset(), y();
|
|
317
|
-
}, 10);
|
|
318
|
-
window.addEventListener("resize", E);
|
|
319
|
-
const m = new ResizeObserver(E);
|
|
320
|
-
m.observe(e);
|
|
321
|
-
const a = { attributes: !0, childList: !0, subtree: !0 }, C = new MutationObserver(ee((A) => {
|
|
322
|
-
A.every((N) => N.target === e || e.contains(N.target)) || y(!0);
|
|
323
|
-
}, 150));
|
|
324
|
-
return C.observe(document.body, a), {
|
|
325
|
-
destroy: () => {
|
|
326
|
-
e.removeEventListener("pointermove", d), r.destroy(), s.unobserve(R), b(), h(), document.removeEventListener("scroll", S), window.removeEventListener("resize", E), m.disconnect(), C.disconnect();
|
|
327
|
-
},
|
|
328
|
-
redraw: y,
|
|
329
|
-
setStyle: g,
|
|
330
|
-
setFilter: x,
|
|
331
|
-
setPainter: w,
|
|
332
|
-
setVisible: r.setVisible
|
|
333
|
-
};
|
|
334
|
-
}, Je = () => {
|
|
335
|
-
const e = document.createElement("canvas");
|
|
336
|
-
return e.width = window.innerWidth, e.height = window.innerHeight, e.className = "r6o-canvas-highlight-layer bg", e;
|
|
337
|
-
}, et = (e, t) => {
|
|
338
|
-
e.width = window.innerWidth, e.height = window.innerHeight;
|
|
339
|
-
}, tt = (e) => {
|
|
340
|
-
console.warn('WARNING! Canvas renderer is deprecated and will be removed in the next major release. Please use the default "SPANS" renderer instead.'), e.classList.add("r6o-annotatable");
|
|
341
|
-
const t = Je(), n = t.getContext("2d");
|
|
342
|
-
document.body.appendChild(t);
|
|
343
|
-
const r = (c, l, f, u) => requestAnimationFrame(() => {
|
|
344
|
-
const { width: d, height: y } = t;
|
|
345
|
-
n.clearRect(-0.5, -0.5, d + 1, y + 1), u && u.clear();
|
|
346
|
-
const { top: w, left: g } = l;
|
|
347
|
-
[...c].sort((R, b) => {
|
|
348
|
-
const { annotation: { target: { created: h } } } = R, { annotation: { target: { created: S } } } = b;
|
|
349
|
-
return h.getTime() - S.getTime();
|
|
350
|
-
}).forEach((R) => {
|
|
351
|
-
const b = f ? typeof f == "function" ? f(R.annotation, R.state) : f : R.state?.selected ? Z : _, h = u && u.paint(R, l) || b, S = R.rects.map(({ x: E, y: m, width: a, height: C }) => ({
|
|
352
|
-
x: E + g,
|
|
353
|
-
y: m + w,
|
|
354
|
-
width: a,
|
|
355
|
-
height: C
|
|
356
|
-
}));
|
|
357
|
-
if (n.fillStyle = h.fill, n.globalAlpha = h.fillOpacity || 1, S.forEach(
|
|
358
|
-
({ x: E, y: m, width: a, height: C }) => n.fillRect(E, m, a, C)
|
|
359
|
-
), h.underlineColor) {
|
|
360
|
-
n.globalAlpha = 1, n.strokeStyle = h.underlineColor, n.lineWidth = h.underlineThickness ?? 1;
|
|
361
|
-
const E = h.underlineOffset ?? 0;
|
|
362
|
-
S.forEach(({ x: m, y: a, width: C, height: L }) => {
|
|
363
|
-
n.beginPath(), n.moveTo(m, a + L + E), n.lineTo(m + C, a + L + E), n.stroke();
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
});
|
|
367
|
-
}), s = de(() => et(t), 10);
|
|
368
|
-
return window.addEventListener("resize", s), {
|
|
369
|
-
destroy: () => {
|
|
370
|
-
t.remove(), s.clear(), window.removeEventListener("resize", s);
|
|
371
|
-
},
|
|
372
|
-
setVisible: (c) => {
|
|
373
|
-
console.log("setVisible not implemented on Canvas renderer");
|
|
374
|
-
},
|
|
375
|
-
redraw: r
|
|
376
|
-
};
|
|
377
|
-
}, nt = (e, t, n) => se(e, t, n, tt(e)), ot = (e) => [
|
|
378
|
-
`background-color:${ne(e?.fill || _.fill).alpha(e?.fillOpacity === void 0 ? _.fillOpacity : e.fillOpacity).toHex()}`,
|
|
379
|
-
e?.underlineThickness ? "text-decoration:underline" : void 0,
|
|
380
|
-
e?.underlineColor ? `text-decoration-color:${e.underlineColor}` : void 0,
|
|
381
|
-
e?.underlineOffset ? `text-underline-offset:${e.underlineOffset}px` : void 0,
|
|
382
|
-
e?.underlineThickness ? `text-decoration-thickness:${e.underlineThickness}px` : void 0
|
|
383
|
-
].filter(Boolean).join(";"), st = () => {
|
|
384
|
-
const e = document.createElement("style");
|
|
385
|
-
document.getElementsByTagName("head")[0].appendChild(e);
|
|
386
|
-
let t = /* @__PURE__ */ new Set();
|
|
387
|
-
return {
|
|
388
|
-
destroy: () => {
|
|
389
|
-
CSS.highlights.clear(), e.remove();
|
|
390
|
-
},
|
|
391
|
-
setVisible: (o) => {
|
|
392
|
-
console.log("setVisible not implemented on CSS Custom Highlights renderer");
|
|
393
|
-
},
|
|
394
|
-
redraw: (o, i, c, l) => {
|
|
395
|
-
l && l.clear();
|
|
396
|
-
const f = new Set(o.map((d) => d.annotation.id));
|
|
397
|
-
Array.from(t).filter((d) => !f.has(d));
|
|
398
|
-
const u = o.map((d) => {
|
|
399
|
-
const y = c ? typeof c == "function" ? c(d.annotation, d.state) : c : d.state?.selected ? Z : _, w = l && l.paint(d, i) || y;
|
|
400
|
-
return `::highlight(_${d.annotation.id}) { ${ot(w)} }`;
|
|
401
|
-
});
|
|
402
|
-
e.innerHTML = u.join(`
|
|
403
|
-
`), CSS.highlights.clear(), o.forEach(({ annotation: d }) => {
|
|
404
|
-
const y = d.target.selector.map((g) => g.range), w = new Highlight(...y);
|
|
405
|
-
CSS.highlights.set(`_${d.id}`, w);
|
|
406
|
-
}), t = f;
|
|
407
|
-
}
|
|
408
|
-
};
|
|
409
|
-
}, rt = (e, t, n) => se(e, t, n, st()), it = (e) => e?.fillOpacity !== void 0 ? ne(e?.fill || _.fill).alpha(e.fillOpacity).toHex() : e?.fill ? e.fill : ne(_.fill).alpha(_.fillOpacity).toHex(), at = (e, t, n, r, s) => {
|
|
410
|
-
const o = n ? typeof n == "function" ? n(e.annotation, e.state, s) || (e.state?.selected ? Z : _) : n : e.state?.selected ? Z : _;
|
|
411
|
-
return r && r.paint(e, t) || o;
|
|
412
|
-
}, ct = (e, t) => {
|
|
413
|
-
const n = (o, i) => o.x <= i.x + i.width && o.x + o.width >= i.x && o.y <= i.y + i.height && o.y + o.height >= i.y, r = (o) => o.rects.reduce((i, c) => i + c.width, 0), s = t.filter(({ rects: o }) => o.some((i) => n(e, i)));
|
|
414
|
-
return s.sort((o, i) => r(i) - r(o)), s.findIndex((o) => o.rects.includes(e));
|
|
415
|
-
}, lt = (e) => {
|
|
416
|
-
e.classList.add("r6o-annotatable");
|
|
417
|
-
const t = document.createElement("div");
|
|
418
|
-
t.className = "r6o-span-highlight-layer", e.appendChild(t);
|
|
419
|
-
let n = [];
|
|
420
|
-
return {
|
|
421
|
-
destroy: () => {
|
|
422
|
-
t.remove();
|
|
423
|
-
},
|
|
424
|
-
redraw: (i, c, l, f, u) => {
|
|
425
|
-
const y = !(ke(n, i) && u);
|
|
426
|
-
if (!f && !y) return;
|
|
427
|
-
y && (t.innerHTML = ""), [...i].sort((g, x) => {
|
|
428
|
-
const { annotation: { target: { created: R } } } = g, { annotation: { target: { created: b } } } = x;
|
|
429
|
-
return R && b ? R.getTime() - b.getTime() : 0;
|
|
430
|
-
}).forEach((g) => {
|
|
431
|
-
g.rects.map((x) => {
|
|
432
|
-
const R = ct(x, i), b = at(g, c, l, f, R);
|
|
433
|
-
if (y) {
|
|
434
|
-
const h = document.createElement("span");
|
|
435
|
-
h.className = "r6o-annotation", h.dataset.annotation = g.annotation.id, h.style.left = `${x.x}px`, h.style.top = `${x.y}px`, h.style.width = `${x.width}px`, h.style.height = `${x.height}px`, h.style.backgroundColor = it(b), b.underlineStyle && (h.style.borderStyle = b.underlineStyle), b.underlineColor && (h.style.borderColor = b.underlineColor), b.underlineThickness && (h.style.borderBottomWidth = `${b.underlineThickness}px`), b.underlineOffset && (h.style.paddingBottom = `${b.underlineOffset}px`), t.appendChild(h);
|
|
436
|
-
}
|
|
437
|
-
});
|
|
438
|
-
}), n = i;
|
|
439
|
-
},
|
|
440
|
-
setVisible: (i) => {
|
|
441
|
-
i ? t.classList.remove("hidden") : t.classList.add("hidden");
|
|
442
|
-
}
|
|
443
|
-
};
|
|
444
|
-
}, dt = (e, t, n) => se(e, t, n, lt(e)), _t = (e, t) => ({
|
|
445
|
-
parse: (n) => gt(n),
|
|
446
|
-
serialize: (n) => mt(n, e, t)
|
|
447
|
-
}), ut = (e) => e.quote !== void 0 && e.start !== void 0 && e.end !== void 0, ft = (e) => {
|
|
120
|
+
const { range: a } = r.target.selector[0];
|
|
121
|
+
if (a && !a.collapsed)
|
|
122
|
+
return it(e, r.target, n), !0;
|
|
123
|
+
const d = Q(r.target, t), { range: g } = d.selector[0];
|
|
124
|
+
return g && !g.collapsed ? (it(e, d, n), !0) : !1;
|
|
125
|
+
}, xe = (t, e) => ({
|
|
126
|
+
parse: (o) => jt(o),
|
|
127
|
+
serialize: (o) => qt(o, t, e)
|
|
128
|
+
}), Vt = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, zt = (t) => {
|
|
448
129
|
const {
|
|
449
|
-
id:
|
|
450
|
-
creator:
|
|
451
|
-
created:
|
|
130
|
+
id: e,
|
|
131
|
+
creator: o,
|
|
132
|
+
created: i,
|
|
452
133
|
modified: s,
|
|
453
|
-
target:
|
|
454
|
-
} =
|
|
455
|
-
if (
|
|
456
|
-
return { error: Error(`No targets found for annotation: ${
|
|
457
|
-
const
|
|
458
|
-
creator:
|
|
459
|
-
created:
|
|
134
|
+
target: n
|
|
135
|
+
} = t, r = Array.isArray(n) ? n : [n];
|
|
136
|
+
if (r.length === 0)
|
|
137
|
+
return { error: Error(`No targets found for annotation: ${t.id}`) };
|
|
138
|
+
const a = {
|
|
139
|
+
creator: Tt(o),
|
|
140
|
+
created: i ? new Date(i) : void 0,
|
|
460
141
|
updated: s ? new Date(s) : void 0,
|
|
461
|
-
annotation:
|
|
142
|
+
annotation: e,
|
|
462
143
|
selector: [],
|
|
463
144
|
// @ts-expect-error: `styleClass` is not part of the core `TextAnnotationTarget` type
|
|
464
|
-
styleClass: "styleClass" in
|
|
145
|
+
styleClass: "styleClass" in r[0] ? r[0].styleClass : void 0
|
|
465
146
|
};
|
|
466
|
-
for (const
|
|
467
|
-
const
|
|
468
|
-
switch (
|
|
147
|
+
for (const d of r) {
|
|
148
|
+
const m = (Array.isArray(d.selector) ? d.selector : [d.selector]).reduce((b, h) => {
|
|
149
|
+
switch (h.type) {
|
|
469
150
|
case "TextQuoteSelector":
|
|
470
|
-
|
|
151
|
+
b.quote = h.exact;
|
|
471
152
|
break;
|
|
472
153
|
case "TextPositionSelector":
|
|
473
|
-
|
|
154
|
+
b.start = h.start, b.end = h.end;
|
|
474
155
|
break;
|
|
475
156
|
}
|
|
476
|
-
return
|
|
157
|
+
return b;
|
|
477
158
|
}, {});
|
|
478
|
-
if (
|
|
479
|
-
|
|
159
|
+
if (Vt(m))
|
|
160
|
+
a.selector.push(
|
|
480
161
|
{
|
|
481
|
-
...
|
|
482
|
-
id:
|
|
162
|
+
...m,
|
|
163
|
+
id: d.id,
|
|
483
164
|
// @ts-expect-error: `scope` is not part of the core `TextSelector` type
|
|
484
|
-
scope:
|
|
165
|
+
scope: d.scope
|
|
485
166
|
}
|
|
486
167
|
);
|
|
487
168
|
else {
|
|
488
|
-
const
|
|
489
|
-
|
|
490
|
-
|
|
169
|
+
const b = [
|
|
170
|
+
m.start ? void 0 : "TextPositionSelector",
|
|
171
|
+
m.quote ? void 0 : "TextQuoteSelector"
|
|
491
172
|
].filter(Boolean);
|
|
492
|
-
return { error: Error(`Missing selector types: ${
|
|
173
|
+
return { error: Error(`Missing selector types: ${b.join(" and ")} for annotation: ${t.id}`) };
|
|
493
174
|
}
|
|
494
175
|
}
|
|
495
|
-
return { parsed:
|
|
496
|
-
},
|
|
497
|
-
const
|
|
498
|
-
creator:
|
|
499
|
-
created:
|
|
176
|
+
return { parsed: a };
|
|
177
|
+
}, jt = (t) => {
|
|
178
|
+
const e = t.id || lt(), {
|
|
179
|
+
creator: o,
|
|
180
|
+
created: i,
|
|
500
181
|
modified: s,
|
|
501
|
-
body:
|
|
502
|
-
...
|
|
503
|
-
} =
|
|
504
|
-
return "error" in
|
|
182
|
+
body: n,
|
|
183
|
+
...r
|
|
184
|
+
} = t, a = Ct(n, e), d = zt(t);
|
|
185
|
+
return "error" in d ? { error: d.error } : {
|
|
505
186
|
parsed: {
|
|
506
|
-
...
|
|
507
|
-
id:
|
|
508
|
-
bodies:
|
|
509
|
-
target:
|
|
187
|
+
...r,
|
|
188
|
+
id: e,
|
|
189
|
+
bodies: a,
|
|
190
|
+
target: d.parsed
|
|
510
191
|
}
|
|
511
192
|
};
|
|
512
|
-
},
|
|
513
|
-
const { bodies:
|
|
514
|
-
selector:
|
|
515
|
-
creator:
|
|
516
|
-
created:
|
|
517
|
-
updated:
|
|
518
|
-
...
|
|
519
|
-
} = s,
|
|
520
|
-
const { id:
|
|
193
|
+
}, qt = (t, e, o) => {
|
|
194
|
+
const { bodies: i, target: s, ...n } = t, {
|
|
195
|
+
selector: r,
|
|
196
|
+
creator: a,
|
|
197
|
+
created: d,
|
|
198
|
+
updated: g,
|
|
199
|
+
...m
|
|
200
|
+
} = s, b = r.map((h) => {
|
|
201
|
+
const { id: T, quote: u, start: L, end: x, range: v } = h, p = {
|
|
521
202
|
type: "TextQuoteSelector",
|
|
522
|
-
exact:
|
|
203
|
+
exact: u
|
|
523
204
|
};
|
|
524
|
-
if (
|
|
525
|
-
const { prefix:
|
|
526
|
-
|
|
205
|
+
if (o) {
|
|
206
|
+
const { prefix: w, suffix: c } = Yt(v, o);
|
|
207
|
+
p.prefix = w, p.suffix = c;
|
|
527
208
|
}
|
|
528
|
-
const
|
|
209
|
+
const E = {
|
|
529
210
|
type: "TextPositionSelector",
|
|
530
|
-
start:
|
|
531
|
-
end:
|
|
211
|
+
start: L,
|
|
212
|
+
end: x
|
|
532
213
|
};
|
|
533
214
|
return {
|
|
534
|
-
...
|
|
535
|
-
id:
|
|
215
|
+
...m,
|
|
216
|
+
id: T,
|
|
536
217
|
// @ts-expect-error: `scope` is not part of the core `TextSelector` type
|
|
537
|
-
scope: "scope" in
|
|
538
|
-
source:
|
|
539
|
-
selector: [
|
|
218
|
+
scope: "scope" in h ? h.scope : void 0,
|
|
219
|
+
source: e,
|
|
220
|
+
selector: [p, E]
|
|
540
221
|
};
|
|
541
222
|
});
|
|
542
223
|
return {
|
|
543
|
-
...
|
|
224
|
+
...n,
|
|
544
225
|
"@context": "http://www.w3.org/ns/anno.jsonld",
|
|
545
|
-
id:
|
|
226
|
+
id: t.id,
|
|
546
227
|
type: "Annotation",
|
|
547
|
-
body:
|
|
548
|
-
creator:
|
|
549
|
-
created:
|
|
550
|
-
modified:
|
|
551
|
-
target:
|
|
228
|
+
body: At(t.bodies),
|
|
229
|
+
creator: a,
|
|
230
|
+
created: d?.toISOString(),
|
|
231
|
+
modified: g?.toISOString(),
|
|
232
|
+
target: b
|
|
552
233
|
};
|
|
553
|
-
},
|
|
554
|
-
|
|
555
|
-
e.
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
234
|
+
}, Gt = (t) => t.addEventListener("click", (e) => {
|
|
235
|
+
// Allow clicks within not-annotatable elements
|
|
236
|
+
!e.target.closest(Y) && !e.target.closest("a") && e.preventDefault();
|
|
237
|
+
}), J = (t) => ({
|
|
238
|
+
...t,
|
|
239
|
+
type: t.type,
|
|
240
|
+
x: t.x,
|
|
241
|
+
y: t.y,
|
|
242
|
+
clientX: t.clientX,
|
|
243
|
+
clientY: t.clientY,
|
|
244
|
+
offsetX: t.offsetX,
|
|
245
|
+
offsetY: t.offsetY,
|
|
246
|
+
screenX: t.screenX,
|
|
247
|
+
screenY: t.screenY,
|
|
248
|
+
isPrimary: t.isPrimary,
|
|
249
|
+
altKey: t.altKey,
|
|
250
|
+
ctrlKey: t.ctrlKey,
|
|
251
|
+
metaKey: t.metaKey,
|
|
252
|
+
shiftKey: t.shiftKey,
|
|
253
|
+
button: t.button,
|
|
254
|
+
buttons: t.buttons,
|
|
255
|
+
currentTarget: t.currentTarget,
|
|
256
|
+
target: t.target,
|
|
257
|
+
defaultPrevented: t.defaultPrevented,
|
|
258
|
+
detail: t.detail,
|
|
259
|
+
eventPhase: t.eventPhase,
|
|
260
|
+
pointerId: t.pointerId,
|
|
261
|
+
pointerType: t.pointerType,
|
|
262
|
+
timeStamp: t.timeStamp
|
|
263
|
+
}), G = (t) => ({
|
|
264
|
+
...t,
|
|
265
|
+
type: t.type,
|
|
266
|
+
key: t.key,
|
|
267
|
+
code: t.code,
|
|
268
|
+
location: t.location,
|
|
269
|
+
repeat: t.repeat,
|
|
270
|
+
altKey: t.altKey,
|
|
271
|
+
ctrlKey: t.ctrlKey,
|
|
272
|
+
metaKey: t.metaKey,
|
|
273
|
+
shiftKey: t.shiftKey,
|
|
274
|
+
currentTarget: t.currentTarget,
|
|
275
|
+
target: t.target,
|
|
276
|
+
defaultPrevented: t.defaultPrevented,
|
|
277
|
+
detail: t.detail,
|
|
278
|
+
timeStamp: t.timeStamp
|
|
279
|
+
}), tt = (t, e = 10) => {
|
|
280
|
+
let o;
|
|
281
|
+
return ((...i) => {
|
|
282
|
+
clearTimeout(o), o = setTimeout(() => t.apply(void 0, i), e);
|
|
283
|
+
});
|
|
284
|
+
}, yt = (t, e, o, i) => {
|
|
285
|
+
const { store: s, selection: n, hover: r } = o, a = dt();
|
|
286
|
+
let d;
|
|
287
|
+
const g = /* @__PURE__ */ new Map();
|
|
288
|
+
let m;
|
|
289
|
+
const b = ae(i), h = (y) => {
|
|
290
|
+
const { x: C, y: O } = e.getBoundingClientRect(), B = s.getAt(y.clientX - C, y.clientY - O, !1, m);
|
|
291
|
+
B && o.selection.evalSelectAction(B) !== Rt.NONE ? r.current !== B.id && (e.classList.add("hovered"), r.set(B.id)) : r.current && (e.classList.remove("hovered"), r.set(null));
|
|
292
|
+
};
|
|
293
|
+
e.addEventListener("pointermove", h);
|
|
294
|
+
const T = tt((y = !1) => requestAnimationFrame(() => {
|
|
295
|
+
const C = ie(e), { minX: O, minY: B, maxX: V, maxY: z } = C, K = m ? s.getIntersecting(O, B, V, z).filter(({ annotation: S }) => m(S)) : s.getIntersecting(O, B, V, z), st = n.selected.map(({ id: S }) => S), f = K.map(({ annotation: S, rects: M }) => {
|
|
296
|
+
const U = st.includes(S.id), I = S.id === r.current;
|
|
297
|
+
return {
|
|
298
|
+
annotation: S,
|
|
299
|
+
rects: M,
|
|
300
|
+
state: { selected: U, hovered: I }
|
|
301
|
+
};
|
|
302
|
+
});
|
|
303
|
+
t.redraw(f, C, d, g, y), setTimeout(() => {
|
|
304
|
+
b(K.map(({ annotation: S }) => S)), a.emit("onRedraw");
|
|
305
|
+
}, 1);
|
|
306
|
+
}), 10), u = (y, C) => {
|
|
307
|
+
C ? y ? g.set(C, y) : g.delete(C) : d = y, T(!0);
|
|
308
|
+
}, L = (y) => {
|
|
309
|
+
m = y, T(!1);
|
|
310
|
+
}, x = (y, C) => a.on(y, C), v = () => {
|
|
311
|
+
T();
|
|
312
|
+
};
|
|
313
|
+
s.observe(v);
|
|
314
|
+
const p = n.subscribe(() => {
|
|
315
|
+
T();
|
|
316
|
+
}), E = r.subscribe(() => {
|
|
317
|
+
T();
|
|
318
|
+
}), w = () => {
|
|
319
|
+
T(!0);
|
|
320
|
+
};
|
|
321
|
+
document.addEventListener("scroll", w, { capture: !0, passive: !0 });
|
|
322
|
+
const c = tt(() => {
|
|
323
|
+
s.recalculatePositions(), T();
|
|
324
|
+
}, 10);
|
|
325
|
+
window.addEventListener("resize", c);
|
|
326
|
+
const l = new ResizeObserver(c);
|
|
327
|
+
l.observe(e);
|
|
328
|
+
const A = { attributes: !0, childList: !0, subtree: !0 }, R = new MutationObserver(tt((y) => {
|
|
329
|
+
y.every((O) => O.target === e || e.contains(O.target)) || T(!0);
|
|
330
|
+
}, 150));
|
|
331
|
+
return R.observe(document.body, A), {
|
|
332
|
+
destroy: () => {
|
|
333
|
+
e.removeEventListener("pointermove", h), t.destroy(), s.unobserve(v), p(), E(), document.removeEventListener("scroll", w), window.removeEventListener("resize", c), l.disconnect(), R.disconnect();
|
|
568
334
|
},
|
|
335
|
+
on: x,
|
|
336
|
+
redraw: T,
|
|
337
|
+
setStyle: u,
|
|
338
|
+
setFilter: L,
|
|
339
|
+
setVisible: t.setVisible.bind(t)
|
|
340
|
+
};
|
|
341
|
+
}, P = {
|
|
342
|
+
fill: "rgb(0, 128, 255)",
|
|
343
|
+
fillOpacity: 0.18
|
|
344
|
+
}, ot = {
|
|
345
|
+
fill: "rgb(0, 128, 255)",
|
|
346
|
+
fillOpacity: 0.45
|
|
347
|
+
}, Qt = (t) => t?.fillOpacity !== void 0 ? et(t?.fill || P.fill).alpha(t.fillOpacity).toHex() : t?.fill ? t.fill : et(P.fill).alpha(P.fillOpacity).toHex(), St = (t, e, o) => e ? typeof e == "function" ? e(t.annotation, t.state, o) || (t.state?.selected ? ot : P) : e : t.state?.selected ? ot : P, Zt = (t, e) => {
|
|
348
|
+
const o = (n, r) => n.x <= r.x + r.width && n.x + n.width >= r.x && n.y <= r.y + r.height && n.y + n.height >= r.y, i = (n) => n.rects.reduce((r, a) => r + a.width, 0), s = e.filter(({ rects: n }) => n.some((r) => o(t, r)));
|
|
349
|
+
return s.sort((n, r) => i(r) - i(n)), s.findIndex((n) => n.rects.includes(t));
|
|
350
|
+
}, Jt = (t) => {
|
|
351
|
+
const e = [], o = document.createNodeIterator(
|
|
352
|
+
t.commonAncestorContainer,
|
|
353
|
+
NodeFilter.SHOW_TEXT
|
|
354
|
+
);
|
|
355
|
+
let i;
|
|
356
|
+
for (; i = o.nextNode(); )
|
|
357
|
+
t.intersectsNode(i) && e.push(i);
|
|
358
|
+
if (e.length < 2)
|
|
359
|
+
return Array.from(t.getClientRects());
|
|
360
|
+
{
|
|
361
|
+
const s = e[0], n = e[e.length - 1], r = document.createRange();
|
|
362
|
+
if (r.selectNode(s), t.startContainer.nodeType === Node.TEXT_NODE)
|
|
363
|
+
r.setStart(s, t.startOffset);
|
|
364
|
+
else {
|
|
365
|
+
const g = t.startContainer.childNodes[t.startOffset];
|
|
366
|
+
g ? r.setStartBefore(g) : r.setStartAfter(t.startContainer);
|
|
367
|
+
}
|
|
368
|
+
const a = document.createRange();
|
|
369
|
+
if (a.selectNode(n), t.endContainer.nodeType === Node.TEXT_NODE)
|
|
370
|
+
a.setEnd(n, t.endOffset);
|
|
371
|
+
else {
|
|
372
|
+
const g = t.endContainer.childNodes[t.endOffset];
|
|
373
|
+
g ? a.setEndBefore(g) : a.setEndAfter(t.endContainer);
|
|
374
|
+
}
|
|
375
|
+
const d = (g) => {
|
|
376
|
+
const m = document.createRange();
|
|
377
|
+
return m.selectNode(g), Array.from(m.getClientRects());
|
|
378
|
+
};
|
|
379
|
+
return [
|
|
380
|
+
...Array.from(r.getClientRects()),
|
|
381
|
+
...e.slice(1, -1).flatMap(d),
|
|
382
|
+
...Array.from(a.getClientRects())
|
|
383
|
+
];
|
|
384
|
+
}
|
|
385
|
+
}, te = (t, e, o, i) => {
|
|
386
|
+
const s = (a) => Math.round(a * 10) / 10, n = {
|
|
387
|
+
top: s(t.top),
|
|
388
|
+
bottom: s(t.bottom),
|
|
389
|
+
left: s(t.left),
|
|
390
|
+
right: s(t.right)
|
|
391
|
+
}, r = {
|
|
392
|
+
top: s(e.top),
|
|
393
|
+
bottom: s(e.bottom),
|
|
394
|
+
left: s(e.left),
|
|
395
|
+
right: s(e.right)
|
|
396
|
+
};
|
|
397
|
+
if (Math.abs(n.top - r.top) < i && Math.abs(n.bottom - r.bottom) < i) {
|
|
398
|
+
if (Math.abs(n.left - r.right) < o || Math.abs(n.right - r.left) < o)
|
|
399
|
+
return "inline-adjacent";
|
|
400
|
+
if (n.left >= r.left && n.right <= r.right)
|
|
401
|
+
return "inline-is-contained";
|
|
402
|
+
if (n.left <= r.left && n.right >= r.right)
|
|
403
|
+
return "inline-contains";
|
|
404
|
+
} else if (n.top <= r.top && n.bottom >= r.bottom) {
|
|
405
|
+
if (n.left <= r.left && n.right >= r.right)
|
|
406
|
+
return "block-contains";
|
|
407
|
+
} else if (n.top >= r.top && n.bottom <= r.bottom && n.left >= r.left && n.right <= r.right)
|
|
408
|
+
return "block-is-contained";
|
|
409
|
+
}, ee = (t, e) => {
|
|
410
|
+
const o = Math.min(t.left, e.left), i = Math.max(t.right, e.right), s = Math.min(t.top, e.top), n = Math.max(t.bottom, e.bottom);
|
|
411
|
+
return new DOMRect(o, s, i - o, n - s);
|
|
412
|
+
}, ne = (t, e = 0.5, o = 0.5) => t.reduce((i, s) => {
|
|
413
|
+
if (s.width === 0 || s.height === 0)
|
|
414
|
+
return i;
|
|
415
|
+
let n = [...i], r = !1;
|
|
416
|
+
for (const a of i) {
|
|
417
|
+
const d = te(s, a, e, o);
|
|
418
|
+
if (d === "inline-adjacent") {
|
|
419
|
+
n = n.map((g) => g === a ? ee(s, a) : g), r = !0;
|
|
420
|
+
break;
|
|
421
|
+
} else if (d === "inline-contains") {
|
|
422
|
+
n = n.map((g) => g === a ? s : g), r = !0;
|
|
423
|
+
break;
|
|
424
|
+
} else if (d === "inline-is-contained") {
|
|
425
|
+
r = !0;
|
|
426
|
+
break;
|
|
427
|
+
} else if (d === "block-contains" || d === "block-is-contained") {
|
|
428
|
+
s.width < a.width && (n = n.map((g) => g === a ? s : g)), s.width === a.width && s.height < a.width && (n = n.map((g) => g === a ? s : g)), r = !0;
|
|
429
|
+
break;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return r ? n : [...n, s];
|
|
433
|
+
}, []), Le = (t) => ({
|
|
434
|
+
length: t.length,
|
|
435
|
+
item: (e) => t[e],
|
|
436
|
+
[Symbol.iterator]: function* () {
|
|
437
|
+
for (let e = 0; e < this.length; e++)
|
|
438
|
+
yield this.item(e);
|
|
439
|
+
}
|
|
440
|
+
}), oe = (t, e) => {
|
|
441
|
+
const { left: o, top: i, right: s, bottom: n } = t;
|
|
442
|
+
return new DOMRect(o - e.left, i - e.top, s - o, n - i);
|
|
443
|
+
}, Ne = (t, e) => {
|
|
444
|
+
const { left: o, top: i, right: s, bottom: n } = t;
|
|
445
|
+
return new DOMRect(o + e.left, i + e.top, s - o, n - i);
|
|
446
|
+
}, se = (t) => {
|
|
447
|
+
t.classList.add("r6o-annotatable");
|
|
448
|
+
const e = document.createElement("div");
|
|
449
|
+
e.className = "r6o-span-highlight-layer", t.appendChild(e);
|
|
450
|
+
let o = [];
|
|
451
|
+
return {
|
|
569
452
|
destroy: () => {
|
|
570
|
-
|
|
453
|
+
e.remove();
|
|
571
454
|
},
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
const
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
};
|
|
583
|
-
}
|
|
455
|
+
redraw: (r, a, d, g, m) => {
|
|
456
|
+
if (!(!Bt(o, r) || m)) return;
|
|
457
|
+
e.innerHTML = "", [...r].sort((u, L) => {
|
|
458
|
+
const { annotation: { target: { created: x } } } = u, { annotation: { target: { created: v } } } = L;
|
|
459
|
+
return x && v ? x.getTime() - v.getTime() : 0;
|
|
460
|
+
}).forEach((u) => {
|
|
461
|
+
const L = g.get(u.annotation.id) || d;
|
|
462
|
+
u.rects.map((x) => {
|
|
463
|
+
const v = Zt(x, r), p = St(u, L, v), E = document.createElement("span");
|
|
464
|
+
E.className = "r6o-annotation", E.dataset.annotation = u.annotation.id, E.style.left = `${x.x}px`, E.style.top = `${x.y}px`, E.style.width = `${x.width}px`, E.style.height = `${x.height}px`, E.style.backgroundColor = Qt(p), p.underlineStyle && (E.style.borderStyle = p.underlineStyle), p.underlineColor && (E.style.borderColor = p.underlineColor), p.underlineThickness && (E.style.borderBottomWidth = `${p.underlineThickness}px`), p.underlineOffset && (E.style.paddingBottom = `${p.underlineOffset}px`), e.appendChild(E);
|
|
465
|
+
});
|
|
466
|
+
}), o = r;
|
|
584
467
|
},
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
const u = n.getContext("2d");
|
|
588
|
-
u.scale(2, 2), u.translate(0.5, 0.5);
|
|
468
|
+
setVisible: (r) => {
|
|
469
|
+
r ? e.classList.remove("hidden") : e.classList.add("hidden");
|
|
589
470
|
}
|
|
590
471
|
};
|
|
591
|
-
},
|
|
592
|
-
const
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
472
|
+
}, re = (t, e, o) => yt(se(t), t, e, o), ie = (t) => {
|
|
473
|
+
const { top: e, left: o } = t.getBoundingClientRect(), { innerWidth: i, innerHeight: s } = window, n = -o, r = -e, a = i - o, d = s - e;
|
|
474
|
+
return { top: e, left: o, minX: n, minY: r, maxX: a, maxY: d };
|
|
475
|
+
}, ae = (t) => {
|
|
476
|
+
let e = /* @__PURE__ */ new Set();
|
|
477
|
+
return (i) => {
|
|
478
|
+
const s = i.map((n) => n.id);
|
|
479
|
+
(e.size !== s.length || s.some((n) => !e.has(n))) && t.set(s), e = new Set(s);
|
|
480
|
+
};
|
|
481
|
+
}, ce = (t, e, o, i) => {
|
|
482
|
+
const s = new It(), n = /* @__PURE__ */ new Map(), r = dt(), a = (c, l) => {
|
|
483
|
+
const A = c.selector.flatMap((N) => {
|
|
484
|
+
const y = D([N]) ? N.range : pt(N, e).range;
|
|
485
|
+
return Jt(y);
|
|
486
|
+
}), R = ne(A, o, i).map((N) => oe(N, l));
|
|
487
|
+
return R.map((N) => {
|
|
488
|
+
const { x: y, y: C, width: O, height: B } = N;
|
|
599
489
|
return {
|
|
600
|
-
minX:
|
|
601
|
-
minY:
|
|
602
|
-
maxX:
|
|
603
|
-
maxY:
|
|
490
|
+
minX: y,
|
|
491
|
+
minY: C,
|
|
492
|
+
maxX: y + O,
|
|
493
|
+
maxY: C + B,
|
|
604
494
|
annotation: {
|
|
605
|
-
id:
|
|
606
|
-
rects:
|
|
495
|
+
id: c.annotation,
|
|
496
|
+
rects: R
|
|
607
497
|
}
|
|
608
498
|
};
|
|
609
499
|
});
|
|
610
|
-
},
|
|
611
|
-
s.clear(),
|
|
612
|
-
},
|
|
613
|
-
const
|
|
614
|
-
|
|
615
|
-
},
|
|
616
|
-
const
|
|
617
|
-
|
|
618
|
-
},
|
|
619
|
-
|
|
620
|
-
},
|
|
621
|
-
|
|
622
|
-
const
|
|
623
|
-
|
|
624
|
-
|
|
500
|
+
}, d = () => [...n.values()], g = () => {
|
|
501
|
+
s.clear(), n.clear();
|
|
502
|
+
}, m = (c) => {
|
|
503
|
+
const l = a(c, e.getBoundingClientRect());
|
|
504
|
+
l.length !== 0 && (l.forEach((A) => s.insert(A)), n.set(c.annotation, l));
|
|
505
|
+
}, b = (c) => {
|
|
506
|
+
const l = n.get(c.annotation);
|
|
507
|
+
l && (l.forEach((A) => s.remove(A)), n.delete(c.annotation));
|
|
508
|
+
}, h = (c) => {
|
|
509
|
+
b(c), m(c);
|
|
510
|
+
}, T = (c, l = !0) => {
|
|
511
|
+
l && g();
|
|
512
|
+
const A = e.getBoundingClientRect(), R = c.map((y) => ({ target: y, rects: a(y, A) }));
|
|
513
|
+
R.forEach(({ target: y, rects: C }) => {
|
|
514
|
+
C.length > 0 && n.set(y.annotation, C);
|
|
625
515
|
});
|
|
626
|
-
const
|
|
627
|
-
s.load(
|
|
628
|
-
},
|
|
629
|
-
const
|
|
630
|
-
minX:
|
|
631
|
-
minY:
|
|
632
|
-
maxX:
|
|
633
|
-
maxY:
|
|
634
|
-
}),
|
|
635
|
-
return
|
|
636
|
-
},
|
|
637
|
-
const
|
|
638
|
-
if (
|
|
516
|
+
const N = R.flatMap(({ rects: y }) => y);
|
|
517
|
+
s.load(N);
|
|
518
|
+
}, u = (c, l, A = !1) => {
|
|
519
|
+
const R = s.search({
|
|
520
|
+
minX: c,
|
|
521
|
+
minY: l,
|
|
522
|
+
maxX: c,
|
|
523
|
+
maxY: l
|
|
524
|
+
}), N = (y) => y.annotation.rects.reduce((C, O) => C + O.width * O.height, 0);
|
|
525
|
+
return R.length > 0 ? (R.sort((y, C) => N(y) - N(C)), A ? R.map((y) => y.annotation.id) : [R[0].annotation.id]) : [];
|
|
526
|
+
}, L = (c) => {
|
|
527
|
+
const l = x(c);
|
|
528
|
+
if (l.length === 0)
|
|
639
529
|
return;
|
|
640
|
-
let
|
|
641
|
-
for (let
|
|
642
|
-
const O =
|
|
643
|
-
|
|
530
|
+
let A = l[0].left, R = l[0].top, N = l[0].right, y = l[0].bottom;
|
|
531
|
+
for (let C = 1; C < l.length; C++) {
|
|
532
|
+
const O = l[C];
|
|
533
|
+
A = Math.min(A, O.left), R = Math.min(R, O.top), N = Math.max(N, O.right), y = Math.max(y, O.bottom);
|
|
644
534
|
}
|
|
645
|
-
return new DOMRect(
|
|
646
|
-
},
|
|
647
|
-
const
|
|
648
|
-
return
|
|
535
|
+
return new DOMRect(A, R, N - A, y - R);
|
|
536
|
+
}, x = (c) => {
|
|
537
|
+
const l = n.get(c);
|
|
538
|
+
return l ? l[0].annotation.rects : [];
|
|
649
539
|
};
|
|
650
540
|
return {
|
|
651
|
-
all:
|
|
652
|
-
clear:
|
|
653
|
-
getAt:
|
|
654
|
-
getAnnotationBounds:
|
|
655
|
-
getAnnotationRects:
|
|
656
|
-
getIntersecting: (
|
|
657
|
-
const
|
|
658
|
-
return Array.from(
|
|
659
|
-
annotation:
|
|
660
|
-
rects:
|
|
661
|
-
})).filter((
|
|
541
|
+
all: d,
|
|
542
|
+
clear: g,
|
|
543
|
+
getAt: u,
|
|
544
|
+
getAnnotationBounds: L,
|
|
545
|
+
getAnnotationRects: x,
|
|
546
|
+
getIntersecting: (c, l, A, R) => {
|
|
547
|
+
const N = s.search({ minX: c, minY: l, maxX: A, maxY: R }), y = new Set(N.map((C) => C.annotation.id));
|
|
548
|
+
return Array.from(y).map((C) => ({
|
|
549
|
+
annotation: t.getAnnotation(C),
|
|
550
|
+
rects: x(C)
|
|
551
|
+
})).filter((C) => !!C.annotation);
|
|
662
552
|
},
|
|
663
|
-
insert:
|
|
553
|
+
insert: m,
|
|
664
554
|
recalculate: () => {
|
|
665
|
-
|
|
555
|
+
T(t.all().map((c) => c.target), !0), r.emit("recalculate");
|
|
666
556
|
},
|
|
667
|
-
remove:
|
|
668
|
-
set:
|
|
557
|
+
remove: b,
|
|
558
|
+
set: T,
|
|
669
559
|
size: () => s.all().length,
|
|
670
|
-
update:
|
|
671
|
-
on: (
|
|
560
|
+
update: h,
|
|
561
|
+
on: (c, l) => r.on(c, l)
|
|
672
562
|
};
|
|
673
|
-
},
|
|
674
|
-
const
|
|
675
|
-
const
|
|
676
|
-
return
|
|
677
|
-
},
|
|
678
|
-
const
|
|
679
|
-
return
|
|
680
|
-
},
|
|
681
|
-
const
|
|
682
|
-
return
|
|
683
|
-
|
|
684
|
-
}),
|
|
685
|
-
},
|
|
686
|
-
const
|
|
687
|
-
|
|
688
|
-
},
|
|
689
|
-
const
|
|
690
|
-
|
|
563
|
+
}, le = (t, e) => {
|
|
564
|
+
const o = vt(), i = ce(o, t, e.mergeHighlights?.horizontalTolerance, e.mergeHighlights?.verticalTolerance), s = wt(o, e.userSelectAction, e.adapter), n = xt(o), r = Lt(), a = (p, E = F.LOCAL) => {
|
|
565
|
+
const w = Z(p, t), c = D(w.target.selector);
|
|
566
|
+
return c && o.addAnnotation(w, E), c;
|
|
567
|
+
}, d = (p, E = !0, w = F.LOCAL) => {
|
|
568
|
+
const c = p.map((A) => Z(A, t)), l = c.filter((A) => !D(A.target.selector));
|
|
569
|
+
return o.bulkAddAnnotations(c, E, w), l;
|
|
570
|
+
}, g = (p, E = F.LOCAL) => {
|
|
571
|
+
const w = p.map((l) => Z(l, t)), c = w.filter((l) => !D(l.target.selector));
|
|
572
|
+
return w.forEach((l) => {
|
|
573
|
+
o.getAnnotation(l.id) ? o.updateAnnotation(l, E) : o.addAnnotation(l, E);
|
|
574
|
+
}), c;
|
|
575
|
+
}, m = (p, E = F.LOCAL) => {
|
|
576
|
+
const w = Q(p, t);
|
|
577
|
+
o.updateTarget(w, E);
|
|
578
|
+
}, b = (p, E = F.LOCAL) => {
|
|
579
|
+
const w = p.map((c) => Q(c, t));
|
|
580
|
+
o.bulkUpdateTargets(w, E);
|
|
691
581
|
};
|
|
692
|
-
function
|
|
693
|
-
const
|
|
694
|
-
if (
|
|
695
|
-
return
|
|
582
|
+
function h(p, E, w, c) {
|
|
583
|
+
const l = w || !!c, A = i.getAt(p, E, l).map((N) => o.getAnnotation(N)), R = c ? A.filter(c) : A;
|
|
584
|
+
if (R.length !== 0)
|
|
585
|
+
return w ? R : R[0];
|
|
696
586
|
}
|
|
697
|
-
const
|
|
698
|
-
return
|
|
699
|
-
const
|
|
700
|
-
|
|
587
|
+
const T = (p) => i.getAnnotationRects(p).length > 0 ? i.getAnnotationBounds(p) : void 0, u = (p, E, w, c) => i.getIntersecting(p, E, w, c), L = (p) => i.getAnnotationRects(p), x = () => i.recalculate(), v = (p) => i.on("recalculate", p);
|
|
588
|
+
return o.observe(({ changes: p }) => {
|
|
589
|
+
const E = (p.deleted || []).filter((l) => D(l.target.selector)), w = (p.created || []).filter((l) => D(l.target.selector)), c = (p.updated || []).filter((l) => D(l.newValue.target.selector));
|
|
590
|
+
E?.length > 0 && E.forEach((l) => i.remove(l.target)), w.length > 0 && i.set(w.map((l) => l.target), !1), c?.length > 0 && c.forEach(({ newValue: l }) => i.update(l.target));
|
|
701
591
|
}), {
|
|
702
592
|
store: {
|
|
703
|
-
...
|
|
704
|
-
addAnnotation:
|
|
705
|
-
bulkAddAnnotations:
|
|
706
|
-
bulkUpdateTargets:
|
|
707
|
-
bulkUpsertAnnotations:
|
|
708
|
-
getAnnotationBounds:
|
|
709
|
-
getAnnotationRects:
|
|
710
|
-
getIntersecting:
|
|
711
|
-
getAt:
|
|
712
|
-
recalculatePositions:
|
|
713
|
-
onRecalculatePositions:
|
|
714
|
-
updateTarget:
|
|
593
|
+
...o,
|
|
594
|
+
addAnnotation: a,
|
|
595
|
+
bulkAddAnnotations: d,
|
|
596
|
+
bulkUpdateTargets: b,
|
|
597
|
+
bulkUpsertAnnotations: g,
|
|
598
|
+
getAnnotationBounds: T,
|
|
599
|
+
getAnnotationRects: L,
|
|
600
|
+
getIntersecting: u,
|
|
601
|
+
getAt: h,
|
|
602
|
+
recalculatePositions: x,
|
|
603
|
+
onRecalculatePositions: v,
|
|
604
|
+
updateTarget: m
|
|
715
605
|
},
|
|
716
606
|
selection: s,
|
|
717
|
-
hover:
|
|
718
|
-
viewport:
|
|
607
|
+
hover: n,
|
|
608
|
+
viewport: r
|
|
719
609
|
};
|
|
720
|
-
},
|
|
721
|
-
...
|
|
722
|
-
|
|
723
|
-
],
|
|
724
|
-
const { store: s, selection:
|
|
725
|
-
let
|
|
610
|
+
}, at = 300, Et = ["up", "down", "left", "right"], bt = ut ? "⌘+a" : "ctrl+a", de = [
|
|
611
|
+
...Et.map((t) => `shift+${t}`),
|
|
612
|
+
bt
|
|
613
|
+
], ue = (t, e, o, i) => {
|
|
614
|
+
const { store: s, selection: n } = e;
|
|
615
|
+
let r;
|
|
726
616
|
const {
|
|
727
|
-
annotatingEnabled:
|
|
728
|
-
offsetReferenceSelector:
|
|
729
|
-
selectionMode:
|
|
730
|
-
dismissOnNotAnnotatable:
|
|
731
|
-
} =
|
|
732
|
-
let
|
|
733
|
-
const
|
|
734
|
-
|
|
735
|
-
},
|
|
736
|
-
if (
|
|
617
|
+
annotatingEnabled: a,
|
|
618
|
+
offsetReferenceSelector: d,
|
|
619
|
+
selectionMode: g,
|
|
620
|
+
dismissOnNotAnnotatable: m = "NEVER"
|
|
621
|
+
} = i;
|
|
622
|
+
let b, h = a, T = "CREATE_NEW", u, L, x, v;
|
|
623
|
+
const p = (f) => {
|
|
624
|
+
h = f, R.clear(), f || (L = void 0, u = void 0, x = void 0, v = void 0);
|
|
625
|
+
}, E = (f) => T = f || "CREATE_NEW", w = (f) => b = f, c = (f) => r = f, l = (f) => {
|
|
626
|
+
if (T === "ADD_TO_CURRENT")
|
|
737
627
|
return !0;
|
|
738
|
-
if (
|
|
739
|
-
const
|
|
740
|
-
return
|
|
628
|
+
if (i.allowModifierSelect) {
|
|
629
|
+
const S = f;
|
|
630
|
+
return ut ? S.metaKey : S.ctrlKey;
|
|
741
631
|
} else
|
|
742
632
|
return !1;
|
|
743
|
-
},
|
|
744
|
-
if (!
|
|
745
|
-
const { selected:
|
|
746
|
-
if ((
|
|
747
|
-
const
|
|
748
|
-
if (
|
|
749
|
-
|
|
750
|
-
annotation:
|
|
633
|
+
}, A = () => {
|
|
634
|
+
if (!h || x === !1) return;
|
|
635
|
+
const { selected: f } = n;
|
|
636
|
+
if ((l(v) || T === "REPLACE_CURRENT") && f.length === 1 && f[0].editable) {
|
|
637
|
+
const M = s.getAnnotation(f[0].id);
|
|
638
|
+
if (M?.target) {
|
|
639
|
+
L = M.target, u = {
|
|
640
|
+
annotation: M.id,
|
|
751
641
|
selector: [],
|
|
752
|
-
created:
|
|
753
|
-
creator:
|
|
642
|
+
created: L.created,
|
|
643
|
+
creator: L.creator,
|
|
754
644
|
updated: /* @__PURE__ */ new Date(),
|
|
755
|
-
updatedBy:
|
|
645
|
+
updatedBy: r
|
|
756
646
|
};
|
|
757
647
|
return;
|
|
758
648
|
}
|
|
759
649
|
}
|
|
760
|
-
|
|
761
|
-
annotation:
|
|
650
|
+
L = void 0, u = {
|
|
651
|
+
annotation: lt(),
|
|
762
652
|
selector: [],
|
|
763
653
|
created: /* @__PURE__ */ new Date(),
|
|
764
|
-
creator:
|
|
654
|
+
creator: r
|
|
765
655
|
};
|
|
766
|
-
},
|
|
767
|
-
if (!
|
|
768
|
-
const
|
|
769
|
-
if (!
|
|
770
|
-
const
|
|
771
|
-
if (
|
|
772
|
-
|
|
656
|
+
}, R = _t((f) => {
|
|
657
|
+
if (!h) return;
|
|
658
|
+
const S = document.getSelection();
|
|
659
|
+
if (!S?.anchorNode) return;
|
|
660
|
+
const M = Array.from(Array(S.rangeCount).keys()).map((k) => S.getRangeAt(k));
|
|
661
|
+
if (M.every((k) => !gt(t, k))) {
|
|
662
|
+
u = void 0;
|
|
773
663
|
return;
|
|
774
664
|
}
|
|
775
|
-
const U =
|
|
776
|
-
if (
|
|
665
|
+
const U = f.timeStamp - (v?.timeStamp || f.timeStamp);
|
|
666
|
+
if (v?.type === "pointerdown" && (U < 1e3 && !u || S.isCollapsed && U < at) && A(), !u && (A(), !u))
|
|
777
667
|
return;
|
|
778
|
-
if (
|
|
779
|
-
s.getAnnotation(
|
|
668
|
+
if (S.isCollapsed) {
|
|
669
|
+
s.getAnnotation(u.annotation) && !(l(v) || T === "REPLACE_CURRENT") && (n.clear(), s.deleteAnnotation(u.annotation));
|
|
780
670
|
return;
|
|
781
671
|
}
|
|
782
|
-
const
|
|
783
|
-
if (
|
|
784
|
-
const
|
|
785
|
-
if (!(
|
|
786
|
-
const j =
|
|
787
|
-
...
|
|
788
|
-
...
|
|
789
|
-
]) :
|
|
790
|
-
|
|
791
|
-
...
|
|
792
|
-
selector: j.map((
|
|
672
|
+
const I = M.map((k) => $t(k, t));
|
|
673
|
+
if (I.every((k) => Ht(k))) return;
|
|
674
|
+
const _ = I.flatMap((k) => Ft(t, k.cloneRange()));
|
|
675
|
+
if (!(_.length > 0 && !u || _.length !== u.selector.length || _.some((k, W) => k.toString() !== u.selector[W]?.quote))) return;
|
|
676
|
+
const j = l(v) && L ? Pt([
|
|
677
|
+
...L.selector.map((k) => k.range),
|
|
678
|
+
..._
|
|
679
|
+
]) : _;
|
|
680
|
+
u = {
|
|
681
|
+
...u,
|
|
682
|
+
selector: j.map((k) => Wt(k, t, d)),
|
|
793
683
|
updated: /* @__PURE__ */ new Date()
|
|
794
|
-
}, !(
|
|
795
|
-
}, 10),
|
|
796
|
-
|
|
797
|
-
},
|
|
798
|
-
if (!
|
|
799
|
-
const
|
|
800
|
-
const { x:
|
|
801
|
-
if (
|
|
802
|
-
(typeof
|
|
684
|
+
}, !(l(v) || T === "REPLACE_CURRENT") && (s.getAnnotation(u.annotation) ? s.updateTarget(u, F.LOCAL) : n.clear());
|
|
685
|
+
}, 10), N = (f) => {
|
|
686
|
+
v = J(f), x = v.button === 0;
|
|
687
|
+
}, y = async (f) => {
|
|
688
|
+
if (!x) return;
|
|
689
|
+
const S = J(f), M = () => {
|
|
690
|
+
const { x: I, y: _ } = t.getBoundingClientRect();
|
|
691
|
+
if ($(t, S.target)) {
|
|
692
|
+
(typeof m == "function" ? m(S, t) : m === "ALWAYS") && n.clear();
|
|
803
693
|
return;
|
|
804
694
|
}
|
|
805
|
-
const
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
695
|
+
const H = S.target instanceof Node && t.contains(S.target) && s.getAt(
|
|
696
|
+
S.clientX - I,
|
|
697
|
+
S.clientY - _,
|
|
698
|
+
g === "all",
|
|
699
|
+
b
|
|
810
700
|
);
|
|
811
|
-
if (
|
|
812
|
-
const { selected: j } =
|
|
813
|
-
(
|
|
701
|
+
if (H) {
|
|
702
|
+
const { selected: j } = n, k = new Set(j.map((X) => X.id)), W = Array.isArray(H) ? H.map((X) => X.id) : [H.id];
|
|
703
|
+
(k.size !== W.length || !W.every((X) => k.has(X))) && (o.emit("clickAnnotation", H), n.userSelect(W, S));
|
|
814
704
|
} else
|
|
815
|
-
|
|
705
|
+
n.clear();
|
|
816
706
|
};
|
|
817
|
-
if (
|
|
818
|
-
await
|
|
819
|
-
const
|
|
820
|
-
if (
|
|
821
|
-
|
|
707
|
+
if (S.timeStamp - v.timeStamp < at) {
|
|
708
|
+
await C();
|
|
709
|
+
const I = document.getSelection(), _ = $(t, v.target), H = $(t, S.target);
|
|
710
|
+
if (I?.isCollapsed || _ && H) {
|
|
711
|
+
u = void 0, M();
|
|
822
712
|
return;
|
|
823
713
|
}
|
|
824
714
|
}
|
|
825
|
-
|
|
826
|
-
},
|
|
827
|
-
const
|
|
828
|
-
let
|
|
829
|
-
const U = () =>
|
|
830
|
-
return setTimeout(() =>
|
|
831
|
-
}, O = (
|
|
832
|
-
document.getSelection()?.isCollapsed || ((!
|
|
833
|
-
},
|
|
834
|
-
|
|
835
|
-
},
|
|
836
|
-
const
|
|
837
|
-
|
|
838
|
-
id:
|
|
715
|
+
u && u.selector.length > 0 && (K(), n.userSelect(u.annotation, S));
|
|
716
|
+
}, C = async () => {
|
|
717
|
+
const f = document.getSelection();
|
|
718
|
+
let S = !1, M = f?.isCollapsed;
|
|
719
|
+
const U = () => M || S, I = 1;
|
|
720
|
+
return setTimeout(() => S = !0, 50), Dt(() => M = f?.isCollapsed, I, U);
|
|
721
|
+
}, O = (f) => {
|
|
722
|
+
document.getSelection()?.isCollapsed || ((!u || u.selector.length === 0) && R(f), u && (K(), n.userSelect(u.annotation, J(f))));
|
|
723
|
+
}, B = (f) => {
|
|
724
|
+
h && (f.repeat || f.target instanceof Node && $(t, f.target) && f.target !== document.body || f.key === "Shift" && u && (document.getSelection().isCollapsed || (K(), n.userSelect(u.annotation, G(f)))));
|
|
725
|
+
}, V = (f) => {
|
|
726
|
+
const S = () => setTimeout(() => {
|
|
727
|
+
u?.selector.length > 0 && (n.clear(), s.addAnnotation({
|
|
728
|
+
id: u.annotation,
|
|
839
729
|
bodies: [],
|
|
840
|
-
target:
|
|
841
|
-
}),
|
|
730
|
+
target: u
|
|
731
|
+
}), n.userSelect(u.annotation, G(f))), document.removeEventListener("selectionchange", S);
|
|
842
732
|
}, 100);
|
|
843
|
-
document.addEventListener("selectionchange",
|
|
733
|
+
document.addEventListener("selectionchange", S), A();
|
|
844
734
|
};
|
|
845
|
-
q(
|
|
846
|
-
|
|
847
|
-
}), q(
|
|
848
|
-
|
|
735
|
+
q(de.join(","), { element: t, keydown: !0, keyup: !1 }, (f) => {
|
|
736
|
+
f.repeat || (v = G(f));
|
|
737
|
+
}), q(bt, { keydown: !0, keyup: !1 }, (f) => {
|
|
738
|
+
v = G(f), V(f);
|
|
849
739
|
});
|
|
850
|
-
const z = (
|
|
851
|
-
|
|
740
|
+
const z = (f) => {
|
|
741
|
+
f.repeat || f.target instanceof Node && $(t, f.target) && f.target !== document.body || (u = void 0, n.clear());
|
|
852
742
|
};
|
|
853
|
-
q(
|
|
854
|
-
const
|
|
855
|
-
const
|
|
856
|
-
if (!
|
|
743
|
+
q(Et.join(","), { keydown: !0, keyup: !1 }, z);
|
|
744
|
+
const K = () => {
|
|
745
|
+
const f = s.getAnnotation(u.annotation);
|
|
746
|
+
if (!f)
|
|
857
747
|
s.addAnnotation({
|
|
858
|
-
id:
|
|
748
|
+
id: u.annotation,
|
|
859
749
|
bodies: [],
|
|
860
|
-
target:
|
|
750
|
+
target: u
|
|
861
751
|
});
|
|
862
752
|
else {
|
|
863
|
-
const { target: { updated:
|
|
864
|
-
(!
|
|
753
|
+
const { target: { updated: S } } = f, { updated: M } = u;
|
|
754
|
+
(!S || !M || S < M) && s.updateTarget(u);
|
|
865
755
|
}
|
|
866
756
|
};
|
|
867
|
-
return document.addEventListener("pointerdown",
|
|
757
|
+
return document.addEventListener("pointerdown", N), document.addEventListener("pointerup", y), document.addEventListener("contextmenu", O), document.addEventListener("keyup", B), t.addEventListener("selectstart", A), document.addEventListener("selectionchange", R), {
|
|
868
758
|
destroy: () => {
|
|
869
|
-
|
|
759
|
+
u = void 0, L = void 0, x = void 0, v = void 0, R.clear(), document.removeEventListener("pointerdown", N), document.removeEventListener("pointerup", y), document.removeEventListener("contextmenu", O), document.removeEventListener("keyup", B), t.removeEventListener("selectstart", A), document.removeEventListener("selectionchange", R), q.unbind();
|
|
870
760
|
},
|
|
871
|
-
setFilter:
|
|
872
|
-
setUser:
|
|
873
|
-
setAnnotatingEnabled:
|
|
874
|
-
setAnnotatingMode:
|
|
761
|
+
setFilter: w,
|
|
762
|
+
setUser: c,
|
|
763
|
+
setAnnotatingEnabled: p,
|
|
764
|
+
setAnnotatingMode: E
|
|
765
|
+
};
|
|
766
|
+
}, fe = (t) => [
|
|
767
|
+
`background-color:${et(t?.fill || P.fill).alpha(t?.fillOpacity === void 0 ? P.fillOpacity : t.fillOpacity).toHex()}`,
|
|
768
|
+
t?.underlineThickness ? "text-decoration:underline" : void 0,
|
|
769
|
+
t?.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
|
|
770
|
+
t?.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
|
|
771
|
+
t?.underlineThickness ? `text-decoration-thickness:${t.underlineThickness}px` : void 0
|
|
772
|
+
].filter(Boolean).join(";"), ge = () => {
|
|
773
|
+
const t = document.createElement("style");
|
|
774
|
+
document.getElementsByTagName("head")[0].appendChild(t);
|
|
775
|
+
let e = /* @__PURE__ */ new Set();
|
|
776
|
+
return {
|
|
777
|
+
destroy: () => {
|
|
778
|
+
CSS.highlights.clear(), t.remove();
|
|
779
|
+
},
|
|
780
|
+
setVisible: (n) => {
|
|
781
|
+
console.log("setVisible not implemented on CSS Custom Highlights renderer");
|
|
782
|
+
},
|
|
783
|
+
redraw: (n, r, a, d, g) => {
|
|
784
|
+
const m = new Set(n.map((h) => h.annotation.id));
|
|
785
|
+
Array.from(e).filter((h) => !m.has(h));
|
|
786
|
+
const b = n.map((h) => {
|
|
787
|
+
a ? typeof a == "function" && a(h.annotation, h.state) : h.state?.selected;
|
|
788
|
+
const T = St(h, a);
|
|
789
|
+
return `::highlight(_${h.annotation.id}) { ${fe(T)} }`;
|
|
790
|
+
});
|
|
791
|
+
t.innerHTML = b.join(`
|
|
792
|
+
`), CSS.highlights.clear(), n.forEach(({ annotation: h }) => {
|
|
793
|
+
const T = h.target.selector.map((L) => L.range), u = new Highlight(...T);
|
|
794
|
+
CSS.highlights.set(`_${h.id}`, u);
|
|
795
|
+
}), e = m;
|
|
796
|
+
}
|
|
875
797
|
};
|
|
876
|
-
},
|
|
877
|
-
...
|
|
878
|
-
annotatingEnabled:
|
|
879
|
-
user:
|
|
880
|
-
}),
|
|
881
|
-
|
|
882
|
-
const
|
|
798
|
+
}, me = (t, e, o) => yt(ge(), t, e, o), pe = (t, e) => ({
|
|
799
|
+
...t,
|
|
800
|
+
annotatingEnabled: t.annotatingEnabled ?? e.annotatingEnabled,
|
|
801
|
+
user: t.user || e.user
|
|
802
|
+
}), ct = "SPANS", Oe = (t, e = {}) => {
|
|
803
|
+
Gt(t), Ut(t);
|
|
804
|
+
const o = pe(e, {
|
|
883
805
|
annotatingEnabled: !0,
|
|
884
|
-
user:
|
|
885
|
-
}),
|
|
886
|
-
let
|
|
887
|
-
const
|
|
888
|
-
if (!
|
|
889
|
-
throw `Unknown renderer implementation: ${
|
|
890
|
-
console.debug(
|
|
891
|
-
const
|
|
892
|
-
|
|
893
|
-
const
|
|
894
|
-
|
|
895
|
-
|
|
806
|
+
user: Nt()
|
|
807
|
+
}), i = le(t, o), { selection: s, viewport: n } = i, r = i.store, a = Ot(r), d = kt(i, a, o.adapter);
|
|
808
|
+
let g = o.user;
|
|
809
|
+
const m = typeof o.renderer != "function" ? o.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : ct : o.renderer || ct : null, b = m === null ? o.renderer(t, i, n) : m === "SPANS" ? re(t, i, n) : m === "CSS_HIGHLIGHTS" ? me(t, i, n) : void 0;
|
|
810
|
+
if (!b)
|
|
811
|
+
throw `Unknown renderer implementation: ${o.renderer}`;
|
|
812
|
+
console.debug(m ? `Using ${m} renderer` : "Using custom renderer implementation"), o.style && b.setStyle(o.style);
|
|
813
|
+
const h = ue(t, i, d, o);
|
|
814
|
+
h.setUser(g);
|
|
815
|
+
const T = Mt(i, a, o.adapter), u = () => g, L = (c) => {
|
|
816
|
+
h.setAnnotatingEnabled(
|
|
817
|
+
c === void 0 ? !0 : c
|
|
896
818
|
);
|
|
897
|
-
},
|
|
898
|
-
|
|
899
|
-
},
|
|
900
|
-
|
|
901
|
-
},
|
|
902
|
-
|
|
903
|
-
},
|
|
904
|
-
|
|
905
|
-
}, E = (a) => {
|
|
906
|
-
a ? s.setSelected(a) : s.clear();
|
|
819
|
+
}, x = (c) => {
|
|
820
|
+
h.setAnnotatingMode(c);
|
|
821
|
+
}, v = (c) => {
|
|
822
|
+
b.setFilter(c), h.setFilter(c);
|
|
823
|
+
}, p = (c) => {
|
|
824
|
+
g = c, h.setUser(c);
|
|
825
|
+
}, E = (c) => {
|
|
826
|
+
c ? s.setSelected(c) : s.clear();
|
|
907
827
|
};
|
|
908
828
|
return {
|
|
909
|
-
...
|
|
829
|
+
...T,
|
|
910
830
|
destroy: () => {
|
|
911
|
-
|
|
831
|
+
b.destroy(), h.destroy(), a.destroy();
|
|
912
832
|
},
|
|
913
|
-
element:
|
|
914
|
-
getUser:
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
setUser:
|
|
833
|
+
element: t,
|
|
834
|
+
getUser: u,
|
|
835
|
+
renderer: b,
|
|
836
|
+
setAnnotatingEnabled: L,
|
|
837
|
+
setAnnotatingMode: x,
|
|
838
|
+
setFilter: v,
|
|
839
|
+
setStyle: b.setStyle.bind(b),
|
|
840
|
+
setUser: p,
|
|
921
841
|
setSelected: E,
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
state: r
|
|
842
|
+
setVisible: b.setVisible.bind(b),
|
|
843
|
+
on: d.on,
|
|
844
|
+
off: d.off,
|
|
845
|
+
scrollIntoView: Xt(t, r),
|
|
846
|
+
state: i
|
|
928
847
|
};
|
|
929
848
|
};
|
|
930
849
|
export {
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
850
|
+
ot as DEFAULT_SELECTED_STYLE,
|
|
851
|
+
P as DEFAULT_STYLE,
|
|
852
|
+
ft as NOT_ANNOTATABLE_CLASS,
|
|
853
|
+
Y as NOT_ANNOTATABLE_SELECTOR,
|
|
854
|
+
Be as Origin,
|
|
855
|
+
Ie as UserSelectAction,
|
|
856
|
+
xe as W3CTextFormat,
|
|
857
|
+
Gt as cancelSingleClickEvents,
|
|
939
858
|
G as cloneKeyboardEvent,
|
|
940
859
|
J as clonePointerEvent,
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
ze as rangeToSelector,
|
|
970
|
-
te as reviveAnnotation,
|
|
971
|
-
he as reviveSelector,
|
|
860
|
+
St as computeStyle,
|
|
861
|
+
Zt as computeZIndex,
|
|
862
|
+
_e as createBody,
|
|
863
|
+
yt as createRenderer,
|
|
864
|
+
ue as createSelectionHandler,
|
|
865
|
+
re as createSpansRenderer,
|
|
866
|
+
Oe as createTextAnnotator,
|
|
867
|
+
le as createTextAnnotatorState,
|
|
868
|
+
tt as debounce,
|
|
869
|
+
pe as fillDefaults,
|
|
870
|
+
Qt as getBackgroundColor,
|
|
871
|
+
Jt as getHighlightClientRects,
|
|
872
|
+
Yt as getQuoteContext,
|
|
873
|
+
nt as getRangeAnnotatableContents,
|
|
874
|
+
ie as getViewportBounds,
|
|
875
|
+
ut as isMac,
|
|
876
|
+
we as isNodeWhitespaceOrEmpty,
|
|
877
|
+
$ as isNotAnnotatable,
|
|
878
|
+
gt as isRangeAnnotatable,
|
|
879
|
+
Ht as isRangeWhitespaceOrEmpty,
|
|
880
|
+
D as isRevived,
|
|
881
|
+
ne as mergeClientRects,
|
|
882
|
+
Pt as mergeRanges,
|
|
883
|
+
jt as parseW3CTextAnnotation,
|
|
884
|
+
Ut as programmaticallyFocusable,
|
|
885
|
+
Wt as rangeToSelector,
|
|
886
|
+
Z as reviveAnnotation,
|
|
887
|
+
pt as reviveSelector,
|
|
972
888
|
Q as reviveTarget,
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
889
|
+
Xt as scrollIntoView,
|
|
890
|
+
qt as serializeW3CTextAnnotation,
|
|
891
|
+
Ft as splitAnnotatableRanges,
|
|
892
|
+
Le as toDomRectList,
|
|
893
|
+
oe as toParentBounds,
|
|
894
|
+
Ne as toViewportBounds,
|
|
895
|
+
ae as trackViewport,
|
|
896
|
+
$t as trimRangeToContainer,
|
|
897
|
+
mt as whitespaceOrEmptyRegex
|
|
982
898
|
};
|
|
983
899
|
//# sourceMappingURL=text-annotator.es.js.map
|