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