@soomo/text-annotator 3.3.0-staging.0 → 3.4.0-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.
@@ -6,14 +6,14 @@ import { serializeW3CBodies as ft, parseW3CBodies as gt, parseW3CUser as mt, cre
6
6
  import { Origin as Le, UserSelectAction as ke, createBody as Ne } from "@annotorious/core";
7
7
  import At from "rbush";
8
8
  import { createNanoEvents as vt } from "nanoevents";
9
- import V from "hotkeys-js";
9
+ import W 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}`, Y = (t, n) => {
12
12
  var o;
13
13
  return t.contains(n) ? !!(n instanceof HTMLElement ? n.closest(_) : (o = n.parentElement) == null ? void 0 : o.closest(_)) : !0;
14
14
  }, Rt = (t, n) => {
15
15
  const e = n.commonAncestorContainer;
16
- return !U(t, e);
16
+ return !Y(t, e);
17
17
  }, Tt = (t) => t.addEventListener("click", (n) => {
18
18
  // Allow clicks within not-annotatable elements
19
19
  !n.target.closest(_) && !n.target.closest("a") && n.preventDefault();
@@ -195,7 +195,7 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
195
195
  pointerId: t.pointerId,
196
196
  pointerType: t.pointerType,
197
197
  timeStamp: t.timeStamp
198
- }), Y = (t) => ({
198
+ }), V = (t) => ({
199
199
  ...t,
200
200
  type: t.type,
201
201
  key: t.key,
@@ -266,11 +266,11 @@ 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: 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 }) => {
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: F }) => {
270
270
  const N = I.includes(L.id), K = L.id === i.current;
271
271
  return {
272
272
  annotation: L,
273
- rects: W,
273
+ rects: F,
274
274
  state: { selected: N, hovered: K }
275
275
  };
276
276
  });
@@ -707,7 +707,7 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
707
707
  const E = (h) => {
708
708
  R = h, l.clear(), h || (c = void 0, x = void 0, A = void 0);
709
709
  }, m = (h) => {
710
- R && x !== !1 && (c = U(t, h.target) ? void 0 : {
710
+ R && x !== !1 && (c = Y(t, h.target) ? void 0 : {
711
711
  annotation: st(),
712
712
  selector: [],
713
713
  creator: r,
@@ -718,7 +718,7 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
718
718
  const T = document.getSelection();
719
719
  if (!(T != null && T.anchorNode))
720
720
  return;
721
- if (U(t, T.anchorNode)) {
721
+ if (Y(t, T.anchorNode)) {
722
722
  c = void 0;
723
723
  return;
724
724
  }
@@ -740,18 +740,19 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
740
740
  updated: /* @__PURE__ */ new Date()
741
741
  }, o.getAnnotation(c.annotation) ? o.updateTarget(c, $.LOCAL) : s.clear());
742
742
  }, 10), g = (h) => {
743
- U(t, h.target) || (A = Q(h), x = A.button === 0);
743
+ A = Q(h), x = A.button === 0;
744
744
  }, d = async (h) => {
745
745
  if (!x) return;
746
- if (U(t, h.target)) {
747
- (typeof S == "function" ? S(h, t) : S === "ALWAYS") && s.clear();
748
- return;
749
- }
750
746
  const T = () => {
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);
747
+ const { x: I, y: H } = t.getBoundingClientRect();
748
+ if (Y(t, h.target)) {
749
+ (typeof S == "function" ? S(h, t) : S === "ALWAYS") && s.clear();
750
+ return;
751
+ }
752
+ const L = h.target instanceof Node && t.contains(h.target) && o.getAt(h.clientX - I, h.clientY - H, u === "all", f);
752
753
  if (L) {
753
- const { selected: W } = s, N = new Set(W.map((F) => F.id)), K = Array.isArray(L) ? L.map((F) => F.id) : [L.id];
754
- (N.size !== K.length || !K.every((F) => N.has(F))) && s.userSelect(K, h);
754
+ const { selected: F } = s, N = new Set(F.map((U) => U.id)), K = Array.isArray(L) ? L.map((U) => U.id) : [L.id];
755
+ (N.size !== K.length || !K.every((U) => N.has(U))) && s.userSelect(K, h);
755
756
  } else
756
757
  s.clear();
757
758
  };
@@ -773,26 +774,26 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
773
774
  const T = document.getSelection();
774
775
  T != null && T.isCollapsed || ((!c || c.selector.length === 0) && l(h), c && (B(), s.userSelect(c.annotation, Q(h))));
775
776
  }, v = (h) => {
776
- R && h.key === "Shift" && c && (document.getSelection().isCollapsed || (B(), s.userSelect(c.annotation, Y(h))));
777
+ R && h.key === "Shift" && c && (document.getSelection().isCollapsed || (B(), s.userSelect(c.annotation, V(h))));
777
778
  }, C = (h) => {
778
779
  const T = () => setTimeout(() => {
779
780
  (c == null ? void 0 : c.selector.length) > 0 && (s.clear(), o.addAnnotation({
780
781
  id: c.annotation,
781
782
  bodies: [],
782
783
  target: c
783
- }), s.userSelect(c.annotation, Y(h))), document.removeEventListener("selectionchange", T);
784
+ }), s.userSelect(c.annotation, V(h))), document.removeEventListener("selectionchange", T);
784
785
  }, 100);
785
786
  document.addEventListener("selectionchange", T), m(h);
786
787
  };
787
- V(de.join(","), { element: t, keydown: !0, keyup: !1 }, (h) => {
788
- h.repeat || (A = Y(h));
789
- }), V(dt, { keydown: !0, keyup: !1 }, (h) => {
790
- A = Y(h), C(h);
788
+ W(de.join(","), { element: t, keydown: !0, keyup: !1 }, (h) => {
789
+ h.repeat || (A = V(h));
790
+ }), W(dt, { keydown: !0, keyup: !1 }, (h) => {
791
+ A = V(h), C(h);
791
792
  });
792
793
  const k = (h) => {
793
794
  h.repeat || h.target !== t && h.target !== document.body || (c = void 0, s.clear());
794
795
  };
795
- V(lt.join(","), { keydown: !0, keyup: !1 }, k);
796
+ W(lt.join(","), { keydown: !0, keyup: !1 }, k);
796
797
  const B = () => {
797
798
  const h = o.getAnnotation(c.annotation);
798
799
  if (!h) {
@@ -806,9 +807,9 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
806
807
  const { target: { updated: T } } = h, { updated: O } = c;
807
808
  (!T || !O || T < O) && o.updateTarget(c);
808
809
  };
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
+ return document.addEventListener("pointerdown", g), document.addEventListener("pointerup", d), document.addEventListener("contextmenu", w), t.addEventListener("keyup", v), t.addEventListener("selectstart", m), document.addEventListener("selectionchange", l), {
810
811
  destroy: () => {
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
+ c = void 0, x = void 0, A = void 0, l.clear(), document.removeEventListener("pointerdown", g), document.removeEventListener("pointerup", d), document.removeEventListener("contextmenu", w), t.removeEventListener("keyup", v), t.removeEventListener("selectstart", m), document.removeEventListener("selectionchange", l), W.unbind();
812
813
  },
813
814
  setFilter: p,
814
815
  setUser: b,
@@ -874,7 +875,7 @@ export {
874
875
  ke as UserSelectAction,
875
876
  ve as W3CTextFormat,
876
877
  Tt as cancelSingleClickEvents,
877
- Y as cloneKeyboardEvent,
878
+ V as cloneKeyboardEvent,
878
879
  Q as clonePointerEvent,
879
880
  Ne as createBody,
880
881
  jt as createCanvasRenderer,
@@ -889,7 +890,7 @@ export {
889
890
  Ot as getQuoteContext,
890
891
  Z as getRangeAnnotatableContents,
891
892
  Lt as isMac,
892
- U as isNotAnnotatable,
893
+ Y as isNotAnnotatable,
893
894
  Rt as isRangeAnnotatable,
894
895
  M as isRevived,
895
896
  Mt as isWhitespaceOrEmpty,