@soomo/text-annotator 3.2.0-staging.16 → 3.2.0-staging.17

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.
@@ -9,13 +9,12 @@ export interface TextAnnotatorOptions<I extends TextAnnotation = TextAnnotation,
9
9
  * Determines whether an active selection should be dismissed
10
10
  * when a user ends their interaction (click, selection)
11
11
  * on a non-annotatable element.
12
- * - ALWAYS - always dismiss the selection.
13
- * - ANNOTATABLE_AREAS - will dismiss selection only if you click on annotatable areas
14
- * (inside the `container`, not marked as not-annotatable)
15
- * - function - a custom matcher that takes an event and container as arguments
16
- * and returns true if the selection should be dismissed.
12
+ * - NEVER - don't dismiss the selection, ignore the action.
13
+ * - ALWAYS - dismiss the selection.
14
+ * - function - a custom matcher that takes an event and container as arguments.
15
+ * Returns `true` if the selection should be dismissed.
17
16
  *
18
- * @defaut ANNOTATABLE_AREAS
17
+ * @defaut NEVER
19
18
  */
20
19
  dismissOnNotAnnotatable?: DismissOnNotAnnotatableExpression;
21
20
  renderer?: RendererType;
@@ -27,5 +26,5 @@ export interface TextAnnotatorOptions<I extends TextAnnotation = TextAnnotation,
27
26
  user?: User;
28
27
  }
29
28
  export type RendererType = 'SPANS' | 'CANVAS' | 'CSS_HIGHLIGHTS';
30
- export type DismissOnNotAnnotatableExpression = 'ALWAYS' | 'ANNOTATABLE_AREAS' | ((event: Event, container: HTMLElement) => boolean);
29
+ export type DismissOnNotAnnotatableExpression = 'NEVER' | 'ALWAYS' | ((event: Event, container: HTMLElement) => boolean);
31
30
  export declare const fillDefaults: <I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation>(opts: TextAnnotatorOptions<I, E>, defaults: TextAnnotatorOptions<I, E>) => TextAnnotatorOptions<I, E>;
@@ -2,21 +2,21 @@ import X from "debounce";
2
2
  import { colord as ot } from "colord";
3
3
  import { dequal as ut } from "dequal/lite";
4
4
  import { v4 as st } from "uuid";
5
- import { serializeW3CBodies as ft, parseW3CBodies as gt, parseW3CUser as mt, createStore as pt, createSelectionState as ht, createHoverState as yt, createViewportState as bt, Origin as _, createAnonymousGuest as St, createUndoStack as Ct, createLifecycleObserver as Et, createBaseAnnotator as At } from "@annotorious/core";
5
+ import { serializeW3CBodies as ft, parseW3CBodies as gt, parseW3CUser as mt, createStore as pt, createSelectionState as ht, createHoverState as yt, createViewportState as bt, Origin as $, createAnonymousGuest as St, createUndoStack as Ct, createLifecycleObserver as Et, createBaseAnnotator as wt } from "@annotorious/core";
6
6
  import { Origin as Le, UserSelectAction as ke, createBody as Ne } from "@annotorious/core";
7
- import wt from "rbush";
7
+ import At from "rbush";
8
8
  import { createNanoEvents as vt } from "nanoevents";
9
9
  import V from "hotkeys-js";
10
10
  import { poll as xt } from "poll";
11
- const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
11
+ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
12
12
  var o;
13
- return t.contains(n) ? !!(n instanceof HTMLElement ? n.closest($) : (o = n.parentElement) == null ? void 0 : o.closest($)) : !0;
14
- }, Tt = (t, n) => {
13
+ return t.contains(n) ? !!(n instanceof HTMLElement ? n.closest(_) : (o = n.parentElement) == null ? void 0 : o.closest(_)) : !0;
14
+ }, Rt = (t, n) => {
15
15
  const e = n.commonAncestorContainer;
16
16
  return !U(t, e);
17
- }, Rt = (t) => t.addEventListener("click", (n) => {
17
+ }, Tt = (t) => t.addEventListener("click", (n) => {
18
18
  // Allow clicks within not-annotatable elements
19
- !n.target.closest($) && !n.target.closest("a") && n.preventDefault();
19
+ !n.target.closest(_) && !n.target.closest("a") && n.preventDefault();
20
20
  }), Lt = typeof navigator < "u" && // @ts-ignore
21
21
  /mac/i.test(navigator.userAgentData ? navigator.userAgentData.platform : navigator.platform), kt = (t) => {
22
22
  !t.hasAttribute("tabindex") && t.tabIndex < 0 && t.setAttribute("tabindex", "-1"), t.classList.add("no-focus-outline");
@@ -24,13 +24,13 @@ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
24
24
  const n = document.createNodeIterator(
25
25
  t.commonAncestorContainer,
26
26
  NodeFilter.SHOW_ELEMENT,
27
- (o) => o instanceof HTMLElement && o.classList.contains(rt) && !o.parentElement.closest($) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
27
+ (o) => o instanceof HTMLElement && o.classList.contains(rt) && !o.parentElement.closest(_) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
28
28
  );
29
29
  let e;
30
30
  for (; e = n.nextNode(); )
31
31
  e instanceof HTMLElement && (yield e);
32
32
  }, Bt = (t, n) => {
33
- if (!Tt(t, n)) return [];
33
+ if (!Rt(t, n)) return [];
34
34
  const e = [];
35
35
  let o = null;
36
36
  for (const s of Nt(n)) {
@@ -44,7 +44,7 @@ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
44
44
  return e.length > 0 ? e : [n];
45
45
  }, Z = (t) => {
46
46
  const n = t.cloneContents();
47
- return n.querySelectorAll($).forEach((e) => e.remove()), n;
47
+ return n.querySelectorAll(_).forEach((e) => e.remove()), n;
48
48
  }, Ot = (t, n, e = 10, o) => {
49
49
  const s = o ? t.startContainer.parentElement.closest(o) : n, r = document.createRange();
50
50
  r.setStart(s, 0), r.setEnd(t.startContainer, t.startOffset);
@@ -103,7 +103,7 @@ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
103
103
  }
104
104
  }
105
105
  return s ? o : [...o, e];
106
- }, []), Ae = (t) => ({
106
+ }, []), we = (t) => ({
107
107
  length: t.length,
108
108
  item: (n) => t[n],
109
109
  [Symbol.iterator]: function* () {
@@ -122,7 +122,7 @@ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
122
122
  NodeFilter.SHOW_TEXT,
123
123
  (p) => {
124
124
  var c;
125
- return (c = p.parentElement) != null && c.closest($) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
125
+ return (c = p.parentElement) != null && c.closest(_) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
126
126
  }
127
127
  );
128
128
  let i = 0;
@@ -163,12 +163,12 @@ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
163
163
  if (at(e, n))
164
164
  return !0;
165
165
  return !1;
166
- }, _t = (t, n) => {
166
+ }, $t = (t, n) => {
167
167
  const e = t.cloneContents();
168
168
  return at(e, n);
169
- }, $t = (t, n) => {
169
+ }, _t = (t, n) => {
170
170
  const e = t.cloneRange(), o = n.contains(e.startContainer), s = n.contains(e.endContainer);
171
- return !o && !s && !_t(e, n) ? (e.collapse(), e) : (o || e.setStart(n, 0), s || e.setEnd(n, n.childNodes.length), e);
171
+ return !o && !s && !$t(e, n) ? (e.collapse(), e) : (o || e.setStart(n, 0), s || e.setEnd(n, n.childNodes.length), e);
172
172
  }, Q = (t) => ({
173
173
  ...t,
174
174
  type: t.type,
@@ -214,7 +214,7 @@ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
214
214
  }), Ft = (t, n) => {
215
215
  const { left: e, top: o, right: s, bottom: r } = t;
216
216
  return new DOMRect(e - n.left, o - n.top, s - e, r - o);
217
- }, we = (t, n) => {
217
+ }, Ae = (t, n) => {
218
218
  const { left: e, top: o, right: s, bottom: r } = t;
219
219
  return new DOMRect(e + n.left, o + n.top, s - e, r - o);
220
220
  }, ct = (t) => {
@@ -266,7 +266,7 @@ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
266
266
  t.addEventListener("pointermove", f);
267
267
  const p = (C = !1) => {
268
268
  S && S.clear();
269
- const k = Vt(t), { minX: B, minY: D, maxX: h, maxY: R } = k, O = u ? s.getIntersecting(B, D, h, R).filter(({ annotation: L }) => u(L)) : s.getIntersecting(B, D, h, R), I = r.selected.map(({ id: L }) => L), H = O.map(({ annotation: L, rects: W }) => {
269
+ const k = Vt(t), { minX: B, minY: D, maxX: h, maxY: T } = k, O = u ? s.getIntersecting(B, D, h, T).filter(({ annotation: L }) => u(L)) : s.getIntersecting(B, D, h, T), I = r.selected.map(({ id: L }) => L), H = O.map(({ annotation: L, rects: W }) => {
270
270
  const N = I.includes(L.id), K = L.id === i.current;
271
271
  return {
272
272
  annotation: L,
@@ -279,10 +279,10 @@ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
279
279
  S = C, p();
280
280
  }, x = (C) => {
281
281
  a = C, p();
282
- }, w = (C) => {
282
+ }, A = (C) => {
283
283
  u = C, p(!1);
284
- }, T = () => p();
285
- s.observe(T);
284
+ }, R = () => p();
285
+ s.observe(R);
286
286
  const E = r.subscribe(() => p()), m = i.subscribe(() => p()), l = () => p(!0);
287
287
  document.addEventListener("scroll", l, { capture: !0, passive: !0 });
288
288
  const g = X(() => {
@@ -291,16 +291,16 @@ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
291
291
  window.addEventListener("resize", g);
292
292
  const d = new ResizeObserver(g);
293
293
  d.observe(t);
294
- const y = { attributes: !0, childList: !0, subtree: !0 }, A = new MutationObserver(X((C) => {
294
+ const y = { attributes: !0, childList: !0, subtree: !0 }, w = new MutationObserver(X((C) => {
295
295
  C.every((B) => B.target === t || t.contains(B.target)) || p(!0);
296
296
  }, 150));
297
- return A.observe(document.body, y), {
297
+ return w.observe(document.body, y), {
298
298
  destroy: () => {
299
- t.removeEventListener("pointermove", f), o.destroy(), s.unobserve(T), E(), m(), document.removeEventListener("scroll", l), g.clear(), window.removeEventListener("resize", g), d.disconnect(), A.disconnect();
299
+ t.removeEventListener("pointermove", f), o.destroy(), s.unobserve(R), E(), m(), document.removeEventListener("scroll", l), g.clear(), window.removeEventListener("resize", g), d.disconnect(), w.disconnect();
300
300
  },
301
301
  redraw: p,
302
302
  setStyle: x,
303
- setFilter: w,
303
+ setFilter: A,
304
304
  setPainter: c,
305
305
  setVisible: o.setVisible
306
306
  };
@@ -317,24 +317,24 @@ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
317
317
  const { width: f, height: p } = n;
318
318
  e.clearRect(-0.5, -0.5, f + 1, p + 1), b && b.clear();
319
319
  const { top: c, left: x } = u;
320
- [...a].sort((T, E) => {
321
- const { annotation: { target: { created: m } } } = T, { annotation: { target: { created: l } } } = E;
320
+ [...a].sort((R, E) => {
321
+ const { annotation: { target: { created: m } } } = R, { annotation: { target: { created: l } } } = E;
322
322
  return m.getTime() - l.getTime();
323
- }).forEach((T) => {
323
+ }).forEach((R) => {
324
324
  var g;
325
- const E = S ? typeof S == "function" ? S(T.annotation, T.state) : S : (g = T.state) != null && g.selected ? q : P, m = b && b.paint(T, u) || E, l = T.rects.map(({ x: d, y, width: A, height: v }) => ({
325
+ const E = S ? typeof S == "function" ? S(R.annotation, R.state) : S : (g = R.state) != null && g.selected ? q : P, m = b && b.paint(R, u) || E, l = R.rects.map(({ x: d, y, width: w, height: v }) => ({
326
326
  x: d + x,
327
327
  y: y + c,
328
- width: A,
328
+ width: w,
329
329
  height: v
330
330
  }));
331
331
  if (e.fillStyle = m.fill, e.globalAlpha = m.fillOpacity || 1, l.forEach(
332
- ({ x: d, y, width: A, height: v }) => e.fillRect(d, y, A, v)
332
+ ({ x: d, y, width: w, height: v }) => e.fillRect(d, y, w, v)
333
333
  ), m.underlineColor) {
334
334
  e.globalAlpha = 1, e.strokeStyle = m.underlineColor, e.lineWidth = m.underlineThickness ?? 1;
335
335
  const d = m.underlineOffset ?? 0;
336
- l.forEach(({ x: y, y: A, width: v, height: C }) => {
337
- e.beginPath(), e.moveTo(y, A + C + d), e.lineTo(y + v, A + C + d), e.stroke();
336
+ l.forEach(({ x: y, y: w, width: v, height: C }) => {
337
+ e.beginPath(), e.moveTo(y, w + C + d), e.lineTo(y + v, w + C + d), e.stroke();
338
338
  });
339
339
  }
340
340
  });
@@ -396,15 +396,15 @@ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
396
396
  redraw: (i, a, u, S, b) => {
397
397
  const p = !(ut(e, i) && b);
398
398
  if (!S && !p) return;
399
- p && (n.innerHTML = ""), [...i].sort((x, w) => {
400
- const { annotation: { target: { created: T } } } = x, { annotation: { target: { created: E } } } = w;
401
- return T && E ? T.getTime() - E.getTime() : 0;
399
+ p && (n.innerHTML = ""), [...i].sort((x, A) => {
400
+ const { annotation: { target: { created: R } } } = x, { annotation: { target: { created: E } } } = A;
401
+ return R && E ? R.getTime() - E.getTime() : 0;
402
402
  }).forEach((x) => {
403
- x.rects.map((w) => {
404
- const T = Jt(w, i), E = Wt(x, a, u, S, T);
403
+ x.rects.map((A) => {
404
+ const R = Jt(A, i), E = Wt(x, a, u, S, R);
405
405
  if (p) {
406
406
  const m = document.createElement("span");
407
- m.className = "r6o-annotation", m.dataset.annotation = x.annotation.id, m.style.left = `${w.x}px`, m.style.top = `${w.y}px`, m.style.width = `${w.width}px`, m.style.height = `${w.height}px`, m.style.backgroundColor = ot((E == null ? void 0 : E.fill) || P.fill).alpha((E == null ? void 0 : E.fillOpacity) === void 0 ? P.fillOpacity : E.fillOpacity).toHex(), E.underlineStyle && (m.style.borderStyle = E.underlineStyle), E.underlineColor && (m.style.borderColor = E.underlineColor), E.underlineThickness && (m.style.borderBottomWidth = `${E.underlineThickness}px`), E.underlineOffset && (m.style.paddingBottom = `${E.underlineOffset}px`), n.appendChild(m);
407
+ m.className = "r6o-annotation", m.dataset.annotation = x.annotation.id, m.style.left = `${A.x}px`, m.style.top = `${A.y}px`, m.style.width = `${A.width}px`, m.style.height = `${A.height}px`, m.style.backgroundColor = ot((E == null ? void 0 : E.fill) || P.fill).alpha((E == null ? void 0 : E.fillOpacity) === void 0 ? P.fillOpacity : E.fillOpacity).toHex(), E.underlineStyle && (m.style.borderStyle = E.underlineStyle), E.underlineColor && (m.style.borderColor = E.underlineColor), E.underlineThickness && (m.style.borderBottomWidth = `${E.underlineThickness}px`), E.underlineOffset && (m.style.paddingBottom = `${E.underlineOffset}px`), n.appendChild(m);
408
408
  }
409
409
  });
410
410
  }), e = i;
@@ -489,7 +489,7 @@ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
489
489
  updated: S,
490
490
  ...b
491
491
  } = s, f = i.map((p) => {
492
- const { id: c, quote: x, start: w, end: T, range: E } = p, m = {
492
+ const { id: c, quote: x, start: A, end: R, range: E } = p, m = {
493
493
  type: "TextQuoteSelector",
494
494
  exact: x
495
495
  };
@@ -499,8 +499,8 @@ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
499
499
  }
500
500
  const l = {
501
501
  type: "TextPositionSelector",
502
- start: w,
503
- end: T
502
+ start: A,
503
+ end: R
504
504
  };
505
505
  return {
506
506
  ...b,
@@ -523,13 +523,13 @@ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
523
523
  target: f
524
524
  };
525
525
  }, ie = (t, n) => {
526
- const e = new wt(), o = /* @__PURE__ */ new Map(), s = vt(), r = (l, g) => {
527
- const d = l.selector.flatMap((A) => {
528
- const v = M([A]) ? A.range : it(A, n).range;
526
+ const e = new At(), o = /* @__PURE__ */ new Map(), s = vt(), r = (l, g) => {
527
+ const d = l.selector.flatMap((w) => {
528
+ const v = M([w]) ? w.range : it(w, n).range;
529
529
  return Array.from(v.getClientRects());
530
- }), y = Dt(d).map((A) => Ft(A, g));
531
- return y.map((A) => {
532
- const { x: v, y: C, width: k, height: B } = A;
530
+ }), y = Dt(d).map((w) => Ft(w, g));
531
+ return y.map((w) => {
532
+ const { x: v, y: C, width: k, height: B } = w;
533
533
  return {
534
534
  minX: v,
535
535
  minY: C,
@@ -557,26 +557,26 @@ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
557
557
  y.forEach(({ target: v, rects: C }) => {
558
558
  C.length > 0 && o.set(v.annotation, C);
559
559
  });
560
- const A = y.flatMap(({ rects: v }) => v);
561
- e.load(A);
560
+ const w = y.flatMap(({ rects: v }) => v);
561
+ e.load(w);
562
562
  }, p = (l, g, d = !1) => {
563
563
  const y = e.search({
564
564
  minX: l,
565
565
  minY: g,
566
566
  maxX: l,
567
567
  maxY: g
568
- }), A = (v) => v.annotation.rects.reduce((C, k) => C + k.width * k.height, 0);
569
- return y.length > 0 ? (y.sort((v, C) => A(v) - A(C)), d ? y.map((v) => v.annotation.id) : [y[0].annotation.id]) : [];
568
+ }), w = (v) => v.annotation.rects.reduce((C, k) => C + k.width * k.height, 0);
569
+ return y.length > 0 ? (y.sort((v, C) => w(v) - w(C)), d ? y.map((v) => v.annotation.id) : [y[0].annotation.id]) : [];
570
570
  }, c = (l) => {
571
571
  const g = x(l);
572
572
  if (g.length === 0)
573
573
  return;
574
- let d = g[0].left, y = g[0].top, A = g[0].right, v = g[0].bottom;
574
+ let d = g[0].left, y = g[0].top, w = g[0].right, v = g[0].bottom;
575
575
  for (let C = 1; C < g.length; C++) {
576
576
  const k = g[C];
577
- d = Math.min(d, k.left), y = Math.min(y, k.top), A = Math.max(A, k.right), v = Math.max(v, k.bottom);
577
+ d = Math.min(d, k.left), y = Math.min(y, k.top), w = Math.max(w, k.right), v = Math.max(v, k.bottom);
578
578
  }
579
- return new DOMRect(d, y, A - d, v - y);
579
+ return new DOMRect(d, y, w - d, v - y);
580
580
  }, x = (l) => {
581
581
  const g = o.get(l);
582
582
  return g ? g[0].annotation.rects : [];
@@ -588,7 +588,7 @@ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
588
588
  getAnnotationBounds: c,
589
589
  getAnnotationRects: x,
590
590
  getIntersecting: (l, g, d, y) => {
591
- const A = e.search({ minX: l, minY: g, maxX: d, maxY: y }), v = new Set(A.map((C) => C.annotation.id));
591
+ const w = e.search({ minX: l, minY: g, maxX: d, maxY: y }), v = new Set(w.map((C) => C.annotation.id));
592
592
  return Array.from(v).map((C) => ({
593
593
  annotation: t.getAnnotation(C),
594
594
  rects: x(C)
@@ -605,30 +605,30 @@ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
605
605
  on: (l, g) => s.on(l, g)
606
606
  };
607
607
  }, ae = (t, n) => {
608
- const e = pt(), o = ie(e, t), s = ht(e, n.userSelectAction, n.adapter), r = yt(e), i = bt(), a = (m, l = _.LOCAL) => {
608
+ const e = pt(), o = ie(e, t), s = ht(e, n.userSelectAction, n.adapter), r = yt(e), i = bt(), a = (m, l = $.LOCAL) => {
609
609
  const g = G(m, t), d = M(g.target.selector);
610
610
  return d && e.addAnnotation(g, l), d;
611
- }, u = (m, l = !0, g = _.LOCAL) => {
612
- const d = m.map((A) => G(A, t)), y = d.filter((A) => !M(A.target.selector));
611
+ }, u = (m, l = !0, g = $.LOCAL) => {
612
+ const d = m.map((w) => G(w, t)), y = d.filter((w) => !M(w.target.selector));
613
613
  return e.bulkAddAnnotations(d, l, g), y;
614
- }, S = (m, l = _.LOCAL) => {
614
+ }, S = (m, l = $.LOCAL) => {
615
615
  const g = m.map((y) => G(y, t)), d = g.filter((y) => !M(y.target.selector));
616
616
  return g.forEach((y) => {
617
617
  e.getAnnotation(y.id) ? e.updateAnnotation(y, l) : e.addAnnotation(y, l);
618
618
  }), d;
619
- }, b = (m, l = _.LOCAL) => {
619
+ }, b = (m, l = $.LOCAL) => {
620
620
  const g = z(m, t);
621
621
  e.updateTarget(g, l);
622
- }, f = (m, l = _.LOCAL) => {
622
+ }, f = (m, l = $.LOCAL) => {
623
623
  const g = m.map((d) => z(d, t));
624
624
  e.bulkUpdateTargets(g, l);
625
625
  };
626
626
  function p(m, l, g, d) {
627
- const y = g || !!d, A = o.getAt(m, l, y).map((C) => e.getAnnotation(C)), v = d ? A.filter(d) : A;
627
+ const y = g || !!d, w = o.getAt(m, l, y).map((C) => e.getAnnotation(C)), v = d ? w.filter(d) : w;
628
628
  if (v.length !== 0)
629
629
  return g ? v : v[0];
630
630
  }
631
- const c = (m) => o.getAnnotationRects(m).length > 0 ? o.getAnnotationBounds(m) : void 0, x = (m, l, g, d) => o.getIntersecting(m, l, g, d), w = (m) => o.getAnnotationRects(m), T = () => o.recalculate(), E = (m) => o.on("recalculate", m);
631
+ const c = (m) => o.getAnnotationRects(m).length > 0 ? o.getAnnotationBounds(m) : void 0, x = (m, l, g, d) => o.getIntersecting(m, l, g, d), A = (m) => o.getAnnotationRects(m), R = () => o.recalculate(), E = (m) => o.on("recalculate", m);
632
632
  return e.observe(({ changes: m }) => {
633
633
  const l = (m.deleted || []).filter((y) => M(y.target.selector)), g = (m.created || []).filter((y) => M(y.target.selector)), d = (m.updated || []).filter((y) => M(y.newValue.target.selector));
634
634
  (l == null ? void 0 : l.length) > 0 && l.forEach((y) => o.remove(y.target)), g.length > 0 && o.set(g.map((y) => y.target), !1), (d == null ? void 0 : d.length) > 0 && d.forEach(({ newValue: y }) => o.update(y.target));
@@ -640,10 +640,10 @@ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
640
640
  bulkUpdateTargets: f,
641
641
  bulkUpsertAnnotations: S,
642
642
  getAnnotationBounds: c,
643
- getAnnotationRects: w,
643
+ getAnnotationRects: A,
644
644
  getIntersecting: x,
645
645
  getAt: p,
646
- recalculatePositions: T,
646
+ recalculatePositions: R,
647
647
  onRecalculatePositions: E,
648
648
  updateTarget: b
649
649
  },
@@ -674,10 +674,10 @@ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
674
674
  n.font && (o.font = n.font);
675
675
  const c = s.get(b.annotation.id);
676
676
  if (c) {
677
- const { height: x } = b.rects[0], w = b.rects[0].x + f.left, T = b.rects[0].y + f.top;
678
- o.fillStyle = c.appearance.color, o.fillRect(w - 2, T - 2.5, 2, x + 5);
677
+ const { height: x } = b.rects[0], A = b.rects[0].x + f.left, R = b.rects[0].y + f.top;
678
+ o.fillStyle = c.appearance.color, o.fillRect(A - 2, R - 2.5, 2, x + 5);
679
679
  const E = o.measureText(c.appearance.label), m = E.width + 6, l = E.actualBoundingBoxAscent + E.actualBoundingBoxDescent + 8, g = E.fontBoundingBoxAscent ? 8 : 6.5;
680
- return o.fillRect(w - 2, T - 2.5 - l, m, l), o.fillStyle = "#fff", o.fillText(c.appearance.label, w + 1, T - g), {
680
+ return o.fillRect(A - 2, R - 2.5 - l, m, l), o.fillStyle = "#fff", o.fillText(c.appearance.label, A + 1, R - g), {
681
681
  fill: c.appearance.color,
682
682
  fillOpacity: p ? 0.45 : 0.18
683
683
  };
@@ -699,36 +699,36 @@ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
699
699
  annotatingEnabled: i,
700
700
  offsetReferenceSelector: a,
701
701
  selectionMode: u,
702
- dismissOnNotAnnotatable: S = "ANNOTATABLE_AREAS"
702
+ dismissOnNotAnnotatable: S = "NEVER"
703
703
  } = e, b = (h) => r = h;
704
704
  let f;
705
705
  const p = (h) => f = h;
706
- let c, x, w, T = i;
706
+ let c, x, A, R = i;
707
707
  const E = (h) => {
708
- T = h, l.clear(), h || (c = void 0, x = void 0, w = void 0);
708
+ R = h, l.clear(), h || (c = void 0, x = void 0, A = void 0);
709
709
  }, m = (h) => {
710
- T && x !== !1 && (c = U(t, h.target) ? void 0 : {
710
+ R && x !== !1 && (c = U(t, h.target) ? void 0 : {
711
711
  annotation: st(),
712
712
  selector: [],
713
713
  creator: r,
714
714
  created: /* @__PURE__ */ new Date()
715
715
  });
716
716
  }, l = X((h) => {
717
- if (!T) return;
718
- const R = document.getSelection();
719
- if (!(R != null && R.anchorNode))
717
+ if (!R) return;
718
+ const T = document.getSelection();
719
+ if (!(T != null && T.anchorNode))
720
720
  return;
721
- if (U(t, R.anchorNode)) {
721
+ if (U(t, T.anchorNode)) {
722
722
  c = void 0;
723
723
  return;
724
724
  }
725
- const O = h.timeStamp - ((w == null ? void 0 : w.timeStamp) || h.timeStamp);
726
- if ((w == null ? void 0 : w.type) === "pointerdown" && (O < 1e3 && !c || R.isCollapsed && O < et) && m(w || h), !c) return;
727
- if (R.isCollapsed) {
725
+ const O = h.timeStamp - ((A == null ? void 0 : A.timeStamp) || h.timeStamp);
726
+ if ((A == null ? void 0 : A.type) === "pointerdown" && (O < 1e3 && !c || T.isCollapsed && O < et) && m(A || h), !c) return;
727
+ if (T.isCollapsed) {
728
728
  o.getAnnotation(c.annotation) && (s.clear(), o.deleteAnnotation(c.annotation));
729
729
  return;
730
730
  }
731
- const H = Array.from(Array(R.rangeCount).keys()).map((N) => R.getRangeAt(N)).map((N) => $t(N, t));
731
+ const H = Array.from(Array(T.rangeCount).keys()).map((N) => T.getRangeAt(N)).map((N) => _t(N, t));
732
732
  if (H.every((N) => Mt(N))) return;
733
733
  const L = H.flatMap((N) => Bt(t, N.cloneRange()));
734
734
  (L.length !== c.selector.length || L.some((N, K) => {
@@ -738,16 +738,16 @@ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
738
738
  ...c,
739
739
  selector: L.map((N) => Kt(N, t, a)),
740
740
  updated: /* @__PURE__ */ new Date()
741
- }, o.getAnnotation(c.annotation) ? o.updateTarget(c, _.LOCAL) : s.clear());
741
+ }, o.getAnnotation(c.annotation) ? o.updateTarget(c, $.LOCAL) : s.clear());
742
742
  }, 10), g = (h) => {
743
- U(t, h.target) || (w = Q(h), x = w.button === 0);
743
+ U(t, h.target) || (A = Q(h), x = A.button === 0);
744
744
  }, d = async (h) => {
745
745
  if (!x) return;
746
746
  if (U(t, h.target)) {
747
747
  (typeof S == "function" ? S(h, t) : S === "ALWAYS") && s.clear();
748
748
  return;
749
749
  }
750
- const R = () => {
750
+ const T = () => {
751
751
  const { x: I, y: H } = t.getBoundingClientRect(), L = h.target instanceof Node && t.contains(h.target) && o.getAt(h.clientX - I, h.clientY - H, u === "all", f);
752
752
  if (L) {
753
753
  const { selected: W } = s, N = new Set(W.map((F) => F.id)), K = Array.isArray(L) ? L.map((F) => F.id) : [L.id];
@@ -755,39 +755,39 @@ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
755
755
  } else
756
756
  s.clear();
757
757
  };
758
- if (h.timeStamp - w.timeStamp < et) {
758
+ if (h.timeStamp - A.timeStamp < et) {
759
759
  await y();
760
760
  const I = document.getSelection();
761
761
  if (I != null && I.isCollapsed) {
762
- c = void 0, R();
762
+ c = void 0, T();
763
763
  return;
764
764
  }
765
765
  }
766
766
  c && c.selector.length > 0 && (B(), s.userSelect(c.annotation, Q(h)));
767
767
  }, y = async () => {
768
768
  const h = document.getSelection();
769
- let R = !1, O = h == null ? void 0 : h.isCollapsed;
770
- const I = () => O || R, H = 1;
771
- return setTimeout(() => R = !0, 50), xt(() => O = h == null ? void 0 : h.isCollapsed, H, I);
772
- }, A = (h) => {
773
- const R = document.getSelection();
774
- R != null && R.isCollapsed || ((!c || c.selector.length === 0) && l(h), c && (B(), s.userSelect(c.annotation, Q(h))));
769
+ let T = !1, O = h == null ? void 0 : h.isCollapsed;
770
+ const I = () => O || T, H = 1;
771
+ return setTimeout(() => T = !0, 50), xt(() => O = h == null ? void 0 : h.isCollapsed, H, I);
772
+ }, w = (h) => {
773
+ const T = document.getSelection();
774
+ T != null && T.isCollapsed || ((!c || c.selector.length === 0) && l(h), c && (B(), s.userSelect(c.annotation, Q(h))));
775
775
  }, v = (h) => {
776
- T && h.key === "Shift" && c && (document.getSelection().isCollapsed || (B(), s.userSelect(c.annotation, Y(h))));
776
+ R && h.key === "Shift" && c && (document.getSelection().isCollapsed || (B(), s.userSelect(c.annotation, Y(h))));
777
777
  }, C = (h) => {
778
- const R = () => setTimeout(() => {
778
+ const T = () => setTimeout(() => {
779
779
  (c == null ? void 0 : c.selector.length) > 0 && (s.clear(), o.addAnnotation({
780
780
  id: c.annotation,
781
781
  bodies: [],
782
782
  target: c
783
- }), s.userSelect(c.annotation, Y(h))), document.removeEventListener("selectionchange", R);
783
+ }), s.userSelect(c.annotation, Y(h))), document.removeEventListener("selectionchange", T);
784
784
  }, 100);
785
- document.addEventListener("selectionchange", R), m(h);
785
+ document.addEventListener("selectionchange", T), m(h);
786
786
  };
787
787
  V(de.join(","), { element: t, keydown: !0, keyup: !1 }, (h) => {
788
- h.repeat || (w = Y(h));
788
+ h.repeat || (A = Y(h));
789
789
  }), V(dt, { keydown: !0, keyup: !1 }, (h) => {
790
- w = Y(h), C(h);
790
+ A = Y(h), C(h);
791
791
  });
792
792
  const k = (h) => {
793
793
  h.repeat || h.target !== t && h.target !== document.body || (c = void 0, s.clear());
@@ -803,12 +803,12 @@ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
803
803
  });
804
804
  return;
805
805
  }
806
- const { target: { updated: R } } = h, { updated: O } = c;
807
- (!R || !O || R < O) && o.updateTarget(c);
806
+ const { target: { updated: T } } = h, { updated: O } = c;
807
+ (!T || !O || T < O) && o.updateTarget(c);
808
808
  };
809
- return t.addEventListener("pointerdown", g), document.addEventListener("pointerup", d), document.addEventListener("contextmenu", A), t.addEventListener("keyup", v), t.addEventListener("selectstart", m), document.addEventListener("selectionchange", l), {
809
+ return t.addEventListener("pointerdown", g), document.addEventListener("pointerup", d), document.addEventListener("contextmenu", w), t.addEventListener("keyup", v), t.addEventListener("selectstart", m), document.addEventListener("selectionchange", l), {
810
810
  destroy: () => {
811
- c = void 0, x = void 0, w = void 0, l.clear(), t.removeEventListener("pointerdown", g), document.removeEventListener("pointerup", d), document.removeEventListener("contextmenu", A), t.removeEventListener("keyup", v), t.removeEventListener("selectstart", m), document.removeEventListener("selectionchange", l), V.unbind();
811
+ c = void 0, x = void 0, A = void 0, l.clear(), t.removeEventListener("pointerdown", g), document.removeEventListener("pointerup", d), document.removeEventListener("contextmenu", w), t.removeEventListener("keyup", v), t.removeEventListener("selectstart", m), document.removeEventListener("selectionchange", l), V.unbind();
812
812
  },
813
813
  setFilter: p,
814
814
  setUser: b,
@@ -819,7 +819,7 @@ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
819
819
  annotatingEnabled: t.annotatingEnabled ?? n.annotatingEnabled,
820
820
  user: t.user || n.user
821
821
  }), nt = "SPANS", xe = (t, n = {}) => {
822
- Rt(t), kt(t);
822
+ Tt(t), kt(t);
823
823
  const e = fe(n, {
824
824
  annotatingEnabled: !0,
825
825
  user: St()
@@ -831,11 +831,11 @@ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
831
831
  console.debug(`Using ${b} renderer`), e.style && f.setStyle(e.style);
832
832
  const p = ue(t, o, e);
833
833
  p.setUser(S), p.setAnnotatingEnabled(e.annotatingEnabled);
834
- const c = At(o, a, e.adapter), x = () => S, w = (d) => {
834
+ const c = wt(o, a, e.adapter), x = () => S, A = (d) => {
835
835
  p.setAnnotatingEnabled(
836
836
  d === void 0 ? !0 : d
837
837
  );
838
- }, T = (d) => {
838
+ }, R = (d) => {
839
839
  f.setFilter(d), p.setFilter(d);
840
840
  }, E = (d) => {
841
841
  S = d, p.setUser(d);
@@ -851,8 +851,8 @@ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
851
851
  },
852
852
  element: t,
853
853
  getUser: x,
854
- setAnnotatingEnabled: w,
855
- setFilter: T,
854
+ setAnnotatingEnabled: A,
855
+ setFilter: R,
856
856
  setStyle: f.setStyle.bind(f),
857
857
  redraw: f.redraw.bind(f),
858
858
  setUser: E,
@@ -869,11 +869,11 @@ export {
869
869
  q as DEFAULT_SELECTED_STYLE,
870
870
  P as DEFAULT_STYLE,
871
871
  rt as NOT_ANNOTATABLE_CLASS,
872
- $ as NOT_ANNOTATABLE_SELECTOR,
872
+ _ as NOT_ANNOTATABLE_SELECTOR,
873
873
  Le as Origin,
874
874
  ke as UserSelectAction,
875
875
  ve as W3CTextFormat,
876
- Rt as cancelSingleClickEvents,
876
+ Tt as cancelSingleClickEvents,
877
877
  Y as cloneKeyboardEvent,
878
878
  Q as clonePointerEvent,
879
879
  Ne as createBody,
@@ -890,14 +890,14 @@ export {
890
890
  Z as getRangeAnnotatableContents,
891
891
  Lt as isMac,
892
892
  U as isNotAnnotatable,
893
- Tt as isRangeAnnotatable,
893
+ Rt as isRangeAnnotatable,
894
894
  M as isRevived,
895
895
  Mt as isWhitespaceOrEmpty,
896
896
  Dt as mergeClientRects,
897
897
  Wt as paint,
898
898
  se as parseW3CTextAnnotation,
899
899
  kt as programmaticallyFocusable,
900
- _t as rangeContains,
900
+ $t as rangeContains,
901
901
  Kt as rangeToSelector,
902
902
  G as reviveAnnotation,
903
903
  it as reviveSelector,
@@ -905,10 +905,10 @@ export {
905
905
  Ut as scrollIntoView,
906
906
  re as serializeW3CTextAnnotation,
907
907
  Bt as splitAnnotatableRanges,
908
- Ae as toDomRectList,
908
+ we as toDomRectList,
909
909
  Ft as toParentBounds,
910
- we as toViewportBounds,
911
- $t as trimRangeToContainer,
910
+ Ae as toViewportBounds,
911
+ _t as trimRangeToContainer,
912
912
  It as whitespaceOrEmptyRegex
913
913
  };
914
914
  //# sourceMappingURL=text-annotator.es.js.map