@soomo/react-text-annotator 3.0.0-staging.51 → 3.0.0-staging.53

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.
Files changed (41) hide show
  1. package/dist/TextAnnotator.d.ts +1 -1
  2. package/dist/TextAnnotator.d.ts.map +1 -1
  3. package/dist/TextAnnotatorPopup/TextAnnotatorPopup.d.ts +6 -7
  4. package/dist/TextAnnotatorPopup/TextAnnotatorPopup.d.ts.map +1 -1
  5. package/dist/react-text-annotator.css +1 -1
  6. package/dist/react-text-annotator.es10.js +60 -483
  7. package/dist/react-text-annotator.es10.js.map +1 -1
  8. package/dist/react-text-annotator.es11.js +33 -1456
  9. package/dist/react-text-annotator.es11.js.map +1 -1
  10. package/dist/react-text-annotator.es12.js +490 -0
  11. package/dist/react-text-annotator.es12.js.map +1 -0
  12. package/dist/react-text-annotator.es13.js +1416 -189
  13. package/dist/react-text-annotator.es13.js.map +1 -1
  14. package/dist/react-text-annotator.es15.js +234 -57
  15. package/dist/react-text-annotator.es15.js.map +1 -1
  16. package/dist/react-text-annotator.es16.js +557 -33
  17. package/dist/react-text-annotator.es16.js.map +1 -1
  18. package/dist/react-text-annotator.es18.js +1 -1
  19. package/dist/react-text-annotator.es19.js +1 -1
  20. package/dist/react-text-annotator.es2.js +1 -1
  21. package/dist/react-text-annotator.es20.js +2 -114
  22. package/dist/react-text-annotator.es20.js.map +1 -1
  23. package/dist/react-text-annotator.es21.js +2 -309
  24. package/dist/react-text-annotator.es21.js.map +1 -1
  25. package/dist/react-text-annotator.es22.js +109 -53
  26. package/dist/react-text-annotator.es22.js.map +1 -1
  27. package/dist/react-text-annotator.es23.js +306 -17
  28. package/dist/react-text-annotator.es23.js.map +1 -1
  29. package/dist/react-text-annotator.es24.js +58 -2
  30. package/dist/react-text-annotator.es24.js.map +1 -1
  31. package/dist/react-text-annotator.es25.js +20 -2
  32. package/dist/react-text-annotator.es25.js.map +1 -1
  33. package/dist/react-text-annotator.es4.js +2 -2
  34. package/dist/react-text-annotator.es5.js.map +1 -1
  35. package/dist/react-text-annotator.es6.js +8 -4
  36. package/dist/react-text-annotator.es6.js.map +1 -1
  37. package/dist/react-text-annotator.es7.js +27 -27
  38. package/dist/react-text-annotator.es7.js.map +1 -1
  39. package/package.json +6 -6
  40. package/dist/react-text-annotator.es14.js +0 -572
  41. package/dist/react-text-annotator.es14.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"react-text-annotator.es24.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"react-text-annotator.es24.js","sources":["../../../node_modules/CETEIcean/src/behaviors.js"],"sourcesContent":["\n/* \n Add a user-defined set of behaviors to CETEIcean's processing\n workflow. Added behaviors will override predefined behaviors with the\n same name.\n*/\nexport function addBehaviors(bhvs) {\n if (bhvs.namespaces) {\n for (let prefix of Object.keys(bhvs.namespaces)) {\n if (!this.namespaces.has(bhvs.namespaces[prefix]) && !Array.from(this.namespaces.values()).includes(prefix)) {\n this.namespaces.set(bhvs.namespaces[prefix], prefix);\n }\n }\n }\n for (let prefix of this.namespaces.values()) {\n if (bhvs[prefix]) {\n for (let b of Object.keys(bhvs[prefix])) {\n this.behaviors[`${prefix}:${b}`] = bhvs[prefix][b];\n }\n }\n }\n if (bhvs[\"functions\"]) {\n for (let fn of Object.keys(bhvs[\"functions\"])) {\n this.utilities[fn] = bhvs[\"functions\"][fn].bind(this.utilities);\n }\n }\n if (bhvs[\"handlers\"]) {\n console.log(\"Behavior handlers are no longer used.\")\n }\n if (bhvs[\"fallbacks\"]) {\n console.log(\"Fallback behaviors are no longer used.\")\n }\n}\n\n/* \n Adds or replaces an individual behavior. Takes a namespace prefix or namespace definition,\n the element name, and the behavior. E.g.\n addBehavior(\"tei\", \"add\", [\"`\",\"`\"]) for an already-declared namespace or\n addBehavior({\"doc\": \"http://docbook.org/ns/docbook\"}, \"note\", [\"[\",\"]\"]) for a new one\n*/\nexport function addBehavior(ns, element, b) {\n let p;\n if (ns === Object(ns)) {\n for (let prefix of Object.keys(ns)) {\n if (!this.namespaces.has(ns[prefix])) {\n this.namespaces.set(ns[prefix], prefix);\n p = prefix;\n }\n }\n } else {\n p = ns;\n }\n this.behaviors[`${p}:${element}`] = b;\n}\n\n/*\n Removes a previously-defined or default behavior. Takes a namespace prefix or namespace definition\n and the element name.\n*/\nexport function removeBehavior(ns, element) {\n let p;\n if (ns === Object(ns)) {\n for (let prefix of Object.keys(ns)) {\n if (!this.namespaces.has(ns[prefix])) {\n this.namespaces.set(ns[prefix], prefix);\n p = prefix;\n }\n }\n } else {\n p = ns;\n }\n delete this.behaviors[`${p}:${element}`];\n}\n"],"names":[],"mappings":"AAMO,SAAS,aAAa,MAAM;AACjC,MAAI,KAAK,YAAY;AACnB,aAAS,UAAU,OAAO,KAAK,KAAK,UAAU,GAAG;AAC/C,UAAI,CAAC,KAAK,WAAW,IAAI,KAAK,WAAW,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,KAAK,WAAW,OAAM,CAAE,EAAE,SAAS,MAAM,GAAG;AAC3G,aAAK,WAAW,IAAI,KAAK,WAAW,MAAM,GAAG,MAAM;AAAA,MACpD;AAAA,IACF;AAAA,EACF;AACD,WAAS,UAAU,KAAK,WAAW,OAAM,GAAI;AAC3C,QAAI,KAAK,MAAM,GAAG;AAChB,eAAS,KAAK,OAAO,KAAK,KAAK,MAAM,CAAC,GAAG;AACvC,aAAK,UAAU,GAAG,MAAM,IAAI,CAAC,EAAE,IAAI,KAAK,MAAM,EAAE,CAAC;AAAA,MAClD;AAAA,IACF;AAAA,EACF;AACD,MAAI,KAAK,WAAW,GAAG;AACrB,aAAS,MAAM,OAAO,KAAK,KAAK,WAAW,CAAC,GAAG;AAC7C,WAAK,UAAU,EAAE,IAAI,KAAK,WAAW,EAAE,EAAE,EAAE,KAAK,KAAK,SAAS;AAAA,IAC/D;AAAA,EACF;AACD,MAAI,KAAK,UAAU,GAAG;AACpB,YAAQ,IAAI,uCAAuC;AAAA,EACpD;AACD,MAAI,KAAK,WAAW,GAAG;AACrB,YAAQ,IAAI,wCAAwC;AAAA,EACrD;AACH;AAQO,SAAS,YAAY,IAAI,SAAS,GAAG;AAC1C,MAAI;AACJ,MAAI,OAAO,OAAO,EAAE,GAAG;AACrB,aAAS,UAAU,OAAO,KAAK,EAAE,GAAG;AAClC,UAAI,CAAC,KAAK,WAAW,IAAI,GAAG,MAAM,CAAC,GAAG;AACpC,aAAK,WAAW,IAAI,GAAG,MAAM,GAAG,MAAM;AACtC,YAAI;AAAA,MACL;AAAA,IACF;AAAA,EACL,OAAS;AACL,QAAI;AAAA,EACL;AACD,OAAK,UAAU,GAAG,CAAC,IAAI,OAAO,EAAE,IAAI;AACtC;AAMO,SAAS,eAAe,IAAI,SAAS;AAC1C,MAAI;AACJ,MAAI,OAAO,OAAO,EAAE,GAAG;AACrB,aAAS,UAAU,OAAO,KAAK,EAAE,GAAG;AAClC,UAAI,CAAC,KAAK,WAAW,IAAI,GAAG,MAAM,CAAC,GAAG;AACpC,aAAK,WAAW,IAAI,GAAG,MAAM,GAAG,MAAM;AACtC,YAAI;AAAA,MACL;AAAA,IACF;AAAA,EACL,OAAS;AACL,QAAI;AAAA,EACL;AACD,SAAO,KAAK,UAAU,GAAG,CAAC,IAAI,OAAO,EAAE;AACzC;","x_google_ignoreList":[0]}
@@ -1,5 +1,23 @@
1
- var reactJsxRuntime_development = {};
1
+ function learnElementNames(XML_dom, namespaces) {
2
+ const root = XML_dom.documentElement;
3
+ let i = 1;
4
+ let qname = function(e) {
5
+ if (!namespaces.has(e.namespaceURI ? e.namespaceURI : "")) {
6
+ namespaces.set(e.namespaceURI, "ns" + i++);
7
+ }
8
+ return namespaces.get(e.namespaceURI ? e.namespaceURI : "") + ":" + e.localName;
9
+ };
10
+ const els = new Set(
11
+ Array.from(root.querySelectorAll("*"), qname)
12
+ );
13
+ els.add(qname(root));
14
+ return els;
15
+ }
16
+ function learnCustomElementNames(HTML_dom) {
17
+ return new Set(Array.from(HTML_dom.querySelectorAll("*[data-origname]"), (e) => e.localName.replace(/(\w+)-.+/, "$1:") + e.getAttribute("data-origname")));
18
+ }
2
19
  export {
3
- reactJsxRuntime_development as __exports
20
+ learnCustomElementNames,
21
+ learnElementNames
4
22
  };
5
23
  //# sourceMappingURL=react-text-annotator.es25.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-text-annotator.es25.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"react-text-annotator.es25.js","sources":["../../../node_modules/CETEIcean/src/dom.js"],"sourcesContent":["export function learnElementNames(XML_dom, namespaces) {\n const root = XML_dom.documentElement;\n let i = 1;\n let qname = function(e) { \n if (!namespaces.has(e.namespaceURI ? e.namespaceURI : \"\")) {\n namespaces.set(e.namespaceURI, \"ns\" + i++);\n } \n return namespaces.get(e.namespaceURI ? e.namespaceURI : \"\") + \":\" + e.localName;\n };\n const els = new Set(\n Array.from(root.querySelectorAll(\"*\"), qname));\n \n // Add the root element to the array\n els.add(qname(root));\n return els\n}\n\nexport function learnCustomElementNames(HTML_dom) {\n return new Set(Array.from(HTML_dom.querySelectorAll(\"*[data-origname]\"), e => e.localName.replace(/(\\w+)-.+/,\"$1:\") + e.getAttribute(\"data-origname\")));\n}"],"names":[],"mappings":"AAAO,SAAS,kBAAkB,SAAS,YAAY;AACrD,QAAM,OAAO,QAAQ;AACrB,MAAI,IAAI;AACR,MAAI,QAAQ,SAAS,GAAG;AACtB,QAAI,CAAC,WAAW,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,GAAG;AACzD,iBAAW,IAAI,EAAE,cAAc,OAAO,GAAG;AAAA,IAC1C;AACD,WAAO,WAAW,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,IAAI,MAAM,EAAE;AAAA,EAC1E;AACE,QAAM,MAAM,IAAI;AAAA,IACd,MAAM,KAAK,KAAK,iBAAiB,GAAG,GAAG,KAAK;AAAA,EAAC;AAG/C,MAAI,IAAI,MAAM,IAAI,CAAC;AACnB,SAAO;AACT;AAEO,SAAS,wBAAwB,UAAU;AAChD,SAAO,IAAI,IAAI,MAAM,KAAK,SAAS,iBAAiB,kBAAkB,GAAG,OAAK,EAAE,UAAU,QAAQ,YAAW,KAAK,IAAI,EAAE,aAAa,eAAe,CAAC,CAAC;AACxJ;","x_google_ignoreList":[0]}
@@ -1,7 +1,7 @@
1
1
  import { useCallback, useLayoutEffect, useMemo, useRef, useEffect } from "react";
2
2
  import { useAnnotationStore, useSelection, Origin } from "@annotorious/react";
3
- import { announce as $319e236875307eab$export$a9b970dcc4ae71a9, destroyAnnouncer as $319e236875307eab$export$d8686216b8b81b2f } from "./react-text-annotator.es15.js";
4
- import { exhaustiveUniqueRandom } from "./react-text-annotator.es16.js";
3
+ import { announce as $319e236875307eab$export$a9b970dcc4ae71a9, destroyAnnouncer as $319e236875307eab$export$d8686216b8b81b2f } from "./react-text-annotator.es10.js";
4
+ import { exhaustiveUniqueRandom } from "./react-text-annotator.es11.js";
5
5
  const useAnnouncePopupNavigation = (args) => {
6
6
  const {
7
7
  message = "Press Tab to move to Notes Dialog",
@@ -1 +1 @@
1
- {"version":3,"file":"react-text-annotator.es5.js","sources":["../src/TextAnnotator.tsx"],"sourcesContent":["import { ReactNode, useContext, useEffect, useRef } from 'react';\nimport { AnnotoriousContext, Filter } from '@annotorious/react';\nimport type { FormatAdapter } from '@annotorious/core';\nimport type { HighlightStyleExpression, TextAnnotation, TextAnnotatorOptions } from '@soomo/text-annotator';\nimport { createTextAnnotator } from '@soomo/text-annotator';\n\nimport '@soomo/text-annotator/dist/text-annotator.css';\n\n\nexport interface TextAnnotatorProps<E extends unknown> extends Omit<TextAnnotatorOptions<E>, 'adapter'> {\n\n children?: ReactNode | JSX.Element;\n\n adapter?: FormatAdapter<TextAnnotation, E> | ((container: HTMLElement) => FormatAdapter<TextAnnotation, E>) | null;\n\n filter?: Filter;\n\n style?: HighlightStyleExpression;\n\n className?: string;\n\n}\n\nexport const TextAnnotator = <E extends unknown>(props: TextAnnotatorProps<E>) => {\n\n const el = useRef<HTMLDivElement>(null);\n\n const { className, children, ...opts } = props;\n const { style, filter, user, annotatingEnabled, userSelectAction } = opts;\n\n const { anno, setAnno } = useContext(AnnotoriousContext);\n\n useEffect(() => {\n if (!setAnno) 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?.setFilter(filter), [anno, filter]);\n\n useEffect(() => anno?.setUserSelectAction(userSelectAction), [anno, userSelectAction]);\n\n useEffect(() => anno?.setUser(user), [anno, user]);\n\n useEffect(() => anno?.setAnnotatingEnabled(annotatingEnabled), [anno, annotatingEnabled]);\n\n return (\n <div ref={el} className={className}>\n {children}\n </div>\n );\n\n};\n"],"names":["anno","jsx"],"mappings":";;;;;AAuBa,MAAA,gBAAgB,CAAoB,UAAiC;AAE1E,QAAA,KAAK,OAAuB,IAAI;AAEtC,QAAM,EAAE,WAAW,UAAU,GAAG,SAAS;AACzC,QAAM,EAAE,OAAO,QAAQ,MAAM,mBAAmB,iBAAqB,IAAA;AAErE,QAAM,EAAE,MAAM,QAAQ,IAAI,WAAW,kBAAkB;AAEvD,YAAU,MAAM;AACd,QAAI,CAAC,QAAS;AAER,UAAA,UAAU,OAAO,KAAK,YAAY,aAAa,KAAK,QAAQ,GAAG,OAAO,IAAI,KAAK;AAE/EA,UAAAA,QAAO,oBAAoB,GAAG,SAAS,EAAE,GAAG,MAAM,SAAS;AACjE,YAAQA,KAAI;AAEL,WAAA,MAAMA,MAAK;EAAQ,GACzB,CAAC,OAAO,CAAC;AAEF,YAAA,MAAM,6BAAM,SAAS,QAAQ,CAAC,MAAM,KAAK,CAAC;AAE1C,YAAA,MAAM,6BAAM,UAAU,SAAS,CAAC,MAAM,MAAM,CAAC;AAE7C,YAAA,MAAM,6BAAM,UAAU,SAAS,CAAC,MAAM,MAAM,CAAC;AAE7C,YAAA,MAAM,6BAAM,oBAAoB,mBAAmB,CAAC,MAAM,gBAAgB,CAAC;AAE3E,YAAA,MAAM,6BAAM,QAAQ,OAAO,CAAC,MAAM,IAAI,CAAC;AAEvC,YAAA,MAAM,6BAAM,qBAAqB,oBAAoB,CAAC,MAAM,iBAAiB,CAAC;AAExF,SACGC,kCAAAA,IAAA,OAAA,EAAI,KAAK,IAAI,WACX,SACH,CAAA;AAGJ;"}
1
+ {"version":3,"file":"react-text-annotator.es5.js","sources":["../src/TextAnnotator.tsx"],"sourcesContent":["import { ReactNode, useContext, useEffect, useRef } from 'react';\nimport { AnnotoriousContext, Filter } from '@annotorious/react';\nimport type { FormatAdapter } from '@annotorious/core';\nimport type { HighlightStyleExpression, TextAnnotation, TextAnnotatorOptions } from '@soomo/text-annotator';\nimport { createTextAnnotator } from '@soomo/text-annotator';\n\nimport '@soomo/text-annotator/dist/text-annotator.css';\n\n\nexport interface TextAnnotatorProps<E extends unknown> extends Omit<TextAnnotatorOptions<TextAnnotation, E>, 'adapter'> {\n\n children?: ReactNode | JSX.Element;\n\n adapter?: FormatAdapter<TextAnnotation, E> | ((container: HTMLElement) => FormatAdapter<TextAnnotation, E>) | null;\n\n filter?: Filter;\n\n style?: HighlightStyleExpression;\n\n className?: string;\n\n}\n\nexport const TextAnnotator = <E extends unknown>(props: TextAnnotatorProps<E>) => {\n\n const el = useRef<HTMLDivElement>(null);\n\n const { className, children, ...opts } = props;\n const { style, filter, user, annotatingEnabled, userSelectAction } = opts;\n\n const { anno, setAnno } = useContext(AnnotoriousContext);\n\n useEffect(() => {\n if (!setAnno) 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?.setFilter(filter), [anno, filter]);\n\n useEffect(() => anno?.setUserSelectAction(userSelectAction), [anno, userSelectAction]);\n\n useEffect(() => anno?.setUser(user), [anno, user]);\n\n useEffect(() => anno?.setAnnotatingEnabled(annotatingEnabled), [anno, annotatingEnabled]);\n\n return (\n <div ref={el} className={className}>\n {children}\n </div>\n );\n\n};\n"],"names":["anno","jsx"],"mappings":";;;;;AAuBa,MAAA,gBAAgB,CAAoB,UAAiC;AAE1E,QAAA,KAAK,OAAuB,IAAI;AAEtC,QAAM,EAAE,WAAW,UAAU,GAAG,SAAS;AACzC,QAAM,EAAE,OAAO,QAAQ,MAAM,mBAAmB,iBAAqB,IAAA;AAErE,QAAM,EAAE,MAAM,QAAQ,IAAI,WAAW,kBAAkB;AAEvD,YAAU,MAAM;AACd,QAAI,CAAC,QAAS;AAER,UAAA,UAAU,OAAO,KAAK,YAAY,aAAa,KAAK,QAAQ,GAAG,OAAO,IAAI,KAAK;AAE/EA,UAAAA,QAAO,oBAAoB,GAAG,SAAS,EAAE,GAAG,MAAM,SAAS;AACjE,YAAQA,KAAI;AAEL,WAAA,MAAMA,MAAK;EAAQ,GACzB,CAAC,OAAO,CAAC;AAEF,YAAA,MAAM,6BAAM,SAAS,QAAQ,CAAC,MAAM,KAAK,CAAC;AAE1C,YAAA,MAAM,6BAAM,UAAU,SAAS,CAAC,MAAM,MAAM,CAAC;AAE7C,YAAA,MAAM,6BAAM,UAAU,SAAS,CAAC,MAAM,MAAM,CAAC;AAE7C,YAAA,MAAM,6BAAM,oBAAoB,mBAAmB,CAAC,MAAM,gBAAgB,CAAC;AAE3E,YAAA,MAAM,6BAAM,QAAQ,OAAO,CAAC,MAAM,IAAI,CAAC;AAEvC,YAAA,MAAM,6BAAM,qBAAqB,oBAAoB,CAAC,MAAM,iBAAiB,CAAC;AAExF,SACGC,kCAAAA,IAAA,OAAA,EAAI,KAAK,IAAI,WACX,SACH,CAAA;AAGJ;"}
@@ -1,12 +1,12 @@
1
1
  import { j as jsxRuntimeExports } from "./react-text-annotator.es8.js";
2
2
  import { useState, useEffect, useCallback } from "react";
3
- import { useFloating, useDismiss, useRole, useInteractions, FloatingPortal, FloatingFocusManager } from "./react-text-annotator.es11.js";
3
+ import { useFloating, useDismiss, useRole, useInteractions, FloatingPortal, FloatingFocusManager } from "./react-text-annotator.es13.js";
4
4
  import { useAnnotator, useSelection } from "@annotorious/react";
5
5
  import { denormalizeRectWithOffset, toDomRectList } from "@soomo/text-annotator";
6
6
  import { useAnnouncePopupNavigation } from "./react-text-annotator.es4.js";
7
7
  /* empty css */
8
- import { offset, inline, flip, shift } from "./react-text-annotator.es13.js";
9
- import { autoUpdate } from "./react-text-annotator.es14.js";
8
+ import { offset, inline, flip, shift } from "./react-text-annotator.es15.js";
9
+ import { autoUpdate } from "./react-text-annotator.es16.js";
10
10
  const TextAnnotatorPopup = (props) => {
11
11
  var _a;
12
12
  const { popup, popupNavigationMessage } = props;
@@ -118,7 +118,11 @@ const TextAnnotatorPopup = (props) => {
118
118
  ...getFloatingProps(),
119
119
  ...getStopEventsPropagationProps(),
120
120
  children: [
121
- popup({ selected }),
121
+ popup({
122
+ annotation: selected[0].annotation,
123
+ editable: selected[0].editable,
124
+ event
125
+ }),
122
126
  /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "popup-close-message", onClick: handleClose, children: "This dialog closes when you leave it." })
123
127
  ]
124
128
  }
@@ -1 +1 @@
1
- {"version":3,"file":"react-text-annotator.es6.js","sources":["../src/TextAnnotatorPopup/TextAnnotatorPopup.tsx"],"sourcesContent":["import React, { FC, PointerEvent, ReactNode, useCallback, useEffect, useState } from 'react';\nimport {\n autoUpdate,\n flip,\n FloatingFocusManager,\n FloatingPortal,\n inline,\n offset,\n shift,\n useDismiss,\n useFloating,\n useInteractions,\n useRole\n} from '@floating-ui/react';\n\nimport { useAnnotator, useSelection } from '@annotorious/react';\nimport {\n denormalizeRectWithOffset,\n toDomRectList,\n type TextAnnotation,\n type TextAnnotator,\n} from '@soomo/text-annotator';\n\nimport { useAnnouncePopupNavigation } from '../hooks';\nimport './TextAnnotatorPopup.css';\n\ninterface TextAnnotationPopupProps {\n\n popupNavigationMessage?: string;\n\n popup(props: TextAnnotatorPopupProps): ReactNode;\n\n}\n\nexport interface TextAnnotatorPopupProps {\n\n selected: { annotation: TextAnnotation, editable?: boolean }[];\n\n}\n\nexport const TextAnnotatorPopup: FC<TextAnnotationPopupProps> = (props) => {\n\n const { popup, popupNavigationMessage } = props;\n\n const r = useAnnotator<TextAnnotator>();\n\n const { selected, event } = useSelection<TextAnnotation>();\n const annotation = selected[0]?.annotation;\n\n const [isOpen, setOpen] = useState(selected?.length > 0);\n const handleClose = () => r?.cancelSelected();\n\n const [isFloatingFocused, setFloatingFocused] = useState(false);\n const handleFloatingFocus = () => setFloatingFocused(true);\n const handleFloatingBlur = () => setFloatingFocused(false);\n useEffect(() => {\n if (!isOpen) handleFloatingBlur();\n }, [isOpen, handleFloatingBlur]);\n\n const { refs, floatingStyles, update, context } = useFloating({\n placement: 'top',\n open: isOpen,\n onOpenChange: (open, _event, reason) => {\n setOpen(open);\n\n if (!open) {\n if (reason === 'escape-key' || reason === 'focus-out') {\n handleClose();\n }\n }\n },\n middleware: [\n offset(10),\n inline(),\n flip(),\n shift({ mainAxis: false, crossAxis: true, padding: 10 })\n ],\n whileElementsMounted: autoUpdate\n });\n\n const dismiss = useDismiss(context);\n const role = useRole(context, { role: 'dialog' });\n const { getFloatingProps } = useInteractions([dismiss, role]);\n\n const selectedKey = selected.map(a => a.annotation.id).join('-');\n useEffect(() => {\n // Ignore all selection changes except those accompanied by a user event.\n if (selected.length > 0 && event) {\n setOpen(event.type === 'pointerup' || event.type === 'keydown');\n }\n }, [selectedKey, event]);\n\n useEffect(() => {\n // Close the popup if the selection is cleared\n if (selected.length === 0 && isOpen) {\n setOpen(false);\n }\n }, [isOpen, selectedKey]);\n\n useEffect(() => {\n if (!r) return;\n\n if (isOpen && annotation?.id) {\n refs.setPositionReference({\n getBoundingClientRect: () => denormalizeRectWithOffset(\n r.state.store.getAnnotationBounds(annotation.id),\n r.element.getBoundingClientRect()\n ),\n getClientRects: () => {\n const rects = r.state.store.getAnnotationRects(annotation.id);\n const denormalizedRects = rects.map(\n rect => denormalizeRectWithOffset(rect, r.element.getBoundingClientRect())\n );\n return toDomRectList(denormalizedRects);\n }\n });\n } else {\n // Don't leave the reference depending on the previously selected annotation\n refs.setPositionReference(null);\n }\n }, [isOpen, annotation?.id, annotation?.target, r]);\n\n // Prevent text-annotator from handling the irrelevant events triggered from the popup\n const getStopEventsPropagationProps = useCallback(\n () => ({ onPointerUp: (event: PointerEvent<HTMLDivElement>) => event.stopPropagation() }),\n []\n );\n\n useEffect(() => {\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]);\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: isFloatingFocused,\n floatingOpen: isOpen,\n message: popupNavigationMessage,\n });\n\n return isOpen && selected.length > 0 ? (\n <FloatingPortal>\n <FloatingFocusManager\n context={context}\n modal={false}\n closeOnFocusOut={true}\n initialFocus={\n /**\n * Don't shift focus to the floating element\n * when the selection performed with the keyboard\n */\n event?.type === 'keydown' ? -1 : 0\n }\n returnFocus={false}\n >\n <div\n className=\"annotation-popup text-annotation-popup not-annotatable\"\n ref={refs.setFloating}\n style={floatingStyles}\n onFocus={handleFloatingFocus}\n onBlur={handleFloatingBlur}\n {...getFloatingProps()}\n {...getStopEventsPropagationProps()}>\n {popup({ selected })}\n\n {/* It lets keyboard/sr users to know that the dialog closes when they focus out of it */}\n <button className=\"popup-close-message\" onClick={handleClose}>\n This dialog closes when you leave it.\n </button>\n </div>\n </FloatingFocusManager>\n </FloatingPortal>\n ) : null;\n\n};\n"],"names":["event","jsx","jsxs"],"mappings":";;;;;;;;;AAwCa,MAAA,qBAAmD,CAAC,UAAU;;AAEnE,QAAA,EAAE,OAAO,uBAA2B,IAAA;AAE1C,QAAM,IAAI;AAEV,QAAM,EAAE,UAAU,MAAM,IAAI,aAA6B;AACnD,QAAA,cAAa,cAAS,CAAC,MAAV,mBAAa;AAEhC,QAAM,CAAC,QAAQ,OAAO,IAAI,UAAS,qCAAU,UAAS,CAAC;AACjD,QAAA,cAAc,MAAM,uBAAG;AAE7B,QAAM,CAAC,mBAAmB,kBAAkB,IAAI,SAAS,KAAK;AACxD,QAAA,sBAAsB,MAAM,mBAAmB,IAAI;AACnD,QAAA,qBAAqB,MAAM,mBAAmB,KAAK;AACzD,YAAU,MAAM;AACV,QAAA,CAAC,OAA2B;EAAA,GAC/B,CAAC,QAAQ,kBAAkB,CAAC;AAE/B,QAAM,EAAE,MAAM,gBAAgB,QAAQ,QAAA,IAAY,YAAY;AAAA,IAC5D,WAAW;AAAA,IACX,MAAM;AAAA,IACN,cAAc,CAAC,MAAM,QAAQ,WAAW;AACtC,cAAQ,IAAI;AAEZ,UAAI,CAAC,MAAM;AACL,YAAA,WAAW,gBAAgB,WAAW,aAAa;AACzC;QACd;AAAA,MACF;AAAA,IACF;AAAA,IACA,YAAY;AAAA,MACV,OAAO,EAAE;AAAA,MACT,OAAO;AAAA,MACP,KAAK;AAAA,MACL,MAAM,EAAE,UAAU,OAAO,WAAW,MAAM,SAAS,IAAI;AAAA,IACzD;AAAA,IACA,sBAAsB;AAAA,EAAA,CACvB;AAEK,QAAA,UAAU,WAAW,OAAO;AAClC,QAAM,OAAO,QAAQ,SAAS,EAAE,MAAM,UAAU;AAChD,QAAM,EAAE,iBAAiB,IAAI,gBAAgB,CAAC,SAAS,IAAI,CAAC;AAEtD,QAAA,cAAc,SAAS,IAAI,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AAU,QAAQ,IAAI;AAEvD,WAAO,MAAM;AACX,uBAAiB,WAAW;AAC5B,aAAO,SAAS,oBAAoB,UAAU,QAAQ,IAAI;AAAA,IAAA;AAAA,EAC5D,GACC,CAAC,MAAM,CAAC;AAMgB,6BAAA;AAAA,IACzB,UAAU;AAAA,IACV,cAAc;AAAA,IACd,SAAS;AAAA,EAAA,CACV;AAED,SAAO,UAAU,SAAS,SAAS,0CAChC,gBACC,EAAA,UAAAC,kCAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,OAAO;AAAA,MACP,iBAAiB;AAAA,MACjB;AAAA;AAAA;AAAA;AAAA;AAAA,SAKE,+BAAO,UAAS,YAAY,KAAK;AAAA;AAAA,MAEnC,aAAa;AAAA,MAEb,UAAAC,kCAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAU;AAAA,UACV,KAAK,KAAK;AAAA,UACV,OAAO;AAAA,UACP,SAAS;AAAA,UACT,QAAQ;AAAA,UACP,GAAG,iBAAiB;AAAA,UACpB,GAAG,8BAA8B;AAAA,UACjC,UAAA;AAAA,YAAM,MAAA,EAAE,UAAU;AAAA,kDAGlB,UAAO,EAAA,WAAU,uBAAsB,SAAS,aAAa,UAE9D,yCAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA,EAEJ,CAAA,IACE;AAEN;"}
1
+ {"version":3,"file":"react-text-annotator.es6.js","sources":["../src/TextAnnotatorPopup/TextAnnotatorPopup.tsx"],"sourcesContent":["import React, { FC, PointerEvent, ReactNode, useCallback, useEffect, useState } from 'react';\nimport {\n autoUpdate,\n flip,\n FloatingFocusManager,\n FloatingPortal,\n inline,\n offset,\n shift,\n useDismiss,\n useFloating,\n useInteractions,\n useRole\n} from '@floating-ui/react';\n\nimport { useAnnotator, useSelection } from '@annotorious/react';\nimport {\n denormalizeRectWithOffset,\n toDomRectList,\n type TextAnnotation,\n type TextAnnotator,\n} from '@soomo/text-annotator';\n\nimport { useAnnouncePopupNavigation } from '../hooks';\nimport './TextAnnotatorPopup.css';\n\ninterface TextAnnotationPopupProps {\n\n popupNavigationMessage?: string;\n\n popup(props: TextAnnotationPopupContentProps): ReactNode;\n\n}\n\nexport interface TextAnnotationPopupContentProps {\n\n annotation: TextAnnotation;\n\n editable?: boolean;\n\n event?: PointerEvent;\n\n}\n\nexport const TextAnnotatorPopup: FC<TextAnnotationPopupProps> = (props) => {\n\n const { popup, popupNavigationMessage } = props;\n\n const r = useAnnotator<TextAnnotator>();\n\n const { selected, event } = useSelection<TextAnnotation>();\n const annotation = selected[0]?.annotation;\n\n const [isOpen, setOpen] = useState(selected?.length > 0);\n const handleClose = () => r?.cancelSelected();\n\n const [isFloatingFocused, setFloatingFocused] = useState(false);\n const handleFloatingFocus = () => setFloatingFocused(true);\n const handleFloatingBlur = () => setFloatingFocused(false);\n useEffect(() => {\n if (!isOpen) handleFloatingBlur();\n }, [isOpen, handleFloatingBlur]);\n\n const { refs, floatingStyles, update, context } = useFloating({\n placement: 'top',\n open: isOpen,\n onOpenChange: (open, _event, reason) => {\n setOpen(open);\n\n if (!open) {\n if (reason === 'escape-key' || reason === 'focus-out') {\n handleClose();\n }\n }\n },\n middleware: [\n offset(10),\n inline(),\n flip(),\n shift({ mainAxis: false, crossAxis: true, padding: 10 })\n ],\n whileElementsMounted: autoUpdate\n });\n\n const dismiss = useDismiss(context);\n const role = useRole(context, { role: 'dialog' });\n const { getFloatingProps } = useInteractions([dismiss, role]);\n\n const selectedKey = selected.map(a => a.annotation.id).join('-');\n useEffect(() => {\n // Ignore all selection changes except those accompanied by a user event.\n if (selected.length > 0 && event) {\n setOpen(event.type === 'pointerup' || event.type === 'keydown');\n }\n }, [selectedKey, event]);\n\n useEffect(() => {\n // Close the popup if the selection is cleared\n if (selected.length === 0 && isOpen) {\n setOpen(false);\n }\n }, [isOpen, selectedKey]);\n\n useEffect(() => {\n if (!r) return;\n\n if (isOpen && annotation?.id) {\n refs.setPositionReference({\n getBoundingClientRect: () => denormalizeRectWithOffset(\n r.state.store.getAnnotationBounds(annotation.id),\n r.element.getBoundingClientRect()\n ),\n getClientRects: () => {\n const rects = r.state.store.getAnnotationRects(annotation.id);\n const denormalizedRects = rects.map(\n rect => denormalizeRectWithOffset(rect, r.element.getBoundingClientRect())\n );\n return toDomRectList(denormalizedRects);\n }\n });\n } else {\n // Don't leave the reference depending on the previously selected annotation\n refs.setPositionReference(null);\n }\n }, [isOpen, annotation?.id, annotation?.target, r]);\n\n // Prevent text-annotator from handling the irrelevant events triggered from the popup\n const getStopEventsPropagationProps = useCallback(\n () => ({ onPointerUp: (event: PointerEvent<HTMLDivElement>) => event.stopPropagation() }),\n []\n );\n\n useEffect(() => {\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]);\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: isFloatingFocused,\n floatingOpen: isOpen,\n message: popupNavigationMessage,\n });\n\n return isOpen && selected.length > 0 ? (\n <FloatingPortal>\n <FloatingFocusManager\n context={context}\n modal={false}\n closeOnFocusOut={true}\n initialFocus={\n /**\n * Don't shift focus to the floating element\n * when the selection performed with the keyboard\n */\n event?.type === 'keydown' ? -1 : 0\n }\n returnFocus={false}\n >\n <div\n className=\"annotation-popup text-annotation-popup not-annotatable\"\n ref={refs.setFloating}\n style={floatingStyles}\n onFocus={handleFloatingFocus}\n onBlur={handleFloatingBlur}\n {...getFloatingProps()}\n {...getStopEventsPropagationProps()}>\n {popup({\n annotation: selected[0].annotation,\n editable: selected[0].editable,\n event\n })}\n\n {/* It lets keyboard/sr users to know that the dialog closes when they focus out of it */}\n <button className=\"popup-close-message\" onClick={handleClose}>\n This dialog closes when you le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AO,MAAM;AACX,uBAAiB,WAAW;AAC5B,aAAO,SAAS,oBAAoB,UAAU,QAAQ,IAAI;AAAA,IAAA;AAAA,EAC5D,GACC,CAAC,MAAM,CAAC;AAMgB,6BAAA;AAAA,IACzB,UAAU;AAAA,IACV,cAAc;AAAA,IACd,SAAS;AAAA,EAAA,CACV;AAED,SAAO,UAAU,SAAS,SAAS,0CAChC,gBACC,EAAA,UAAAC,kCAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,OAAO;AAAA,MACP,iBAAiB;AAAA,MACjB;AAAA;AAAA;AAAA;AAAA;AAAA,SAKE,+BAAO,UAAS,YAAY,KAAK;AAAA;AAAA,MAEnC,aAAa;AAAA,MAEb,UAAAC,kCAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAU;AAAA,UACV,KAAK,KAAK;AAAA,UACV,OAAO;AAAA,UACP,SAAS;AAAA,UACT,QAAQ;AAAA,UACP,GAAG,iBAAiB;AAAA,UACpB,GAAG,8BAA8B;AAAA,UACjC,UAAA;AAAA,YAAM,MAAA;AAAA,cACL,YAAY,SAAS,CAAC,EAAE;AAAA,cACxB,UAAU,SAAS,CAAC,EAAE;AAAA,cACtB;AAAA,YAAA,CACD;AAAA,kDAGA,UAAO,EAAA,WAAU,uBAAsB,SAAS,aAAa,UAE9D,yCAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA,EAEJ,CAAA,IACE;AAEN;"}
@@ -12,32 +12,32 @@ const Dt = "not-annotatable", X = `.${Dt}`, mt = (t) => {
12
12
  suffix: u.substring(0, n)
13
13
  };
14
14
  };
15
- var V = [];
15
+ var U = [];
16
16
  for (var dt = 0; dt < 256; ++dt)
17
- V.push((dt + 256).toString(16).slice(1));
17
+ U.push((dt + 256).toString(16).slice(1));
18
18
  function Oe(t, e = 0) {
19
- return (V[t[e + 0]] + V[t[e + 1]] + V[t[e + 2]] + V[t[e + 3]] + "-" + V[t[e + 4]] + V[t[e + 5]] + "-" + V[t[e + 6]] + V[t[e + 7]] + "-" + V[t[e + 8]] + V[t[e + 9]] + "-" + V[t[e + 10]] + V[t[e + 11]] + V[t[e + 12]] + V[t[e + 13]] + V[t[e + 14]] + V[t[e + 15]]).toLowerCase();
19
+ return (U[t[e + 0]] + U[t[e + 1]] + U[t[e + 2]] + U[t[e + 3]] + "-" + U[t[e + 4]] + U[t[e + 5]] + "-" + U[t[e + 6]] + U[t[e + 7]] + "-" + U[t[e + 8]] + U[t[e + 9]] + "-" + U[t[e + 10]] + U[t[e + 11]] + U[t[e + 12]] + U[t[e + 13]] + U[t[e + 14]] + U[t[e + 15]]).toLowerCase();
20
20
  }
21
21
  var Z, Ie = new Uint8Array(16);
22
- function Ve() {
22
+ function Ue() {
23
23
  if (!Z && (Z = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !Z))
24
24
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
25
25
  return Z(Ie);
26
26
  }
27
- var Ue = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
27
+ var Ve = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
28
28
  const Ot = {
29
- randomUUID: Ue
29
+ randomUUID: Ve
30
30
  };
31
31
  function Pt(t, e, n) {
32
32
  if (Ot.randomUUID && !e && !t)
33
33
  return Ot.randomUUID();
34
34
  t = t || {};
35
- var o = t.random || (t.rng || Ve)();
35
+ var o = t.random || (t.rng || Ue)();
36
36
  return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Oe(o);
37
37
  }
38
- var U = [];
38
+ var V = [];
39
39
  for (var ht = 0; ht < 256; ++ht)
40
- U.push((ht + 256).toString(16).slice(1));
40
+ V.push((ht + 256).toString(16).slice(1));
41
41
  typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
42
42
  const sn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
43
43
  let dn = (t = 21) => {
@@ -55,7 +55,7 @@ const hn = (t) => {
55
55
  }
56
56
  return `${n}`;
57
57
  }, jt = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, fn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
58
- const { id: o, type: i, purpose: r, value: s, created: a, modified: u, creator: h, ...p } = n;
58
+ const { id: o, type: i, purpose: r, value: s, created: a, modified: u, creator: h, ...g } = n;
59
59
  return {
60
60
  id: o || `temp-${hn(n)}`,
61
61
  annotation: e,
@@ -65,7 +65,7 @@ const hn = (t) => {
65
65
  creator: jt(h),
66
66
  created: a ? new Date(a) : void 0,
67
67
  updated: u ? new Date(u) : void 0,
68
- ...p
68
+ ...g
69
69
  };
70
70
  }), gn = (t) => t.map((e) => {
71
71
  var n;
@@ -95,23 +95,23 @@ const kn = (t, e) => ({
95
95
  selector: []
96
96
  };
97
97
  for (const u of s) {
98
- const p = (Array.isArray(u.selector) ? u.selector : [u.selector]).reduce((d, f) => {
99
- switch (f.type) {
98
+ const g = (Array.isArray(u.selector) ? u.selector : [u.selector]).reduce((d, b) => {
99
+ switch (b.type) {
100
100
  case "TextQuoteSelector":
101
- d.quote = f.exact;
101
+ d.quote = b.exact;
102
102
  break;
103
103
  case "TextPositionSelector":
104
- d.start = f.start, d.end = f.end;
104
+ d.start = b.start, d.end = b.end;
105
105
  break;
106
106
  }
107
107
  return d;
108
108
  }, {});
109
- if (pn(p))
110
- a.selector.push({ id: u.id, ...p });
109
+ if (pn(g))
110
+ a.selector.push({ id: u.id, ...g });
111
111
  else {
112
112
  const d = [
113
- p.start ? void 0 : "TextPositionSelector",
114
- p.quote ? void 0 : "TextQuoteSelector"
113
+ g.start ? void 0 : "TextPositionSelector",
114
+ g.quote ? void 0 : "TextQuoteSelector"
115
115
  ].filter(Boolean);
116
116
  return { error: Error(`Missing selector types: ${d.join(" and ")} for annotation: ${t.id}`) };
117
117
  }
@@ -139,23 +139,23 @@ const kn = (t, e) => ({
139
139
  creator: a,
140
140
  created: u,
141
141
  updated: h,
142
- ...p
143
- } = i, d = s.map((f) => {
144
- const { quote: g, start: A, end: y, range: m } = f, { prefix: l, suffix: c } = re(m, n), b = [{
142
+ ...g
143
+ } = i, d = s.map((b) => {
144
+ const { quote: f, start: A, end: v, range: p } = b, { prefix: l, suffix: c } = re(p, n), m = [{
145
145
  type: "TextQuoteSelector",
146
- exact: g,
146
+ exact: f,
147
147
  prefix: l,
148
148
  suffix: c
149
149
  }, {
150
150
  type: "TextPositionSelector",
151
151
  start: A,
152
- end: y
152
+ end: v
153
153
  }];
154
154
  return {
155
- ...p,
156
- id: f.id,
155
+ ...g,
156
+ id: b.id,
157
157
  source: e,
158
- selector: b
158
+ selector: m
159
159
  };
160
160
  });
161
161
  return {