@soomo/text-annotator 3.4.1-staging.0 → 3.4.2-staging.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -21,21 +21,34 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
21
21
|
!e.target.closest(W) && !e.target.closest("a") && e.preventDefault();
|
|
22
22
|
}), Ot = ft(), kt = Ot.os.is(ut.MACOS), Bt = (t) => {
|
|
23
23
|
!t.hasAttribute("tabindex") && t.tabIndex < 0 && t.setAttribute("tabindex", "-1"), t.classList.add("no-focus-outline");
|
|
24
|
-
},
|
|
25
|
-
const e = [], n = document.createNodeIterator(
|
|
24
|
+
}, It = (t) => {
|
|
25
|
+
const e = [], n = document.createNodeIterator(
|
|
26
|
+
t.commonAncestorContainer,
|
|
27
|
+
NodeFilter.SHOW_TEXT
|
|
28
|
+
);
|
|
26
29
|
let r;
|
|
27
30
|
for (; r = n.nextNode(); )
|
|
28
|
-
t.intersectsNode(r) &&
|
|
31
|
+
t.intersectsNode(r) && e.push(r);
|
|
29
32
|
if (e.length < 2)
|
|
30
33
|
return Array.from(t.getClientRects());
|
|
31
34
|
{
|
|
32
35
|
const o = e[0], s = e[e.length - 1], i = document.createRange();
|
|
33
|
-
i.selectNode(o), t.startContainer.nodeType === Node.TEXT_NODE
|
|
36
|
+
if (i.selectNode(o), t.startContainer.nodeType === Node.TEXT_NODE)
|
|
37
|
+
i.setStart(o, t.startOffset);
|
|
38
|
+
else {
|
|
39
|
+
const f = t.startContainer.childNodes[t.startOffset];
|
|
40
|
+
f ? i.setStartBefore(f) : i.setStartAfter(t.startContainer);
|
|
41
|
+
}
|
|
34
42
|
const c = document.createRange();
|
|
35
|
-
c.selectNode(s), t.endContainer.nodeType === Node.TEXT_NODE
|
|
36
|
-
|
|
43
|
+
if (c.selectNode(s), t.endContainer.nodeType === Node.TEXT_NODE)
|
|
44
|
+
c.setEnd(s, t.endOffset);
|
|
45
|
+
else {
|
|
46
|
+
const f = t.endContainer.childNodes[t.endOffset];
|
|
47
|
+
f ? c.setEndBefore(f) : c.setEndAfter(t.endContainer);
|
|
48
|
+
}
|
|
49
|
+
const l = (f) => {
|
|
37
50
|
const p = document.createRange();
|
|
38
|
-
return p.selectNode(
|
|
51
|
+
return p.selectNode(f), Array.from(p.getClientRects());
|
|
39
52
|
};
|
|
40
53
|
return [
|
|
41
54
|
...Array.from(i.getClientRects()),
|
|
@@ -43,7 +56,7 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
43
56
|
...Array.from(c.getClientRects())
|
|
44
57
|
];
|
|
45
58
|
}
|
|
46
|
-
},
|
|
59
|
+
}, Mt = function* (t) {
|
|
47
60
|
const e = document.createNodeIterator(
|
|
48
61
|
t.commonAncestorContainer,
|
|
49
62
|
NodeFilter.SHOW_ELEMENT,
|
|
@@ -52,11 +65,11 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
52
65
|
let n;
|
|
53
66
|
for (; n = e.nextNode(); )
|
|
54
67
|
n instanceof HTMLElement && (yield n);
|
|
55
|
-
},
|
|
68
|
+
}, Ht = (t, e) => {
|
|
56
69
|
if (!Lt(t, e)) return [];
|
|
57
70
|
const n = [];
|
|
58
71
|
let r = null;
|
|
59
|
-
for (const o of
|
|
72
|
+
for (const o of Mt(e)) {
|
|
60
73
|
let s;
|
|
61
74
|
r ? (s = document.createRange(), s.setStartAfter(r), s.setEndBefore(o)) : (s = e.cloneRange(), s.setEndBefore(o)), s.collapsed || n.push(s), r = o;
|
|
62
75
|
}
|
|
@@ -68,7 +81,7 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
68
81
|
}, J = (t) => {
|
|
69
82
|
const e = t.cloneContents();
|
|
70
83
|
return e.querySelectorAll(W).forEach((n) => n.remove()), e;
|
|
71
|
-
},
|
|
84
|
+
}, Pt = (t, e, n = 10, r) => {
|
|
72
85
|
const o = r ? t.startContainer.parentElement.closest(r) : e, s = document.createRange();
|
|
73
86
|
s.setStart(o, 0), s.setEnd(t.startContainer, t.startOffset);
|
|
74
87
|
const i = J(s).textContent, c = document.createRange();
|
|
@@ -78,7 +91,7 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
78
91
|
prefix: i.substring(i.length - n),
|
|
79
92
|
suffix: l.substring(0, n)
|
|
80
93
|
};
|
|
81
|
-
}, P = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed),
|
|
94
|
+
}, P = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), it = /^\s*$/, _t = (t) => it.test(t.toString()), Le = (t) => it.test(t.textContent || ""), Dt = (t, e, n, r) => {
|
|
82
95
|
const o = (c) => Math.round(c * 10) / 10, s = {
|
|
83
96
|
top: o(t.top),
|
|
84
97
|
bottom: o(t.bottom),
|
|
@@ -102,26 +115,26 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
102
115
|
return "block-contains";
|
|
103
116
|
} else if (s.top >= i.top && s.bottom <= i.bottom && s.left >= i.left && s.right <= i.right)
|
|
104
117
|
return "block-is-contained";
|
|
105
|
-
},
|
|
118
|
+
}, Ut = (t, e) => {
|
|
106
119
|
const n = Math.min(t.left, e.left), r = Math.max(t.right, e.right), o = Math.min(t.top, e.top), s = Math.max(t.bottom, e.bottom);
|
|
107
120
|
return new DOMRect(n, o, r - n, s - o);
|
|
108
|
-
},
|
|
121
|
+
}, Ft = (t, e = 0.5, n = 0.5) => t.reduce((r, o) => {
|
|
109
122
|
if (o.width === 0 || o.height === 0)
|
|
110
123
|
return r;
|
|
111
124
|
let s = [...r], i = !1;
|
|
112
125
|
for (const c of r) {
|
|
113
|
-
const l =
|
|
126
|
+
const l = Dt(o, c, e, n);
|
|
114
127
|
if (l === "inline-adjacent") {
|
|
115
|
-
s = s.map((
|
|
128
|
+
s = s.map((f) => f === c ? Ut(o, c) : f), i = !0;
|
|
116
129
|
break;
|
|
117
130
|
} else if (l === "inline-contains") {
|
|
118
|
-
s = s.map((
|
|
131
|
+
s = s.map((f) => f === c ? o : f), i = !0;
|
|
119
132
|
break;
|
|
120
133
|
} else if (l === "inline-is-contained") {
|
|
121
134
|
i = !0;
|
|
122
135
|
break;
|
|
123
136
|
} else if (l === "block-contains" || l === "block-is-contained") {
|
|
124
|
-
o.width < c.width && (s = s.map((
|
|
137
|
+
o.width < c.width && (s = s.map((f) => f === c ? o : f)), o.width === c.width && o.height < c.width && (s = s.map((f) => f === c ? o : f)), i = !0;
|
|
125
138
|
break;
|
|
126
139
|
}
|
|
127
140
|
}
|
|
@@ -133,13 +146,13 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
133
146
|
for (let e = 0; e < this.length; e++)
|
|
134
147
|
yield this.item(e);
|
|
135
148
|
}
|
|
136
|
-
}),
|
|
149
|
+
}), Kt = (t, e, n) => {
|
|
137
150
|
const r = document.createRange(), o = n ? t.startContainer.parentElement.closest(n) : e;
|
|
138
151
|
r.setStart(o, 0), r.setEnd(t.startContainer, t.startOffset);
|
|
139
152
|
const s = J(r).textContent, i = t.toString(), c = s.length || 0, l = c + i.length;
|
|
140
153
|
return n ? { quote: i, start: c, end: l, range: t, offsetReference: o } : { quote: i, start: c, end: l, range: t };
|
|
141
154
|
}, at = (t, e) => {
|
|
142
|
-
var p,
|
|
155
|
+
var p, u;
|
|
143
156
|
const { start: n, end: r } = t, o = t.offsetReference || e, s = document.createNodeIterator(
|
|
144
157
|
e,
|
|
145
158
|
NodeFilter.SHOW_TEXT,
|
|
@@ -152,9 +165,9 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
152
165
|
const c = document.createRange();
|
|
153
166
|
let l = s.nextNode();
|
|
154
167
|
l === null && console.error("Could not revive annotation target. Content missing.");
|
|
155
|
-
let
|
|
168
|
+
let f = !o;
|
|
156
169
|
for (; l !== null; ) {
|
|
157
|
-
if (
|
|
170
|
+
if (f || (f = typeof (o == null ? void 0 : o.contains) == "function" ? o.contains(l) : !1), f) {
|
|
158
171
|
const g = ((p = l.textContent) == null ? void 0 : p.length) || 0;
|
|
159
172
|
if (i + g > n) {
|
|
160
173
|
c.setStart(l, n - i);
|
|
@@ -165,7 +178,7 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
165
178
|
l = s.nextNode();
|
|
166
179
|
}
|
|
167
180
|
for (; l !== null; ) {
|
|
168
|
-
const g = ((
|
|
181
|
+
const g = ((u = l.textContent) == null ? void 0 : u.length) || 0;
|
|
169
182
|
if (i + g >= r) {
|
|
170
183
|
c.setEnd(l, r - i);
|
|
171
184
|
break;
|
|
@@ -179,7 +192,7 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
179
192
|
}, q = (t, e) => P(t.selector) ? t : {
|
|
180
193
|
...t,
|
|
181
194
|
selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : at(n, e))
|
|
182
|
-
}, G = (t, e) => P(t.target.selector) ? t : { ...t, target: q(t.target, e) },
|
|
195
|
+
}, G = (t, e) => P(t.target.selector) ? t : { ...t, target: q(t.target, e) }, $t = (t, e) => {
|
|
183
196
|
const n = t.cloneRange();
|
|
184
197
|
return e.contains(n.startContainer) || n.setStart(e, 0), e.contains(n.endContainer) || n.setEnd(e, e.childNodes.length), n;
|
|
185
198
|
}, Q = (t) => ({
|
|
@@ -224,7 +237,7 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
224
237
|
defaultPrevented: t.defaultPrevented,
|
|
225
238
|
detail: t.detail,
|
|
226
239
|
timeStamp: t.timeStamp
|
|
227
|
-
}),
|
|
240
|
+
}), Wt = (t, e) => {
|
|
228
241
|
const { left: n, top: r, right: o, bottom: s } = t;
|
|
229
242
|
return new DOMRect(n - e.left, r - e.top, o - n, s - r);
|
|
230
243
|
}, Oe = (t, e) => {
|
|
@@ -236,9 +249,9 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
236
249
|
const { overflowY: e } = window.getComputedStyle(t);
|
|
237
250
|
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : ct(t.parentElement);
|
|
238
251
|
}, et = (t, e, n) => {
|
|
239
|
-
const r = n.getBoundingClientRect(), o = n.clientHeight, s = n.clientWidth, i = e.selector[0].range.getBoundingClientRect(), { width: c, height: l } = t.getAnnotationBounds(e.annotation),
|
|
252
|
+
const r = n.getBoundingClientRect(), o = n.clientHeight, s = n.clientWidth, i = e.selector[0].range.getBoundingClientRect(), { width: c, height: l } = t.getAnnotationBounds(e.annotation), f = i.top - r.top, p = i.left - r.left, u = n.parentElement ? n.scrollTop : 0, g = n.parentElement ? n.scrollLeft : 0, d = f + u - (o - l) / 2, L = p + g - (s - c) / 2;
|
|
240
253
|
n.scroll({ top: d, left: L, behavior: "smooth" });
|
|
241
|
-
},
|
|
254
|
+
}, Vt = (t, e) => (n, r) => {
|
|
242
255
|
const o = typeof n == "string" ? n : n.id, s = r ? typeof r == "string" ? document.getElementById(r) : r : ct(t);
|
|
243
256
|
if (!s)
|
|
244
257
|
return console.warn(`The scroll parent is missing for the annotation: ${o}`, { container: t }), !1;
|
|
@@ -248,22 +261,22 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
248
261
|
const { range: c } = i.target.selector[0];
|
|
249
262
|
if (c && !c.collapsed)
|
|
250
263
|
return et(e, i.target, s), !0;
|
|
251
|
-
const l = q(i.target, t), { range:
|
|
252
|
-
return
|
|
264
|
+
const l = q(i.target, t), { range: f } = l.selector[0];
|
|
265
|
+
return f && !f.collapsed ? (et(e, l, s), !0) : !1;
|
|
253
266
|
}, _ = {
|
|
254
267
|
fill: "rgb(0, 128, 255)",
|
|
255
268
|
fillOpacity: 0.18
|
|
256
269
|
}, j = {
|
|
257
270
|
fill: "rgb(0, 128, 255)",
|
|
258
271
|
fillOpacity: 0.45
|
|
259
|
-
},
|
|
272
|
+
}, Yt = (t, e, n, r, o) => {
|
|
260
273
|
var i, c;
|
|
261
274
|
const s = n ? typeof n == "function" ? n(t.annotation, t.state, o) || ((i = t.state) != null && i.selected ? j : _) : n : (c = t.state) != null && c.selected ? j : _;
|
|
262
275
|
return r && r.paint(t, e) || s;
|
|
263
|
-
},
|
|
276
|
+
}, Xt = (t) => {
|
|
264
277
|
const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: r, innerHeight: o } = window, s = -n, i = -e, c = r - n, l = o - e;
|
|
265
278
|
return { top: e, left: n, minX: s, minY: i, maxX: c, maxY: l };
|
|
266
|
-
},
|
|
279
|
+
}, zt = (t) => {
|
|
267
280
|
let e = /* @__PURE__ */ new Set();
|
|
268
281
|
return (r) => {
|
|
269
282
|
const o = r.map((s) => s.id);
|
|
@@ -271,15 +284,15 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
271
284
|
};
|
|
272
285
|
}, tt = (t, e, n, r) => {
|
|
273
286
|
const { store: o, selection: s, hover: i } = e;
|
|
274
|
-
let c, l,
|
|
275
|
-
const p =
|
|
287
|
+
let c, l, f;
|
|
288
|
+
const p = zt(n), u = $((S) => {
|
|
276
289
|
const { x: A, y: T } = t.getBoundingClientRect(), B = o.getAt(S.clientX - A, S.clientY - T, !1, l);
|
|
277
290
|
B ? i.current !== B.id && (t.classList.add("hovered"), i.set(B.id)) : i.current && (t.classList.remove("hovered"), i.set(null));
|
|
278
291
|
}, 10);
|
|
279
|
-
t.addEventListener("pointermove",
|
|
292
|
+
t.addEventListener("pointermove", u);
|
|
280
293
|
const g = $((S = !1) => requestAnimationFrame(() => {
|
|
281
|
-
|
|
282
|
-
const A =
|
|
294
|
+
f && f.clear();
|
|
295
|
+
const A = Xt(t), { minX: T, minY: B, maxX: y, maxY: v } = A, I = l ? o.getIntersecting(T, B, y, v).filter(({ annotation: O }) => l(O)) : o.getIntersecting(T, B, y, v), D = s.selected.map(({ id: O }) => O), M = I.map(({ annotation: O, rects: H }) => {
|
|
283
296
|
const k = D.includes(O.id), U = O.id === i.current;
|
|
284
297
|
return {
|
|
285
298
|
annotation: O,
|
|
@@ -287,9 +300,9 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
287
300
|
state: { selected: k, hovered: U }
|
|
288
301
|
};
|
|
289
302
|
});
|
|
290
|
-
r.redraw(M, A, c,
|
|
303
|
+
r.redraw(M, A, c, f, S), setTimeout(() => p(I.map(({ annotation: O }) => O)), 1);
|
|
291
304
|
}), 10), d = (S) => {
|
|
292
|
-
|
|
305
|
+
f = S, g();
|
|
293
306
|
}, L = (S) => {
|
|
294
307
|
c = S, g();
|
|
295
308
|
}, w = (S) => {
|
|
@@ -299,7 +312,7 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
299
312
|
const R = s.subscribe(() => g()), C = i.subscribe(() => g()), N = () => g(!0);
|
|
300
313
|
document.addEventListener("scroll", N, { capture: !0, passive: !0 });
|
|
301
314
|
const E = $(() => {
|
|
302
|
-
o.recalculatePositions(),
|
|
315
|
+
o.recalculatePositions(), f == null || f.reset(), g();
|
|
303
316
|
}, 10);
|
|
304
317
|
window.addEventListener("resize", E);
|
|
305
318
|
const a = new ResizeObserver(E);
|
|
@@ -309,7 +322,7 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
309
322
|
}, 150));
|
|
310
323
|
return b.observe(document.body, m), {
|
|
311
324
|
destroy: () => {
|
|
312
|
-
t.removeEventListener("pointermove",
|
|
325
|
+
t.removeEventListener("pointermove", u), r.destroy(), o.unobserve(x), R(), C(), document.removeEventListener("scroll", N), E.clear(), window.removeEventListener("resize", E), a.disconnect(), b.disconnect();
|
|
313
326
|
},
|
|
314
327
|
redraw: g,
|
|
315
328
|
setStyle: L,
|
|
@@ -317,25 +330,25 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
317
330
|
setPainter: d,
|
|
318
331
|
setVisible: r.setVisible
|
|
319
332
|
};
|
|
320
|
-
},
|
|
333
|
+
}, qt = () => {
|
|
321
334
|
const t = document.createElement("canvas");
|
|
322
335
|
return t.width = window.innerWidth, t.height = window.innerHeight, t.className = "r6o-canvas-highlight-layer bg", t;
|
|
323
|
-
},
|
|
336
|
+
}, jt = (t, e) => {
|
|
324
337
|
t.width = window.innerWidth, t.height = window.innerHeight;
|
|
325
|
-
},
|
|
338
|
+
}, Gt = (t) => {
|
|
326
339
|
t.classList.add("r6o-annotatable");
|
|
327
|
-
const e =
|
|
340
|
+
const e = qt(), n = e.getContext("2d");
|
|
328
341
|
document.body.appendChild(e);
|
|
329
|
-
const r = (c, l,
|
|
330
|
-
const { width:
|
|
331
|
-
n.clearRect(-0.5, -0.5,
|
|
342
|
+
const r = (c, l, f, p) => requestAnimationFrame(() => {
|
|
343
|
+
const { width: u, height: g } = e;
|
|
344
|
+
n.clearRect(-0.5, -0.5, u + 1, g + 1), p && p.clear();
|
|
332
345
|
const { top: d, left: L } = l;
|
|
333
346
|
[...c].sort((x, R) => {
|
|
334
347
|
const { annotation: { target: { created: C } } } = x, { annotation: { target: { created: N } } } = R;
|
|
335
348
|
return C.getTime() - N.getTime();
|
|
336
349
|
}).forEach((x) => {
|
|
337
350
|
var E;
|
|
338
|
-
const R =
|
|
351
|
+
const R = f ? typeof f == "function" ? f(x.annotation, x.state) : f : (E = x.state) != null && E.selected ? j : _, C = p && p.paint(x, l) || R, N = x.rects.map(({ x: a, y: m, width: b, height: h }) => ({
|
|
339
352
|
x: a + L,
|
|
340
353
|
y: m + d,
|
|
341
354
|
width: b,
|
|
@@ -351,7 +364,7 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
351
364
|
});
|
|
352
365
|
}
|
|
353
366
|
});
|
|
354
|
-
}), o = $(() =>
|
|
367
|
+
}), o = $(() => jt(e), 10);
|
|
355
368
|
return window.addEventListener("resize", o), {
|
|
356
369
|
destroy: () => {
|
|
357
370
|
e.remove(), o.clear(), window.removeEventListener("resize", o);
|
|
@@ -361,13 +374,13 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
361
374
|
},
|
|
362
375
|
redraw: r
|
|
363
376
|
};
|
|
364
|
-
},
|
|
377
|
+
}, Qt = (t, e, n) => tt(t, e, n, Gt(t)), Zt = (t) => [
|
|
365
378
|
`background-color:${Z((t == null ? void 0 : t.fill) || _.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? _.fillOpacity : t.fillOpacity).toHex()}`,
|
|
366
379
|
t != null && t.underlineThickness ? "text-decoration:underline" : void 0,
|
|
367
380
|
t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
|
|
368
381
|
t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
|
|
369
382
|
t != null && t.underlineThickness ? `text-decoration-thickness:${t.underlineThickness}px` : void 0
|
|
370
|
-
].filter(Boolean).join(";"),
|
|
383
|
+
].filter(Boolean).join(";"), Jt = () => {
|
|
371
384
|
const t = document.createElement("style");
|
|
372
385
|
document.getElementsByTagName("head")[0].appendChild(t);
|
|
373
386
|
let e = /* @__PURE__ */ new Set();
|
|
@@ -380,24 +393,24 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
380
393
|
},
|
|
381
394
|
redraw: (s, i, c, l) => {
|
|
382
395
|
l && l.clear();
|
|
383
|
-
const
|
|
384
|
-
Array.from(e).filter((
|
|
385
|
-
const p = s.map((
|
|
396
|
+
const f = new Set(s.map((u) => u.annotation.id));
|
|
397
|
+
Array.from(e).filter((u) => !f.has(u));
|
|
398
|
+
const p = s.map((u) => {
|
|
386
399
|
var L;
|
|
387
|
-
const g = c ? typeof c == "function" ? c(
|
|
388
|
-
return `::highlight(_${
|
|
400
|
+
const g = c ? typeof c == "function" ? c(u.annotation, u.state) : c : (L = u.state) != null && L.selected ? j : _, d = l && l.paint(u, i) || g;
|
|
401
|
+
return `::highlight(_${u.annotation.id}) { ${Zt(d)} }`;
|
|
389
402
|
});
|
|
390
403
|
t.innerHTML = p.join(`
|
|
391
|
-
`), CSS.highlights.clear(), s.forEach(({ annotation:
|
|
392
|
-
const g =
|
|
393
|
-
CSS.highlights.set(`_${
|
|
394
|
-
}), e =
|
|
404
|
+
`), CSS.highlights.clear(), s.forEach(({ annotation: u }) => {
|
|
405
|
+
const g = u.target.selector.map((L) => L.range), d = new Highlight(...g);
|
|
406
|
+
CSS.highlights.set(`_${u.id}`, d);
|
|
407
|
+
}), e = f;
|
|
395
408
|
}
|
|
396
409
|
};
|
|
397
|
-
},
|
|
410
|
+
}, te = (t, e, n) => tt(t, e, n, Jt()), ee = (t) => (t == null ? void 0 : t.fillOpacity) !== void 0 ? Z((t == null ? void 0 : t.fill) || _.fill).alpha(t.fillOpacity).toHex() : t != null && t.fill ? t.fill : Z(_.fill).alpha(_.fillOpacity).toHex(), ne = (t, e) => {
|
|
398
411
|
const n = (s, i) => s.x <= i.x + i.width && s.x + s.width >= i.x && s.y <= i.y + i.height && s.y + s.height >= i.y, r = (s) => s.rects.reduce((i, c) => i + c.width, 0), o = e.filter(({ rects: s }) => s.some((i) => n(t, i)));
|
|
399
412
|
return o.sort((s, i) => r(i) - r(s)), o.findIndex((s) => s.rects.includes(t));
|
|
400
|
-
},
|
|
413
|
+
}, oe = (t) => {
|
|
401
414
|
t.classList.add("r6o-annotatable");
|
|
402
415
|
const e = document.createElement("div");
|
|
403
416
|
e.className = "r6o-span-highlight-layer", t.insertBefore(e, t.firstChild);
|
|
@@ -406,18 +419,18 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
406
419
|
destroy: () => {
|
|
407
420
|
e.remove();
|
|
408
421
|
},
|
|
409
|
-
redraw: (i, c, l,
|
|
422
|
+
redraw: (i, c, l, f, p) => {
|
|
410
423
|
const g = !(gt(n, i) && p);
|
|
411
|
-
if (!
|
|
424
|
+
if (!f && !g) return;
|
|
412
425
|
g && (e.innerHTML = ""), [...i].sort((L, w) => {
|
|
413
426
|
const { annotation: { target: { created: x } } } = L, { annotation: { target: { created: R } } } = w;
|
|
414
427
|
return x && R ? x.getTime() - R.getTime() : 0;
|
|
415
428
|
}).forEach((L) => {
|
|
416
429
|
L.rects.map((w) => {
|
|
417
|
-
const x =
|
|
430
|
+
const x = ne(w, i), R = Yt(L, c, l, f, x);
|
|
418
431
|
if (g) {
|
|
419
432
|
const C = document.createElement("span");
|
|
420
|
-
C.className = "r6o-annotation", C.dataset.annotation = L.annotation.id, C.style.left = `${w.x}px`, C.style.top = `${w.y}px`, C.style.width = `${w.width}px`, C.style.height = `${w.height}px`, C.style.backgroundColor =
|
|
433
|
+
C.className = "r6o-annotation", C.dataset.annotation = L.annotation.id, C.style.left = `${w.x}px`, C.style.top = `${w.y}px`, C.style.width = `${w.width}px`, C.style.height = `${w.height}px`, C.style.backgroundColor = ee(R), R.underlineStyle && (C.style.borderStyle = R.underlineStyle), R.underlineColor && (C.style.borderColor = R.underlineColor), R.underlineThickness && (C.style.borderBottomWidth = `${R.underlineThickness}px`), R.underlineOffset && (C.style.paddingBottom = `${R.underlineOffset}px`), e.appendChild(C);
|
|
421
434
|
}
|
|
422
435
|
});
|
|
423
436
|
}), n = i;
|
|
@@ -426,10 +439,10 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
426
439
|
i ? e.classList.remove("hidden") : e.classList.add("hidden");
|
|
427
440
|
}
|
|
428
441
|
};
|
|
429
|
-
},
|
|
430
|
-
parse: (n) =>
|
|
431
|
-
serialize: (n) =>
|
|
432
|
-
}),
|
|
442
|
+
}, se = (t, e, n) => tt(t, e, n, oe(t)), ke = (t, e) => ({
|
|
443
|
+
parse: (n) => ae(n),
|
|
444
|
+
serialize: (n) => ce(n, t, e)
|
|
445
|
+
}), re = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, ie = (t) => {
|
|
433
446
|
const {
|
|
434
447
|
id: e,
|
|
435
448
|
creator: n,
|
|
@@ -449,18 +462,18 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
449
462
|
styleClass: "styleClass" in i[0] ? i[0].styleClass : void 0
|
|
450
463
|
};
|
|
451
464
|
for (const l of i) {
|
|
452
|
-
const p = (Array.isArray(l.selector) ? l.selector : [l.selector]).reduce((
|
|
465
|
+
const p = (Array.isArray(l.selector) ? l.selector : [l.selector]).reduce((u, g) => {
|
|
453
466
|
switch (g.type) {
|
|
454
467
|
case "TextQuoteSelector":
|
|
455
|
-
|
|
468
|
+
u.quote = g.exact;
|
|
456
469
|
break;
|
|
457
470
|
case "TextPositionSelector":
|
|
458
|
-
|
|
471
|
+
u.start = g.start, u.end = g.end;
|
|
459
472
|
break;
|
|
460
473
|
}
|
|
461
|
-
return
|
|
474
|
+
return u;
|
|
462
475
|
}, {});
|
|
463
|
-
if (c.outdated || (c.outdated = "outdated" in l ? l.outdated : void 0),
|
|
476
|
+
if (c.outdated || (c.outdated = "outdated" in l ? l.outdated : void 0), re(p))
|
|
464
477
|
c.selector.push(
|
|
465
478
|
{
|
|
466
479
|
...p,
|
|
@@ -470,22 +483,22 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
470
483
|
}
|
|
471
484
|
);
|
|
472
485
|
else {
|
|
473
|
-
const
|
|
486
|
+
const u = [
|
|
474
487
|
p.start ? void 0 : "TextPositionSelector",
|
|
475
488
|
p.quote ? void 0 : "TextQuoteSelector"
|
|
476
489
|
].filter(Boolean);
|
|
477
|
-
return { error: Error(`Missing selector types: ${
|
|
490
|
+
return { error: Error(`Missing selector types: ${u.join(" and ")} for annotation: ${t.id}`) };
|
|
478
491
|
}
|
|
479
492
|
}
|
|
480
493
|
return { parsed: c };
|
|
481
|
-
},
|
|
494
|
+
}, ae = (t) => {
|
|
482
495
|
const e = t.id || st(), {
|
|
483
496
|
creator: n,
|
|
484
497
|
created: r,
|
|
485
498
|
modified: o,
|
|
486
499
|
body: s,
|
|
487
500
|
...i
|
|
488
|
-
} = t, c = pt(s, e), l =
|
|
501
|
+
} = t, c = pt(s, e), l = ie(t);
|
|
489
502
|
return "error" in l ? { error: l.error } : {
|
|
490
503
|
parsed: {
|
|
491
504
|
...i,
|
|
@@ -494,20 +507,20 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
494
507
|
target: l.parsed
|
|
495
508
|
}
|
|
496
509
|
};
|
|
497
|
-
},
|
|
510
|
+
}, ce = (t, e, n) => {
|
|
498
511
|
const { bodies: r, target: o, ...s } = t, {
|
|
499
512
|
selector: i,
|
|
500
513
|
creator: c,
|
|
501
514
|
created: l,
|
|
502
|
-
updated:
|
|
515
|
+
updated: f,
|
|
503
516
|
...p
|
|
504
|
-
} = o,
|
|
517
|
+
} = o, u = i.map((g) => {
|
|
505
518
|
const { id: d, quote: L, start: w, end: x, range: R } = g, C = {
|
|
506
519
|
type: "TextQuoteSelector",
|
|
507
520
|
exact: L
|
|
508
521
|
};
|
|
509
522
|
if (n) {
|
|
510
|
-
const { prefix: E, suffix: a } =
|
|
523
|
+
const { prefix: E, suffix: a } = Pt(R, n);
|
|
511
524
|
C.prefix = E, C.suffix = a;
|
|
512
525
|
}
|
|
513
526
|
const N = {
|
|
@@ -532,15 +545,15 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
532
545
|
body: mt(t.bodies),
|
|
533
546
|
creator: c,
|
|
534
547
|
created: l == null ? void 0 : l.toISOString(),
|
|
535
|
-
modified:
|
|
536
|
-
target:
|
|
548
|
+
modified: f == null ? void 0 : f.toISOString(),
|
|
549
|
+
target: u
|
|
537
550
|
};
|
|
538
|
-
},
|
|
551
|
+
}, le = (t, e, n, r) => {
|
|
539
552
|
const o = new xt(), s = /* @__PURE__ */ new Map(), i = Tt(), c = (a, m) => {
|
|
540
553
|
const b = a.selector.flatMap((S) => {
|
|
541
554
|
const A = P([S]) ? S.range : at(S, e).range;
|
|
542
|
-
return
|
|
543
|
-
}), h =
|
|
555
|
+
return It(A);
|
|
556
|
+
}), h = Ft(b, n, r).map((S) => Wt(S, m));
|
|
544
557
|
return h.map((S) => {
|
|
545
558
|
const { x: A, y: T, width: B, height: y } = S;
|
|
546
559
|
return {
|
|
@@ -554,18 +567,18 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
554
567
|
}
|
|
555
568
|
};
|
|
556
569
|
});
|
|
557
|
-
}, l = () => [...s.values()],
|
|
570
|
+
}, l = () => [...s.values()], f = () => {
|
|
558
571
|
o.clear(), s.clear();
|
|
559
572
|
}, p = (a) => {
|
|
560
573
|
const m = c(a, e.getBoundingClientRect());
|
|
561
574
|
m.length !== 0 && (m.forEach((b) => o.insert(b)), s.set(a.annotation, m));
|
|
562
|
-
},
|
|
575
|
+
}, u = (a) => {
|
|
563
576
|
const m = s.get(a.annotation);
|
|
564
577
|
m && (m.forEach((b) => o.remove(b)), s.delete(a.annotation));
|
|
565
578
|
}, g = (a) => {
|
|
566
|
-
|
|
579
|
+
u(a), p(a);
|
|
567
580
|
}, d = (a, m = !0) => {
|
|
568
|
-
m &&
|
|
581
|
+
m && f();
|
|
569
582
|
const b = e.getBoundingClientRect(), h = a.map((A) => ({ target: A, rects: c(A, b) }));
|
|
570
583
|
h.forEach(({ target: A, rects: T }) => {
|
|
571
584
|
T.length > 0 && s.set(A.annotation, T);
|
|
@@ -596,7 +609,7 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
596
609
|
};
|
|
597
610
|
return {
|
|
598
611
|
all: l,
|
|
599
|
-
clear:
|
|
612
|
+
clear: f,
|
|
600
613
|
getAt: L,
|
|
601
614
|
getAnnotationBounds: w,
|
|
602
615
|
getAnnotationRects: x,
|
|
@@ -611,21 +624,21 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
611
624
|
recalculate: () => {
|
|
612
625
|
d(t.all().map((a) => a.target), !0), i.emit("recalculate");
|
|
613
626
|
},
|
|
614
|
-
remove:
|
|
627
|
+
remove: u,
|
|
615
628
|
set: d,
|
|
616
629
|
size: () => o.all().length,
|
|
617
630
|
update: g,
|
|
618
631
|
on: (a, m) => i.on(a, m)
|
|
619
632
|
};
|
|
620
|
-
},
|
|
633
|
+
}, de = (t, e) => {
|
|
621
634
|
var C, N;
|
|
622
|
-
const n = bt(), r =
|
|
635
|
+
const n = bt(), r = le(n, t, (C = e.mergeHighlights) == null ? void 0 : C.horizontalTolerance, (N = e.mergeHighlights) == null ? void 0 : N.verticalTolerance), o = yt(n, e.userSelectAction, e.adapter), s = St(n), i = Ct(), c = (E, a = K.LOCAL) => {
|
|
623
636
|
const m = G(E, t), b = P(m.target.selector);
|
|
624
637
|
return b && n.addAnnotation(m, a), b;
|
|
625
638
|
}, l = (E, a = !0, m = K.LOCAL) => {
|
|
626
639
|
const b = E.map((S) => G(S, t)), h = b.filter((S) => !P(S.target.selector));
|
|
627
640
|
return n.bulkAddAnnotations(b, a, m), h;
|
|
628
|
-
},
|
|
641
|
+
}, f = (E, a = K.LOCAL) => {
|
|
629
642
|
const m = E.map((h) => G(h, t)), b = m.filter((h) => !P(h.target.selector));
|
|
630
643
|
return m.forEach((h) => {
|
|
631
644
|
n.getAnnotation(h.id) ? n.updateAnnotation(h, a) : n.addAnnotation(h, a);
|
|
@@ -633,7 +646,7 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
633
646
|
}, p = (E, a = K.LOCAL) => {
|
|
634
647
|
const m = q(E, t);
|
|
635
648
|
n.updateTarget(m, a);
|
|
636
|
-
},
|
|
649
|
+
}, u = (E, a = K.LOCAL) => {
|
|
637
650
|
const m = E.map((b) => q(b, t));
|
|
638
651
|
n.bulkUpdateTargets(m, a);
|
|
639
652
|
};
|
|
@@ -651,8 +664,8 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
651
664
|
...n,
|
|
652
665
|
addAnnotation: c,
|
|
653
666
|
bulkAddAnnotations: l,
|
|
654
|
-
bulkUpdateTargets:
|
|
655
|
-
bulkUpsertAnnotations:
|
|
667
|
+
bulkUpdateTargets: u,
|
|
668
|
+
bulkUpsertAnnotations: f,
|
|
656
669
|
getAnnotationBounds: d,
|
|
657
670
|
getAnnotationRects: w,
|
|
658
671
|
getIntersecting: L,
|
|
@@ -665,30 +678,30 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
665
678
|
hover: s,
|
|
666
679
|
viewport: i
|
|
667
680
|
};
|
|
668
|
-
},
|
|
681
|
+
}, fe = () => {
|
|
669
682
|
const t = document.createElement("canvas");
|
|
670
683
|
t.width = 2 * window.innerWidth, t.height = 2 * window.innerHeight, t.className = "r6o-presence-layer";
|
|
671
684
|
const e = t.getContext("2d");
|
|
672
685
|
return e.scale(2, 2), e.translate(0.5, 0.5), t;
|
|
673
|
-
},
|
|
674
|
-
const n =
|
|
686
|
+
}, ue = (t, e = {}) => {
|
|
687
|
+
const n = fe(), r = n.getContext("2d");
|
|
675
688
|
document.body.appendChild(n);
|
|
676
|
-
const o = /* @__PURE__ */ new Map(), s = (p) => Array.from(o.entries()).filter(([
|
|
677
|
-
return t.on("selectionChange", (p,
|
|
678
|
-
s(p).forEach((d) => o.delete(d)),
|
|
689
|
+
const o = /* @__PURE__ */ new Map(), s = (p) => Array.from(o.entries()).filter(([u, g]) => g.presenceKey === p.presenceKey).map(([u, g]) => u);
|
|
690
|
+
return t.on("selectionChange", (p, u) => {
|
|
691
|
+
s(p).forEach((d) => o.delete(d)), u && u.forEach((d) => o.set(d, p));
|
|
679
692
|
}), {
|
|
680
693
|
clear: () => {
|
|
681
|
-
const { width: p, height:
|
|
682
|
-
r.clearRect(-0.5, -0.5, p + 1,
|
|
694
|
+
const { width: p, height: u } = n;
|
|
695
|
+
r.clearRect(-0.5, -0.5, p + 1, u + 1);
|
|
683
696
|
},
|
|
684
697
|
destroy: () => {
|
|
685
698
|
n.remove();
|
|
686
699
|
},
|
|
687
|
-
paint: (p,
|
|
700
|
+
paint: (p, u, g) => {
|
|
688
701
|
e.font && (r.font = e.font);
|
|
689
702
|
const d = o.get(p.annotation.id);
|
|
690
703
|
if (d) {
|
|
691
|
-
const { height: L } = p.rects[0], w = p.rects[0].x +
|
|
704
|
+
const { height: L } = p.rects[0], w = p.rects[0].x + u.left, x = p.rects[0].y + u.top;
|
|
692
705
|
r.fillStyle = d.appearance.color, r.fillRect(w - 2, x - 2.5, 2, L + 5);
|
|
693
706
|
const R = r.measureText(d.appearance.label), C = R.width + 6, N = R.actualBoundingBoxAscent + R.actualBoundingBoxDescent + 8, E = R.fontBoundingBoxAscent ? 8 : 6.5;
|
|
694
707
|
return r.fillRect(w - 2, x - 2.5 - N, C, N), r.fillStyle = "#fff", r.fillText(d.appearance.label, w + 1, x - E), {
|
|
@@ -703,20 +716,20 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
703
716
|
p.scale(2, 2), p.translate(0.5, 0.5);
|
|
704
717
|
}
|
|
705
718
|
};
|
|
706
|
-
}, nt = 300, lt = ["up", "down", "left", "right"], dt = kt ? "⌘+a" : "ctrl+a",
|
|
719
|
+
}, nt = 300, lt = ["up", "down", "left", "right"], dt = kt ? "⌘+a" : "ctrl+a", ge = [
|
|
707
720
|
...lt.map((t) => `shift+${t}`),
|
|
708
721
|
dt
|
|
709
|
-
],
|
|
722
|
+
], me = (t, e, n) => {
|
|
710
723
|
const { store: r, selection: o } = e;
|
|
711
724
|
let s;
|
|
712
725
|
const {
|
|
713
726
|
annotatingEnabled: i,
|
|
714
727
|
offsetReferenceSelector: c,
|
|
715
728
|
selectionMode: l,
|
|
716
|
-
dismissOnNotAnnotatable:
|
|
729
|
+
dismissOnNotAnnotatable: f = "NEVER"
|
|
717
730
|
} = n, p = (y) => s = y;
|
|
718
|
-
let
|
|
719
|
-
const g = (y) =>
|
|
731
|
+
let u;
|
|
732
|
+
const g = (y) => u = y;
|
|
720
733
|
let d, L, w, x = i;
|
|
721
734
|
const R = (y) => {
|
|
722
735
|
x = y, N.clear(), y || (d = void 0, L = void 0, w = void 0);
|
|
@@ -742,15 +755,15 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
742
755
|
r.getAnnotation(d.annotation) && (o.clear(), r.deleteAnnotation(d.annotation));
|
|
743
756
|
return;
|
|
744
757
|
}
|
|
745
|
-
const M = I.map((k) =>
|
|
746
|
-
if (M.every((k) =>
|
|
747
|
-
const O = M.flatMap((k) =>
|
|
758
|
+
const M = I.map((k) => $t(k, t));
|
|
759
|
+
if (M.every((k) => _t(k))) return;
|
|
760
|
+
const O = M.flatMap((k) => Ht(t, k.cloneRange()));
|
|
748
761
|
(O.length > 0 && !d || O.length !== d.selector.length || O.some((k, U) => {
|
|
749
762
|
var F;
|
|
750
763
|
return k.toString() !== ((F = d.selector[U]) == null ? void 0 : F.quote);
|
|
751
764
|
})) && (d = {
|
|
752
765
|
...d,
|
|
753
|
-
selector: O.map((k) =>
|
|
766
|
+
selector: O.map((k) => Kt(k, t, c)),
|
|
754
767
|
updated: /* @__PURE__ */ new Date()
|
|
755
768
|
}, r.getAnnotation(d.annotation) ? r.updateTarget(d, K.LOCAL) : o.clear());
|
|
756
769
|
}, 10), E = (y) => {
|
|
@@ -760,14 +773,14 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
760
773
|
const v = Q(y), I = () => {
|
|
761
774
|
const { x: M, y: O } = t.getBoundingClientRect();
|
|
762
775
|
if (z(t, v.target)) {
|
|
763
|
-
(typeof
|
|
776
|
+
(typeof f == "function" ? f(v, t) : f === "ALWAYS") && o.clear();
|
|
764
777
|
return;
|
|
765
778
|
}
|
|
766
779
|
const H = v.target instanceof Node && t.contains(v.target) && r.getAt(
|
|
767
780
|
v.clientX - M,
|
|
768
781
|
v.clientY - O,
|
|
769
782
|
l === "all",
|
|
770
|
-
|
|
783
|
+
u
|
|
771
784
|
);
|
|
772
785
|
if (H) {
|
|
773
786
|
const { selected: k } = o, U = new Set(k.map((V) => V.id)), F = Array.isArray(H) ? H.map((V) => V.id) : [H.id];
|
|
@@ -804,7 +817,7 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
804
817
|
}, 100);
|
|
805
818
|
document.addEventListener("selectionchange", v), C();
|
|
806
819
|
};
|
|
807
|
-
Y(
|
|
820
|
+
Y(ge.join(","), { element: t, keydown: !0, keyup: !1 }, (y) => {
|
|
808
821
|
y.repeat || (w = X(y));
|
|
809
822
|
}), Y(dt, { keydown: !0, keyup: !1 }, (y) => {
|
|
810
823
|
w = X(y), S(y);
|
|
@@ -834,54 +847,54 @@ const rt = "not-annotatable", W = `.${rt}`, z = (t, e) => {
|
|
|
834
847
|
setUser: p,
|
|
835
848
|
setAnnotatingEnabled: R
|
|
836
849
|
};
|
|
837
|
-
},
|
|
850
|
+
}, pe = (t, e) => ({
|
|
838
851
|
...t,
|
|
839
852
|
annotatingEnabled: t.annotatingEnabled ?? e.annotatingEnabled,
|
|
840
853
|
user: t.user || e.user
|
|
841
854
|
}), ot = "SPANS", Be = (t, e = {}) => {
|
|
842
855
|
Nt(t), Bt(t);
|
|
843
|
-
const n =
|
|
856
|
+
const n = pe(e, {
|
|
844
857
|
annotatingEnabled: !0,
|
|
845
858
|
user: Et()
|
|
846
|
-
}), r =
|
|
847
|
-
let
|
|
848
|
-
const p = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : ot : n.renderer || ot,
|
|
849
|
-
if (!
|
|
859
|
+
}), r = de(t, n), { selection: o, viewport: s } = r, i = r.store, c = wt(i), l = At(r, c, n.adapter);
|
|
860
|
+
let f = n.user;
|
|
861
|
+
const p = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : ot : n.renderer || ot, u = p === "SPANS" ? se(t, r, s) : p === "CSS_HIGHLIGHTS" ? te(t, r, s) : p === "CANVAS" ? Qt(t, r, s) : void 0;
|
|
862
|
+
if (!u)
|
|
850
863
|
throw `Unknown renderer implementation: ${p}`;
|
|
851
|
-
console.debug(`Using ${p} renderer`), n.style &&
|
|
852
|
-
const g =
|
|
853
|
-
g.setUser(
|
|
854
|
-
const d = vt(r, c, n.adapter), L = () =>
|
|
864
|
+
console.debug(`Using ${p} renderer`), n.style && u.setStyle(n.style);
|
|
865
|
+
const g = me(t, r, n);
|
|
866
|
+
g.setUser(f), g.setAnnotatingEnabled(n.annotatingEnabled);
|
|
867
|
+
const d = vt(r, c, n.adapter), L = () => f, w = (a) => {
|
|
855
868
|
g.setAnnotatingEnabled(
|
|
856
869
|
a === void 0 ? !0 : a
|
|
857
870
|
);
|
|
858
871
|
}, x = (a) => {
|
|
859
|
-
|
|
872
|
+
u.setFilter(a), g.setFilter(a);
|
|
860
873
|
}, R = (a) => {
|
|
861
|
-
|
|
874
|
+
f = a, g.setUser(a);
|
|
862
875
|
}, C = (a) => {
|
|
863
|
-
a && (
|
|
876
|
+
a && (u.setPainter(ue(a, n.presence)), a.on("selectionChange", () => u.redraw()));
|
|
864
877
|
}, N = (a) => {
|
|
865
878
|
a ? o.setSelected(a) : o.clear();
|
|
866
879
|
};
|
|
867
880
|
return {
|
|
868
881
|
...d,
|
|
869
882
|
destroy: () => {
|
|
870
|
-
|
|
883
|
+
u.destroy(), g.destroy(), c.destroy();
|
|
871
884
|
},
|
|
872
885
|
element: t,
|
|
873
886
|
getUser: L,
|
|
874
887
|
setAnnotatingEnabled: w,
|
|
875
888
|
setFilter: x,
|
|
876
|
-
setStyle:
|
|
877
|
-
redraw:
|
|
889
|
+
setStyle: u.setStyle.bind(u),
|
|
890
|
+
redraw: u.redraw.bind(u),
|
|
878
891
|
setUser: R,
|
|
879
892
|
setSelected: N,
|
|
880
893
|
setPresenceProvider: C,
|
|
881
|
-
setVisible:
|
|
894
|
+
setVisible: u.setVisible.bind(u),
|
|
882
895
|
on: l.on,
|
|
883
896
|
off: l.off,
|
|
884
|
-
scrollIntoView:
|
|
897
|
+
scrollIntoView: Vt(t, i),
|
|
885
898
|
state: r
|
|
886
899
|
};
|
|
887
900
|
};
|
|
@@ -897,39 +910,39 @@ export {
|
|
|
897
910
|
X as cloneKeyboardEvent,
|
|
898
911
|
Q as clonePointerEvent,
|
|
899
912
|
_e as createBody,
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
913
|
+
Qt as createCanvasRenderer,
|
|
914
|
+
te as createHighlightsRenderer,
|
|
915
|
+
ue as createPresencePainter,
|
|
916
|
+
Jt as createRenderer,
|
|
917
|
+
me as createSelectionHandler,
|
|
918
|
+
se as createSpansRenderer,
|
|
906
919
|
Be as createTextAnnotator,
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
920
|
+
de as createTextAnnotatorState,
|
|
921
|
+
pe as fillDefaults,
|
|
922
|
+
It as getHighlightClientRects,
|
|
923
|
+
Pt as getQuoteContext,
|
|
911
924
|
J as getRangeAnnotatableContents,
|
|
912
925
|
kt as isMac,
|
|
913
|
-
|
|
926
|
+
Le as isNodeWhitespaceOrEmpty,
|
|
914
927
|
z as isNotAnnotatable,
|
|
915
928
|
Lt as isRangeAnnotatable,
|
|
916
|
-
|
|
929
|
+
_t as isRangeWhitespaceOrEmpty,
|
|
917
930
|
P as isRevived,
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
931
|
+
Ft as mergeClientRects,
|
|
932
|
+
Yt as paint,
|
|
933
|
+
ae as parseW3CTextAnnotation,
|
|
921
934
|
Bt as programmaticallyFocusable,
|
|
922
|
-
|
|
935
|
+
Kt as rangeToSelector,
|
|
923
936
|
G as reviveAnnotation,
|
|
924
937
|
at as reviveSelector,
|
|
925
938
|
q as reviveTarget,
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
939
|
+
Vt as scrollIntoView,
|
|
940
|
+
ce as serializeW3CTextAnnotation,
|
|
941
|
+
Ht as splitAnnotatableRanges,
|
|
929
942
|
Ne as toDomRectList,
|
|
930
|
-
|
|
943
|
+
Wt as toParentBounds,
|
|
931
944
|
Oe as toViewportBounds,
|
|
932
|
-
|
|
945
|
+
$t as trimRangeToContainer,
|
|
933
946
|
it as whitespaceOrEmptyRegex
|
|
934
947
|
};
|
|
935
948
|
//# sourceMappingURL=text-annotator.es.js.map
|