@soomo/text-annotator 3.2.0-staging.8 → 3.2.0-staging.9
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.
|
@@ -2,21 +2,21 @@ import Q from "debounce";
|
|
|
2
2
|
import { colord as nt } from "colord";
|
|
3
3
|
import { dequal as dt } from "dequal/lite";
|
|
4
4
|
import { v4 as ot } from "uuid";
|
|
5
|
-
import { serializeW3CBodies as ut, parseW3CBodies as ft, parseW3CUser as gt, createStore as mt, createSelectionState as pt, createHoverState as ht, createViewportState as yt, Origin as
|
|
5
|
+
import { serializeW3CBodies as ut, parseW3CBodies as ft, parseW3CUser as gt, createStore as mt, createSelectionState as pt, createHoverState as ht, createViewportState as yt, Origin as _, createAnonymousGuest as bt, createUndoStack as St, createLifecycleObserver as Ct, createBaseAnnotator as Et } from "@annotorious/core";
|
|
6
6
|
import { Origin as Re, UserSelectAction as Le, createBody as ke } from "@annotorious/core";
|
|
7
7
|
import wt from "rbush";
|
|
8
8
|
import { createNanoEvents as At } from "nanoevents";
|
|
9
|
-
import
|
|
9
|
+
import V from "hotkeys-js";
|
|
10
10
|
import { poll as vt } from "poll";
|
|
11
|
-
const st = "not-annotatable",
|
|
11
|
+
const st = "not-annotatable", D = `.${st}`, W = (t) => {
|
|
12
12
|
var e;
|
|
13
|
-
return !!(t instanceof HTMLElement ? t.closest(
|
|
13
|
+
return !!(t instanceof HTMLElement ? t.closest(D) : (e = t.parentElement) == null ? void 0 : e.closest(D));
|
|
14
14
|
}, xt = (t) => {
|
|
15
15
|
const n = t.commonAncestorContainer;
|
|
16
|
-
return !
|
|
16
|
+
return !W(n);
|
|
17
17
|
}, Tt = (t) => t.addEventListener("click", (n) => {
|
|
18
18
|
// Allow clicks within not-annotatable elements
|
|
19
|
-
!n.target.closest(
|
|
19
|
+
!n.target.closest(D) && !n.target.closest("a") && n.preventDefault();
|
|
20
20
|
}), Rt = typeof navigator < "u" && // @ts-ignore
|
|
21
21
|
/mac/i.test(navigator.userAgentData ? navigator.userAgentData.platform : navigator.platform), Lt = (t) => {
|
|
22
22
|
!t.hasAttribute("tabindex") && t.tabIndex < 0 && t.setAttribute("tabindex", "-1"), t.classList.add("no-focus-outline");
|
|
@@ -24,7 +24,7 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
|
|
|
24
24
|
const n = document.createNodeIterator(
|
|
25
25
|
t.commonAncestorContainer,
|
|
26
26
|
NodeFilter.SHOW_ELEMENT,
|
|
27
|
-
(o) => o instanceof HTMLElement && o.classList.contains(st) && !o.parentElement.closest(
|
|
27
|
+
(o) => o instanceof HTMLElement && o.classList.contains(st) && !o.parentElement.closest(D) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
|
|
28
28
|
);
|
|
29
29
|
let e;
|
|
30
30
|
for (; e = n.nextNode(); )
|
|
@@ -44,7 +44,7 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
|
|
|
44
44
|
return n.length > 0 ? n : [t];
|
|
45
45
|
}, G = (t) => {
|
|
46
46
|
const n = t.cloneContents();
|
|
47
|
-
return n.querySelectorAll(
|
|
47
|
+
return n.querySelectorAll(D).forEach((e) => e.remove()), n;
|
|
48
48
|
}, Nt = (t, n, e = 10, o) => {
|
|
49
49
|
const s = o ? t.startContainer.parentElement.closest(o) : n, i = document.createRange();
|
|
50
50
|
i.setStart(s, 0), i.setEnd(t.startContainer, t.startOffset);
|
|
@@ -55,7 +55,7 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
|
|
|
55
55
|
prefix: a.substring(a.length - e),
|
|
56
56
|
suffix: u.substring(0, e)
|
|
57
57
|
};
|
|
58
|
-
},
|
|
58
|
+
}, M = (t) => t.every((n) => n.range instanceof Range && !n.range.collapsed), Ot = /^\s*$/, It = (t) => Ot.test(t.toString()), Mt = (t, n) => {
|
|
59
59
|
const e = (i) => Math.round(i * 10) / 10, o = {
|
|
60
60
|
top: e(t.top),
|
|
61
61
|
bottom: e(t.bottom),
|
|
@@ -121,17 +121,17 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
|
|
|
121
121
|
n,
|
|
122
122
|
NodeFilter.SHOW_TEXT,
|
|
123
123
|
(r) => {
|
|
124
|
-
var
|
|
125
|
-
return (
|
|
124
|
+
var A;
|
|
125
|
+
return (A = r.parentElement) != null && A.closest(D) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
|
|
126
126
|
}
|
|
127
127
|
);
|
|
128
128
|
let a = 0;
|
|
129
129
|
const c = document.createRange();
|
|
130
130
|
let u = i.nextNode();
|
|
131
131
|
u === null && console.error("Could not revive annotation target. Content missing.");
|
|
132
|
-
let
|
|
132
|
+
let b = !s;
|
|
133
133
|
for (; u !== null; ) {
|
|
134
|
-
if (
|
|
134
|
+
if (b || (b = typeof (s == null ? void 0 : s.contains) == "function" ? s.contains(u) : !1), b) {
|
|
135
135
|
const r = ((y = u.textContent) == null ? void 0 : y.length) || 0;
|
|
136
136
|
if (a + r > e) {
|
|
137
137
|
c.setStart(u, e - a);
|
|
@@ -153,10 +153,10 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
|
|
|
153
153
|
...t,
|
|
154
154
|
range: c
|
|
155
155
|
};
|
|
156
|
-
},
|
|
156
|
+
}, X = (t, n) => M(t.selector) ? t : {
|
|
157
157
|
...t,
|
|
158
158
|
selector: t.selector.map((e) => e.range instanceof Range && !e.range.collapsed ? e : rt(e, n))
|
|
159
|
-
}, q = (t, n) =>
|
|
159
|
+
}, q = (t, n) => M(t.target.selector) ? t : { ...t, target: X(t.target, n) }, it = (t, n) => {
|
|
160
160
|
if (t.isEqualNode(n))
|
|
161
161
|
return !0;
|
|
162
162
|
for (let e of t.childNodes)
|
|
@@ -195,7 +195,7 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
|
|
|
195
195
|
pointerId: t.pointerId,
|
|
196
196
|
pointerType: t.pointerType,
|
|
197
197
|
timeStamp: t.timeStamp
|
|
198
|
-
}),
|
|
198
|
+
}), Y = (t) => ({
|
|
199
199
|
...t,
|
|
200
200
|
type: t.type,
|
|
201
201
|
key: t.key,
|
|
@@ -223,8 +223,8 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
|
|
|
223
223
|
const { overflowY: n } = window.getComputedStyle(t);
|
|
224
224
|
return n !== "visible" && n !== "hidden" && t.scrollHeight > t.clientHeight ? t : at(t.parentElement);
|
|
225
225
|
}, J = (t, n, e) => {
|
|
226
|
-
const o = e.getBoundingClientRect(), s = e.clientHeight, i = e.clientWidth, a = n.selector[0].range.getBoundingClientRect(), { width: c, height: u } = t.getAnnotationBounds(n.annotation),
|
|
227
|
-
e.scroll({ top:
|
|
226
|
+
const o = e.getBoundingClientRect(), s = e.clientHeight, i = e.clientWidth, a = n.selector[0].range.getBoundingClientRect(), { width: c, height: u } = t.getAnnotationBounds(n.annotation), b = a.top - o.top, y = a.left - o.left, g = e.parentElement ? e.scrollTop : 0, r = e.parentElement ? e.scrollLeft : 0, A = b + g - (s - u) / 2, S = y + r - (i - c) / 2;
|
|
227
|
+
e.scroll({ top: A, left: S, behavior: "smooth" });
|
|
228
228
|
}, Ft = (t, n) => (e, o) => {
|
|
229
229
|
const s = typeof e == "string" ? e : e.id, i = o ? typeof o == "string" ? document.getElementById(o) : o : at(t);
|
|
230
230
|
if (!i)
|
|
@@ -235,17 +235,17 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
|
|
|
235
235
|
const { range: c } = a.target.selector[0];
|
|
236
236
|
if (c && !c.collapsed)
|
|
237
237
|
return J(n, a.target, i), !0;
|
|
238
|
-
const u =
|
|
239
|
-
return
|
|
240
|
-
},
|
|
238
|
+
const u = X(a.target, t), { range: b } = u.selector[0];
|
|
239
|
+
return b && !b.collapsed ? (J(n, u, i), !0) : !1;
|
|
240
|
+
}, K = {
|
|
241
241
|
fill: "rgb(0, 128, 255)",
|
|
242
242
|
fillOpacity: 0.18
|
|
243
|
-
},
|
|
243
|
+
}, z = {
|
|
244
244
|
fill: "rgb(0, 128, 255)",
|
|
245
245
|
fillOpacity: 0.45
|
|
246
246
|
}, Ut = (t, n, e, o, s) => {
|
|
247
247
|
var a, c;
|
|
248
|
-
const i = e ? typeof e == "function" ? e(t.annotation, t.state, s) || ((a = t.state) != null && a.selected ?
|
|
248
|
+
const i = e ? typeof e == "function" ? e(t.annotation, t.state, s) || ((a = t.state) != null && a.selected ? z : K) : e : (c = t.state) != null && c.selected ? z : K;
|
|
249
249
|
return o && o.paint(t, n) || i;
|
|
250
250
|
}, Wt = (t) => {
|
|
251
251
|
const { top: n, left: e } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: s } = window, i = -e, a = -n, c = o - e, u = s - n;
|
|
@@ -258,50 +258,50 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
|
|
|
258
258
|
};
|
|
259
259
|
}, Z = (t, n, e, o) => {
|
|
260
260
|
const { store: s, selection: i, hover: a } = n;
|
|
261
|
-
let c, u,
|
|
262
|
-
const y = Vt(e), g = (
|
|
263
|
-
const { x:
|
|
264
|
-
|
|
261
|
+
let c, u, b;
|
|
262
|
+
const y = Vt(e), g = (E) => {
|
|
263
|
+
const { x: L, y: I } = t.getBoundingClientRect(), p = s.getAt(E.clientX - L, E.clientY - I, !1, u);
|
|
264
|
+
p ? a.current !== p.id && (t.classList.add("hovered"), a.set(p.id)) : a.current && (t.classList.remove("hovered"), a.set(null));
|
|
265
265
|
};
|
|
266
266
|
t.addEventListener("pointermove", g);
|
|
267
|
-
const r = (
|
|
268
|
-
|
|
269
|
-
const
|
|
270
|
-
const
|
|
267
|
+
const r = (E = !1) => {
|
|
268
|
+
b && b.clear();
|
|
269
|
+
const L = Wt(t), { minX: I, minY: p, maxX: R, maxY: k } = L, B = u ? s.getIntersecting(I, p, R, k).filter(({ annotation: N }) => u(N)) : s.getIntersecting(I, p, R, k), H = i.selected.map(({ id: N }) => N), O = B.map(({ annotation: N, rects: P }) => {
|
|
270
|
+
const $ = H.includes(N.id), F = N.id === a.current;
|
|
271
271
|
return {
|
|
272
|
-
annotation:
|
|
273
|
-
rects:
|
|
274
|
-
state: { selected:
|
|
272
|
+
annotation: N,
|
|
273
|
+
rects: P,
|
|
274
|
+
state: { selected: $, hovered: F }
|
|
275
275
|
};
|
|
276
276
|
});
|
|
277
|
-
o.redraw(
|
|
278
|
-
},
|
|
279
|
-
|
|
280
|
-
},
|
|
281
|
-
c =
|
|
282
|
-
}, T = (
|
|
283
|
-
u =
|
|
277
|
+
o.redraw(O, L, c, b, E), setTimeout(() => y(B.map(({ annotation: N }) => N)), 1);
|
|
278
|
+
}, A = (E) => {
|
|
279
|
+
b = E, r();
|
|
280
|
+
}, S = (E) => {
|
|
281
|
+
c = E, r();
|
|
282
|
+
}, T = (E) => {
|
|
283
|
+
u = E, r(!1);
|
|
284
284
|
}, x = () => r();
|
|
285
285
|
s.observe(x);
|
|
286
|
-
const
|
|
287
|
-
document.addEventListener("scroll",
|
|
288
|
-
const
|
|
289
|
-
s.recalculatePositions(),
|
|
286
|
+
const C = i.subscribe(() => r()), m = a.subscribe(() => r()), d = () => r(!0);
|
|
287
|
+
document.addEventListener("scroll", d, { capture: !0, passive: !0 });
|
|
288
|
+
const f = Q(() => {
|
|
289
|
+
s.recalculatePositions(), b == null || b.reset(), r();
|
|
290
290
|
}, 10);
|
|
291
|
-
window.addEventListener("resize",
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
const
|
|
295
|
-
|
|
291
|
+
window.addEventListener("resize", f);
|
|
292
|
+
const l = new ResizeObserver(f);
|
|
293
|
+
l.observe(t);
|
|
294
|
+
const h = { attributes: !0, childList: !0, subtree: !0 }, w = new MutationObserver((E) => {
|
|
295
|
+
E.every((I) => I.target === t || t.contains(I.target)) || r(!0);
|
|
296
296
|
});
|
|
297
|
-
return
|
|
297
|
+
return w.observe(document.body, h), {
|
|
298
298
|
destroy: () => {
|
|
299
|
-
t.removeEventListener("pointermove", g), o.destroy(), s.unobserve(x),
|
|
299
|
+
t.removeEventListener("pointermove", g), o.destroy(), s.unobserve(x), C(), m(), document.removeEventListener("scroll", d), f.clear(), window.removeEventListener("resize", f), l.disconnect(), w.disconnect();
|
|
300
300
|
},
|
|
301
301
|
redraw: r,
|
|
302
|
-
setStyle:
|
|
302
|
+
setStyle: S,
|
|
303
303
|
setFilter: T,
|
|
304
|
-
setPainter:
|
|
304
|
+
setPainter: A,
|
|
305
305
|
setVisible: o.setVisible
|
|
306
306
|
};
|
|
307
307
|
}, Yt = () => {
|
|
@@ -313,28 +313,28 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
|
|
|
313
313
|
t.classList.add("r6o-annotatable");
|
|
314
314
|
const n = Yt(), e = n.getContext("2d");
|
|
315
315
|
document.body.appendChild(n);
|
|
316
|
-
const o = (c, u,
|
|
316
|
+
const o = (c, u, b, y) => requestAnimationFrame(() => {
|
|
317
317
|
const { width: g, height: r } = n;
|
|
318
318
|
e.clearRect(-0.5, -0.5, g + 1, r + 1), y && y.clear();
|
|
319
|
-
const { top:
|
|
320
|
-
[...c].sort((x,
|
|
321
|
-
const { annotation: { target: { created:
|
|
322
|
-
return
|
|
319
|
+
const { top: A, left: S } = u;
|
|
320
|
+
[...c].sort((x, C) => {
|
|
321
|
+
const { annotation: { target: { created: m } } } = x, { annotation: { target: { created: d } } } = C;
|
|
322
|
+
return m.getTime() - d.getTime();
|
|
323
323
|
}).forEach((x) => {
|
|
324
|
-
var
|
|
325
|
-
const
|
|
326
|
-
x:
|
|
327
|
-
y: h +
|
|
328
|
-
width:
|
|
329
|
-
height:
|
|
324
|
+
var f;
|
|
325
|
+
const C = b ? typeof b == "function" ? b(x.annotation, x.state) : b : (f = x.state) != null && f.selected ? z : K, m = y && y.paint(x, u) || C, d = x.rects.map(({ x: l, y: h, width: w, height: v }) => ({
|
|
326
|
+
x: l + S,
|
|
327
|
+
y: h + A,
|
|
328
|
+
width: w,
|
|
329
|
+
height: v
|
|
330
330
|
}));
|
|
331
|
-
if (e.fillStyle =
|
|
332
|
-
({ x:
|
|
333
|
-
),
|
|
334
|
-
e.globalAlpha = 1, e.strokeStyle =
|
|
335
|
-
const
|
|
336
|
-
|
|
337
|
-
e.beginPath(), e.moveTo(h,
|
|
331
|
+
if (e.fillStyle = m.fill, e.globalAlpha = m.fillOpacity || 1, d.forEach(
|
|
332
|
+
({ x: l, y: h, width: w, height: v }) => e.fillRect(l, h, w, v)
|
|
333
|
+
), m.underlineColor) {
|
|
334
|
+
e.globalAlpha = 1, e.strokeStyle = m.underlineColor, e.lineWidth = m.underlineThickness ?? 1;
|
|
335
|
+
const l = m.underlineOffset ?? 0;
|
|
336
|
+
d.forEach(({ x: h, y: w, width: v, height: E }) => {
|
|
337
|
+
e.beginPath(), e.moveTo(h, w + E + l), e.lineTo(h + v, w + E + l), e.stroke();
|
|
338
338
|
});
|
|
339
339
|
}
|
|
340
340
|
});
|
|
@@ -349,7 +349,7 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
|
|
|
349
349
|
redraw: o
|
|
350
350
|
};
|
|
351
351
|
}, qt = (t, n, e) => Z(t, n, e, zt(t)), jt = (t) => [
|
|
352
|
-
`background-color:${nt((t == null ? void 0 : t.fill) ||
|
|
352
|
+
`background-color:${nt((t == null ? void 0 : t.fill) || K.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? K.fillOpacity : t.fillOpacity).toHex()}`,
|
|
353
353
|
t != null && t.underlineThickness ? "text-decoration:underline" : void 0,
|
|
354
354
|
t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
|
|
355
355
|
t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
|
|
@@ -367,18 +367,18 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
|
|
|
367
367
|
},
|
|
368
368
|
redraw: (i, a, c, u) => {
|
|
369
369
|
u && u.clear();
|
|
370
|
-
const
|
|
371
|
-
Array.from(n).filter((g) => !
|
|
370
|
+
const b = new Set(i.map((g) => g.annotation.id));
|
|
371
|
+
Array.from(n).filter((g) => !b.has(g));
|
|
372
372
|
const y = i.map((g) => {
|
|
373
|
-
var
|
|
374
|
-
const r = c ? typeof c == "function" ? c(g.annotation, g.state) : c : (
|
|
375
|
-
return `::highlight(_${g.annotation.id}) { ${jt(
|
|
373
|
+
var S;
|
|
374
|
+
const r = c ? typeof c == "function" ? c(g.annotation, g.state) : c : (S = g.state) != null && S.selected ? z : K, A = u && u.paint(g, a) || r;
|
|
375
|
+
return `::highlight(_${g.annotation.id}) { ${jt(A)} }`;
|
|
376
376
|
});
|
|
377
377
|
t.innerHTML = y.join(`
|
|
378
378
|
`), CSS.highlights.clear(), i.forEach(({ annotation: g }) => {
|
|
379
|
-
const r = g.target.selector.map((
|
|
380
|
-
CSS.highlights.set(`_${g.id}`,
|
|
381
|
-
}), n =
|
|
379
|
+
const r = g.target.selector.map((S) => S.range), A = new Highlight(...r);
|
|
380
|
+
CSS.highlights.set(`_${g.id}`, A);
|
|
381
|
+
}), n = b;
|
|
382
382
|
}
|
|
383
383
|
};
|
|
384
384
|
}, Qt = (t, n, e) => Z(t, n, e, Gt()), Zt = (t, n) => {
|
|
@@ -393,18 +393,18 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
|
|
|
393
393
|
destroy: () => {
|
|
394
394
|
n.remove();
|
|
395
395
|
},
|
|
396
|
-
redraw: (a, c, u,
|
|
396
|
+
redraw: (a, c, u, b, y) => {
|
|
397
397
|
const r = !(dt(e, a) && y);
|
|
398
|
-
if (!
|
|
399
|
-
r && (n.innerHTML = ""), [...a].sort((
|
|
400
|
-
const { annotation: { target: { created: x } } } =
|
|
401
|
-
return x &&
|
|
402
|
-
}).forEach((
|
|
403
|
-
|
|
404
|
-
const x = Zt(T, a),
|
|
398
|
+
if (!b && !r) return;
|
|
399
|
+
r && (n.innerHTML = ""), [...a].sort((S, T) => {
|
|
400
|
+
const { annotation: { target: { created: x } } } = S, { annotation: { target: { created: C } } } = T;
|
|
401
|
+
return x && C ? x.getTime() - C.getTime() : 0;
|
|
402
|
+
}).forEach((S) => {
|
|
403
|
+
S.rects.map((T) => {
|
|
404
|
+
const x = Zt(T, a), C = Ut(S, c, u, b, x);
|
|
405
405
|
if (r) {
|
|
406
|
-
const
|
|
407
|
-
|
|
406
|
+
const m = document.createElement("span");
|
|
407
|
+
m.className = "r6o-annotation", m.dataset.annotation = S.annotation.id, m.style.left = `${T.x}px`, m.style.top = `${T.y}px`, m.style.width = `${T.width}px`, m.style.height = `${T.height}px`, m.style.backgroundColor = nt((C == null ? void 0 : C.fill) || K.fill).alpha((C == null ? void 0 : C.fillOpacity) === void 0 ? K.fillOpacity : C.fillOpacity).toHex(), C.underlineStyle && (m.style.borderStyle = C.underlineStyle), C.underlineColor && (m.style.borderColor = C.underlineColor), C.underlineThickness && (m.style.borderBottomWidth = `${C.underlineThickness}px`), C.underlineOffset && (m.style.paddingBottom = `${C.underlineOffset}px`), n.appendChild(m);
|
|
408
408
|
}
|
|
409
409
|
});
|
|
410
410
|
}), e = a;
|
|
@@ -486,29 +486,29 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
|
|
|
486
486
|
selector: a,
|
|
487
487
|
creator: c,
|
|
488
488
|
created: u,
|
|
489
|
-
updated:
|
|
489
|
+
updated: b,
|
|
490
490
|
...y
|
|
491
491
|
} = s, g = a.map((r) => {
|
|
492
|
-
const { id:
|
|
492
|
+
const { id: A, quote: S, start: T, end: x, range: C } = r, m = {
|
|
493
493
|
type: "TextQuoteSelector",
|
|
494
|
-
exact:
|
|
494
|
+
exact: S
|
|
495
495
|
};
|
|
496
496
|
if (e) {
|
|
497
|
-
const { prefix:
|
|
498
|
-
|
|
497
|
+
const { prefix: f, suffix: l } = Nt(C, e);
|
|
498
|
+
m.prefix = f, m.suffix = l;
|
|
499
499
|
}
|
|
500
|
-
const
|
|
500
|
+
const d = {
|
|
501
501
|
type: "TextPositionSelector",
|
|
502
502
|
start: T,
|
|
503
503
|
end: x
|
|
504
504
|
};
|
|
505
505
|
return {
|
|
506
506
|
...y,
|
|
507
|
-
id:
|
|
507
|
+
id: A,
|
|
508
508
|
// @ts-expect-error: `scope` is not part of the core `TextSelector` type
|
|
509
509
|
scope: "scope" in r ? r.scope : void 0,
|
|
510
510
|
source: n,
|
|
511
|
-
selector: [
|
|
511
|
+
selector: [m, d]
|
|
512
512
|
};
|
|
513
513
|
});
|
|
514
514
|
return {
|
|
@@ -519,132 +519,132 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
|
|
|
519
519
|
body: ut(t.bodies),
|
|
520
520
|
creator: c,
|
|
521
521
|
created: u == null ? void 0 : u.toISOString(),
|
|
522
|
-
modified:
|
|
522
|
+
modified: b == null ? void 0 : b.toISOString(),
|
|
523
523
|
target: g
|
|
524
524
|
};
|
|
525
525
|
}, re = (t, n) => {
|
|
526
|
-
const e = new wt(), o = /* @__PURE__ */ new Map(), s = At(), i = (
|
|
527
|
-
const
|
|
528
|
-
const
|
|
529
|
-
return Array.from(
|
|
530
|
-
}), h = Pt(
|
|
531
|
-
return h.map((
|
|
532
|
-
const { x:
|
|
526
|
+
const e = new wt(), o = /* @__PURE__ */ new Map(), s = At(), i = (d, f) => {
|
|
527
|
+
const l = d.selector.flatMap((w) => {
|
|
528
|
+
const v = M([w]) ? w.range : rt(w, n).range;
|
|
529
|
+
return Array.from(v.getClientRects());
|
|
530
|
+
}), h = Pt(l).map((w) => Dt(w, f));
|
|
531
|
+
return h.map((w) => {
|
|
532
|
+
const { x: v, y: E, width: L, height: I } = w;
|
|
533
533
|
return {
|
|
534
|
-
minX:
|
|
535
|
-
minY:
|
|
536
|
-
maxX:
|
|
537
|
-
maxY:
|
|
534
|
+
minX: v,
|
|
535
|
+
minY: E,
|
|
536
|
+
maxX: v + L,
|
|
537
|
+
maxY: E + I,
|
|
538
538
|
annotation: {
|
|
539
|
-
id:
|
|
539
|
+
id: d.annotation,
|
|
540
540
|
rects: h
|
|
541
541
|
}
|
|
542
542
|
};
|
|
543
543
|
});
|
|
544
544
|
}, a = () => [...o.values()], c = () => {
|
|
545
545
|
e.clear(), o.clear();
|
|
546
|
-
}, u = (
|
|
547
|
-
const
|
|
548
|
-
|
|
549
|
-
},
|
|
550
|
-
const
|
|
551
|
-
|
|
552
|
-
}, y = (
|
|
553
|
-
|
|
554
|
-
}, g = (
|
|
555
|
-
|
|
556
|
-
const
|
|
557
|
-
h.forEach(({ target:
|
|
558
|
-
|
|
546
|
+
}, u = (d) => {
|
|
547
|
+
const f = i(d, n.getBoundingClientRect());
|
|
548
|
+
f.length !== 0 && (f.forEach((l) => e.insert(l)), o.set(d.annotation, f));
|
|
549
|
+
}, b = (d) => {
|
|
550
|
+
const f = o.get(d.annotation);
|
|
551
|
+
f && (f.forEach((l) => e.remove(l)), o.delete(d.annotation));
|
|
552
|
+
}, y = (d) => {
|
|
553
|
+
b(d), u(d);
|
|
554
|
+
}, g = (d, f = !0) => {
|
|
555
|
+
f && c();
|
|
556
|
+
const l = n.getBoundingClientRect(), h = d.map((v) => ({ target: v, rects: i(v, l) }));
|
|
557
|
+
h.forEach(({ target: v, rects: E }) => {
|
|
558
|
+
E.length > 0 && o.set(v.annotation, E);
|
|
559
559
|
});
|
|
560
|
-
const
|
|
561
|
-
e.load(
|
|
562
|
-
}, r = (
|
|
560
|
+
const w = h.flatMap(({ rects: v }) => v);
|
|
561
|
+
e.load(w);
|
|
562
|
+
}, r = (d, f, l = !1) => {
|
|
563
563
|
const h = e.search({
|
|
564
|
-
minX:
|
|
565
|
-
minY:
|
|
566
|
-
maxX:
|
|
567
|
-
maxY:
|
|
568
|
-
}),
|
|
569
|
-
return h.length > 0 ? (h.sort((
|
|
570
|
-
},
|
|
571
|
-
const
|
|
572
|
-
if (
|
|
564
|
+
minX: d,
|
|
565
|
+
minY: f,
|
|
566
|
+
maxX: d,
|
|
567
|
+
maxY: f
|
|
568
|
+
}), w = (v) => v.annotation.rects.reduce((E, L) => E + L.width * L.height, 0);
|
|
569
|
+
return h.length > 0 ? (h.sort((v, E) => w(v) - w(E)), l ? h.map((v) => v.annotation.id) : [h[0].annotation.id]) : [];
|
|
570
|
+
}, A = (d) => {
|
|
571
|
+
const f = S(d);
|
|
572
|
+
if (f.length === 0)
|
|
573
573
|
return;
|
|
574
|
-
let
|
|
575
|
-
for (let
|
|
576
|
-
const L =
|
|
577
|
-
|
|
574
|
+
let l = f[0].left, h = f[0].top, w = f[0].right, v = f[0].bottom;
|
|
575
|
+
for (let E = 1; E < f.length; E++) {
|
|
576
|
+
const L = f[E];
|
|
577
|
+
l = Math.min(l, L.left), h = Math.min(h, L.top), w = Math.max(w, L.right), v = Math.max(v, L.bottom);
|
|
578
578
|
}
|
|
579
|
-
return new DOMRect(
|
|
580
|
-
},
|
|
581
|
-
const
|
|
582
|
-
return
|
|
579
|
+
return new DOMRect(l, h, w - l, v - h);
|
|
580
|
+
}, S = (d) => {
|
|
581
|
+
const f = o.get(d);
|
|
582
|
+
return f ? f[0].annotation.rects : [];
|
|
583
583
|
};
|
|
584
584
|
return {
|
|
585
585
|
all: a,
|
|
586
586
|
clear: c,
|
|
587
587
|
getAt: r,
|
|
588
|
-
getAnnotationBounds:
|
|
589
|
-
getAnnotationRects:
|
|
590
|
-
getIntersecting: (
|
|
591
|
-
const
|
|
592
|
-
return Array.from(
|
|
593
|
-
annotation: t.getAnnotation(
|
|
594
|
-
rects:
|
|
595
|
-
})).filter((
|
|
588
|
+
getAnnotationBounds: A,
|
|
589
|
+
getAnnotationRects: S,
|
|
590
|
+
getIntersecting: (d, f, l, h) => {
|
|
591
|
+
const w = e.search({ minX: d, minY: f, maxX: l, maxY: h }), v = new Set(w.map((E) => E.annotation.id));
|
|
592
|
+
return Array.from(v).map((E) => ({
|
|
593
|
+
annotation: t.getAnnotation(E),
|
|
594
|
+
rects: S(E)
|
|
595
|
+
})).filter((E) => !!E.annotation);
|
|
596
596
|
},
|
|
597
597
|
insert: u,
|
|
598
598
|
recalculate: () => {
|
|
599
|
-
g(t.all().map((
|
|
599
|
+
g(t.all().map((d) => d.target), !0), s.emit("recalculate");
|
|
600
600
|
},
|
|
601
|
-
remove:
|
|
601
|
+
remove: b,
|
|
602
602
|
set: g,
|
|
603
603
|
size: () => e.all().length,
|
|
604
604
|
update: y,
|
|
605
|
-
on: (
|
|
605
|
+
on: (d, f) => s.on(d, f)
|
|
606
606
|
};
|
|
607
607
|
}, ie = (t, n) => {
|
|
608
|
-
const e = mt(), o = re(e, t), s = pt(e, n.userSelectAction, n.adapter), i = ht(e), a = yt(), c = (
|
|
609
|
-
const
|
|
610
|
-
return
|
|
611
|
-
}, u = (
|
|
612
|
-
const
|
|
613
|
-
return e.bulkAddAnnotations(
|
|
614
|
-
},
|
|
615
|
-
const
|
|
616
|
-
return
|
|
617
|
-
e.getAnnotation(h.id) ? e.updateAnnotation(h,
|
|
618
|
-
}),
|
|
619
|
-
}, y = (
|
|
620
|
-
const
|
|
621
|
-
e.updateTarget(
|
|
622
|
-
}, g = (
|
|
623
|
-
const
|
|
624
|
-
e.bulkUpdateTargets(
|
|
608
|
+
const e = mt(), o = re(e, t), s = pt(e, n.userSelectAction, n.adapter), i = ht(e), a = yt(), c = (m, d = _.LOCAL) => {
|
|
609
|
+
const f = q(m, t), l = M(f.target.selector);
|
|
610
|
+
return l && e.addAnnotation(f, d), l;
|
|
611
|
+
}, u = (m, d = !0, f = _.LOCAL) => {
|
|
612
|
+
const l = m.map((w) => q(w, t)), h = l.filter((w) => !M(w.target.selector));
|
|
613
|
+
return e.bulkAddAnnotations(l, d, f), h;
|
|
614
|
+
}, b = (m, d = _.LOCAL) => {
|
|
615
|
+
const f = m.map((h) => q(h, t)), l = f.filter((h) => !M(h.target.selector));
|
|
616
|
+
return f.forEach((h) => {
|
|
617
|
+
e.getAnnotation(h.id) ? e.updateAnnotation(h, d) : e.addAnnotation(h, d);
|
|
618
|
+
}), l;
|
|
619
|
+
}, y = (m, d = _.LOCAL) => {
|
|
620
|
+
const f = X(m, t);
|
|
621
|
+
e.updateTarget(f, d);
|
|
622
|
+
}, g = (m, d = _.LOCAL) => {
|
|
623
|
+
const f = m.map((l) => X(l, t));
|
|
624
|
+
e.bulkUpdateTargets(f, d);
|
|
625
625
|
};
|
|
626
|
-
function r(
|
|
627
|
-
const h =
|
|
628
|
-
if (
|
|
629
|
-
return
|
|
626
|
+
function r(m, d, f, l) {
|
|
627
|
+
const h = f || !!l, w = o.getAt(m, d, h).map((E) => e.getAnnotation(E)), v = l ? w.filter(l) : w;
|
|
628
|
+
if (v.length !== 0)
|
|
629
|
+
return f ? v : v[0];
|
|
630
630
|
}
|
|
631
|
-
const
|
|
632
|
-
return e.observe(({ changes:
|
|
633
|
-
const
|
|
634
|
-
(
|
|
631
|
+
const A = (m) => o.getAnnotationRects(m).length > 0 ? o.getAnnotationBounds(m) : void 0, S = (m, d, f, l) => o.getIntersecting(m, d, f, l), T = (m) => o.getAnnotationRects(m), x = () => o.recalculate(), C = (m) => o.on("recalculate", m);
|
|
632
|
+
return e.observe(({ changes: m }) => {
|
|
633
|
+
const d = (m.deleted || []).filter((h) => M(h.target.selector)), f = (m.created || []).filter((h) => M(h.target.selector)), l = (m.updated || []).filter((h) => M(h.newValue.target.selector));
|
|
634
|
+
(d == null ? void 0 : d.length) > 0 && d.forEach((h) => o.remove(h.target)), f.length > 0 && o.set(f.map((h) => h.target), !1), (l == null ? void 0 : l.length) > 0 && l.forEach(({ newValue: h }) => o.update(h.target));
|
|
635
635
|
}), {
|
|
636
636
|
store: {
|
|
637
637
|
...e,
|
|
638
638
|
addAnnotation: c,
|
|
639
639
|
bulkAddAnnotations: u,
|
|
640
640
|
bulkUpdateTargets: g,
|
|
641
|
-
bulkUpsertAnnotations:
|
|
642
|
-
getAnnotationBounds:
|
|
641
|
+
bulkUpsertAnnotations: b,
|
|
642
|
+
getAnnotationBounds: A,
|
|
643
643
|
getAnnotationRects: T,
|
|
644
|
-
getIntersecting:
|
|
644
|
+
getIntersecting: S,
|
|
645
645
|
getAt: r,
|
|
646
646
|
recalculatePositions: x,
|
|
647
|
-
onRecalculatePositions:
|
|
647
|
+
onRecalculatePositions: C,
|
|
648
648
|
updateTarget: y
|
|
649
649
|
},
|
|
650
650
|
selection: s,
|
|
@@ -661,7 +661,7 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
|
|
|
661
661
|
document.body.appendChild(e);
|
|
662
662
|
const s = /* @__PURE__ */ new Map(), i = (y) => Array.from(s.entries()).filter(([g, r]) => r.presenceKey === y.presenceKey).map(([g, r]) => g);
|
|
663
663
|
return t.on("selectionChange", (y, g) => {
|
|
664
|
-
i(y).forEach((
|
|
664
|
+
i(y).forEach((A) => s.delete(A)), g && g.forEach((A) => s.set(A, y));
|
|
665
665
|
}), {
|
|
666
666
|
clear: () => {
|
|
667
667
|
const { width: y, height: g } = e;
|
|
@@ -672,13 +672,13 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
|
|
|
672
672
|
},
|
|
673
673
|
paint: (y, g, r) => {
|
|
674
674
|
n.font && (o.font = n.font);
|
|
675
|
-
const
|
|
676
|
-
if (
|
|
677
|
-
const { height:
|
|
678
|
-
o.fillStyle =
|
|
679
|
-
const
|
|
680
|
-
return o.fillRect(T - 2, x - 2.5 -
|
|
681
|
-
fill:
|
|
675
|
+
const A = s.get(y.annotation.id);
|
|
676
|
+
if (A) {
|
|
677
|
+
const { height: S } = y.rects[0], T = y.rects[0].x + g.left, x = y.rects[0].y + g.top;
|
|
678
|
+
o.fillStyle = A.appearance.color, o.fillRect(T - 2, x - 2.5, 2, S + 5);
|
|
679
|
+
const C = o.measureText(A.appearance.label), m = C.width + 6, d = C.actualBoundingBoxAscent + C.actualBoundingBoxDescent + 8, f = C.fontBoundingBoxAscent ? 8 : 6.5;
|
|
680
|
+
return o.fillRect(T - 2, x - 2.5 - d, m, d), o.fillStyle = "#fff", o.fillText(A.appearance.label, T + 1, x - f), {
|
|
681
|
+
fill: A.appearance.color,
|
|
682
682
|
fillOpacity: r ? 0.45 : 0.18
|
|
683
683
|
};
|
|
684
684
|
}
|
|
@@ -695,95 +695,95 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
|
|
|
695
695
|
], de = (t, n, e) => {
|
|
696
696
|
const { store: o, selection: s } = n;
|
|
697
697
|
let i;
|
|
698
|
-
const { annotatingEnabled: a, offsetReferenceSelector: c, selectionMode: u } = e,
|
|
698
|
+
const { annotatingEnabled: a, offsetReferenceSelector: c, selectionMode: u } = e, b = (p) => i = p;
|
|
699
699
|
let y;
|
|
700
700
|
const g = (p) => y = p;
|
|
701
|
-
let r,
|
|
701
|
+
let r, A, S, T = a;
|
|
702
702
|
const x = (p) => {
|
|
703
|
-
T = p,
|
|
704
|
-
},
|
|
705
|
-
T &&
|
|
703
|
+
T = p, m.clear(), p || (r = void 0, A = void 0, S = void 0);
|
|
704
|
+
}, C = (p) => {
|
|
705
|
+
T && A !== !1 && (r = W(p.target) ? void 0 : {
|
|
706
706
|
annotation: ot(),
|
|
707
707
|
selector: [],
|
|
708
708
|
creator: i,
|
|
709
709
|
created: /* @__PURE__ */ new Date()
|
|
710
710
|
});
|
|
711
|
-
},
|
|
711
|
+
}, m = Q((p) => {
|
|
712
712
|
if (!T) return;
|
|
713
713
|
const R = document.getSelection();
|
|
714
714
|
if (!(R != null && R.anchorNode))
|
|
715
715
|
return;
|
|
716
|
-
if (
|
|
716
|
+
if (W(R.anchorNode)) {
|
|
717
717
|
r = void 0;
|
|
718
718
|
return;
|
|
719
719
|
}
|
|
720
|
-
const
|
|
721
|
-
if ((
|
|
720
|
+
const k = p.timeStamp - ((S == null ? void 0 : S.timeStamp) || p.timeStamp);
|
|
721
|
+
if ((S == null ? void 0 : S.type) === "pointerdown" && (k < 1e3 && !r || R.isCollapsed && k < tt) && C(S || p), !r) return;
|
|
722
722
|
if (R.isCollapsed) {
|
|
723
723
|
o.getAnnotation(r.annotation) && (s.clear(), o.deleteAnnotation(r.annotation));
|
|
724
724
|
return;
|
|
725
725
|
}
|
|
726
|
-
const
|
|
727
|
-
if (It(
|
|
728
|
-
const
|
|
729
|
-
(
|
|
730
|
-
var
|
|
731
|
-
return
|
|
726
|
+
const B = R.getRangeAt(0), H = _t(B, t);
|
|
727
|
+
if (It(H)) return;
|
|
728
|
+
const O = Bt(H.cloneRange());
|
|
729
|
+
(O.length !== r.selector.length || O.some((P, $) => {
|
|
730
|
+
var F;
|
|
731
|
+
return P.toString() !== ((F = r.selector[$]) == null ? void 0 : F.quote);
|
|
732
732
|
})) && (r = {
|
|
733
733
|
...r,
|
|
734
|
-
selector:
|
|
734
|
+
selector: O.map((P) => Kt(P, t, c)),
|
|
735
735
|
updated: /* @__PURE__ */ new Date()
|
|
736
|
-
}, o.getAnnotation(r.annotation) ? o.updateTarget(r,
|
|
737
|
-
}, 10),
|
|
738
|
-
|
|
739
|
-
},
|
|
740
|
-
if (
|
|
736
|
+
}, o.getAnnotation(r.annotation) ? o.updateTarget(r, _.LOCAL) : s.clear());
|
|
737
|
+
}, 10), d = (p) => {
|
|
738
|
+
W(p.target) || (S = j(p), A = S.button === 0);
|
|
739
|
+
}, f = async (p) => {
|
|
740
|
+
if (W(p.target) || !A) return;
|
|
741
741
|
const R = () => {
|
|
742
|
-
const { x:
|
|
743
|
-
if (
|
|
744
|
-
const { selected:
|
|
745
|
-
(
|
|
742
|
+
const { x: B, y: H } = t.getBoundingClientRect(), O = p.target instanceof Node && t.contains(p.target) && o.getAt(p.clientX - B, p.clientY - H, u === "all", y);
|
|
743
|
+
if (O) {
|
|
744
|
+
const { selected: N } = s, P = new Set(N.map((U) => U.id)), $ = Array.isArray(O) ? O.map((U) => U.id) : [O.id];
|
|
745
|
+
(P.size !== $.length || !$.every((U) => P.has(U))) && s.userSelect($, p);
|
|
746
746
|
} else
|
|
747
747
|
s.clear();
|
|
748
748
|
};
|
|
749
|
-
if (p.timeStamp -
|
|
750
|
-
await
|
|
751
|
-
const
|
|
752
|
-
if (
|
|
749
|
+
if (p.timeStamp - S.timeStamp < tt) {
|
|
750
|
+
await l();
|
|
751
|
+
const B = document.getSelection();
|
|
752
|
+
if (B != null && B.isCollapsed) {
|
|
753
753
|
r = void 0, R();
|
|
754
754
|
return;
|
|
755
755
|
}
|
|
756
756
|
}
|
|
757
757
|
r && r.selector.length > 0 && (L(), s.userSelect(r.annotation, j(p)));
|
|
758
|
-
},
|
|
758
|
+
}, l = async () => {
|
|
759
759
|
const p = document.getSelection();
|
|
760
|
-
let R = !1,
|
|
761
|
-
const
|
|
762
|
-
return setTimeout(() => R = !0, 50), vt(() =>
|
|
760
|
+
let R = !1, k = p == null ? void 0 : p.isCollapsed;
|
|
761
|
+
const B = () => k || R, H = 1;
|
|
762
|
+
return setTimeout(() => R = !0, 50), vt(() => k = p == null ? void 0 : p.isCollapsed, H, B);
|
|
763
763
|
}, h = (p) => {
|
|
764
764
|
const R = document.getSelection();
|
|
765
|
-
R != null && R.isCollapsed || ((!r || r.selector.length === 0) &&
|
|
766
|
-
},
|
|
767
|
-
T && p.key === "Shift" && r && (document.getSelection().isCollapsed || (L(), s.userSelect(r.annotation,
|
|
768
|
-
},
|
|
765
|
+
R != null && R.isCollapsed || ((!r || r.selector.length === 0) && m(p), r && (L(), s.userSelect(r.annotation, j(p))));
|
|
766
|
+
}, w = (p) => {
|
|
767
|
+
T && p.key === "Shift" && r && (document.getSelection().isCollapsed || (L(), s.userSelect(r.annotation, Y(p))));
|
|
768
|
+
}, v = (p) => {
|
|
769
769
|
const R = () => setTimeout(() => {
|
|
770
770
|
(r == null ? void 0 : r.selector.length) > 0 && (s.clear(), o.addAnnotation({
|
|
771
771
|
id: r.annotation,
|
|
772
772
|
bodies: [],
|
|
773
773
|
target: r
|
|
774
|
-
}), s.userSelect(r.annotation,
|
|
774
|
+
}), s.userSelect(r.annotation, Y(p))), document.removeEventListener("selectionchange", R);
|
|
775
775
|
}, 100);
|
|
776
|
-
document.addEventListener("selectionchange", R),
|
|
776
|
+
document.addEventListener("selectionchange", R), C(p);
|
|
777
777
|
};
|
|
778
|
-
|
|
779
|
-
p.repeat || (
|
|
780
|
-
}),
|
|
781
|
-
|
|
778
|
+
V(le.join(","), { element: t, keydown: !0, keyup: !1 }, (p) => {
|
|
779
|
+
p.repeat || (S = Y(p));
|
|
780
|
+
}), V(lt, { keydown: !0, keyup: !1 }, (p) => {
|
|
781
|
+
S = Y(p), v(p);
|
|
782
782
|
});
|
|
783
|
-
const
|
|
783
|
+
const E = (p) => {
|
|
784
784
|
p.repeat || p.target !== t && p.target !== document.body || (r = void 0, s.clear());
|
|
785
785
|
};
|
|
786
|
-
|
|
786
|
+
V(ct.join(","), { keydown: !0, keyup: !1 }, E);
|
|
787
787
|
const L = () => {
|
|
788
788
|
const p = o.getAnnotation(r.annotation);
|
|
789
789
|
if (!p) {
|
|
@@ -794,15 +794,15 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
|
|
|
794
794
|
});
|
|
795
795
|
return;
|
|
796
796
|
}
|
|
797
|
-
const { target: { updated: R } } = p, { updated:
|
|
798
|
-
(!R || !
|
|
797
|
+
const { target: { updated: R } } = p, { updated: k } = r;
|
|
798
|
+
(!R || !k || R < k) && o.updateTarget(r);
|
|
799
799
|
};
|
|
800
|
-
return document.addEventListener("pointerdown",
|
|
800
|
+
return document.addEventListener("pointerdown", d), document.addEventListener("pointerup", f), document.addEventListener("contextmenu", h), t.addEventListener("keyup", w), t.addEventListener("selectstart", C), document.addEventListener("selectionchange", m), {
|
|
801
801
|
destroy: () => {
|
|
802
|
-
r = void 0,
|
|
802
|
+
r = void 0, A = void 0, S = void 0, m.clear(), document.removeEventListener("pointerdown", d), document.removeEventListener("pointerup", f), document.removeEventListener("contextmenu", h), t.removeEventListener("keyup", w), t.removeEventListener("selectstart", C), document.removeEventListener("selectionchange", m), V.unbind();
|
|
803
803
|
},
|
|
804
804
|
setFilter: g,
|
|
805
|
-
setUser:
|
|
805
|
+
setUser: b,
|
|
806
806
|
setAnnotatingEnabled: x
|
|
807
807
|
};
|
|
808
808
|
}, ue = (t, n) => ({
|
|
@@ -815,40 +815,40 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
|
|
|
815
815
|
annotatingEnabled: !0,
|
|
816
816
|
user: bt()
|
|
817
817
|
}), o = ie(t, e), { selection: s, viewport: i } = o, a = o.store, c = St(a), u = Ct(o, c, e.adapter);
|
|
818
|
-
let
|
|
818
|
+
let b = e.user;
|
|
819
819
|
const y = e.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : et : e.renderer || et, g = y === "SPANS" ? te(t, o, i) : y === "CSS_HIGHLIGHTS" ? Qt(t, o, i) : y === "CANVAS" ? qt(t, o, i) : void 0;
|
|
820
820
|
if (!g)
|
|
821
821
|
throw `Unknown renderer implementation: ${y}`;
|
|
822
822
|
console.debug(`Using ${y} renderer`), e.style && g.setStyle(e.style);
|
|
823
823
|
const r = de(t, o, e);
|
|
824
|
-
r.setUser(
|
|
825
|
-
const
|
|
824
|
+
r.setUser(b), r.setAnnotatingEnabled(e.annotatingEnabled);
|
|
825
|
+
const A = Et(o, c, e.adapter), S = () => b, T = (l) => {
|
|
826
826
|
r.setAnnotatingEnabled(
|
|
827
|
-
|
|
827
|
+
l === void 0 ? !0 : l
|
|
828
828
|
);
|
|
829
|
-
}, x = (
|
|
830
|
-
g.setFilter(
|
|
831
|
-
},
|
|
832
|
-
|
|
833
|
-
},
|
|
834
|
-
|
|
835
|
-
},
|
|
836
|
-
|
|
829
|
+
}, x = (l) => {
|
|
830
|
+
g.setFilter(l), r.setFilter(l);
|
|
831
|
+
}, C = (l) => {
|
|
832
|
+
b = l, r.setUser(l);
|
|
833
|
+
}, m = (l) => {
|
|
834
|
+
l && (g.setPainter(ce(l, e.presence)), l.on("selectionChange", () => g.redraw()));
|
|
835
|
+
}, d = (l) => {
|
|
836
|
+
l ? s.setSelected(l) : s.clear();
|
|
837
837
|
};
|
|
838
838
|
return {
|
|
839
|
-
...
|
|
839
|
+
...A,
|
|
840
840
|
destroy: () => {
|
|
841
841
|
g.destroy(), r.destroy(), c.destroy();
|
|
842
842
|
},
|
|
843
843
|
element: t,
|
|
844
|
-
getUser:
|
|
844
|
+
getUser: S,
|
|
845
845
|
setAnnotatingEnabled: T,
|
|
846
846
|
setFilter: x,
|
|
847
847
|
setStyle: g.setStyle.bind(g),
|
|
848
848
|
redraw: g.redraw.bind(g),
|
|
849
|
-
setUser:
|
|
850
|
-
setSelected:
|
|
851
|
-
setPresenceProvider:
|
|
849
|
+
setUser: C,
|
|
850
|
+
setSelected: d,
|
|
851
|
+
setPresenceProvider: m,
|
|
852
852
|
setVisible: g.setVisible.bind(g),
|
|
853
853
|
on: u.on,
|
|
854
854
|
off: u.off,
|
|
@@ -857,15 +857,15 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
|
|
|
857
857
|
};
|
|
858
858
|
};
|
|
859
859
|
export {
|
|
860
|
-
|
|
861
|
-
|
|
860
|
+
z as DEFAULT_SELECTED_STYLE,
|
|
861
|
+
K as DEFAULT_STYLE,
|
|
862
862
|
st as NOT_ANNOTATABLE_CLASS,
|
|
863
|
-
|
|
863
|
+
D as NOT_ANNOTATABLE_SELECTOR,
|
|
864
864
|
Re as Origin,
|
|
865
865
|
Le as UserSelectAction,
|
|
866
866
|
Ae as W3CTextFormat,
|
|
867
867
|
Tt as cancelSingleClickEvents,
|
|
868
|
-
|
|
868
|
+
Y as cloneKeyboardEvent,
|
|
869
869
|
j as clonePointerEvent,
|
|
870
870
|
ke as createBody,
|
|
871
871
|
qt as createCanvasRenderer,
|
|
@@ -880,9 +880,9 @@ export {
|
|
|
880
880
|
Nt as getQuoteContext,
|
|
881
881
|
G as getRangeAnnotatableContents,
|
|
882
882
|
Rt as isMac,
|
|
883
|
-
|
|
883
|
+
W as isNotAnnotatable,
|
|
884
884
|
xt as isRangeAnnotatable,
|
|
885
|
-
|
|
885
|
+
M as isRevived,
|
|
886
886
|
It as isWhitespaceOrEmpty,
|
|
887
887
|
Pt as mergeClientRects,
|
|
888
888
|
Ut as paint,
|
|
@@ -892,7 +892,7 @@ export {
|
|
|
892
892
|
Kt as rangeToSelector,
|
|
893
893
|
q as reviveAnnotation,
|
|
894
894
|
rt as reviveSelector,
|
|
895
|
-
|
|
895
|
+
X as reviveTarget,
|
|
896
896
|
Ft as scrollIntoView,
|
|
897
897
|
se as serializeW3CTextAnnotation,
|
|
898
898
|
Bt as splitAnnotatableRanges,
|