@soomo/react-text-annotator 3.1.0-staging.21 → 3.1.0-staging.23
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/TextAnnotationPopup/TextAnnotationPopup.d.ts.map +1 -1
- package/dist/hooks/useAnnotationQuoteIdling.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/react-text-annotator.es.js +1 -1
- package/dist/react-text-annotator.es10.js +490 -0
- package/dist/react-text-annotator.es10.js.map +1 -0
- package/dist/react-text-annotator.es11.js +78 -483
- package/dist/react-text-annotator.es11.js.map +1 -1
- package/dist/react-text-annotator.es12.js +40 -77
- package/dist/react-text-annotator.es12.js.map +1 -1
- package/dist/react-text-annotator.es13.js +21 -41
- package/dist/react-text-annotator.es13.js.map +1 -1
- package/dist/react-text-annotator.es14.js +1629 -19
- package/dist/react-text-annotator.es14.js.map +1 -1
- package/dist/react-text-annotator.es15.js +8 -1596
- package/dist/react-text-annotator.es15.js.map +1 -1
- package/dist/react-text-annotator.es17.js +285 -0
- package/dist/react-text-annotator.es17.js.map +1 -0
- package/dist/react-text-annotator.es18.js +559 -244
- package/dist/react-text-annotator.es18.js.map +1 -1
- package/dist/react-text-annotator.es19.js +12 -584
- package/dist/react-text-annotator.es19.js.map +1 -1
- package/dist/react-text-annotator.es2.js +7 -4
- package/dist/react-text-annotator.es2.js.map +1 -1
- package/dist/react-text-annotator.es22.js.map +1 -1
- package/dist/react-text-annotator.es3.js +5 -5
- package/dist/react-text-annotator.es3.js.map +1 -1
- package/dist/react-text-annotator.es4.js +2 -2
- package/dist/react-text-annotator.es4.js.map +1 -1
- package/dist/react-text-annotator.es5.js +1 -1
- package/dist/react-text-annotator.es5.js.map +1 -1
- package/dist/react-text-annotator.es6.js +2 -2
- package/dist/react-text-annotator.es7.js +14 -11
- package/dist/react-text-annotator.es7.js.map +1 -1
- package/dist/react-text-annotator.es8.js +3 -559
- package/dist/react-text-annotator.es8.js.map +1 -1
- package/dist/tei/CETEIcean.d.ts +1 -0
- package/dist/tei/CETEIcean.d.ts.map +1 -1
- package/dist/tei/TEIAnnotator.d.ts.map +1 -1
- package/package.json +11 -11
- package/dist/react-text-annotator.es16.js +0 -12
- package/dist/react-text-annotator.es16.js.map +0 -1
- package/dist/react-text-annotator.es9.js +0 -13
- package/dist/react-text-annotator.es9.js.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { j as jsxRuntimeExports } from "./react-text-annotator.
|
|
1
|
+
import { j as jsxRuntimeExports } from "./react-text-annotator.es8.js";
|
|
2
2
|
import { useState, useCallback, useEffect, useRef, useMemo } from "react";
|
|
3
3
|
import { useAnnotator, useSelection } from "@annotorious/react";
|
|
4
|
-
import {
|
|
5
|
-
import { useFloating, useDismiss, useRole, useInteractions, FloatingPortal, FloatingFocusManager, FloatingArrow } from "./react-text-annotator.
|
|
6
|
-
import { isMobile } from "./react-text-annotator.
|
|
4
|
+
import { toViewportBounds, toDomRectList, NOT_ANNOTATABLE_CLASS } from "@soomo/text-annotator";
|
|
5
|
+
import { useFloating, useDismiss, useRole, useInteractions, FloatingPortal, FloatingFocusManager, FloatingArrow } from "./react-text-annotator.es14.js";
|
|
6
|
+
import { isMobile } from "./react-text-annotator.es15.js";
|
|
7
7
|
import { useAnnouncePopupNavigation } from "./react-text-annotator.es4.js";
|
|
8
8
|
import { useAnnotationQuoteIdling } from "./react-text-annotator.es5.js";
|
|
9
9
|
/* empty css */
|
|
10
|
-
import { inline, offset, flip, shift, arrow } from "./react-text-annotator.
|
|
11
|
-
import { autoUpdate } from "./react-text-annotator.
|
|
10
|
+
import { inline, offset, flip, shift, arrow } from "./react-text-annotator.es17.js";
|
|
11
|
+
import { autoUpdate } from "./react-text-annotator.es18.js";
|
|
12
12
|
const TextAnnotationPopup = (props) => {
|
|
13
13
|
var _a;
|
|
14
14
|
const { popup, ariaNavigationMessage } = props;
|
|
@@ -47,25 +47,28 @@ const TextAnnotationPopup = (props) => {
|
|
|
47
47
|
const role = useRole(context, { role: "dialog" });
|
|
48
48
|
const { getFloatingProps } = useInteractions([dismiss, role]);
|
|
49
49
|
useEffect(() => {
|
|
50
|
-
if (
|
|
51
|
-
|
|
50
|
+
if (!r) return;
|
|
51
|
+
const annotationId = annotation == null ? void 0 : annotation.id;
|
|
52
|
+
const annotationSelectorsLength = annotation == null ? void 0 : annotation.target.selector.length;
|
|
53
|
+
if (annotationId && annotationSelectorsLength > 0 && isAnnotationQuoteIdling) {
|
|
54
|
+
const bounds = r.state.store.getAnnotationBounds(annotation.id);
|
|
52
55
|
setOpen(Boolean(bounds));
|
|
53
56
|
} else {
|
|
54
57
|
setOpen(false);
|
|
55
58
|
}
|
|
56
|
-
}, [annotation == null ? void 0 : annotation.id, r == null ? void 0 : r.state.store
|
|
59
|
+
}, [annotation == null ? void 0 : annotation.id, annotation == null ? void 0 : annotation.target.selector, isAnnotationQuoteIdling, r == null ? void 0 : r.state.store]);
|
|
57
60
|
useEffect(() => {
|
|
58
61
|
if (!r) return;
|
|
59
62
|
if (isOpen && (annotation == null ? void 0 : annotation.id)) {
|
|
60
63
|
refs.setPositionReference({
|
|
61
64
|
getBoundingClientRect: () => {
|
|
62
65
|
const bounds = r.state.store.getAnnotationBounds(annotation.id);
|
|
63
|
-
return bounds ?
|
|
66
|
+
return bounds ? toViewportBounds(bounds, r.element.getBoundingClientRect()) : new DOMRect();
|
|
64
67
|
},
|
|
65
68
|
getClientRects: () => {
|
|
66
69
|
const rects = r.state.store.getAnnotationRects(annotation.id);
|
|
67
70
|
const denormalizedRects = rects.map(
|
|
68
|
-
(rect) =>
|
|
71
|
+
(rect) => toViewportBounds(rect, r.element.getBoundingClientRect())
|
|
69
72
|
);
|
|
70
73
|
return toDomRectList(denormalizedRects);
|
|
71
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-text-annotator.es7.js","sources":["../src/TextAnnotationPopup/TextAnnotationPopup.tsx"],"sourcesContent":["import React, { FC, ReactNode, useCallback, useRef, useEffect, useMemo, useState } from 'react';\nimport { useAnnotator, useSelection } from '@annotorious/react';\nimport {\n NOT_ANNOTATABLE_CLASS,\n denormalizeRectWithOffset,\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 shift,\n useDismiss,\n useFloating,\n useInteractions,\n useRole\n} from '@floating-ui/react';\n\nimport { isMobile } from './isMobile';\nimport { useAnnouncePopupNavigation, useAnnotationQuoteIdling } from '../hooks';\n\nimport './TextAnnotationPopup.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 popup(props: TextAnnotationPopupContentProps): ReactNode;\n\n}\n\nexport interface TextAnnotationPopupContentProps {\n\n annotation: TextAnnotation;\n\n editable?: boolean;\n\n event?: PointerEvent | KeyboardEvent;\n\n}\n\nexport const TextAnnotationPopup: FC<TextAnnotationPopupProps> = (props) => {\n\n const { popup, ariaNavigationMessage } = props;\n\n const r = useAnnotator<TextAnnotator>();\n\n const { selected, event } = useSelection<TextAnnotation>();\n const annotation = selected[0]?.annotation;\n\n const isAnnotationQuoteIdling = useAnnotationQuoteIdling(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 const arrowRef = useRef(null);\n\n const { refs, floatingStyles, update, context } = useFloating({\n placement: isMobile() ? 'bottom' : 'top',\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 const dismiss = useDismiss(context);\n\n const role = useRole(context, { role: 'dialog' });\n\n const { getFloatingProps } = useInteractions([dismiss, role]);\n\n useEffect(() => {\n if (annotation?.id && !isAnnotationQuoteIdling) {\n const bounds = r?.state.store.getAnnotationBounds(annotation.id);\n setOpen(Boolean(bounds));\n } else {\n setOpen(false);\n }\n }, [annotation?.id, r?.state.store, isAnnotationQuoteIdling]);\n\n useEffect(() => {\n if (!r) return;\n\n if (isOpen && annotation?.id) {\n refs.setPositionReference({\n getBoundingClientRect: () => {\n const bounds = r.state.store.getAnnotationBounds(annotation.id);\n return bounds\n ? denormalizeRectWithOffset(bounds, r.element.getBoundingClientRect())\n : new DOMRect();\n },\n getClientRects: () => {\n const rects = r.state.store.getAnnotationRects(annotation.id);\n const denormalizedRects = rects.map((rect) =>\n denormalizeRectWithOffset(rect, r.element.getBoundingClientRect())\n );\n return toDomRectList(denormalizedRects);\n }\n });\n } else {\n refs.setPositionReference(null);\n }\n }, [isOpen, annotation?.id, annotation?.target, r]);\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 // Don't shift focus to the floating element if selected via keyboard or on mobile.\n const initialFocus = useMemo(() => {\n return (event?.type === 'keyup' || event?.type === 'contextmenu' || isMobile()) ? -1 : 0;\n }, [event]);\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 <FloatingFocusManager\n context={context}\n modal={false}\n closeOnFocusOut={true}\n returnFocus={false}\n initialFocus={initialFocus}>\n <div\n className={`a9s-popup r6o-popup annotation-popup r6o-text-popup ${NOT_ANNOTATABLE_CLASS}`}\n ref={refs.setFloating}\n style={floatingStyles}\n {...getFloatingProps({\n onFocus: handleFocus,\n onBlur: handleBlur,\n ...getStopEventsPropagationProps()\n })}>\n {popup({\n annotation: selected[0].annotation,\n editable: selected[0].editable,\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/**\n * Prevent text-annotator from handling the irrelevant events\n * triggered from the popup/toolbar/dialog\n */\nconst getStopEventsPropagationProps = <T extends HTMLElement = HTMLElement>() => ({\n onPointerUp: (event: React.PointerEvent<T>) => event.stopPropagation(),\n onPointerDown: (event: React.PointerEvent<T>) => event.stopPropagation(),\n onMouseDown: (event: React.MouseEvent<T>) => event.stopPropagation(),\n onMouseUp: (event: React.MouseEvent<T>) => event.stopPropagation()\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":["jsx","jsxs"],"mappings":";;;;;;;;;;;AAuDa,MAAA,sBAAoD,CAAC,UAAU;;AAEpE,QAAA,EAAE,OAAO,sBAAA,IAA0B;AAEzC,QAAM,IAAI,aAA4B;AAEtC,QAAM,EAAE,UAAU,MAAM,IAAI,aAA6B;A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E,YAAU,MAAM;AACd,YAAQ,KAAK,mHAAmH;AAAA,EAClI,GAAG,EAAE;AAEE,SAAAA,sCAAC,qBAAqB,EAAA,GAAG,MAAO,CAAA;AACzC;"}
|
|
1
|
+
{"version":3,"file":"react-text-annotator.es7.js","sources":["../src/TextAnnotationPopup/TextAnnotationPopup.tsx"],"sourcesContent":["import React, { FC, ReactNode, useCallback, useRef, useEffect, useMemo, useState } from 'react';\nimport { useAnnotator, useSelection } from '@annotorious/react';\nimport {\n NOT_ANNOTATABLE_CLASS,\n toViewportBounds,\n toDomRectList,\n type TextAnnotation,\n type TextAnnotator,\n} from '@soomo/text-annotator';\n\nimport {\n arrow,\n autoUpdate,\n flip,\n FloatingArrow,\n FloatingArrowProps,\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 { isMobile } from './isMobile';\nimport { useAnnouncePopupNavigation, useAnnotationQuoteIdling } from '../hooks';\n\nimport './TextAnnotationPopup.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 popup(props: TextAnnotationPopupContentProps): ReactNode;\n\n}\n\nexport interface TextAnnotationPopupContentProps {\n\n annotation: TextAnnotation;\n\n editable?: boolean;\n\n event?: PointerEvent | KeyboardEvent;\n\n}\n\nexport const TextAnnotationPopup: FC<TextAnnotationPopupProps> = (props) => {\n\n const { popup, ariaNavigationMessage } = props;\n\n const r = useAnnotator<TextAnnotator>();\n\n const { selected, event } = useSelection<TextAnnotation>();\n const annotation = selected[0]?.annotation;\n\n const isAnnotationQuoteIdling = useAnnotationQuoteIdling(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 const arrowRef = useRef(null);\n\n const { refs, floatingStyles, update, context } = useFloating({\n placement: isMobile() ? 'bottom' : 'top',\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 const dismiss = useDismiss(context);\n\n const role = useRole(context, { role: 'dialog' });\n\n const { getFloatingProps } = useInteractions([dismiss, role]);\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 && isAnnotationQuoteIdling) {\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, isAnnotationQuoteIdling, r?.state.store]);\n\n useEffect(() => {\n if (!r) return;\n\n if (isOpen && annotation?.id) {\n refs.setPositionReference({\n getBoundingClientRect: () => {\n const bounds = r.state.store.getAnnotationBounds(annotation.id);\n return bounds\n ? toViewportBounds(bounds, r.element.getBoundingClientRect())\n : new DOMRect();\n },\n getClientRects: () => {\n const rects = r.state.store.getAnnotationRects(annotation.id);\n const denormalizedRects = rects.map((rect) =>\n toViewportBounds(rect, r.element.getBoundingClientRect())\n );\n return toDomRectList(denormalizedRects);\n }\n });\n } else {\n refs.setPositionReference(null);\n }\n }, [isOpen, annotation?.id, annotation?.target, r]);\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 // Don't shift focus to the floating element if selected via keyboard or on mobile.\n const initialFocus = useMemo(() => {\n return (event?.type === 'keyup' || event?.type === 'contextmenu' || isMobile()) ? -1 : 0;\n }, [event]);\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 <FloatingFocusManager\n context={context}\n modal={false}\n closeOnFocusOut={true}\n returnFocus={false}\n initialFocus={initialFocus}>\n <div\n className={`a9s-popup r6o-popup annotation-popup r6o-text-popup ${NOT_ANNOTATABLE_CLASS}`}\n ref={refs.setFloating}\n style={floatingStyles}\n {...getFloatingProps({\n onFocus: handleFocus,\n onBlur: handleBlur,\n ...getStopEventsPropagationProps()\n })}>\n {popup({\n annotation: selected[0].annotation,\n editable: selected[0].editable,\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/**\n * Prevent text-annotator from handling the irrelevant events\n * triggered from the popup/toolbar/dialog\n */\nconst getStopEventsPropagationProps = <T extends HTMLElement = HTMLElement>() => ({\n onPointerUp: (event: React.PointerEvent<T>) => event.stopPropagation(),\n onPointerDown: (event: React.PointerEvent<T>) => event.stopPropagation(),\n onMouseDown: (event: React.MouseEvent<T>) => event.stopPropagation(),\n onMouseUp: (event: React.MouseEvent<T>) => event.stopPropagation()\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":["jsx","jsxs"],"mappings":";;;;;;;;;;;AAwDa,MAAA,sBAAoD,CAAC,UAAU;;AAEpE,QAAA,EAAE,OAAO,sBAAA,IAA0B;AAEzC,QAAM,IAAI,aAA4B;AAEtC,QAAM,EAAE,UAAU,MAAM,IAAI,aAA6B;AACnD,QAAA,cAAa,cAAS,CAAC,MAAV,mBAAa;AAE1B,QAAA,0BAA0B,yBAAyB,yCAAY,EAAE;AAEvE,QAAM,CAAC,QAAQ,OAAO,IAAI,UAAS,qCAAU,UAAS,CAAC;AACjD,QAAA,cAAc,MAAM,uBAAG;AAE7B,QAAM,CAAC,WAAW,UAAU,IAAI,SAAS,KAAK;AAC9C,QAAM,cAAc,YAAY,MAAM,WAAW,IAAI,GAAG,CAAA,CAAE;AAC1D,QAAM,aAAa,YAAY,MAAM,WAAW,KAAK,GAAG,CAAA,CAAE;AAC1D,YAAU,MAAM;AACV,QAAA,CAAC,OAAmB,YAAA;AAAA,EAAA,GACvB,CAAC,QAAQ,UAAU,CAAC;AAEjB,QAAA,WAAW,OAAO,IAAI;AAE5B,QAAM,EAAE,MAAM,gBAAgB,QAAQ,QAAA,IAAY,YAAY;AAAA,IAC5D,WAAW,aAAa,WAAW;AAAA,IACnC,MAAM;AAAA,IACN,cAAc,CAAC,MAAM,QAAQ,WAAW;AACtC,UAAI,CAAC,SAAS,WAAW,gBAAgB,WAAW,cAAc;AAChE,gBAAQ,IAAI;AACA,oBAAA;AAAA,MAAA;AAAA,IAEhB;AAAA,IACA,YAAY;AAAA,MACV,OAAO;AAAA,MACP,OAAO,EAAE;AAAA,MACT,KAAK,EAAE,WAAW,MAAM;AAAA,MACxB,MAAM,EAAE,WAAW,MAAM,SAAS,IAAI;AAAA,MACtC,MAAM,EAAE,SAAS,SAAU,CAAA;AAAA,IAC7B;AAAA,IACA,sBAAsB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AO,EAAA,WAAU,qBAAoB,aAAU,aAAY,SAAS,aAClE,UAAM,MAAA,oBAAoB,0CAC7B,CAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACF;AAAA,KAEJ,IACE;AAEN;AAMA,MAAM,gCAAgC,OAA4C;AAAA,EAChF,aAAa,CAAC,UAAiC,MAAM,gBAAgB;AAAA,EACrE,eAAe,CAAC,UAAiC,MAAM,gBAAgB;AAAA,EACvE,aAAa,CAAC,UAA+B,MAAM,gBAAgB;AAAA,EACnE,WAAW,CAAC,UAA+B,MAAM,gBAAgB;AACnE;AAIa,MAAA,qBAAqB,CAAC,UAAoC;AAErE,YAAU,MAAM;AACd,YAAQ,KAAK,mHAAmH;AAAA,EAClI,GAAG,EAAE;AAEE,SAAAA,sCAAC,qBAAqB,EAAA,GAAG,MAAO,CAAA;AACzC;"}
|
|
@@ -1,562 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const Nt = (t) => {
|
|
4
|
-
const e = t.cloneContents();
|
|
5
|
-
return e.querySelectorAll(tt).forEach((n) => n.remove()), e;
|
|
6
|
-
}, Re = (t, e, n = 10, o) => {
|
|
7
|
-
const i = e, s = document.createRange();
|
|
8
|
-
s.setStart(i, 0), s.setEnd(t.startContainer, t.startOffset);
|
|
9
|
-
const a = Nt(s).textContent, r = document.createRange();
|
|
10
|
-
r.setStart(t.endContainer, t.endOffset), i === document.body ? r.setEnd(i, i.childNodes.length) : r.setEndAfter(i);
|
|
11
|
-
const l = Nt(r).textContent;
|
|
12
|
-
return {
|
|
13
|
-
prefix: a.substring(a.length - n),
|
|
14
|
-
suffix: l.substring(0, n)
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
const Y = [];
|
|
18
|
-
for (let t = 0; t < 256; ++t)
|
|
19
|
-
Y.push((t + 256).toString(16).slice(1));
|
|
20
|
-
function an(t, e = 0) {
|
|
21
|
-
return (Y[t[e + 0]] + Y[t[e + 1]] + Y[t[e + 2]] + Y[t[e + 3]] + "-" + Y[t[e + 4]] + Y[t[e + 5]] + "-" + Y[t[e + 6]] + Y[t[e + 7]] + "-" + Y[t[e + 8]] + Y[t[e + 9]] + "-" + Y[t[e + 10]] + Y[t[e + 11]] + Y[t[e + 12]] + Y[t[e + 13]] + Y[t[e + 14]] + Y[t[e + 15]]).toLowerCase();
|
|
22
|
-
}
|
|
23
|
-
let Ct;
|
|
24
|
-
const cn = new Uint8Array(16);
|
|
25
|
-
function ln() {
|
|
26
|
-
if (!Ct) {
|
|
27
|
-
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
28
|
-
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
29
|
-
Ct = crypto.getRandomValues.bind(crypto);
|
|
30
|
-
}
|
|
31
|
-
return Ct(cn);
|
|
32
|
-
}
|
|
33
|
-
const dn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Qt = { randomUUID: dn };
|
|
34
|
-
function fe(t, e, n) {
|
|
35
|
-
if (Qt.randomUUID && !e && !t)
|
|
36
|
-
return Qt.randomUUID();
|
|
37
|
-
t = t || {};
|
|
38
|
-
const o = t.random || (t.rng || ln)();
|
|
39
|
-
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, an(o);
|
|
40
|
-
}
|
|
41
|
-
const K = [];
|
|
42
|
-
for (let t = 0; t < 256; ++t)
|
|
43
|
-
K.push((t + 256).toString(16).slice(1));
|
|
44
|
-
typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
45
|
-
const _n = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
46
|
-
let Yn = (t = 21) => {
|
|
47
|
-
let e = "", n = crypto.getRandomValues(new Uint8Array(t));
|
|
48
|
-
for (; t--; )
|
|
49
|
-
e += _n[n[t] & 63];
|
|
50
|
-
return e;
|
|
51
|
-
};
|
|
52
|
-
const Dn = (t) => {
|
|
53
|
-
const e = JSON.stringify(t);
|
|
54
|
-
let n = 0;
|
|
55
|
-
for (let o = 0, i = e.length; o < i; o++) {
|
|
56
|
-
let s = e.charCodeAt(o);
|
|
57
|
-
n = (n << 5) - n + s, n |= 0;
|
|
58
|
-
}
|
|
59
|
-
return `${n}`;
|
|
60
|
-
}, ge = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, Xn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
|
|
61
|
-
const { id: o, type: i, purpose: s, value: a, created: r, modified: l, creator: f, ...h } = n;
|
|
62
|
-
return {
|
|
63
|
-
id: o || `temp-${Dn(n)}`,
|
|
64
|
-
annotation: e,
|
|
65
|
-
type: i,
|
|
66
|
-
purpose: s,
|
|
67
|
-
value: a,
|
|
68
|
-
creator: ge(f),
|
|
69
|
-
created: r ? new Date(r) : void 0,
|
|
70
|
-
updated: l ? new Date(l) : void 0,
|
|
71
|
-
...h
|
|
72
|
-
};
|
|
73
|
-
}), Pn = (t) => t.map((e) => {
|
|
74
|
-
var n;
|
|
75
|
-
const { annotation: o, created: i, updated: s, ...a } = e, r = {
|
|
76
|
-
...a,
|
|
77
|
-
created: i == null ? void 0 : i.toISOString(),
|
|
78
|
-
modified: s == null ? void 0 : s.toISOString()
|
|
79
|
-
};
|
|
80
|
-
return (n = r.id) != null && n.startsWith("temp-") && delete r.id, r;
|
|
81
|
-
});
|
|
82
|
-
Yn();
|
|
83
|
-
const Ao = (t, e) => ({
|
|
84
|
-
parse: (n) => jn(n),
|
|
85
|
-
serialize: (n) => zn(n, t, e)
|
|
86
|
-
}), $n = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, Hn = (t) => {
|
|
87
|
-
const {
|
|
88
|
-
id: e,
|
|
89
|
-
creator: n,
|
|
90
|
-
created: o,
|
|
91
|
-
modified: i,
|
|
92
|
-
target: s
|
|
93
|
-
} = t, a = Array.isArray(s) ? s : [s];
|
|
94
|
-
if (a.length === 0)
|
|
95
|
-
return { error: Error(`No targets found for annotation: ${t.id}`) };
|
|
96
|
-
const r = {
|
|
97
|
-
creator: ge(n),
|
|
98
|
-
created: o ? new Date(o) : void 0,
|
|
99
|
-
updated: i ? new Date(i) : void 0,
|
|
100
|
-
annotation: e,
|
|
101
|
-
selector: [],
|
|
102
|
-
// @ts-expect-error: `styleClass` is not part of the core `TextAnnotationTarget` type
|
|
103
|
-
styleClass: "styleClass" in a[0] ? a[0].styleClass : void 0
|
|
104
|
-
};
|
|
105
|
-
for (const l of a) {
|
|
106
|
-
const h = (Array.isArray(l.selector) ? l.selector : [l.selector]).reduce((u, p) => {
|
|
107
|
-
switch (p.type) {
|
|
108
|
-
case "TextQuoteSelector":
|
|
109
|
-
u.quote = p.exact;
|
|
110
|
-
break;
|
|
111
|
-
case "TextPositionSelector":
|
|
112
|
-
u.start = p.start, u.end = p.end;
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
return u;
|
|
116
|
-
}, {});
|
|
117
|
-
if ($n(h))
|
|
118
|
-
r.selector.push(
|
|
119
|
-
{
|
|
120
|
-
...h,
|
|
121
|
-
id: l.id,
|
|
122
|
-
// @ts-expect-error: `scope` is not part of the core `TextSelector` type
|
|
123
|
-
scope: l.scope
|
|
124
|
-
}
|
|
125
|
-
);
|
|
126
|
-
else {
|
|
127
|
-
const u = [
|
|
128
|
-
h.start ? void 0 : "TextPositionSelector",
|
|
129
|
-
h.quote ? void 0 : "TextQuoteSelector"
|
|
130
|
-
].filter(Boolean);
|
|
131
|
-
return { error: Error(`Missing selector types: ${u.join(" and ")} for annotation: ${t.id}`) };
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return { parsed: r };
|
|
135
|
-
}, jn = (t) => {
|
|
136
|
-
const e = t.id || fe(), {
|
|
137
|
-
creator: n,
|
|
138
|
-
created: o,
|
|
139
|
-
modified: i,
|
|
140
|
-
body: s,
|
|
141
|
-
...a
|
|
142
|
-
} = t, r = Xn(s, e), l = Hn(t);
|
|
143
|
-
return "error" in l ? { error: l.error } : {
|
|
144
|
-
parsed: {
|
|
145
|
-
...a,
|
|
146
|
-
id: e,
|
|
147
|
-
bodies: r,
|
|
148
|
-
target: l.parsed
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
}, zn = (t, e, n) => {
|
|
152
|
-
const { bodies: o, target: i, ...s } = t, {
|
|
153
|
-
selector: a,
|
|
154
|
-
creator: r,
|
|
155
|
-
created: l,
|
|
156
|
-
updated: f,
|
|
157
|
-
...h
|
|
158
|
-
} = i, u = a.map((p) => {
|
|
159
|
-
const { id: g, quote: b, start: w, end: y, range: d } = p, { prefix: c, suffix: A } = Re(d, n), E = [{
|
|
160
|
-
type: "TextQuoteSelector",
|
|
161
|
-
exact: b,
|
|
162
|
-
prefix: c,
|
|
163
|
-
suffix: A
|
|
164
|
-
}, {
|
|
165
|
-
type: "TextPositionSelector",
|
|
166
|
-
start: w,
|
|
167
|
-
end: y
|
|
168
|
-
}];
|
|
169
|
-
return {
|
|
170
|
-
...h,
|
|
171
|
-
id: g,
|
|
172
|
-
// @ts-expect-error: `scope` is not part of the core `TextSelector` type
|
|
173
|
-
scope: "scope" in p ? p.scope : void 0,
|
|
174
|
-
source: e,
|
|
175
|
-
selector: E
|
|
176
|
-
};
|
|
177
|
-
});
|
|
178
|
-
return {
|
|
179
|
-
...s,
|
|
180
|
-
"@context": "http://www.w3.org/ns/anno.jsonld",
|
|
181
|
-
id: t.id,
|
|
182
|
-
type: "Annotation",
|
|
183
|
-
body: Pn(t.bodies),
|
|
184
|
-
creator: r,
|
|
185
|
-
created: l == null ? void 0 : l.toISOString(),
|
|
186
|
-
modified: f == null ? void 0 : f.toISOString(),
|
|
187
|
-
target: u
|
|
188
|
-
};
|
|
189
|
-
};
|
|
190
|
-
const kt = typeof navigator < "u" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : false;
|
|
191
|
-
function It(t, e, n, o) {
|
|
192
|
-
t.addEventListener ? t.addEventListener(e, n, o) : t.attachEvent && t.attachEvent("on".concat(e), n);
|
|
193
|
-
}
|
|
194
|
-
function ot(t, e, n, o) {
|
|
195
|
-
t.removeEventListener ? t.removeEventListener(e, n, o) : t.detachEvent && t.detachEvent("on".concat(e), n);
|
|
196
|
-
}
|
|
197
|
-
function ye(t, e) {
|
|
198
|
-
const n = e.slice(0, e.length - 1);
|
|
199
|
-
for (let o = 0; o < n.length; o++) n[o] = t[n[o].toLowerCase()];
|
|
200
|
-
return n;
|
|
201
|
-
}
|
|
202
|
-
function be(t) {
|
|
203
|
-
typeof t != "string" && (t = ""), t = t.replace(/\s/g, "");
|
|
204
|
-
const e = t.split(",");
|
|
205
|
-
let n = e.lastIndexOf("");
|
|
206
|
-
for (; n >= 0; )
|
|
207
|
-
e[n - 1] += ",", e.splice(n, 1), n = e.lastIndexOf("");
|
|
208
|
-
return e;
|
|
209
|
-
}
|
|
210
|
-
function io(t, e) {
|
|
211
|
-
const n = t.length >= e.length ? t : e, o = t.length >= e.length ? e : t;
|
|
212
|
-
let i = true;
|
|
213
|
-
for (let s = 0; s < n.length; s++)
|
|
214
|
-
o.indexOf(n[s]) === -1 && (i = false);
|
|
215
|
-
return i;
|
|
216
|
-
}
|
|
217
|
-
const lt = {
|
|
218
|
-
backspace: 8,
|
|
219
|
-
"⌫": 8,
|
|
220
|
-
tab: 9,
|
|
221
|
-
clear: 12,
|
|
222
|
-
enter: 13,
|
|
223
|
-
"↩": 13,
|
|
224
|
-
return: 13,
|
|
225
|
-
esc: 27,
|
|
226
|
-
escape: 27,
|
|
227
|
-
space: 32,
|
|
228
|
-
left: 37,
|
|
229
|
-
up: 38,
|
|
230
|
-
right: 39,
|
|
231
|
-
down: 40,
|
|
232
|
-
del: 46,
|
|
233
|
-
delete: 46,
|
|
234
|
-
ins: 45,
|
|
235
|
-
insert: 45,
|
|
236
|
-
home: 36,
|
|
237
|
-
end: 35,
|
|
238
|
-
pageup: 33,
|
|
239
|
-
pagedown: 34,
|
|
240
|
-
capslock: 20,
|
|
241
|
-
num_0: 96,
|
|
242
|
-
num_1: 97,
|
|
243
|
-
num_2: 98,
|
|
244
|
-
num_3: 99,
|
|
245
|
-
num_4: 100,
|
|
246
|
-
num_5: 101,
|
|
247
|
-
num_6: 102,
|
|
248
|
-
num_7: 103,
|
|
249
|
-
num_8: 104,
|
|
250
|
-
num_9: 105,
|
|
251
|
-
num_multiply: 106,
|
|
252
|
-
num_add: 107,
|
|
253
|
-
num_enter: 108,
|
|
254
|
-
num_subtract: 109,
|
|
255
|
-
num_decimal: 110,
|
|
256
|
-
num_divide: 111,
|
|
257
|
-
"⇪": 20,
|
|
258
|
-
",": 188,
|
|
259
|
-
".": 190,
|
|
260
|
-
"/": 191,
|
|
261
|
-
"`": 192,
|
|
262
|
-
"-": kt ? 173 : 189,
|
|
263
|
-
"=": kt ? 61 : 187,
|
|
264
|
-
";": kt ? 59 : 186,
|
|
265
|
-
"'": 222,
|
|
266
|
-
"[": 219,
|
|
267
|
-
"]": 221,
|
|
268
|
-
"\\": 220
|
|
269
|
-
}, H = {
|
|
270
|
-
// shiftKey
|
|
271
|
-
"⇧": 16,
|
|
272
|
-
shift: 16,
|
|
273
|
-
// altKey
|
|
274
|
-
"⌥": 18,
|
|
275
|
-
alt: 18,
|
|
276
|
-
option: 18,
|
|
277
|
-
// ctrlKey
|
|
278
|
-
"⌃": 17,
|
|
279
|
-
ctrl: 17,
|
|
280
|
-
control: 17,
|
|
281
|
-
// metaKey
|
|
282
|
-
"⌘": 91,
|
|
283
|
-
cmd: 91,
|
|
284
|
-
command: 91
|
|
285
|
-
}, Vt = {
|
|
286
|
-
16: "shiftKey",
|
|
287
|
-
18: "altKey",
|
|
288
|
-
17: "ctrlKey",
|
|
289
|
-
91: "metaKey",
|
|
290
|
-
shiftKey: 16,
|
|
291
|
-
ctrlKey: 17,
|
|
292
|
-
altKey: 18,
|
|
293
|
-
metaKey: 91
|
|
294
|
-
}, D = {
|
|
295
|
-
16: false,
|
|
296
|
-
18: false,
|
|
297
|
-
17: false,
|
|
298
|
-
91: false
|
|
299
|
-
}, _ = {};
|
|
300
|
-
for (let t = 1; t < 20; t++)
|
|
301
|
-
lt["f".concat(t)] = 111 + t;
|
|
302
|
-
let I = [], ct = null, we = "all";
|
|
303
|
-
const z = /* @__PURE__ */ new Map(), ut = (t) => lt[t.toLowerCase()] || H[t.toLowerCase()] || t.toUpperCase().charCodeAt(0), so = (t) => Object.keys(lt).find((e) => lt[e] === t), ro = (t) => Object.keys(H).find((e) => H[e] === t);
|
|
304
|
-
function Ae(t) {
|
|
305
|
-
we = t || "all";
|
|
306
|
-
}
|
|
307
|
-
function dt() {
|
|
308
|
-
return we || "all";
|
|
309
|
-
}
|
|
310
|
-
function ao() {
|
|
311
|
-
return I.slice(0);
|
|
312
|
-
}
|
|
313
|
-
function co() {
|
|
314
|
-
return I.map((t) => so(t) || ro(t) || String.fromCharCode(t));
|
|
315
|
-
}
|
|
316
|
-
function lo() {
|
|
317
|
-
const t = [];
|
|
318
|
-
return Object.keys(_).forEach((e) => {
|
|
319
|
-
_[e].forEach((n) => {
|
|
320
|
-
let {
|
|
321
|
-
key: o,
|
|
322
|
-
scope: i,
|
|
323
|
-
mods: s,
|
|
324
|
-
shortcut: a
|
|
325
|
-
} = n;
|
|
326
|
-
t.push({
|
|
327
|
-
scope: i,
|
|
328
|
-
shortcut: a,
|
|
329
|
-
mods: s,
|
|
330
|
-
keys: o.split("+").map((r) => ut(r))
|
|
331
|
-
});
|
|
332
|
-
});
|
|
333
|
-
}), t;
|
|
334
|
-
}
|
|
335
|
-
function uo(t) {
|
|
336
|
-
const e = t.target || t.srcElement, {
|
|
337
|
-
tagName: n
|
|
338
|
-
} = e;
|
|
339
|
-
let o = true;
|
|
340
|
-
const i = n === "INPUT" && !["checkbox", "radio", "range", "button", "file", "reset", "submit", "color"].includes(e.type);
|
|
341
|
-
return (e.isContentEditable || (i || n === "TEXTAREA" || n === "SELECT") && !e.readOnly) && (o = false), o;
|
|
342
|
-
}
|
|
343
|
-
function fo(t) {
|
|
344
|
-
return typeof t == "string" && (t = ut(t)), I.indexOf(t) !== -1;
|
|
345
|
-
}
|
|
346
|
-
function ho(t, e) {
|
|
347
|
-
let n, o;
|
|
348
|
-
t || (t = dt());
|
|
349
|
-
for (const i in _)
|
|
350
|
-
if (Object.prototype.hasOwnProperty.call(_, i))
|
|
351
|
-
for (n = _[i], o = 0; o < n.length; )
|
|
352
|
-
n[o].scope === t ? n.splice(o, 1).forEach((a) => {
|
|
353
|
-
let {
|
|
354
|
-
element: r
|
|
355
|
-
} = a;
|
|
356
|
-
return Xt(r);
|
|
357
|
-
}) : o++;
|
|
358
|
-
dt() === t && Ae(e || "all");
|
|
359
|
-
}
|
|
360
|
-
function po(t) {
|
|
361
|
-
let e = t.keyCode || t.which || t.charCode;
|
|
362
|
-
const n = I.indexOf(e);
|
|
363
|
-
if (n >= 0 && I.splice(n, 1), t.key && t.key.toLowerCase() === "meta" && I.splice(0, I.length), (e === 93 || e === 224) && (e = 91), e in D) {
|
|
364
|
-
D[e] = false;
|
|
365
|
-
for (const o in H) H[o] === e && (P[o] = false);
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
function xe(t) {
|
|
369
|
-
if (typeof t > "u")
|
|
370
|
-
Object.keys(_).forEach((i) => {
|
|
371
|
-
Array.isArray(_[i]) && _[i].forEach((s) => yt(s)), delete _[i];
|
|
372
|
-
}), Xt(null);
|
|
373
|
-
else if (Array.isArray(t))
|
|
374
|
-
t.forEach((i) => {
|
|
375
|
-
i.key && yt(i);
|
|
376
|
-
});
|
|
377
|
-
else if (typeof t == "object")
|
|
378
|
-
t.key && yt(t);
|
|
379
|
-
else if (typeof t == "string") {
|
|
380
|
-
for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), o = 1; o < e; o++)
|
|
381
|
-
n[o - 1] = arguments[o];
|
|
382
|
-
let [i, s] = n;
|
|
383
|
-
typeof i == "function" && (s = i, i = ""), yt({
|
|
384
|
-
key: t,
|
|
385
|
-
scope: i,
|
|
386
|
-
method: s,
|
|
387
|
-
splitKey: "+"
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
const yt = (t) => {
|
|
392
|
-
let {
|
|
393
|
-
key: e,
|
|
394
|
-
scope: n,
|
|
395
|
-
method: o,
|
|
396
|
-
splitKey: i = "+"
|
|
397
|
-
} = t;
|
|
398
|
-
be(e).forEach((a) => {
|
|
399
|
-
const r = a.split(i), l = r.length, f = r[l - 1], h = f === "*" ? "*" : ut(f);
|
|
400
|
-
if (!_[h]) return;
|
|
401
|
-
n || (n = dt());
|
|
402
|
-
const u = l > 1 ? ye(H, r) : [], p = [];
|
|
403
|
-
_[h] = _[h].filter((g) => {
|
|
404
|
-
const w = (o ? g.method === o : true) && g.scope === n && io(g.mods, u);
|
|
405
|
-
return w && p.push(g.element), !w;
|
|
406
|
-
}), p.forEach((g) => Xt(g));
|
|
407
|
-
});
|
|
408
|
-
};
|
|
409
|
-
function ne(t, e, n, o) {
|
|
410
|
-
if (e.element !== o)
|
|
411
|
-
return;
|
|
412
|
-
let i;
|
|
413
|
-
if (e.scope === n || e.scope === "all") {
|
|
414
|
-
i = e.mods.length > 0;
|
|
415
|
-
for (const s in D)
|
|
416
|
-
Object.prototype.hasOwnProperty.call(D, s) && (!D[s] && e.mods.indexOf(+s) > -1 || D[s] && e.mods.indexOf(+s) === -1) && (i = false);
|
|
417
|
-
(e.mods.length === 0 && !D[16] && !D[18] && !D[17] && !D[91] || i || e.shortcut === "*") && (e.keys = [], e.keys = e.keys.concat(I), e.method(t, e) === false && (t.preventDefault ? t.preventDefault() : t.returnValue = false, t.stopPropagation && t.stopPropagation(), t.cancelBubble && (t.cancelBubble = true)));
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
function oe(t, e) {
|
|
421
|
-
const n = _["*"];
|
|
422
|
-
let o = t.keyCode || t.which || t.charCode;
|
|
423
|
-
if (!P.filter.call(this, t)) return;
|
|
424
|
-
if ((o === 93 || o === 224) && (o = 91), I.indexOf(o) === -1 && o !== 229 && I.push(o), ["ctrlKey", "altKey", "shiftKey", "metaKey"].forEach((r) => {
|
|
425
|
-
const l = Vt[r];
|
|
426
|
-
t[r] && I.indexOf(l) === -1 ? I.push(l) : !t[r] && I.indexOf(l) > -1 ? I.splice(I.indexOf(l), 1) : r === "metaKey" && t[r] && I.length === 3 && (t.ctrlKey || t.shiftKey || t.altKey || (I = I.slice(I.indexOf(l))));
|
|
427
|
-
}), o in D) {
|
|
428
|
-
D[o] = true;
|
|
429
|
-
for (const r in H)
|
|
430
|
-
H[r] === o && (P[r] = true);
|
|
431
|
-
if (!n) return;
|
|
432
|
-
}
|
|
433
|
-
for (const r in D)
|
|
434
|
-
Object.prototype.hasOwnProperty.call(D, r) && (D[r] = t[Vt[r]]);
|
|
435
|
-
t.getModifierState && !(t.altKey && !t.ctrlKey) && t.getModifierState("AltGraph") && (I.indexOf(17) === -1 && I.push(17), I.indexOf(18) === -1 && I.push(18), D[17] = true, D[18] = true);
|
|
436
|
-
const i = dt();
|
|
437
|
-
if (n)
|
|
438
|
-
for (let r = 0; r < n.length; r++)
|
|
439
|
-
n[r].scope === i && (t.type === "keydown" && n[r].keydown || t.type === "keyup" && n[r].keyup) && ne(t, n[r], i, e);
|
|
440
|
-
if (!(o in _)) return;
|
|
441
|
-
const s = _[o], a = s.length;
|
|
442
|
-
for (let r = 0; r < a; r++)
|
|
443
|
-
if ((t.type === "keydown" && s[r].keydown || t.type === "keyup" && s[r].keyup) && s[r].key) {
|
|
444
|
-
const l = s[r], {
|
|
445
|
-
splitKey: f
|
|
446
|
-
} = l, h = l.key.split(f), u = [];
|
|
447
|
-
for (let p = 0; p < h.length; p++)
|
|
448
|
-
u.push(ut(h[p]));
|
|
449
|
-
u.sort().join("") === I.sort().join("") && ne(t, l, i, e);
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
function P(t, e, n) {
|
|
453
|
-
I = [];
|
|
454
|
-
const o = be(t);
|
|
455
|
-
let i = [], s = "all", a = document, r = 0, l = false, f = true, h = "+", u = false, p = false;
|
|
456
|
-
for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (s = e.scope), e.element && (a = e.element), e.keyup && (l = e.keyup), e.keydown !== void 0 && (f = e.keydown), e.capture !== void 0 && (u = e.capture), typeof e.splitKey == "string" && (h = e.splitKey), e.single === true && (p = true)), typeof e == "string" && (s = e), p && xe(t, s); r < o.length; r++)
|
|
457
|
-
t = o[r].split(h), i = [], t.length > 1 && (i = ye(H, t)), t = t[t.length - 1], t = t === "*" ? "*" : ut(t), t in _ || (_[t] = []), _[t].push({
|
|
458
|
-
keyup: l,
|
|
459
|
-
keydown: f,
|
|
460
|
-
scope: s,
|
|
461
|
-
mods: i,
|
|
462
|
-
shortcut: o[r],
|
|
463
|
-
method: n,
|
|
464
|
-
key: o[r],
|
|
465
|
-
splitKey: h,
|
|
466
|
-
element: a
|
|
467
|
-
});
|
|
468
|
-
if (typeof a < "u" && window) {
|
|
469
|
-
if (!z.has(a)) {
|
|
470
|
-
const g = function() {
|
|
471
|
-
let w = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
472
|
-
return oe(w, a);
|
|
473
|
-
}, b = function() {
|
|
474
|
-
let w = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
475
|
-
oe(w, a), po(w);
|
|
476
|
-
};
|
|
477
|
-
z.set(a, {
|
|
478
|
-
keydownListener: g,
|
|
479
|
-
keyupListenr: b,
|
|
480
|
-
capture: u
|
|
481
|
-
}), It(a, "keydown", g, u), It(a, "keyup", b, u);
|
|
482
|
-
}
|
|
483
|
-
if (!ct) {
|
|
484
|
-
const g = () => {
|
|
485
|
-
I = [];
|
|
486
|
-
};
|
|
487
|
-
ct = {
|
|
488
|
-
listener: g,
|
|
489
|
-
capture: u
|
|
490
|
-
}, It(window, "focus", g, u);
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
function go(t) {
|
|
495
|
-
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "all";
|
|
496
|
-
Object.keys(_).forEach((n) => {
|
|
497
|
-
_[n].filter((i) => i.scope === e && i.shortcut === t).forEach((i) => {
|
|
498
|
-
i && i.method && i.method();
|
|
499
|
-
});
|
|
500
|
-
});
|
|
501
|
-
}
|
|
502
|
-
function Xt(t) {
|
|
503
|
-
const e = Object.values(_).flat();
|
|
504
|
-
if (e.findIndex((o) => {
|
|
505
|
-
let {
|
|
506
|
-
element: i
|
|
507
|
-
} = o;
|
|
508
|
-
return i === t;
|
|
509
|
-
}) < 0) {
|
|
510
|
-
const {
|
|
511
|
-
keydownListener: o,
|
|
512
|
-
keyupListenr: i,
|
|
513
|
-
capture: s
|
|
514
|
-
} = z.get(t) || {};
|
|
515
|
-
o && i && (ot(t, "keyup", i, s), ot(t, "keydown", o, s), z.delete(t));
|
|
516
|
-
}
|
|
517
|
-
if ((e.length <= 0 || z.size <= 0) && (Object.keys(z).forEach((i) => {
|
|
518
|
-
const {
|
|
519
|
-
keydownListener: s,
|
|
520
|
-
keyupListenr: a,
|
|
521
|
-
capture: r
|
|
522
|
-
} = z.get(i) || {};
|
|
523
|
-
s && a && (ot(i, "keyup", a, r), ot(i, "keydown", s, r), z.delete(i));
|
|
524
|
-
}), z.clear(), Object.keys(_).forEach((i) => delete _[i]), ct)) {
|
|
525
|
-
const {
|
|
526
|
-
listener: i,
|
|
527
|
-
capture: s
|
|
528
|
-
} = ct;
|
|
529
|
-
ot(window, "focus", i, s), ct = null;
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
const _t = {
|
|
533
|
-
getPressedKeyString: co,
|
|
534
|
-
setScope: Ae,
|
|
535
|
-
getScope: dt,
|
|
536
|
-
deleteScope: ho,
|
|
537
|
-
getPressedKeyCodes: ao,
|
|
538
|
-
getAllKeyCodes: lo,
|
|
539
|
-
isPressed: fo,
|
|
540
|
-
filter: uo,
|
|
541
|
-
trigger: go,
|
|
542
|
-
unbind: xe,
|
|
543
|
-
keyMap: lt,
|
|
544
|
-
modifier: H,
|
|
545
|
-
modifierMap: Vt
|
|
546
|
-
};
|
|
547
|
-
for (const t in _t)
|
|
548
|
-
Object.prototype.hasOwnProperty.call(_t, t) && (P[t] = _t[t]);
|
|
549
|
-
if (typeof window < "u") {
|
|
550
|
-
const t = window.hotkeys;
|
|
551
|
-
P.noConflict = (e) => (e && window.hotkeys === P && (window.hotkeys = t), P), window.hotkeys = P;
|
|
552
|
-
}
|
|
1
|
+
import { __require as requireJsxRuntime } from "./react-text-annotator.es19.js";
|
|
2
|
+
var jsxRuntimeExports = requireJsxRuntime();
|
|
553
3
|
export {
|
|
554
|
-
|
|
555
|
-
tt as NOT_ANNOTATABLE_SELECTOR,
|
|
556
|
-
Ao as W3CTextFormat,
|
|
557
|
-
Re as getQuoteContext,
|
|
558
|
-
Nt as getRangeAnnotatableContents,
|
|
559
|
-
jn as parseW3CTextAnnotation,
|
|
560
|
-
zn as serializeW3CTextAnnotation
|
|
4
|
+
jsxRuntimeExports as j
|
|
561
5
|
};
|
|
562
6
|
//# sourceMappingURL=react-text-annotator.es8.js.map
|