@soomo/react-text-annotator 4.4.4-staging.0 → 4.4.5-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.
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ export * from './text-annotator-plugin';
6
6
  export type { Annotation, AnnotationBody, AnnotationTarget, Annotator, AnnotatorState, Filter, FormatAdapter, HoverState, Selection, SelectionState, Store, StoreChangeEvent, StoreObserver, ParseResult, User, UserSelectActionExpression, W3CAnnotation, W3CAnnotationBody, W3CAnnotationTarget } from '@annotorious/core';
7
7
  export { createBody, Origin, UserSelectAction } from '@annotorious/core';
8
8
  export { AnnotoriousPlugin } from '@annotorious/react';
9
- export type { AnnotatingMode, HighlightStyle, HighlightStyleExpression, TextAnnotation, TextAnnotationTarget, TextSelector, W3CTextAnnotation, W3CTextAnnotationTarget, W3CTextSelector, W3CAnnotationStylesheet, TextAnnotator as RecogitoTextAnnotator, TextAnnotationStore } from '@soomo/text-annotator';
9
+ export type { AnnotatingMode, HighlightStyle, HighlightStyleExpression, RevivedTextAnnotationLike, RevivedTextAnnotationTargetLike, RevivedTextSelector, RevivedTextSelectorLike, TextAnnotation, TextAnnotationLike, TextAnnotationTarget, TextAnnotationTargetLike, TextSelector, TextSelectorLike, W3CTextAnnotation, W3CTextAnnotationTarget, W3CTextSelector, W3CAnnotationStylesheet, TextAnnotator as RecogitoTextAnnotator, TextAnnotationStore } from '@soomo/text-annotator';
10
10
  export { W3CTextFormat, parseW3CTextAnnotation, serializeW3CTextAnnotation } from '@soomo/text-annotator';
11
- export type { TEIAnnotator as RecogitoTEIAnnotator, TEIAnnotation, TEIAnnotationTarget, TEIRangeSelector, W3CTEIAnnotation, W3CTEIAnnotationTarget, W3CTEIRangeSelector } from '@recogito/text-annotator-tei';
11
+ export type { RevivedTEIAnnotation, RevivedTEIAnnotationTarget, RevivedTEIRangeSelector, TEIAnnotator as RecogitoTEIAnnotator, TEIAnnotation, TEIAnnotationTarget, TEIRangeSelector, W3CTEIAnnotation, W3CTEIAnnotationTarget, W3CTEIRangeSelector } from '@recogito/text-annotator-tei';
12
12
  export { serializeW3CTEIAnnotation } from '@recogito/text-annotator-tei';
@@ -1,14 +1,14 @@
1
- import { jsx as d, Fragment as L, jsxs as R } from "react/jsx-runtime";
2
- import { useRef as v, useEffect as i, useContext as F, useCallback as x, Children as I, cloneElement as M, useState as E } from "react";
1
+ import { jsx as f, Fragment as L, jsxs as R } from "react/jsx-runtime";
2
+ import { useRef as p, useEffect as s, useContext as F, useCallback as x, Children as I, cloneElement as M, useState as E } from "react";
3
3
  import N from "CETEIcean";
4
- import { AnnotoriousContext as P, useAnnotationStore as U, Origin as k, useAnnotator as W, useSelection as _ } from "@annotorious/react";
4
+ import { AnnotoriousContext as P, useAnnotationStore as U, Origin as k, useAnnotator as V, useSelection as W } from "@annotorious/react";
5
5
  import { AnnotoriousPlugin as Tt } from "@annotorious/react";
6
- import { createTEIAnnotator as j } from "@recogito/text-annotator-tei";
6
+ import { createTEIAnnotator as _ } from "@recogito/text-annotator-tei";
7
7
  import { serializeW3CTEIAnnotation as Et } from "@recogito/text-annotator-tei";
8
8
  import "@soomo/text-annotator/text-annotator.css";
9
- import { Ignore as H } from "@annotorious/core";
9
+ import { Ignore as j } from "@annotorious/core";
10
10
  import { Origin as Ot, UserSelectAction as yt, createBody as Ft } from "@annotorious/core";
11
- import { createTextAnnotator as Q, toViewportBounds as B, toDomRectList as D, NOT_ANNOTATABLE_CLASS as V } from "@soomo/text-annotator";
11
+ import { createTextAnnotator as H, toViewportBounds as B, toDomRectList as Q, NOT_ANNOTATABLE_CLASS as D } from "@soomo/text-annotator";
12
12
  import { W3CTextFormat as Bt, parseW3CTextAnnotation as Lt, serializeW3CTextAnnotation as Rt } from "@soomo/text-annotator";
13
13
  import z from "debounce";
14
14
  import { useFloating as Y, autoUpdate as $, inline as q, offset as J, flip as G, shift as K, arrow as X, FloatingPortal as Z, FloatingFocusManager as tt, FloatingArrow as et } from "@floating-ui/react";
@@ -33,8 +33,8 @@ const y = {
33
33
  }
34
34
  }
35
35
  }, At = (t) => {
36
- const e = v(null);
37
- return i(() => {
36
+ const e = p(null);
37
+ return s(() => {
38
38
  if (t.tei) {
39
39
  const n = new N(t.initArgs);
40
40
  n.addBehaviors({
@@ -44,14 +44,14 @@ const y = {
44
44
  ...y.tei,
45
45
  ...t.behaviors?.tei || {}
46
46
  }
47
- }), n.makeHTML5(t.tei, (r) => {
48
- e.current?.appendChild(r), t.onLoad?.(e.current);
47
+ }), n.makeHTML5(t.tei, (o) => {
48
+ e.current?.appendChild(o), t.onLoad?.(e.current);
49
49
  });
50
50
  }
51
51
  return () => {
52
52
  e.current && (e.current.innerHTML = "");
53
53
  };
54
- }, [t.tei, JSON.stringify(t.initArgs), t.onLoad]), /* @__PURE__ */ d(
54
+ }, [t.tei, JSON.stringify(t.initArgs), t.onLoad]), /* @__PURE__ */ f(
55
55
  "div",
56
56
  {
57
57
  ref: e,
@@ -59,44 +59,44 @@ const y = {
59
59
  }
60
60
  );
61
61
  }, bt = (t) => {
62
- const { children: e, ...n } = t, { anno: r, setAnno: o } = F(P), s = x((l) => {
63
- const c = j(l, n);
64
- o(c);
62
+ const { children: e, ...n } = t, { anno: o, setAnno: r } = F(P), i = x((l) => {
63
+ const c = _(l, n);
64
+ r(c);
65
65
  }, []);
66
- return i(() => r?.setStyle(t.style), [r, t.style]), i(() => r?.setFilter(t.filter), [r, t.filter]), i(() => r?.setUser(n.user), [r, n.user]), i(() => r?.setAnnotatingEnabled(n.annotatingEnabled), [r, n.annotatingEnabled]), i(() => r?.setAnnotatingMode(n.annotatingMode), [r, n.annotatingMode]), t.children ? /* @__PURE__ */ d(L, { children: I.toArray(t.children).map((l) => M(l, { onLoad: s })) }) : null;
66
+ return s(() => o?.setStyle(t.style), [o, t.style]), s(() => o?.setFilter(t.filter), [o, t.filter]), s(() => o?.setVisible(!t.hideAnnotations), [o, t.hideAnnotations]), s(() => o?.setUser(n.user), [o, n.user]), s(() => o?.setAnnotatingEnabled(n.annotatingEnabled), [o, n.annotatingEnabled]), s(() => o?.setAnnotatingMode(n.annotatingMode), [o, n.annotatingMode]), t.children ? /* @__PURE__ */ f(L, { children: I.toArray(t.children).map((l) => M(l, { onLoad: i })) }) : null;
67
67
  }, T = (t, e = { timeout: 250 }) => {
68
- const n = U(), [r, o] = E(!0);
69
- return i(() => {
68
+ const n = U(), [o, r] = E(!0);
69
+ return s(() => {
70
70
  if (!n || !t) return;
71
- let s;
71
+ let i;
72
72
  const l = (c) => {
73
- const { changes: { updated: p } } = c;
74
- p?.some((f) => {
75
- const { targetUpdated: a } = f;
76
- if (a) {
77
- const { oldTarget: u, newTarget: g } = a;
78
- return nt(u, g);
73
+ const { changes: { updated: w } } = c;
74
+ w?.some((g) => {
75
+ const { targetUpdated: u } = g;
76
+ if (u) {
77
+ const { oldTarget: a, newTarget: d } = u;
78
+ return nt(a, d);
79
79
  }
80
- }) && (o(!1), clearTimeout(s), s = setTimeout(() => o(!0), e.timeout));
80
+ }) && (r(!1), clearTimeout(i), i = setTimeout(() => r(!0), e.timeout));
81
81
  };
82
82
  return n.observe(l, {
83
83
  annotations: t,
84
- ignore: H.BODY_ONLY,
84
+ ignore: j.BODY_ONLY,
85
85
  origin: k.LOCAL
86
86
  }), () => {
87
- clearTimeout(s), n.unobserve(l);
87
+ clearTimeout(i), n.unobserve(l);
88
88
  };
89
- }, [n, t, e.timeout]), r;
89
+ }, [n, t, e.timeout]), o;
90
90
  }, nt = (t, e) => {
91
- const { selector: n } = t, r = n.map(({ quote: l }) => l), { selector: o } = e, s = o.map(({ quote: l }) => l);
92
- return r.join() !== s.join();
93
- }, pt = (t) => {
94
- const e = v(null), { className: n, children: r, ...o } = t, { style: s, filter: l, user: c, annotatingEnabled: p, userSelectAction: A, annotatingMode: f } = o, { anno: a, setAnno: u } = F(P);
95
- return i(() => {
96
- if (!u || !e.current) return;
97
- const g = typeof o.adapter == "function" ? o.adapter(e.current) : o.adapter, C = Q(e.current, { ...o, adapter: g });
98
- return u(C), () => C.destroy();
99
- }, [u]), i(() => a?.setStyle(s), [a, s]), i(() => a?.setFilter(l), [a, l]), i(() => a?.setUser(c), [a, c]), i(() => a?.setUserSelectAction(A), [a, A]), i(() => a?.setAnnotatingEnabled(p), [a, p]), i(() => a?.setAnnotatingMode(f), [a, f]), /* @__PURE__ */ d("div", { ref: e, className: `r6o-annotatable no-focus-outline ${n}`, children: r });
91
+ const { selector: n } = t, o = n.map(({ quote: l }) => l), { selector: r } = e, i = r.map(({ quote: l }) => l);
92
+ return o.join() !== i.join();
93
+ }, Ct = (t) => {
94
+ const e = p(null), { className: n, children: o, hideAnnotations: r, ...i } = t, { style: l, filter: c, user: w, annotatingEnabled: b, userSelectAction: g, annotatingMode: u } = i, { anno: a, setAnno: d } = F(P);
95
+ return s(() => {
96
+ if (!d || !e.current) return;
97
+ const v = typeof i.adapter == "function" ? i.adapter(e.current) : i.adapter, m = H(e.current, { ...i, adapter: v });
98
+ return d(m), () => m.destroy();
99
+ }, [d]), s(() => a?.setStyle(l), [a, l]), s(() => a?.setFilter(c), [a, c]), s(() => a?.setVisible(!r), [a, r]), s(() => a?.setUser(w), [a, w]), s(() => a?.setUserSelectAction(g), [a, g]), s(() => a?.setAnnotatingEnabled(b), [a, b]), s(() => a?.setAnnotatingMode(u), [a, u]), /* @__PURE__ */ f("div", { ref: e, className: `r6o-annotatable no-focus-outline ${n}`, children: o });
100
100
  }, ot = () => {
101
101
  if (typeof navigator > "u") return !1;
102
102
  var t = navigator.userAgent || navigator.vendor || window?.opera;
@@ -105,65 +105,65 @@ const y = {
105
105
  let S = null;
106
106
  const rt = z((t, e, n) => {
107
107
  requestAnimationFrame(() => {
108
- const r = e.getAnnotationBounds(t);
109
- r && (S = B(r, n.getBoundingClientRect()));
108
+ const o = e.getAnnotationBounds(t);
109
+ o && (S = B(o, n.getBoundingClientRect()));
110
110
  });
111
111
  }, 250), it = (t) => {
112
- const e = W(), { selected: n, event: r } = _(), o = n[0]?.annotation;
113
- T(o?.id);
114
- const [s, l] = E(n?.length > 0), c = () => e?.cancelSelected(), [p, A] = E(!1);
115
- x(() => A(!0), []);
116
- const f = x(() => A(!1), []);
117
- i(() => {
118
- s || f();
119
- }, [s, f]);
120
- const a = v(!1), u = v(null), { refs: g, floatingStyles: C, update: w, context: O } = Y({
112
+ const e = V(), { selected: n, event: o } = W(), r = n[0]?.annotation;
113
+ T(r?.id);
114
+ const [i, l] = E(n?.length > 0), c = () => e?.cancelSelected(), [w, b] = E(!1);
115
+ x(() => b(!0), []);
116
+ const g = x(() => b(!1), []);
117
+ s(() => {
118
+ i || g();
119
+ }, [i, g]);
120
+ const u = p(!1), a = p(null), { refs: d, floatingStyles: v, update: m, context: O } = Y({
121
121
  placement: ot() ? "bottom" : t.placement || "top",
122
122
  strategy: "absolute",
123
- open: s,
124
- onOpenChange: (m, h, b) => {
125
- !m && (b === "escape-key" || b === "focus-out") && (l(m), c());
123
+ open: i,
124
+ onOpenChange: (h, A, C) => {
125
+ !h && (C === "escape-key" || C === "focus-out") && (l(h), c());
126
126
  },
127
127
  middleware: [
128
128
  q(),
129
129
  J(10),
130
130
  G({ crossAxis: !0 }),
131
131
  K({ crossAxis: !0, padding: 10 }),
132
- X({ element: u })
132
+ X({ element: a })
133
133
  ],
134
134
  whileElementsMounted: $
135
135
  });
136
- return i(() => {
136
+ return s(() => {
137
137
  if (!e) return;
138
- const m = o?.id, h = o?.target.selector.length;
139
- if (m && h > 0 && T) {
140
- const b = e?.state.store.getAnnotationBounds(o.id);
141
- l(!!b);
138
+ const h = r?.id, A = r?.target.selector.length;
139
+ if (h && A > 0 && T) {
140
+ const C = e?.state.store.getAnnotationBounds(r.id);
141
+ l(!!C);
142
142
  } else
143
143
  l(!1);
144
- }, [o?.id, o?.target.selector, T, e?.state.store]), i(() => {
145
- t.onClose && (s ? a.current = !0 : a.current && (a.current = !1, t.onClose()));
146
- }, [t.onClose, s]), i(() => {
147
- e && (s && o?.id ? g.setPositionReference({
148
- getBoundingClientRect: () => (rt(o.id, e.state.store, e.element), S || new DOMRect()),
144
+ }, [r?.id, r?.target.selector, T, e?.state.store]), s(() => {
145
+ t.onClose && (i ? u.current = !0 : u.current && (u.current = !1, t.onClose()));
146
+ }, [t.onClose, i]), s(() => {
147
+ e && (i && r?.id ? d.setPositionReference({
148
+ getBoundingClientRect: () => (rt(r.id, e.state.store, e.element), S || new DOMRect()),
149
149
  getClientRects: () => {
150
- const h = e.state.store.getAnnotationRects(o.id).map(
151
- (b) => B(b, e.element.getBoundingClientRect())
150
+ const A = e.state.store.getAnnotationRects(r.id).map(
151
+ (C) => B(C, e.element.getBoundingClientRect())
152
152
  );
153
- return D(h);
153
+ return Q(A);
154
154
  }
155
- }) : g.setPositionReference(null));
156
- }, [s, o?.id, o?.target, e]), i(() => {
155
+ }) : d.setPositionReference(null));
156
+ }, [i, r?.id, r?.target, e]), s(() => {
157
157
  if (!t.asPortal) return;
158
- const m = { attributes: !0, childList: !0, subtree: !0 }, h = new MutationObserver(() => w());
159
- return h.observe(document.body, m), window.document.addEventListener("scroll", w, !0), () => {
160
- h.disconnect(), window.document.removeEventListener("scroll", w, !0);
158
+ const h = { attributes: !0, childList: !0, subtree: !0 }, A = new MutationObserver(() => m());
159
+ return A.observe(document.body, h), window.document.addEventListener("scroll", m, !0), () => {
160
+ A.disconnect(), window.document.removeEventListener("scroll", m, !0);
161
161
  };
162
- }, [w, t.asPortal]), s && o ? /* @__PURE__ */ d(
162
+ }, [m, t.asPortal]), i && r ? /* @__PURE__ */ f(
163
163
  Z,
164
164
  {
165
165
  root: t.asPortal ? void 0 : e.element,
166
- children: /* @__PURE__ */ d(
166
+ children: /* @__PURE__ */ f(
167
167
  tt,
168
168
  {
169
169
  context: O,
@@ -174,26 +174,26 @@ const rt = z((t, e, n) => {
174
174
  children: /* @__PURE__ */ R(
175
175
  "div",
176
176
  {
177
- className: `a9s-popup r6o-popup annotation-popup r6o-text-popup ${V}`,
178
- ref: g.setFloating,
179
- style: C,
177
+ className: `a9s-popup r6o-popup annotation-popup r6o-text-popup ${D}`,
178
+ ref: d.setFloating,
179
+ style: v,
180
180
  children: [
181
181
  t.popup({
182
182
  annotation: n[0].annotation,
183
183
  // for backwards compatibility
184
184
  editable: n[0].editable,
185
185
  selected: n,
186
- event: r
186
+ event: o
187
187
  }),
188
- t.arrow && /* @__PURE__ */ d(
188
+ t.arrow && /* @__PURE__ */ f(
189
189
  et,
190
190
  {
191
- ref: u,
191
+ ref: a,
192
192
  context: O,
193
193
  ...t.arrowProps || {}
194
194
  }
195
195
  ),
196
- /* @__PURE__ */ d("button", { className: "r6o-popup-sr-only", "aria-live": "assertive", onClick: c, children: t.ariaCloseWarning || "Click or leave this dialog to close it." })
196
+ /* @__PURE__ */ f("button", { className: "r6o-popup-sr-only", "aria-live": "assertive", onClick: c, children: t.ariaCloseWarning || "Click or leave this dialog to close it." })
197
197
  ]
198
198
  }
199
199
  )
@@ -201,17 +201,17 @@ const rt = z((t, e, n) => {
201
201
  )
202
202
  }
203
203
  ) : null;
204
- }, Ct = (t) => (i(() => {
204
+ }, wt = (t) => (s(() => {
205
205
  console.warn("TextAnnotatorPopup is deprecated and will be removed in a future version. Please use TextAnnotationPopup instead.");
206
- }, []), /* @__PURE__ */ d(it, { ...t }));
206
+ }, []), /* @__PURE__ */ f(it, { ...t }));
207
207
  export {
208
208
  Tt as AnnotoriousPlugin,
209
209
  At as CETEIcean,
210
210
  Ot as Origin,
211
211
  bt as TEIAnnotator,
212
212
  it as TextAnnotationPopup,
213
- pt as TextAnnotator,
214
- Ct as TextAnnotatorPopup,
213
+ Ct as TextAnnotator,
214
+ wt as TextAnnotatorPopup,
215
215
  yt as UserSelectAction,
216
216
  Bt as W3CTextFormat,
217
217
  Ft as createBody,
@@ -1 +1 @@
1
- {"version":3,"file":"react-text-annotator.es.js","sources":["../src/tei/ceteicean.tsx","../src/tei/tei-annotator.tsx","../src/hooks/use-annotation-quote-idle.ts","../src/text-annotator.tsx","../src/text-annotation-popup/is-mobile.ts","../src/text-annotation-popup/text-annotation-popup.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport CETEI from 'CETEIcean';\n\ninterface CETEIceanProps {\n\n initArgs?: any;\n\n tei?: string;\n\n onLoad?(element: Element): void;\n\n behaviors?: any;\n\n}\n\n// Override default list, note, table, and ref behaviors \n// so they don't introduce text into the DOM that interferes\n// with annotation. Apply a patch to graphics for robustness.\nconst PRESET_BEHAVIORS = {\n tei: {\n ref: (elem: Element) => {\n const a = document.createElement('a');\n\n while(elem.firstChild) {\n a.appendChild(elem.removeChild(elem.firstChild));\n }\n\n a.setAttribute('href', elem.getAttribute('target')!);\n\n elem.appendChild(a);\n },\n // Cf. https://github.com/TEIC/CETEIcean/issues/67\n graphic: (elem: Element) => {\n const content = new Image();\n content.src = elem.getAttribute('url')?.trim()!;\n\n if (elem.hasAttribute('width'))\n content.setAttribute('width', elem.getAttribute('width')!);\n\n if (elem.hasAttribute('height'))\n content.setAttribute('height', elem.getAttribute('height')!);\n\n elem.appendChild(content);\n },\n list: null,\n note: null,\n table: null,\n teiHeader: (elem: HTMLElement) => {\n elem.hidden = true;\n }\n }\n}\n\nexport const CETEIcean = (props: CETEIceanProps) => {\n\n const el = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (props.tei) {\n const ceteicean = new CETEI(props.initArgs);\n\n ceteicean.addBehaviors({\n ...PRESET_BEHAVIORS,\n ...(props.behaviors || {}),\n tei: {\n ...PRESET_BEHAVIORS.tei,\n ...(props.behaviors?.tei || {})\n }\n });\n\n ceteicean.makeHTML5(props.tei, (data: Element) => {\n el.current?.appendChild(data);\n props.onLoad?.(el.current!);\n });\n }\n\n return () => {\n if (el.current)\n el.current.innerHTML = '';\n }\n }, [props.tei, JSON.stringify(props.initArgs), props.onLoad]);\n\n return (\n <div \n ref={el}\n className=\"tei-container\" />\n )\n\n}","import { Children, JSX, ReactElement, ReactNode, cloneElement, useCallback, useContext, useEffect } from 'react';\nimport { AnnotoriousContext, Filter } from '@annotorious/react';\nimport { createTEIAnnotator, TEIAnnotation } from '@recogito/text-annotator-tei';\nimport type { AnnotatingMode, TextAnnotatorOptions } from '@soomo/text-annotator';\n\nimport '@soomo/text-annotator/text-annotator.css';\n\nexport type TEIAnnotatorProps = TextAnnotatorOptions<TEIAnnotation, unknown> & {\n\n children?: ReactNode | JSX.Element;\n\n annotatingMode?: AnnotatingMode;\n\n filter?: Filter;\n\n}\n\nexport const TEIAnnotator = (props: TEIAnnotatorProps) => {\n\n const { children, ...opts } = props;\n\n const { anno, setAnno } = useContext(AnnotoriousContext);\n\n const onLoad = useCallback((element: HTMLElement) => {\n const anno = createTEIAnnotator(element, opts);\n setAnno(anno);\n }, []);\n\n useEffect(() => anno?.setStyle(props.style), [anno, props.style]);\n\n useEffect(() => anno?.setFilter(props.filter), [anno, props.filter]);\n\n useEffect(() => anno?.setUser(opts.user), [anno, opts.user]);\n\n useEffect(() => anno?.setAnnotatingEnabled(opts.annotatingEnabled), [anno, opts.annotatingEnabled]);\n\n useEffect(() => anno?.setAnnotatingMode(opts.annotatingMode), [anno, opts.annotatingMode]);\n\n return props.children ? (\n <>\n {Children.toArray(props.children).map(child => \n cloneElement(child as ReactElement, { onLoad } as any))}\n </>\n ) : null;\n\n}\n","import { useEffect, useState } from 'react';\nimport { Origin, useAnnotationStore } from '@annotorious/react';\nimport { Ignore, type StoreChangeEvent } from '@annotorious/core';\nimport type { TextAnnotation, TextAnnotationStore, TextAnnotationTarget } from '@soomo/text-annotator';\n\nexport const useAnnotationQuoteIdle = (\n annotationId: string | undefined,\n options: { timeout: number } = { timeout: 250 }\n) => {\n const store = useAnnotationStore<TextAnnotationStore>();\n\n const [isIdle, setIsIdle] = useState(true);\n\n useEffect(() => {\n if (!store || !annotationId) return;\n\n let idleTimeout: ReturnType<typeof setTimeout>;\n\n const scheduleSetIsIdle = (event: StoreChangeEvent<TextAnnotation>) => {\n const { changes: { updated } } = event;\n\n const hasChanged = updated?.some(update => {\n const { targetUpdated } = update;\n if (targetUpdated) {\n const { oldTarget, newTarget } = targetUpdated;\n return hasQuoteChanged(oldTarget, newTarget);\n }\n });\n\n if (hasChanged) {\n setIsIdle(false);\n clearTimeout(idleTimeout);\n idleTimeout = setTimeout(() => setIsIdle(true), options.timeout);\n }\n };\n\n store.observe(scheduleSetIsIdle, {\n annotations: annotationId,\n ignore: Ignore.BODY_ONLY,\n origin: Origin.LOCAL\n });\n\n return () => {\n clearTimeout(idleTimeout);\n store.unobserve(scheduleSetIsIdle);\n };\n }, [store, annotationId, options.timeout]);\n\n return isIdle;\n};\n\nconst hasQuoteChanged = (oldValue: TextAnnotationTarget, newValue: TextAnnotationTarget) => {\n const { selector: oldSelector } = oldValue;\n const oldQuotes = oldSelector.map(({ quote }) => quote);\n\n const { selector: newSelector } = newValue;\n const newQuotes = newSelector.map(({ quote }) => quote);\n\n return oldQuotes.join() !== newQuotes.join();\n};\n","import { JSX, ReactNode, useContext, useEffect, useRef } from 'react';\nimport { AnnotoriousContext, Filter } from '@annotorious/react';\nimport type { FormatAdapter } from '@annotorious/core';\nimport { createTextAnnotator } from '@soomo/text-annotator';\nimport type { AnnotatingMode, TextAnnotation, TextAnnotatorOptions } from '@soomo/text-annotator';\n\nimport '@soomo/text-annotator/text-annotator.css';\n\nexport interface TextAnnotatorProps<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> extends Omit<TextAnnotatorOptions<I, E>, 'adapter'> {\n\n children?: ReactNode | JSX.Element;\n\n adapter?: FormatAdapter<I, E> | ((container: HTMLElement) => FormatAdapter<I, E>);\n\n annotatingMode?: AnnotatingMode;\n\n filter?: Filter<I>;\n\n className?: string;\n\n}\n\nexport const TextAnnotator = <I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation>(\n props: TextAnnotatorProps<I, E>\n) => {\n\n const el = useRef<HTMLDivElement>(null);\n\n const { className, children, ...opts } = props;\n\n const { style, filter, user, annotatingEnabled, userSelectAction, annotatingMode } = opts;\n\n const { anno, setAnno } = useContext(AnnotoriousContext);\n\n useEffect(() => {\n if (!setAnno || !el.current) return;\n\n const adapter = typeof opts.adapter === 'function' ? opts.adapter(el.current) : opts.adapter;\n\n const anno = createTextAnnotator(el.current!, { ...opts, adapter });\n setAnno(anno);\n\n return () => anno.destroy();\n }, [setAnno]);\n\n useEffect(() => anno?.setStyle(style), [anno, style]);\n\n useEffect(() => anno?.setFilter(filter), [anno, filter]);\n\n useEffect(() => anno?.setUser(user), [anno, user]);\n\n useEffect(() => anno?.setUserSelectAction(userSelectAction), [anno, userSelectAction]);\n\n useEffect(() => anno?.setAnnotatingEnabled(annotatingEnabled), [anno, annotatingEnabled]);\n\n useEffect(() => anno?.setAnnotatingMode(annotatingMode), [anno, annotatingMode]);\n\n return (\n <div ref={el} className={`r6o-annotatable no-focus-outline ${className}`}>\n {children}\n </div>\n );\n\n};\n","// https://stackoverflow.com/questions/21741841/detecting-ios-android-operating-system\nexport const isMobile = () => {\n if (typeof navigator === 'undefined') return false;\n\n // @ts-ignore\n var userAgent: string = navigator.userAgent || navigator.vendor || window?.opera;\n\n if (/android/i.test(userAgent)) \n return true;\n\n // @ts-ignore\n // Note: as of recently, this NO LONGER DETECTS FIREFOX ON iOS!\n // This means FF/iOS will behave like on the desktop, and loose\n // selection handlebars after the popup opens.\n if (/iPad|iPhone/.test(userAgent) && !window.MSStream)\n return true;\n\n return false;\n}","import React, { FC, ReactNode, useCallback, useEffect, useRef, useState } from 'react';\nimport debounce from 'debounce';\nimport { useAnnotator, useSelection } from '@annotorious/react';\nimport {\n NOT_ANNOTATABLE_CLASS,\n TextAnnotationStore,\n toViewportBounds,\n toDomRectList,\n type TextAnnotation,\n type TextAnnotator,\n} from '@soomo/text-annotator';\nimport {\n arrow,\n autoUpdate,\n flip,\n FloatingArrow,\n FloatingArrowProps,\n FloatingFocusManager,\n FloatingPortal,\n inline,\n offset,\n Placement,\n shift,\n useFloating\n} from '@floating-ui/react';\nimport { isMobile } from './is-mobile';\nimport { useAnnotationQuoteIdle } from '../hooks';\n\nimport './text-annotation-popup.css';\n\ninterface TextAnnotationPopupProps {\n\n ariaNavigationMessage?: string;\n\n ariaCloseWarning?: string;\n\n arrow?: boolean;\n\n arrowProps?: Omit<FloatingArrowProps, 'context' | 'ref'>;\n\n asPortal?: boolean;\n\n autoFocus?: boolean;\n\n placement?: Placement;\n\n popup(props: TextAnnotationPopupContentProps): ReactNode;\n\n onClose?(): void;\n\n}\n\nexport interface TextAnnotationPopupContentProps<T extends TextAnnotation = TextAnnotation> {\n\n annotation: T;\n\n selected: { annotation: T; editable?: boolean; }[];\n\n editable?: boolean;\n\n event?: PointerEvent | KeyboardEvent;\n\n}\n\nlet cachedBounds: DOMRect | null = null;\n\nconst updateViewportBounds = debounce((annotationId: string, store: TextAnnotationStore, container: HTMLElement) => {\n requestAnimationFrame(() => {\n const bounds = store.getAnnotationBounds(annotationId);\n if (!bounds) return;\n cachedBounds = toViewportBounds(bounds, container.getBoundingClientRect());\n });\n}, 250);\n\nexport const TextAnnotationPopup = (props: TextAnnotationPopupProps) => {\n\n const r = useAnnotator<TextAnnotator>();\n\n const { selected, event } = useSelection<TextAnnotation>();\n\n const annotation = selected[0]?.annotation;\n\n const isAnnotationQuoteIdle = useAnnotationQuoteIdle(annotation?.id);\n\n const [isOpen, setOpen] = useState(selected?.length > 0);\n const handleClose = () => r?.cancelSelected();\n\n const [isFocused, setFocused] = useState(false);\n const handleFocus = useCallback(() => setFocused(true), []);\n const handleBlur = useCallback(() => setFocused(false), []);\n useEffect(() => {\n if (!isOpen) handleBlur();\n }, [isOpen, handleBlur]);\n\n // So we can reliably trigger the onClose callback\n const wasOpenRef = useRef(false);\n\n const arrowRef = useRef(null);\n\n const { refs, floatingStyles, update, context } = useFloating({\n placement: isMobile() ? 'bottom' : props.placement || 'top',\n strategy: 'absolute',\n open: isOpen,\n onOpenChange: (open, _event, reason) => {\n if (!open && (reason === 'escape-key' || reason === 'focus-out')) {\n setOpen(open);\n handleClose();\n }\n },\n middleware: [\n inline(),\n offset(10),\n flip({ crossAxis: true }),\n shift({ crossAxis: true, padding: 10, }),\n arrow({ element: arrowRef })\n ],\n whileElementsMounted: autoUpdate\n });\n\n useEffect(() => {\n if (!r) return;\n\n const annotationId = annotation?.id;\n const annotationSelectorsLength = annotation?.target.selector.length;\n\n if (annotationId && annotationSelectorsLength > 0 && useAnnotationQuoteIdle) {\n const bounds = r?.state.store.getAnnotationBounds(annotation.id);\n setOpen(Boolean(bounds));\n } else {\n setOpen(false);\n }\n }, [annotation?.id, annotation?.target.selector, useAnnotationQuoteIdle, r?.state.store]);\n\n useEffect(() => {\n if (!props.onClose) return;\n\n if (isOpen) {\n wasOpenRef.current = true;\n } else if (wasOpenRef.current) {\n wasOpenRef.current = false;\n props.onClose();\n }\n }, [props.onClose, isOpen]);\n\n useEffect(() => {\n if (!r) return;\n\n if (isOpen && annotation?.id) {\n refs.setPositionReference({\n getBoundingClientRect: () => {\n updateViewportBounds(annotation.id, r.state.store, r.element);\n return cachedBounds ? cachedBounds : new DOMRect();\n },\n getClientRects: () => {\n const rects = r.state.store.getAnnotationRects(annotation.id);\n const viewportRects = rects.map((rect) =>\n toViewportBounds(rect, r.element.getBoundingClientRect())\n );\n return toDomRectList(viewportRects);\n }\n });\n } else {\n refs.setPositionReference(null);\n }\n }, [isOpen, annotation?.id, annotation?.target, r]);\n\n useEffect(() => {\n if (!props.asPortal) return;\n\n const config: MutationObserverInit = { attributes: true, childList: true, subtree: true };\n\n const mutationObserver = new MutationObserver(() => update());\n mutationObserver.observe(document.body, config);\n\n window.document.addEventListener('scroll', update, true);\n\n return () => {\n mutationObserver.disconnect();\n window.document.removeEventListener('scroll', update, true);\n };\n }, [update, props.asPortal]);\n\n const onClose = () => r?.cancelSelected();\n\n /**\n * Announce the navigation hint only on the keyboard selection,\n * because the focus isn't shifted to the popup automatically then\n */\n // useAnnouncePopupNavigation({\n // disabled: isFocused,\n // floatingOpen: isOpen,\n // message: ariaNavigationMessage,\n // });\n\n return isOpen && annotation ? (\n <FloatingPortal\n root={props.asPortal ? undefined : r.element}>\n <FloatingFocusManager\n context={context}\n modal={false}\n closeOnFocusOut={true}\n returnFocus={false}\n initialFocus={-1}>\n <div\n className={`a9s-popup r6o-popup annotation-popup r6o-text-popup ${NOT_ANNOTATABLE_CLASS}`}\n ref={refs.setFloating}\n style={floatingStyles}>\n {props.popup({\n annotation: selected[0].annotation, // for backwards compatibility\n editable: selected[0].editable,\n selected,\n event\n })}\n{props.arrow && (\n <FloatingArrow\n ref={arrowRef}\n context={context}\n {...(props.arrowProps || {})} />\n )}\n\n <button className=\"r6o-popup-sr-only\" aria-live=\"assertive\" onClick={handleClose}>\n {props.ariaCloseWarning || 'Click or leave this dialog to close it.'}\n </button>\n </div>\n </FloatingFocusManager>\n </FloatingPortal>\n ) : null;\n\n};\n\n/** For backwards compatibility **/\n/** @deprecated Use TextAnnotationPopup instead */\nexport const TextAnnotatorPopup = (props: TextAnnotationPopupProps) => {\n\n useEffect(() => {\n console.warn('TextAnnotatorPopup is deprecated and will be removed in a future version. Please use TextAnnotationPopup instead.');\n }, []);\n\n return <TextAnnotationPopup {...props} />;\n};\n"],"names":["PRESET_BEHAVIORS","elem","a","content","CETEIcean","props","el","useRef","useEffect","ceteicean","CETEI","data","jsx","TEIAnnotator","children","opts","anno","setAnno","useContext","AnnotoriousContext","onLoad","useCallback","element","createTEIAnnotator","Fragment","Children","child","cloneElement","useAnnotationQuoteIdle","annotationId","options","store","useAnnotationStore","isIdle","setIsIdle","useState","idleTimeout","scheduleSetIsIdle","event","updated","update","targetUpdated","oldTarget","newTarget","hasQuoteChanged","Ignore","Origin","oldValue","newValue","oldSelector","oldQuotes","quote","newSelector","newQuotes","TextAnnotator","className","style","filter","user","annotatingEnabled","userSelectAction","annotatingMode","adapter","createTextAnnotator","isMobile","userAgent","cachedBounds","updateViewportBounds","debounce","container","bounds","toViewportBounds","TextAnnotationPopup","r","useAnnotator","selected","useSelection","annotation","isOpen","setOpen","handleClose","isFocused","setFocused","handleBlur","wasOpenRef","arrowRef","refs","floatingStyles","context","useFloating","open","_event","reason","inline","offset","flip","shift","arrow","autoUpdate","annotationSelectorsLength","viewportRects","rect","toDomRectList","config","mutationObserver","FloatingPortal","FloatingFocusManager","jsxs","NOT_ANNOTATABLE_CLASS","FloatingArrow","TextAnnotatorPopup"],"mappings":";;;;;;;;;;;;;;AAkBA,MAAMA,IAAmB;AAAA,EACvB,KAAK;AAAA,IACH,KAAK,CAACC,MAAkB;AACtB,YAAMC,IAAI,SAAS,cAAc,GAAG;AAEpC,aAAMD,EAAK;AACT,QAAAC,EAAE,YAAYD,EAAK,YAAYA,EAAK,UAAU,CAAC;AAGjD,MAAAC,EAAE,aAAa,QAAQD,EAAK,aAAa,QAAQ,CAAE,GAEnDA,EAAK,YAAYC,CAAC;AAAA,IACpB;AAAA;AAAA,IAEA,SAAS,CAACD,MAAkB;AAC1B,YAAME,IAAU,IAAI,MAAA;AACpB,MAAAA,EAAQ,MAAMF,EAAK,aAAa,KAAK,GAAG,KAAA,GAEpCA,EAAK,aAAa,OAAO,KAC3BE,EAAQ,aAAa,SAASF,EAAK,aAAa,OAAO,CAAE,GAEvDA,EAAK,aAAa,QAAQ,KAC5BE,EAAQ,aAAa,UAAUF,EAAK,aAAa,QAAQ,CAAE,GAE7DA,EAAK,YAAYE,CAAO;AAAA,IAC1B;AAAA,IACA,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP,WAAW,CAACF,MAAsB;AAChC,MAAAA,EAAK,SAAS;AAAA,IAChB;AAAA,EAAA;AAEJ,GAEaG,KAAY,CAACC,MAA0B;AAElD,QAAMC,IAAKC,EAAuB,IAAI;AAEtC,SAAAC,EAAU,MAAM;AACd,QAAIH,EAAM,KAAK;AACb,YAAMI,IAAY,IAAIC,EAAML,EAAM,QAAQ;AAE1C,MAAAI,EAAU,aAAa;AAAA,QACrB,GAAGT;AAAA,QACH,GAAIK,EAAM,aAAa,CAAA;AAAA,QAC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A,gBACVjC,EAAM,SACK,gBAAAO;AAAA,kBAACiG;AAAA,kBAAA;AAAA,oBACC,KAAKxB;AAAA,oBACL,SAAAG;AAAA,oBACC,GAAInF,EAAM,cAAc,CAAA;AAAA,kBAAC;AAAA,gBAAA;AAAA,gBAG9B,gBAAAO,EAAC,UAAA,EAAO,WAAU,qBAAoB,aAAU,aAAY,SAASoE,GAClE,UAAA3E,EAAM,oBAAoB,0CAAA,CAC7B;AAAA,cAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IACF;AAAA,EAAA,IAEA;AAEN,GAIayG,KAAqB,CAACzG,OAEjCG,EAAU,MAAM;AACd,UAAQ,KAAK,mHAAmH;AAClI,GAAG,CAAA,CAAE,GAEE,gBAAAI,EAAC4D,IAAA,EAAqB,GAAGnE,EAAA,CAAO;"}
1
+ {"version":3,"file":"react-text-annotator.es.js","sources":["../src/tei/ceteicean.tsx","../src/tei/tei-annotator.tsx","../src/hooks/use-annotation-quote-idle.ts","../src/text-annotator.tsx","../src/text-annotation-popup/is-mobile.ts","../src/text-annotation-popup/text-annotation-popup.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport CETEI from 'CETEIcean';\n\ninterface CETEIceanProps {\n\n initArgs?: any;\n\n tei?: string;\n\n onLoad?(element: Element): void;\n\n behaviors?: any;\n\n}\n\n// Override default list, note, table, and ref behaviors \n// so they don't introduce text into the DOM that interferes\n// with annotation. Apply a patch to graphics for robustness.\nconst PRESET_BEHAVIORS = {\n tei: {\n ref: (elem: Element) => {\n const a = document.createElement('a');\n\n while(elem.firstChild) {\n a.appendChild(elem.removeChild(elem.firstChild));\n }\n\n a.setAttribute('href', elem.getAttribute('target')!);\n\n elem.appendChild(a);\n },\n // Cf. https://github.com/TEIC/CETEIcean/issues/67\n graphic: (elem: Element) => {\n const content = new Image();\n content.src = elem.getAttribute('url')?.trim()!;\n\n if (elem.hasAttribute('width'))\n content.setAttribute('width', elem.getAttribute('width')!);\n\n if (elem.hasAttribute('height'))\n content.setAttribute('height', elem.getAttribute('height')!);\n\n elem.appendChild(content);\n },\n list: null,\n note: null,\n table: null,\n teiHeader: (elem: HTMLElement) => {\n elem.hidden = true;\n }\n }\n}\n\nexport const CETEIcean = (props: CETEIceanProps) => {\n\n const el = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (props.tei) {\n const ceteicean = new CETEI(props.initArgs);\n\n ceteicean.addBehaviors({\n ...PRESET_BEHAVIORS,\n ...(props.behaviors || {}),\n tei: {\n ...PRESET_BEHAVIORS.tei,\n ...(props.behaviors?.tei || {})\n }\n });\n\n ceteicean.makeHTML5(props.tei, (data: Element) => {\n el.current?.appendChild(data);\n props.onLoad?.(el.current!);\n });\n }\n\n return () => {\n if (el.current)\n el.current.innerHTML = '';\n }\n }, [props.tei, JSON.stringify(props.initArgs), props.onLoad]);\n\n return (\n <div \n ref={el}\n className=\"tei-container\" />\n )\n\n}","import { Children, JSX, ReactElement, ReactNode, cloneElement, useCallback, useContext, useEffect } from 'react';\nimport { AnnotoriousContext, Filter } from '@annotorious/react';\nimport { createTEIAnnotator, TEIAnnotation } from '@recogito/text-annotator-tei';\nimport type { AnnotatingMode, TextAnnotatorOptions } from '@soomo/text-annotator';\n\nimport '@soomo/text-annotator/text-annotator.css';\n\nexport type TEIAnnotatorProps = TextAnnotatorOptions<TEIAnnotation, unknown> & {\n\n children?: ReactNode | JSX.Element;\n\n annotatingMode?: AnnotatingMode;\n\n filter?: Filter;\n\n hideAnnotations?: boolean;\n\n}\n\nexport const TEIAnnotator = (props: TEIAnnotatorProps) => {\n\n const { children, ...opts } = props;\n\n const { anno, setAnno } = useContext(AnnotoriousContext);\n\n const onLoad = useCallback((element: HTMLElement) => {\n const anno = createTEIAnnotator(element, opts);\n setAnno(anno);\n }, []);\n\n useEffect(() => anno?.setStyle(props.style), [anno, props.style]);\n\n useEffect(() => anno?.setFilter(props.filter), [anno, props.filter]);\n\n useEffect(() => anno?.setVisible(!props.hideAnnotations), [anno, props.hideAnnotations]);\n\n useEffect(() => anno?.setUser(opts.user), [anno, opts.user]);\n\n useEffect(() => anno?.setAnnotatingEnabled(opts.annotatingEnabled), [anno, opts.annotatingEnabled]);\n\n useEffect(() => anno?.setAnnotatingMode(opts.annotatingMode), [anno, opts.annotatingMode]);\n\n return props.children ? (\n <>\n {Children.toArray(props.children).map(child => \n cloneElement(child as ReactElement, { onLoad } as any))}\n </>\n ) : null;\n\n}\n","import { useEffect, useState } from 'react';\nimport { Origin, useAnnotationStore } from '@annotorious/react';\nimport { Ignore, type StoreChangeEvent } from '@annotorious/core';\nimport type { TextAnnotation, TextAnnotationStore, TextAnnotationTarget } from '@soomo/text-annotator';\n\nexport const useAnnotationQuoteIdle = (\n annotationId: string | undefined,\n options: { timeout: number } = { timeout: 250 }\n) => {\n const store = useAnnotationStore<TextAnnotationStore>();\n\n const [isIdle, setIsIdle] = useState(true);\n\n useEffect(() => {\n if (!store || !annotationId) return;\n\n let idleTimeout: ReturnType<typeof setTimeout>;\n\n const scheduleSetIsIdle = (event: StoreChangeEvent<TextAnnotation>) => {\n const { changes: { updated } } = event;\n\n const hasChanged = updated?.some(update => {\n const { targetUpdated } = update;\n if (targetUpdated) {\n const { oldTarget, newTarget } = targetUpdated;\n return hasQuoteChanged(oldTarget, newTarget);\n }\n });\n\n if (hasChanged) {\n setIsIdle(false);\n clearTimeout(idleTimeout);\n idleTimeout = setTimeout(() => setIsIdle(true), options.timeout);\n }\n };\n\n store.observe(scheduleSetIsIdle, {\n annotations: annotationId,\n ignore: Ignore.BODY_ONLY,\n origin: Origin.LOCAL\n });\n\n return () => {\n clearTimeout(idleTimeout);\n store.unobserve(scheduleSetIsIdle);\n };\n }, [store, annotationId, options.timeout]);\n\n return isIdle;\n};\n\nconst hasQuoteChanged = (oldValue: TextAnnotationTarget, newValue: TextAnnotationTarget) => {\n const { selector: oldSelector } = oldValue;\n const oldQuotes = oldSelector.map(({ quote }) => quote);\n\n const { selector: newSelector } = newValue;\n const newQuotes = newSelector.map(({ quote }) => quote);\n\n return oldQuotes.join() !== newQuotes.join();\n};\n","import { JSX, ReactNode, useContext, useEffect, useRef } from 'react';\nimport { AnnotoriousContext, Filter } from '@annotorious/react';\nimport type { FormatAdapter } from '@annotorious/core';\nimport { createTextAnnotator } from '@soomo/text-annotator';\nimport type { AnnotatingMode, TextAnnotation, TextAnnotatorOptions } from '@soomo/text-annotator';\n\nimport '@soomo/text-annotator/text-annotator.css';\n\nexport interface TextAnnotatorProps<I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation> extends Omit<TextAnnotatorOptions<I, E>, 'adapter'> {\n\n children?: ReactNode | JSX.Element;\n\n adapter?: FormatAdapter<I, E> | ((container: HTMLElement) => FormatAdapter<I, E>);\n\n annotatingMode?: AnnotatingMode;\n\n filter?: Filter<I>;\n\n hideAnnotations?: boolean;\n\n className?: string;\n\n}\n\nexport const TextAnnotator = <I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation>(\n props: TextAnnotatorProps<I, E>\n) => {\n\n const el = useRef<HTMLDivElement>(null);\n\n const { className, children, hideAnnotations, ...opts } = props;\n\n const { style, filter, user, annotatingEnabled, userSelectAction, annotatingMode } = opts;\n\n const { anno, setAnno } = useContext(AnnotoriousContext);\n\n useEffect(() => {\n if (!setAnno || !el.current) return;\n\n const adapter = typeof opts.adapter === 'function' ? opts.adapter(el.current) : opts.adapter;\n\n const anno = createTextAnnotator(el.current!, { ...opts, adapter });\n setAnno(anno);\n\n return () => anno.destroy();\n }, [setAnno]);\n\n useEffect(() => anno?.setStyle(style), [anno, style]);\n\n useEffect(() => anno?.setFilter(filter), [anno, filter]);\n\n useEffect(() => anno?.setVisible(!hideAnnotations), [anno, hideAnnotations]);\n\n useEffect(() => anno?.setUser(user), [anno, user]);\n\n useEffect(() => anno?.setUserSelectAction(userSelectAction), [anno, userSelectAction]);\n\n useEffect(() => anno?.setAnnotatingEnabled(annotatingEnabled), [anno, annotatingEnabled]);\n\n useEffect(() => anno?.setAnnotatingMode(annotatingMode), [anno, annotatingMode]);\n\n return (\n <div ref={el} className={`r6o-annotatable no-focus-outline ${className}`}>\n {children}\n </div>\n );\n\n};\n","// https://stackoverflow.com/questions/21741841/detecting-ios-android-operating-system\nexport const isMobile = () => {\n if (typeof navigator === 'undefined') return false;\n\n // @ts-ignore\n var userAgent: string = navigator.userAgent || navigator.vendor || window?.opera;\n\n if (/android/i.test(userAgent)) \n return true;\n\n // @ts-ignore\n // Note: as of recently, this NO LONGER DETECTS FIREFOX ON iOS!\n // This means FF/iOS will behave like on the desktop, and loose\n // selection handlebars after the popup opens.\n if (/iPad|iPhone/.test(userAgent) && !window.MSStream)\n return true;\n\n return false;\n}","import React, { FC, ReactNode, useCallback, useEffect, useRef, useState } from 'react';\nimport debounce from 'debounce';\nimport { useAnnotator, useSelection } from '@annotorious/react';\nimport {\n NOT_ANNOTATABLE_CLASS,\n TextAnnotationStore,\n toViewportBounds,\n toDomRectList,\n type TextAnnotation,\n type TextAnnotator,\n} from '@soomo/text-annotator';\nimport {\n arrow,\n autoUpdate,\n flip,\n FloatingArrow,\n FloatingArrowProps,\n FloatingFocusManager,\n FloatingPortal,\n inline,\n offset,\n Placement,\n shift,\n useFloating\n} from '@floating-ui/react';\nimport { isMobile } from './is-mobile';\nimport { useAnnotationQuoteIdle } from '../hooks';\n\nimport './text-annotation-popup.css';\n\ninterface TextAnnotationPopupProps {\n\n ariaNavigationMessage?: string;\n\n ariaCloseWarning?: string;\n\n arrow?: boolean;\n\n arrowProps?: Omit<FloatingArrowProps, 'context' | 'ref'>;\n\n asPortal?: boolean;\n\n autoFocus?: boolean;\n\n placement?: Placement;\n\n popup(props: TextAnnotationPopupContentProps): ReactNode;\n\n onClose?(): void;\n\n}\n\nexport interface TextAnnotationPopupContentProps<T extends TextAnnotation = TextAnnotation> {\n\n annotation: T;\n\n selected: { annotation: T; editable?: boolean; }[];\n\n editable?: boolean;\n\n event?: PointerEvent | KeyboardEvent;\n\n}\n\nlet cachedBounds: DOMRect | null = null;\n\nconst updateViewportBounds = debounce((annotationId: string, store: TextAnnotationStore, container: HTMLElement) => {\n requestAnimationFrame(() => {\n const bounds = store.getAnnotationBounds(annotationId);\n if (!bounds) return;\n cachedBounds = toViewportBounds(bounds, container.getBoundingClientRect());\n });\n}, 250);\n\nexport const TextAnnotationPopup = (props: TextAnnotationPopupProps) => {\n\n const r = useAnnotator<TextAnnotator>();\n\n const { selected, event } = useSelection<TextAnnotation>();\n\n const annotation = selected[0]?.annotation;\n\n const isAnnotationQuoteIdle = useAnnotationQuoteIdle(annotation?.id);\n\n const [isOpen, setOpen] = useState(selected?.length > 0);\n const handleClose = () => r?.cancelSelected();\n\n const [isFocused, setFocused] = useState(false);\n const handleFocus = useCallback(() => setFocused(true), []);\n const handleBlur = useCallback(() => setFocused(false), []);\n useEffect(() => {\n if (!isOpen) handleBlur();\n }, [isOpen, handleBlur]);\n\n // So we can reliably trigger the onClose callback\n const wasOpenRef = useRef(false);\n\n const arrowRef = useRef(null);\n\n const { refs, floatingStyles, update, context } = useFloating({\n placement: isMobile() ? 'bottom' : props.placement || 'top',\n strategy: 'absolute',\n open: isOpen,\n onOpenChange: (open, _event, reason) => {\n if (!open && (reason === 'escape-key' || reason === 'focus-out')) {\n setOpen(open);\n handleClose();\n }\n },\n middleware: [\n inline(),\n offset(10),\n flip({ crossAxis: true }),\n shift({ crossAxis: true, padding: 10, }),\n arrow({ element: arrowRef })\n ],\n whileElementsMounted: autoUpdate\n });\n\n useEffect(() => {\n if (!r) return;\n\n const annotationId = annotation?.id;\n const annotationSelectorsLength = annotation?.target.selector.length;\n\n if (annotationId && annotationSelectorsLength > 0 && useAnnotationQuoteIdle) {\n const bounds = r?.state.store.getAnnotationBounds(annotation.id);\n setOpen(Boolean(bounds));\n } else {\n setOpen(false);\n }\n }, [annotation?.id, annotation?.target.selector, useAnnotationQuoteIdle, r?.state.store]);\n\n useEffect(() => {\n if (!props.onClose) return;\n\n if (isOpen) {\n wasOpenRef.current = true;\n } else if (wasOpenRef.current) {\n wasOpenRef.current = false;\n props.onClose();\n }\n }, [props.onClose, isOpen]);\n\n useEffect(() => {\n if (!r) return;\n\n if (isOpen && annotation?.id) {\n refs.setPositionReference({\n getBoundingClientRect: () => {\n updateViewportBounds(annotation.id, r.state.store, r.element);\n return cachedBounds ? cachedBounds : new DOMRect();\n },\n getClientRects: () => {\n const rects = r.state.store.getAnnotationRects(annotation.id);\n const viewportRects = rects.map((rect) =>\n toViewportBounds(rect, r.element.getBoundingClientRect())\n );\n return toDomRectList(viewportRects);\n }\n });\n } else {\n refs.setPositionReference(null);\n }\n }, [isOpen, annotation?.id, annotation?.target, r]);\n\n useEffect(() => {\n if (!props.asPortal) return;\n\n const config: MutationObserverInit = { attributes: true, childList: true, subtree: true };\n\n const mutationObserver = new MutationObserver(() => update());\n mutationObserver.observe(document.body, config);\n\n window.document.addEventListener('scroll', update, true);\n\n return () => {\n mutationObserver.disconnect();\n window.document.removeEventListener('scroll', update, true);\n };\n }, [update, props.asPortal]);\n\n const onClose = () => r?.cancelSelected();\n\n /**\n * Announce the navigation hint only on the keyboard selection,\n * because the focus isn't shifted to the popup automatically then\n */\n // useAnnouncePopupNavigation({\n // disabled: isFocused,\n // floatingOpen: isOpen,\n // message: ariaNavigationMessage,\n // });\n\n return isOpen && annotation ? (\n <FloatingPortal\n root={props.asPortal ? undefined : r.element}>\n <FloatingFocusManager\n context={context}\n modal={false}\n closeOnFocusOut={true}\n returnFocus={false}\n initialFocus={-1}>\n <div\n className={`a9s-popup r6o-popup annotation-popup r6o-text-popup ${NOT_ANNOTATABLE_CLASS}`}\n ref={refs.setFloating}\n style={floatingStyles}>\n {props.popup({\n annotation: selected[0].annotation, // for backwards compatibility\n editable: selected[0].editable,\n selected,\n event\n })}\n{props.arrow && (\n <FloatingArrow\n ref={arrowRef}\n context={context}\n {...(props.arrowProps || {})} />\n )}\n\n <button className=\"r6o-popup-sr-only\" aria-live=\"assertive\" onClick={handleClose}>\n {props.ariaCloseWarning || 'Click or leave this dialog to close it.'}\n </button>\n </div>\n </FloatingFocusManager>\n </FloatingPortal>\n ) : null;\n\n};\n\n/** For backwards compatibility **/\n/** @deprecated Use TextAnnotationPopup instead */\nexport const TextAnnotatorPopup = (props: TextAnnotationPopupProps) => {\n\n useEffect(() => {\n console.warn('TextAnnotatorPopup is deprecated and will be removed in a future version. Please use TextAnnotationPopup instead.');\n }, []);\n\n return <TextAnnotationPopup {...props} />;\n};\n"],"names":["PRESET_BEHAVIORS","elem","a","content","CETEIcean","props","el","useRef","useEffect","ceteicean","CETEI","data","jsx","TEIAnnotator","children","opts","anno","setAnno","useContext","AnnotoriousContext","onLoad","useCallback","element","createTEIAnnotator","Fragment","Children","child","cloneElement","useAnnotationQuoteIdle","annotationId","options","store","useAnnotationStore","isIdle","setIsIdle","useState","idleTimeout","scheduleSetIsIdle","event","updated","update","targetUpdated","oldTarget","newTarget","hasQuoteChanged","Ignore","Origin","oldValue","newValue","oldSelector","oldQuotes","quote","newSelector","newQuotes","TextAnnotator","className","hideAnnotations","style","filter","user","annotatingEnabled","userSelectAction","annotatingMode","adapter","createTextAnnotator","isMobile","userAgent","cachedBounds","updateViewportBounds","debounce","container","bounds","toViewportBounds","TextAnnotationPopup","r","useAnnotator","selected","useSelection","annotation","isOpen","setOpen","handleClose","isFocused","setFocused","handleBlur","wasOpenRef","arrowRef","refs","floatingStyles","context","useFloating","open","_event","reason","inline","offset","flip","shift","arrow","autoUpdate","annotationSelectorsLength","viewportRects","rect","toDomRectList","config","mutationObserver","FloatingPortal","FloatingFocusManager","jsxs","NOT_ANNOTATABLE_CLASS","FloatingArrow","TextAnnotatorPopup"],"mappings":";;;;;;;;;;;;;;AAkBA,MAAMA,IAAmB;AAAA,EACvB,KAAK;AAAA,IACH,KAAK,CAACC,MAAkB;AACtB,YAAMC,IAAI,SAAS,cAAc,GAAG;AAEpC,aAAMD,EAAK;AACT,QAAAC,EAAE,YAAYD,EAAK,YAAYA,EAAK,UAAU,CAAC;AA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,SAASqE,GAClE,UAAA5E,EAAM,oBAAoB,0CAAA,CAC7B;AAAA,cAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IACF;AAAA,EAAA,IAEA;AAEN,GAIa0G,KAAqB,CAAC1G,OAEjCG,EAAU,MAAM;AACd,UAAQ,KAAK,mHAAmH;AAClI,GAAG,CAAA,CAAE,GAEE,gBAAAI,EAAC6D,IAAA,EAAqB,GAAGpE,EAAA,CAAO;"}
@@ -7,5 +7,6 @@ export type TEIAnnotatorProps = TextAnnotatorOptions<TEIAnnotation, unknown> & {
7
7
  children?: ReactNode | JSX.Element;
8
8
  annotatingMode?: AnnotatingMode;
9
9
  filter?: Filter;
10
+ hideAnnotations?: boolean;
10
11
  };
11
12
  export declare const TEIAnnotator: (props: TEIAnnotatorProps) => JSX.Element;
@@ -8,6 +8,7 @@ export interface TextAnnotatorProps<I extends TextAnnotation = TextAnnotation, E
8
8
  adapter?: FormatAdapter<I, E> | ((container: HTMLElement) => FormatAdapter<I, E>);
9
9
  annotatingMode?: AnnotatingMode;
10
10
  filter?: Filter<I>;
11
+ hideAnnotations?: boolean;
11
12
  className?: string;
12
13
  }
13
14
  export declare const TextAnnotator: <I extends TextAnnotation = TextAnnotation, E extends unknown = TextAnnotation>(props: TextAnnotatorProps<I, E>) => JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soomo/react-text-annotator",
3
- "version": "4.4.4-staging.0",
3
+ "version": "4.4.5-staging.0",
4
4
  "description": "Recogito Text Annotator React bindings",
5
5
  "author": "Rainer Simon",
6
6
  "license": "BSD-3-Clause",
@@ -30,7 +30,7 @@
30
30
  "react": "^19.2.7",
31
31
  "react-dom": "^19.2.7",
32
32
  "typescript": "^5.9.3",
33
- "vite": "^7.3.5",
33
+ "vite": "^7.3.6",
34
34
  "vite-plugin-externalize-deps": "^0.10.0",
35
35
  "vite-tsconfig-paths": "^5.1.4"
36
36
  },
@@ -49,8 +49,8 @@
49
49
  "@annotorious/react": "^3.8.6",
50
50
  "@floating-ui/react": "^0.27.19",
51
51
  "@react-aria/live-announcer": "^3.3.4",
52
- "@soomo/text-annotator": "4.4.4-staging.0",
53
- "@recogito/text-annotator-tei": "4.2.4",
52
+ "@soomo/text-annotator": "4.4.5-staging.0",
53
+ "@recogito/text-annotator-tei": "4.2.5",
54
54
  "CETEIcean": "^1.9.5",
55
55
  "debounce": "^3.0.0",
56
56
  "dequal": "^2.0.3",