@recogito/text-annotator 3.4.8 → 4.0.0-beta
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 +409 -11
- package/dist/model/core/index.d.ts +1 -1
- package/dist/model/w3c/index.d.ts +2 -2
- package/dist/{src/model/w3c/W3CTextFormatAdapter.d.ts → model/w3c/w3c-text-format-adapter.d.ts} +2 -2
- package/dist/rendering/base-renderer.d.ts +31 -0
- package/dist/{src/highlight/HighlightStyle.d.ts → rendering/highlight-style.d.ts} +4 -1
- package/dist/{src/highlight/Highlight.d.ts → rendering/highlight.d.ts} +2 -1
- package/dist/rendering/index.d.ts +4 -0
- package/dist/rendering/renderer-css-highlight/css-highlight-renderer.d.ts +6 -0
- package/dist/rendering/renderer-css-highlight/index.d.ts +1 -0
- package/dist/rendering/renderer-inline-markup/index.d.ts +0 -0
- package/dist/rendering/renderer-spans/index.d.ts +1 -0
- package/dist/rendering/renderer-spans/spans-renderer.d.ts +2 -0
- package/dist/{SelectionHandler.d.ts → selection-handler.d.ts} +5 -5
- package/dist/src/index.d.ts +8 -7
- package/dist/state/index.d.ts +2 -2
- package/dist/state/{spatialTree.d.ts → spatial-tree.d.ts} +4 -4
- package/dist/{src/state/TextAnnotationStore.d.ts → state/text-annotation-store.d.ts} +3 -0
- package/dist/{src/state/TextAnnotatorState.d.ts → state/text-annotator-state.d.ts} +2 -2
- package/dist/{src/TextAnnotatorOptions.d.ts → text-annotator-options.d.ts} +4 -5
- package/dist/text-annotator.css +1 -1
- package/dist/{TextAnnotator.d.ts → text-annotator.d.ts} +7 -8
- package/dist/text-annotator.es.js +745 -824
- package/dist/text-annotator.es.js.map +1 -1
- package/dist/text-annotator.umd.js +2 -2
- package/dist/text-annotator.umd.js.map +1 -1
- package/dist/utils/annotation/index.d.ts +4 -0
- package/dist/{src/utils/rangeToSelector.d.ts → utils/annotation/range-to-selector.d.ts} +1 -1
- package/dist/{src/utils/reviveSelector.d.ts → utils/annotation/revive-annotation.d.ts} +4 -1
- package/dist/{api/scrollIntoView.d.ts → utils/annotation/scroll-into-view.d.ts} +2 -2
- package/dist/utils/dom/index.d.ts +7 -0
- package/dist/utils/events/index.d.ts +3 -0
- package/dist/utils/highlight/compute-z-index.d.ts +3 -0
- package/dist/utils/highlight/index.d.ts +4 -0
- package/package.json +3 -3
- package/dist/TextAnnotatorOptions.d.ts +0 -35
- package/dist/api/index.d.ts +0 -1
- package/dist/highlight/Highlight.d.ts +0 -5
- package/dist/highlight/HighlightPainter.d.ts +0 -11
- package/dist/highlight/HighlightStyle.d.ts +0 -11
- package/dist/highlight/Renderer.d.ts +0 -22
- package/dist/highlight/RendererImplementation.d.ts +0 -9
- package/dist/highlight/baseRenderer.d.ts +0 -22
- package/dist/highlight/canvas/canvasRenderer.d.ts +0 -5
- package/dist/highlight/canvas/index.d.ts +0 -1
- package/dist/highlight/color.d.ts +0 -2
- package/dist/highlight/highlights/highlightsRenderer.d.ts +0 -6
- package/dist/highlight/highlights/index.d.ts +0 -1
- package/dist/highlight/index.d.ts +0 -8
- package/dist/highlight/span/color.d.ts +0 -2
- package/dist/highlight/span/index.d.ts +0 -2
- package/dist/highlight/span/spansRenderer.d.ts +0 -3
- package/dist/highlight/viewport.d.ts +0 -12
- package/dist/model/core/TextAnnotation.d.ts +0 -15
- package/dist/model/w3c/W3CTextAnnotation.d.ts +0 -34
- package/dist/model/w3c/W3CTextFormatAdapter.d.ts +0 -12
- package/dist/presence/PresencePainter.d.ts +0 -5
- package/dist/presence/PresencePainterOptions.d.ts +0 -3
- package/dist/presence/index.d.ts +0 -2
- package/dist/src/SelectionHandler.d.ts +0 -9
- package/dist/src/TextAnnotator.d.ts +0 -12
- package/dist/src/api/index.d.ts +0 -1
- package/dist/src/api/scrollIntoView.d.ts +0 -3
- package/dist/src/highlight/HighlightPainter.d.ts +0 -11
- package/dist/src/highlight/baseRenderer.d.ts +0 -20
- package/dist/src/highlight/canvas/canvasRenderer.d.ts +0 -4
- package/dist/src/highlight/canvas/index.d.ts +0 -1
- package/dist/src/highlight/highlights/highlightsRenderer.d.ts +0 -6
- package/dist/src/highlight/highlights/index.d.ts +0 -1
- package/dist/src/highlight/index.d.ts +0 -6
- package/dist/src/highlight/span/color.d.ts +0 -2
- package/dist/src/highlight/span/index.d.ts +0 -1
- package/dist/src/highlight/span/spansRenderer.d.ts +0 -4
- package/dist/src/model/core/index.d.ts +0 -1
- package/dist/src/model/index.d.ts +0 -2
- package/dist/src/model/w3c/index.d.ts +0 -2
- package/dist/src/presence/PresencePainter.d.ts +0 -4
- package/dist/src/presence/PresencePainterOptions.d.ts +0 -3
- package/dist/src/presence/index.d.ts +0 -2
- package/dist/src/state/index.d.ts +0 -2
- package/dist/src/state/spatialTree.d.ts +0 -28
- package/dist/src/utils/index.d.ts +0 -17
- package/dist/src/utils/isRevived.d.ts +0 -2
- package/dist/src/utils/isWhitespaceOrEmpty.d.ts +0 -2
- package/dist/src/utils/reviveAnnotation.d.ts +0 -2
- package/dist/src/utils/reviveTarget.d.ts +0 -2
- package/dist/state/TextAnnotationStore.d.ts +0 -28
- package/dist/state/TextAnnotatorState.d.ts +0 -12
- package/dist/test/model/w3c/W3CTextFormatAdapter.test.d.ts +0 -1
- package/dist/test/model/w3c/fixtures.d.ts +0 -3
- package/dist/utils/cancelSingleClickEvents.d.ts +0 -6
- package/dist/utils/cloneEvents.d.ts +0 -11
- package/dist/utils/device.d.ts +0 -1
- package/dist/utils/getHighlightClientRects.d.ts +0 -1
- package/dist/utils/getQuoteContext.d.ts +0 -4
- package/dist/utils/index.d.ts +0 -18
- package/dist/utils/isNotAnnotatable.d.ts +0 -4
- package/dist/utils/isRevived.d.ts +0 -2
- package/dist/utils/mergeClientRects.d.ts +0 -2
- package/dist/utils/programmaticallyFocusable.d.ts +0 -6
- package/dist/utils/rangeToSelector.d.ts +0 -2
- package/dist/utils/reviveAnnotation.d.ts +0 -2
- package/dist/utils/reviveSelector.d.ts +0 -11
- package/dist/utils/reviveTarget.d.ts +0 -2
- package/dist/utils/splitAnnotatableRanges.d.ts +0 -5
- package/dist/utils/trimRangeToContainer.d.ts +0 -1
- /package/dist/{src/model/core/TextAnnotation.d.ts → model/core/text-annotation.d.ts} +0 -0
- /package/dist/{src/model/w3c/W3CTextAnnotation.d.ts → model/w3c/w3c-text-annotation.d.ts} +0 -0
- /package/dist/{src/highlight → rendering}/viewport.d.ts +0 -0
- /package/dist/{src/utils/getQuoteContext.d.ts → utils/annotation/get-quote-context.d.ts} +0 -0
- /package/dist/{src/utils → utils/dom}/device.d.ts +0 -0
- /package/dist/{src/utils/isNotAnnotatable.d.ts → utils/dom/is-not-annotatable.d.ts} +0 -0
- /package/dist/utils/{isWhitespaceOrEmpty.d.ts → dom/is-whitespace-or-empty.d.ts} +0 -0
- /package/dist/utils/{mergeRanges.d.ts → dom/merge-ranges.d.ts} +0 -0
- /package/dist/{src/utils/programmaticallyFocusable.d.ts → utils/dom/programmatically-focusable.d.ts} +0 -0
- /package/dist/{src/utils/splitAnnotatableRanges.d.ts → utils/dom/split-annotatable-ranges.d.ts} +0 -0
- /package/dist/{src/utils/trimRangeToContainer.d.ts → utils/dom/trim-range-to-container.d.ts} +0 -0
- /package/dist/{src/utils/cancelSingleClickEvents.d.ts → utils/events/cancel-single-click-events.d.ts} +0 -0
- /package/dist/{src/utils/cloneEvents.d.ts → utils/events/clone-events.d.ts} +0 -0
- /package/dist/{src/utils → utils/events}/debounce.d.ts +0 -0
- /package/dist/{src/utils/getHighlightClientRects.d.ts → utils/highlight/get-highlight-client-rects.d.ts} +0 -0
- /package/dist/{src/utils/mergeClientRects.d.ts → utils/highlight/merge-client-rects.d.ts} +0 -0
- /package/dist/utils/{rectsToBounds.d.ts → highlight/rects-to-bounds.d.ts} +0 -0
|
@@ -1,977 +1,898 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { colord as
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
return !
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
isPrimary: e.isPrimary,
|
|
31
|
-
altKey: e.altKey,
|
|
32
|
-
ctrlKey: e.ctrlKey,
|
|
33
|
-
metaKey: e.metaKey,
|
|
34
|
-
shiftKey: e.shiftKey,
|
|
35
|
-
button: e.button,
|
|
36
|
-
buttons: e.buttons,
|
|
37
|
-
currentTarget: e.currentTarget,
|
|
38
|
-
target: e.target,
|
|
39
|
-
defaultPrevented: e.defaultPrevented,
|
|
40
|
-
detail: e.detail,
|
|
41
|
-
eventPhase: e.eventPhase,
|
|
42
|
-
pointerId: e.pointerId,
|
|
43
|
-
pointerType: e.pointerType,
|
|
44
|
-
timeStamp: e.timeStamp
|
|
45
|
-
}), G = (e) => ({
|
|
46
|
-
...e,
|
|
47
|
-
type: e.type,
|
|
48
|
-
key: e.key,
|
|
49
|
-
code: e.code,
|
|
50
|
-
location: e.location,
|
|
51
|
-
repeat: e.repeat,
|
|
52
|
-
altKey: e.altKey,
|
|
53
|
-
ctrlKey: e.ctrlKey,
|
|
54
|
-
metaKey: e.metaKey,
|
|
55
|
-
shiftKey: e.shiftKey,
|
|
56
|
-
currentTarget: e.currentTarget,
|
|
57
|
-
target: e.target,
|
|
58
|
-
defaultPrevented: e.defaultPrevented,
|
|
59
|
-
detail: e.detail,
|
|
60
|
-
timeStamp: e.timeStamp
|
|
61
|
-
}), Pe = ye(), ue = Pe.os.is(be.MACOS), De = (e) => {
|
|
62
|
-
!e.hasAttribute("tabindex") && e.tabIndex < 0 && e.setAttribute("tabindex", "-1"), e.classList.add("no-focus-outline");
|
|
63
|
-
}, Ue = (e) => {
|
|
64
|
-
const t = [], n = document.createNodeIterator(
|
|
65
|
-
e.commonAncestorContainer,
|
|
66
|
-
NodeFilter.SHOW_TEXT
|
|
67
|
-
);
|
|
68
|
-
let r;
|
|
69
|
-
for (; r = n.nextNode(); )
|
|
70
|
-
e.intersectsNode(r) && t.push(r);
|
|
71
|
-
if (t.length < 2)
|
|
72
|
-
return Array.from(e.getClientRects());
|
|
73
|
-
{
|
|
74
|
-
const s = t[0], o = t[t.length - 1], i = document.createRange();
|
|
75
|
-
if (i.selectNode(s), e.startContainer.nodeType === Node.TEXT_NODE)
|
|
76
|
-
i.setStart(s, e.startOffset);
|
|
77
|
-
else {
|
|
78
|
-
const f = e.startContainer.childNodes[e.startOffset];
|
|
79
|
-
f ? i.setStartBefore(f) : i.setStartAfter(e.startContainer);
|
|
80
|
-
}
|
|
81
|
-
const c = document.createRange();
|
|
82
|
-
if (c.selectNode(o), e.endContainer.nodeType === Node.TEXT_NODE)
|
|
83
|
-
c.setEnd(o, e.endOffset);
|
|
84
|
-
else {
|
|
85
|
-
const f = e.endContainer.childNodes[e.endOffset];
|
|
86
|
-
f ? c.setEndBefore(f) : c.setEndAfter(e.endContainer);
|
|
87
|
-
}
|
|
88
|
-
const l = (f) => {
|
|
89
|
-
const d = document.createRange();
|
|
90
|
-
return d.selectNode(f), Array.from(d.getClientRects());
|
|
91
|
-
};
|
|
92
|
-
return [
|
|
93
|
-
...Array.from(i.getClientRects()),
|
|
94
|
-
...t.slice(1, -1).flatMap(l),
|
|
95
|
-
...Array.from(c.getClientRects())
|
|
96
|
-
];
|
|
97
|
-
}
|
|
98
|
-
}, Ke = function* (e) {
|
|
99
|
-
const t = document.createNodeIterator(
|
|
100
|
-
e.commonAncestorContainer,
|
|
1
|
+
import { createNanoEvents as at } from "nanoevents";
|
|
2
|
+
import { UserSelectAction as Et, serializeW3CBodies as bt, parseW3CBodies as Ct, parseW3CUser as At, createStore as Tt, createSelectionState as Rt, createHoverState as vt, createViewportState as wt, Origin as F, createAnonymousGuest as xt, createUndoStack as Lt, createLifecycleObserver as Nt, createBaseAnnotator as Ot } from "@annotorious/core";
|
|
3
|
+
import { Origin as He, UserSelectAction as Pe, createBody as Ue } from "@annotorious/core";
|
|
4
|
+
import { UAParser as kt } from "ua-parser-js";
|
|
5
|
+
import { OSName as Mt } from "ua-parser-js/enums";
|
|
6
|
+
import { colord as et } from "colord";
|
|
7
|
+
import { v4 as lt } from "uuid";
|
|
8
|
+
import Bt from "rbush";
|
|
9
|
+
import It from "debounce";
|
|
10
|
+
import q from "hotkeys-js";
|
|
11
|
+
import { poll as _t } from "poll";
|
|
12
|
+
import { dequal as Dt } from "dequal/lite";
|
|
13
|
+
const Ht = kt(), dt = Ht.os.is(Mt.MACOS), ut = "not-annotatable", $ = `.${ut}`, G = (t, e) => t.contains(e) ? !!(e instanceof HTMLElement ? e.closest($) : e.parentElement?.closest($)) : !0, Pt = (t, e) => {
|
|
14
|
+
const o = e.commonAncestorContainer;
|
|
15
|
+
return !G(t, o);
|
|
16
|
+
}, ft = /^\s*$/, Ut = (t) => ft.test(t.toString()), Oe = (t) => ft.test(t.textContent || ""), Kt = (t) => {
|
|
17
|
+
if (t.length === 0) return [];
|
|
18
|
+
if (t.length === 1) return [t[0]];
|
|
19
|
+
t.sort((s, n) => {
|
|
20
|
+
const r = s.compareBoundaryPoints(Range.START_TO_START, n);
|
|
21
|
+
return r !== 0 ? r : s.compareBoundaryPoints(Range.END_TO_END, n);
|
|
22
|
+
});
|
|
23
|
+
const [e, ...o] = t, i = o.reduce((s, n) => s.current.compareBoundaryPoints(Range.START_TO_END, n) >= 0 ? (s.current.compareBoundaryPoints(Range.END_TO_END, n) < 0 && s.current.setEnd(n.endContainer, n.endOffset), s) : (s.merged.push(s.current), s.current = n.cloneRange(), s), { merged: [], current: e.cloneRange() });
|
|
24
|
+
return [...i.merged, i.current];
|
|
25
|
+
}, Ft = (t) => {
|
|
26
|
+
!t.hasAttribute("tabindex") && t.tabIndex < 0 && t.setAttribute("tabindex", "-1"), t.classList.add("no-focus-outline");
|
|
27
|
+
}, $t = function* (t) {
|
|
28
|
+
const e = document.createNodeIterator(
|
|
29
|
+
t.commonAncestorContainer,
|
|
101
30
|
NodeFilter.SHOW_ELEMENT,
|
|
102
|
-
(
|
|
31
|
+
(i) => i instanceof HTMLElement && i.classList.contains(ut) && !i.parentElement.closest($) && t.intersectsNode(i) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
|
|
103
32
|
);
|
|
104
|
-
let
|
|
105
|
-
for (;
|
|
106
|
-
|
|
107
|
-
},
|
|
108
|
-
if (!
|
|
109
|
-
const
|
|
110
|
-
let
|
|
111
|
-
for (const s of
|
|
112
|
-
let
|
|
113
|
-
|
|
33
|
+
let o;
|
|
34
|
+
for (; o = e.nextNode(); )
|
|
35
|
+
o instanceof HTMLElement && (yield o);
|
|
36
|
+
}, Yt = (t, e) => {
|
|
37
|
+
if (!Pt(t, e)) return [];
|
|
38
|
+
const o = [];
|
|
39
|
+
let i = null;
|
|
40
|
+
for (const s of $t(e)) {
|
|
41
|
+
let n;
|
|
42
|
+
i ? (n = document.createRange(), n.setStartAfter(i), n.setEndBefore(s)) : (n = e.cloneRange(), n.setEndBefore(s)), n.collapsed || o.push(n), i = s;
|
|
114
43
|
}
|
|
115
|
-
if (
|
|
116
|
-
const s =
|
|
117
|
-
s.setStartAfter(
|
|
44
|
+
if (i) {
|
|
45
|
+
const s = e.cloneRange();
|
|
46
|
+
s.setStartAfter(i), s.collapsed || o.push(s);
|
|
118
47
|
}
|
|
119
|
-
return
|
|
120
|
-
},
|
|
121
|
-
const
|
|
122
|
-
return
|
|
123
|
-
},
|
|
124
|
-
const
|
|
125
|
-
o.setStart(
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
48
|
+
return o.length > 0 ? o : [e];
|
|
49
|
+
}, nt = (t) => {
|
|
50
|
+
const e = t.cloneContents();
|
|
51
|
+
return e.querySelectorAll($).forEach((o) => o.remove()), e;
|
|
52
|
+
}, Wt = (t, e) => {
|
|
53
|
+
const o = t.cloneRange();
|
|
54
|
+
return e.contains(o.startContainer) || o.setStart(e, 0), e.contains(o.endContainer) || o.setEnd(e, e.childNodes.length), o;
|
|
55
|
+
}, Xt = (t) => t.addEventListener("click", (e) => {
|
|
56
|
+
// Allow clicks within not-annotatable elements
|
|
57
|
+
!e.target.closest($) && !e.target.closest("a") && e.preventDefault();
|
|
58
|
+
}), Z = (t) => ({
|
|
59
|
+
...t,
|
|
60
|
+
type: t.type,
|
|
61
|
+
x: t.x,
|
|
62
|
+
y: t.y,
|
|
63
|
+
clientX: t.clientX,
|
|
64
|
+
clientY: t.clientY,
|
|
65
|
+
offsetX: t.offsetX,
|
|
66
|
+
offsetY: t.offsetY,
|
|
67
|
+
screenX: t.screenX,
|
|
68
|
+
screenY: t.screenY,
|
|
69
|
+
isPrimary: t.isPrimary,
|
|
70
|
+
altKey: t.altKey,
|
|
71
|
+
ctrlKey: t.ctrlKey,
|
|
72
|
+
metaKey: t.metaKey,
|
|
73
|
+
shiftKey: t.shiftKey,
|
|
74
|
+
button: t.button,
|
|
75
|
+
buttons: t.buttons,
|
|
76
|
+
currentTarget: t.currentTarget,
|
|
77
|
+
target: t.target,
|
|
78
|
+
defaultPrevented: t.defaultPrevented,
|
|
79
|
+
detail: t.detail,
|
|
80
|
+
eventPhase: t.eventPhase,
|
|
81
|
+
pointerId: t.pointerId,
|
|
82
|
+
pointerType: t.pointerType,
|
|
83
|
+
timeStamp: t.timeStamp
|
|
84
|
+
}), j = (t) => ({
|
|
85
|
+
...t,
|
|
86
|
+
type: t.type,
|
|
87
|
+
key: t.key,
|
|
88
|
+
code: t.code,
|
|
89
|
+
location: t.location,
|
|
90
|
+
repeat: t.repeat,
|
|
91
|
+
altKey: t.altKey,
|
|
92
|
+
ctrlKey: t.ctrlKey,
|
|
93
|
+
metaKey: t.metaKey,
|
|
94
|
+
shiftKey: t.shiftKey,
|
|
95
|
+
currentTarget: t.currentTarget,
|
|
96
|
+
target: t.target,
|
|
97
|
+
defaultPrevented: t.defaultPrevented,
|
|
98
|
+
detail: t.detail,
|
|
99
|
+
timeStamp: t.timeStamp
|
|
100
|
+
}), J = (t, e = 10) => {
|
|
101
|
+
let o;
|
|
102
|
+
return ((...i) => {
|
|
103
|
+
clearTimeout(o), o = setTimeout(() => t.apply(void 0, i), e);
|
|
104
|
+
});
|
|
105
|
+
}, gt = (t, e, o, i) => {
|
|
106
|
+
const { store: s, selection: n, hover: r } = o, c = at();
|
|
107
|
+
let d;
|
|
108
|
+
const f = /* @__PURE__ */ new Map();
|
|
109
|
+
let p;
|
|
110
|
+
const C = qt(i), h = (y) => {
|
|
111
|
+
const { x: b, y: O } = e.getBoundingClientRect(), B = s.getAt(y.clientX - b, y.clientY - O, !1, p);
|
|
112
|
+
B && o.selection.evalSelectAction(B) !== Et.NONE ? r.current !== B.id && (e.classList.add("hovered"), r.set(B.id)) : r.current && (e.classList.remove("hovered"), r.set(null));
|
|
132
113
|
};
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
114
|
+
e.addEventListener("pointermove", h);
|
|
115
|
+
const T = J((y = !1) => requestAnimationFrame(() => {
|
|
116
|
+
const b = zt(e), { minX: O, minY: B, maxX: X, maxY: V } = b, K = p ? s.getIntersecting(O, B, X, V).filter(({ annotation: S }) => p(S)) : s.getIntersecting(O, B, X, V), st = n.selected.map(({ id: S }) => S), g = K.map(({ annotation: S, rects: M }) => {
|
|
117
|
+
const U = st.includes(S.id), I = S.id === r.current;
|
|
118
|
+
return {
|
|
119
|
+
annotation: S,
|
|
120
|
+
rects: M,
|
|
121
|
+
state: { selected: U, hovered: I }
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
t.redraw(g, b, d, f, y), setTimeout(() => {
|
|
125
|
+
C(K.map(({ annotation: S }) => S)), c.emit("onRedraw");
|
|
126
|
+
}, 1);
|
|
127
|
+
}), 10), u = (y, b) => {
|
|
128
|
+
b ? y ? f.set(b, y) : f.delete(b) : d = y, T(!0);
|
|
129
|
+
}, L = (y) => {
|
|
130
|
+
p = y, T(!1);
|
|
131
|
+
}, x = (y, b) => c.on(y, b), v = () => {
|
|
132
|
+
T();
|
|
144
133
|
};
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const { left: n, top: r, right: s, bottom: o } = e;
|
|
207
|
-
return new DOMRect(n + t.left, r + t.top, s - n, o - r);
|
|
208
|
-
}, ge = (e, t) => {
|
|
209
|
-
const { start: n, end: r } = e, s = e.offsetReference || t, o = document.createNodeIterator(
|
|
210
|
-
t,
|
|
134
|
+
s.observe(v);
|
|
135
|
+
const m = n.subscribe(() => {
|
|
136
|
+
T();
|
|
137
|
+
}), E = r.subscribe(() => {
|
|
138
|
+
T();
|
|
139
|
+
}), w = () => {
|
|
140
|
+
T(!0);
|
|
141
|
+
};
|
|
142
|
+
document.addEventListener("scroll", w, { capture: !0, passive: !0 });
|
|
143
|
+
const a = J(() => {
|
|
144
|
+
s.recalculatePositions(), T();
|
|
145
|
+
}, 10);
|
|
146
|
+
window.addEventListener("resize", a);
|
|
147
|
+
const l = new ResizeObserver(a);
|
|
148
|
+
l.observe(e);
|
|
149
|
+
const A = { attributes: !0, childList: !0, subtree: !0 }, R = new MutationObserver(J((y) => {
|
|
150
|
+
y.every((O) => O.target === e || e.contains(O.target)) || T(!0);
|
|
151
|
+
}, 150));
|
|
152
|
+
return R.observe(document.body, A), {
|
|
153
|
+
destroy: () => {
|
|
154
|
+
e.removeEventListener("pointermove", h), t.destroy(), s.unobserve(v), m(), E(), document.removeEventListener("scroll", w), window.removeEventListener("resize", a), l.disconnect(), R.disconnect();
|
|
155
|
+
},
|
|
156
|
+
on: x,
|
|
157
|
+
redraw: T,
|
|
158
|
+
setStyle: u,
|
|
159
|
+
setFilter: L,
|
|
160
|
+
setVisible: t.setVisible.bind(t)
|
|
161
|
+
};
|
|
162
|
+
}, P = {
|
|
163
|
+
fill: "rgb(0, 128, 255)",
|
|
164
|
+
fillOpacity: 0.18
|
|
165
|
+
}, ot = {
|
|
166
|
+
fill: "rgb(0, 128, 255)",
|
|
167
|
+
fillOpacity: 0.45
|
|
168
|
+
}, Vt = (t) => t?.fillOpacity !== void 0 ? et(t?.fill || P.fill).alpha(t.fillOpacity).toHex() : t?.fill ? t.fill : et(P.fill).alpha(P.fillOpacity).toHex(), mt = (t, e, o) => e ? typeof e == "function" ? e(t.annotation, t.state, o) || (t.state?.selected ? ot : P) : e : t.state?.selected ? ot : P, zt = (t) => {
|
|
169
|
+
const { top: e, left: o } = t.getBoundingClientRect(), { innerWidth: i, innerHeight: s } = window, n = -o, r = -e, c = i - o, d = s - e;
|
|
170
|
+
return { top: e, left: o, minX: n, minY: r, maxX: c, maxY: d };
|
|
171
|
+
}, qt = (t) => {
|
|
172
|
+
let e = /* @__PURE__ */ new Set();
|
|
173
|
+
return (i) => {
|
|
174
|
+
const s = i.map((n) => n.id);
|
|
175
|
+
(e.size !== s.length || s.some((n) => !e.has(n))) && t.set(s), e = new Set(s);
|
|
176
|
+
};
|
|
177
|
+
}, jt = (t, e, o = 10, i) => {
|
|
178
|
+
const s = i ? t.startContainer.parentElement.closest(i) : e, n = document.createRange();
|
|
179
|
+
n.setStart(s, 0), n.setEnd(t.startContainer, t.startOffset);
|
|
180
|
+
const r = nt(n).textContent, c = document.createRange();
|
|
181
|
+
c.setStart(t.endContainer, t.endOffset), s === document.body ? c.setEnd(s, s.childNodes.length) : c.setEndAfter(s);
|
|
182
|
+
const d = nt(c).textContent;
|
|
183
|
+
return {
|
|
184
|
+
prefix: r.substring(r.length - o),
|
|
185
|
+
suffix: d.substring(0, o)
|
|
186
|
+
};
|
|
187
|
+
}, Gt = (t, e, o) => {
|
|
188
|
+
const i = document.createRange(), s = o ? t.startContainer.parentElement.closest(o) : e;
|
|
189
|
+
i.setStart(s, 0), i.setEnd(t.startContainer, t.startOffset);
|
|
190
|
+
const n = nt(i).textContent, r = t.toString(), c = n.length || 0, d = c + r.length;
|
|
191
|
+
return o ? { quote: r, start: c, end: d, range: t, offsetReference: s } : { quote: r, start: c, end: d, range: t };
|
|
192
|
+
}, D = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), pt = (t, e) => {
|
|
193
|
+
const { start: o, end: i } = t, s = t.offsetReference || e, n = document.createNodeIterator(
|
|
194
|
+
e,
|
|
211
195
|
NodeFilter.SHOW_TEXT,
|
|
212
|
-
(
|
|
196
|
+
(p) => p.parentElement?.closest($) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT
|
|
213
197
|
);
|
|
214
|
-
let
|
|
198
|
+
let r = 0;
|
|
215
199
|
const c = document.createRange();
|
|
216
|
-
let
|
|
217
|
-
|
|
200
|
+
let d = n.nextNode();
|
|
201
|
+
d === null && console.error("Could not revive annotation target. Content missing.");
|
|
218
202
|
let f = !s;
|
|
219
|
-
for (;
|
|
220
|
-
if (f ||= typeof s?.contains == "function" ? s.contains(
|
|
221
|
-
const
|
|
222
|
-
if (
|
|
223
|
-
c.setStart(
|
|
203
|
+
for (; d !== null; ) {
|
|
204
|
+
if (f ||= typeof s?.contains == "function" ? s.contains(d) : !1, f) {
|
|
205
|
+
const p = d.textContent?.length || 0;
|
|
206
|
+
if (r + p > o) {
|
|
207
|
+
c.setStart(d, o - r);
|
|
224
208
|
break;
|
|
225
209
|
}
|
|
226
|
-
|
|
210
|
+
r += p;
|
|
227
211
|
}
|
|
228
|
-
|
|
212
|
+
d = n.nextNode();
|
|
229
213
|
}
|
|
230
|
-
for (;
|
|
231
|
-
const
|
|
232
|
-
if (
|
|
233
|
-
c.setEnd(
|
|
214
|
+
for (; d !== null; ) {
|
|
215
|
+
const p = d.textContent?.length || 0;
|
|
216
|
+
if (r + p >= i) {
|
|
217
|
+
c.setEnd(d, i - r);
|
|
234
218
|
break;
|
|
235
219
|
}
|
|
236
|
-
|
|
220
|
+
r += p, d = n.nextNode();
|
|
237
221
|
}
|
|
238
222
|
return {
|
|
239
|
-
...
|
|
223
|
+
...t,
|
|
240
224
|
range: c
|
|
241
225
|
};
|
|
242
|
-
},
|
|
243
|
-
...
|
|
244
|
-
selector:
|
|
245
|
-
},
|
|
246
|
-
|
|
247
|
-
return t.contains(n.startContainer) || n.setStart(t, 0), t.contains(n.endContainer) || n.setEnd(t, t.childNodes.length), n;
|
|
248
|
-
}, me = (e) => {
|
|
249
|
-
if (!e)
|
|
226
|
+
}, Q = (t, e) => D(t.selector) ? t : {
|
|
227
|
+
...t,
|
|
228
|
+
selector: t.selector.map((o) => o.range instanceof Range && !o.range.collapsed ? o : pt(o, e))
|
|
229
|
+
}, tt = (t, e) => D(t.target.selector) ? t : { ...t, target: Q(t.target, e) }, ht = (t) => {
|
|
230
|
+
if (!t)
|
|
250
231
|
return document.scrollingElement;
|
|
251
|
-
const { overflowY:
|
|
252
|
-
return
|
|
253
|
-
},
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
},
|
|
257
|
-
const s = typeof
|
|
258
|
-
if (!
|
|
259
|
-
return console.warn(`The scroll parent is missing for the annotation: ${s}`, { container:
|
|
260
|
-
const
|
|
261
|
-
if (!
|
|
232
|
+
const { overflowY: e } = window.getComputedStyle(t);
|
|
233
|
+
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : ht(t.parentElement);
|
|
234
|
+
}, rt = (t, e, o) => {
|
|
235
|
+
const i = o.getBoundingClientRect(), s = o.clientHeight, n = o.clientWidth, r = e.selector[0].range.getBoundingClientRect(), { width: c, height: d } = t.getAnnotationBounds(e.annotation), f = r.top - i.top, p = r.left - i.left, C = o.parentElement ? o.scrollTop : 0, h = o.parentElement ? o.scrollLeft : 0, T = f + C - (s - d) / 2, u = p + h - (n - c) / 2;
|
|
236
|
+
o.scroll({ top: T, left: u, behavior: "smooth" });
|
|
237
|
+
}, Qt = (t, e) => (o, i) => {
|
|
238
|
+
const s = typeof o == "string" ? o : o.id, n = i ? typeof i == "string" ? document.getElementById(i) : i : ht(t);
|
|
239
|
+
if (!n)
|
|
240
|
+
return console.warn(`The scroll parent is missing for the annotation: ${s}`, { container: t }), !1;
|
|
241
|
+
const r = e.getAnnotation(s);
|
|
242
|
+
if (!r)
|
|
262
243
|
return console.warn(`The annotation is missing in the store: ${s}`), !1;
|
|
263
|
-
const { range: c } =
|
|
244
|
+
const { range: c } = r.target.selector[0];
|
|
264
245
|
if (c && !c.collapsed)
|
|
265
|
-
return
|
|
266
|
-
const
|
|
267
|
-
return f && !f.collapsed ? (
|
|
268
|
-
},
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
},
|
|
272
|
-
fill: "rgb(0, 128, 255)",
|
|
273
|
-
fillOpacity: 0.45
|
|
274
|
-
}, Ze = (e) => {
|
|
275
|
-
const { top: t, left: n } = e.getBoundingClientRect(), { innerWidth: r, innerHeight: s } = window, o = -n, i = -t, c = r - n, l = s - t;
|
|
276
|
-
return { top: t, left: n, minX: o, minY: i, maxX: c, maxY: l };
|
|
277
|
-
}, Je = (e) => {
|
|
278
|
-
let t = /* @__PURE__ */ new Set();
|
|
279
|
-
return (r) => {
|
|
280
|
-
const s = r.map((o) => o.id);
|
|
281
|
-
(t.size !== s.length || s.some((o) => !t.has(o))) && e.set(s), t = new Set(s);
|
|
282
|
-
};
|
|
283
|
-
}, se = (e, t, n, r) => {
|
|
284
|
-
const { store: s, selection: o, hover: i } = t;
|
|
285
|
-
let c, l, f;
|
|
286
|
-
const d = Je(n), u = (A) => {
|
|
287
|
-
const { x: v, y: N } = e.getBoundingClientRect(), O = s.getAt(A.clientX - v, A.clientY - N, !1, l);
|
|
288
|
-
O && t.selection.evalSelectAction(O) !== Ee.NONE ? i.current !== O.id && (e.classList.add("hovered"), i.set(O.id)) : i.current && (e.classList.remove("hovered"), i.set(null));
|
|
289
|
-
};
|
|
290
|
-
e.addEventListener("pointermove", u);
|
|
291
|
-
const y = Y((A = !1) => requestAnimationFrame(() => {
|
|
292
|
-
f && f.clear();
|
|
293
|
-
const v = Ze(e), { minX: N, minY: O, maxX: D, maxY: X } = v, z = l ? s.getIntersecting(N, O, D, X).filter(({ annotation: h }) => l(h)) : s.getIntersecting(N, O, D, X), F = o.selected.map(({ id: h }) => h), re = z.map(({ annotation: h, rects: T }) => {
|
|
294
|
-
const k = F.includes(h.id), U = h.id === i.current;
|
|
295
|
-
return {
|
|
296
|
-
annotation: h,
|
|
297
|
-
rects: T,
|
|
298
|
-
state: { selected: k, hovered: U }
|
|
299
|
-
};
|
|
300
|
-
});
|
|
301
|
-
r.redraw(re, v, c, f, A), setTimeout(() => d(z.map(({ annotation: h }) => h)), 1);
|
|
302
|
-
}), 10), w = (A) => {
|
|
303
|
-
f = A, y();
|
|
304
|
-
}, g = (A) => {
|
|
305
|
-
c = A, y();
|
|
306
|
-
}, x = (A) => {
|
|
307
|
-
l = A, y(!1);
|
|
308
|
-
}, R = () => y();
|
|
309
|
-
s.observe(R);
|
|
310
|
-
const b = o.subscribe(() => y()), p = i.subscribe(() => y()), S = () => y(!0);
|
|
311
|
-
document.addEventListener("scroll", S, { capture: !0, passive: !0 });
|
|
312
|
-
const E = Y(() => {
|
|
313
|
-
s.recalculatePositions(), f?.reset(), y();
|
|
314
|
-
}, 10);
|
|
315
|
-
window.addEventListener("resize", E);
|
|
316
|
-
const m = new ResizeObserver(E);
|
|
317
|
-
m.observe(e);
|
|
318
|
-
const a = { attributes: !0, childList: !0, subtree: !0 }, C = new MutationObserver(Y((A) => {
|
|
319
|
-
A.every((N) => N.target === e || e.contains(N.target)) || y(!0);
|
|
320
|
-
}, 150));
|
|
321
|
-
return C.observe(document.body, a), {
|
|
322
|
-
destroy: () => {
|
|
323
|
-
e.removeEventListener("pointermove", u), r.destroy(), s.unobserve(R), b(), p(), document.removeEventListener("scroll", S), E.clear(), window.removeEventListener("resize", E), m.disconnect(), C.disconnect();
|
|
324
|
-
},
|
|
325
|
-
redraw: y,
|
|
326
|
-
setStyle: g,
|
|
327
|
-
setFilter: x,
|
|
328
|
-
setPainter: w,
|
|
329
|
-
setVisible: r.setVisible
|
|
330
|
-
};
|
|
331
|
-
}, et = () => {
|
|
332
|
-
const e = document.createElement("canvas");
|
|
333
|
-
return e.width = window.innerWidth, e.height = window.innerHeight, e.className = "r6o-canvas-highlight-layer bg", e;
|
|
334
|
-
}, tt = (e, t) => {
|
|
335
|
-
e.width = window.innerWidth, e.height = window.innerHeight;
|
|
336
|
-
}, nt = (e) => {
|
|
337
|
-
console.warn('WARNING! Canvas renderer is deprecated and will be removed in the next major release. Please use the default "SPANS" renderer instead.'), e.classList.add("r6o-annotatable");
|
|
338
|
-
const t = et(), n = t.getContext("2d");
|
|
339
|
-
document.body.appendChild(t);
|
|
340
|
-
const r = (c, l, f, d) => requestAnimationFrame(() => {
|
|
341
|
-
const { width: u, height: y } = t;
|
|
342
|
-
n.clearRect(-0.5, -0.5, u + 1, y + 1), d && d.clear();
|
|
343
|
-
const { top: w, left: g } = l;
|
|
344
|
-
[...c].sort((R, b) => {
|
|
345
|
-
const { annotation: { target: { created: p } } } = R, { annotation: { target: { created: S } } } = b;
|
|
346
|
-
return p.getTime() - S.getTime();
|
|
347
|
-
}).forEach((R) => {
|
|
348
|
-
const b = f ? typeof f == "function" ? f(R.annotation, R.state) : f : R.state?.selected ? J : _, p = d && d.paint(R, l) || b, S = R.rects.map(({ x: E, y: m, width: a, height: C }) => ({
|
|
349
|
-
x: E + g,
|
|
350
|
-
y: m + w,
|
|
351
|
-
width: a,
|
|
352
|
-
height: C
|
|
353
|
-
}));
|
|
354
|
-
if (n.fillStyle = p.fill, n.globalAlpha = p.fillOpacity || 1, S.forEach(
|
|
355
|
-
({ x: E, y: m, width: a, height: C }) => n.fillRect(E, m, a, C)
|
|
356
|
-
), p.underlineColor) {
|
|
357
|
-
n.globalAlpha = 1, n.strokeStyle = p.underlineColor, n.lineWidth = p.underlineThickness ?? 1;
|
|
358
|
-
const E = p.underlineOffset ?? 0;
|
|
359
|
-
S.forEach(({ x: m, y: a, width: C, height: L }) => {
|
|
360
|
-
n.beginPath(), n.moveTo(m, a + L + E), n.lineTo(m + C, a + L + E), n.stroke();
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
});
|
|
364
|
-
}), s = Y(() => tt(t), 10);
|
|
365
|
-
return window.addEventListener("resize", s), {
|
|
366
|
-
destroy: () => {
|
|
367
|
-
t.remove(), s.clear(), window.removeEventListener("resize", s);
|
|
368
|
-
},
|
|
369
|
-
setVisible: (c) => {
|
|
370
|
-
console.log("setVisible not implemented on Canvas renderer");
|
|
371
|
-
},
|
|
372
|
-
redraw: r
|
|
373
|
-
};
|
|
374
|
-
}, ot = (e, t, n) => se(e, t, n, nt(e)), st = (e) => [
|
|
375
|
-
`background-color:${ne(e?.fill || _.fill).alpha(e?.fillOpacity === void 0 ? _.fillOpacity : e.fillOpacity).toHex()}`,
|
|
376
|
-
e?.underlineThickness ? "text-decoration:underline" : void 0,
|
|
377
|
-
e?.underlineColor ? `text-decoration-color:${e.underlineColor}` : void 0,
|
|
378
|
-
e?.underlineOffset ? `text-underline-offset:${e.underlineOffset}px` : void 0,
|
|
379
|
-
e?.underlineThickness ? `text-decoration-thickness:${e.underlineThickness}px` : void 0
|
|
380
|
-
].filter(Boolean).join(";"), rt = () => {
|
|
381
|
-
const e = document.createElement("style");
|
|
382
|
-
document.getElementsByTagName("head")[0].appendChild(e);
|
|
383
|
-
let t = /* @__PURE__ */ new Set();
|
|
384
|
-
return {
|
|
385
|
-
destroy: () => {
|
|
386
|
-
CSS.highlights.clear(), e.remove();
|
|
387
|
-
},
|
|
388
|
-
setVisible: (o) => {
|
|
389
|
-
console.log("setVisible not implemented on CSS Custom Highlights renderer");
|
|
390
|
-
},
|
|
391
|
-
redraw: (o, i, c, l) => {
|
|
392
|
-
l && l.clear();
|
|
393
|
-
const f = new Set(o.map((u) => u.annotation.id));
|
|
394
|
-
Array.from(t).filter((u) => !f.has(u));
|
|
395
|
-
const d = o.map((u) => {
|
|
396
|
-
const y = c ? typeof c == "function" ? c(u.annotation, u.state) : c : u.state?.selected ? J : _, w = l && l.paint(u, i) || y;
|
|
397
|
-
return `::highlight(_${u.annotation.id}) { ${st(w)} }`;
|
|
398
|
-
});
|
|
399
|
-
e.innerHTML = d.join(`
|
|
400
|
-
`), CSS.highlights.clear(), o.forEach(({ annotation: u }) => {
|
|
401
|
-
const y = u.target.selector.map((g) => g.range), w = new Highlight(...y);
|
|
402
|
-
CSS.highlights.set(`_${u.id}`, w);
|
|
403
|
-
}), t = f;
|
|
404
|
-
}
|
|
405
|
-
};
|
|
406
|
-
}, it = (e, t, n) => se(e, t, n, rt()), at = (e) => e?.fillOpacity !== void 0 ? ne(e?.fill || _.fill).alpha(e.fillOpacity).toHex() : e?.fill ? e.fill : ne(_.fill).alpha(_.fillOpacity).toHex(), ct = (e, t, n, r, s) => {
|
|
407
|
-
const o = n ? typeof n == "function" ? n(e.annotation, e.state, s) || (e.state?.selected ? J : _) : n : e.state?.selected ? J : _;
|
|
408
|
-
return r && r.paint(e, t) || o;
|
|
409
|
-
}, lt = (e, t) => {
|
|
410
|
-
const n = (o, i) => o.x <= i.x + i.width && o.x + o.width >= i.x && o.y <= i.y + i.height && o.y + o.height >= i.y, r = (o) => o.rects.reduce((i, c) => i + c.width, 0), s = t.filter(({ rects: o }) => o.some((i) => n(e, i)));
|
|
411
|
-
return s.sort((o, i) => r(i) - r(o)), s.findIndex((o) => o.rects.includes(e));
|
|
412
|
-
}, dt = (e) => {
|
|
413
|
-
e.classList.add("r6o-annotatable");
|
|
414
|
-
const t = document.createElement("div");
|
|
415
|
-
t.className = "r6o-span-highlight-layer", e.insertBefore(t, e.firstChild);
|
|
416
|
-
let n = [];
|
|
417
|
-
return {
|
|
418
|
-
destroy: () => {
|
|
419
|
-
t.remove();
|
|
420
|
-
},
|
|
421
|
-
redraw: (i, c, l, f, d) => {
|
|
422
|
-
const y = !(Be(n, i) && d);
|
|
423
|
-
if (!f && !y) return;
|
|
424
|
-
y && (t.innerHTML = ""), [...i].sort((g, x) => {
|
|
425
|
-
const { annotation: { target: { created: R } } } = g, { annotation: { target: { created: b } } } = x;
|
|
426
|
-
return R && b ? R.getTime() - b.getTime() : 0;
|
|
427
|
-
}).forEach((g) => {
|
|
428
|
-
g.rects.map((x) => {
|
|
429
|
-
const R = lt(x, i), b = ct(g, c, l, f, R);
|
|
430
|
-
if (y) {
|
|
431
|
-
const p = document.createElement("span");
|
|
432
|
-
p.className = "r6o-annotation", p.dataset.annotation = g.annotation.id, p.style.left = `${x.x}px`, p.style.top = `${x.y}px`, p.style.width = `${x.width}px`, p.style.height = `${x.height}px`, p.style.backgroundColor = at(b), b.underlineStyle && (p.style.borderStyle = b.underlineStyle), b.underlineColor && (p.style.borderColor = b.underlineColor), b.underlineThickness && (p.style.borderBottomWidth = `${b.underlineThickness}px`), b.underlineOffset && (p.style.paddingBottom = `${b.underlineOffset}px`), t.appendChild(p);
|
|
433
|
-
}
|
|
434
|
-
});
|
|
435
|
-
}), n = i;
|
|
436
|
-
},
|
|
437
|
-
setVisible: (i) => {
|
|
438
|
-
i ? t.classList.remove("hidden") : t.classList.add("hidden");
|
|
439
|
-
}
|
|
440
|
-
};
|
|
441
|
-
}, ut = (e, t, n) => se(e, t, n, dt(e)), Dt = (e, t) => ({
|
|
442
|
-
parse: (n) => mt(n),
|
|
443
|
-
serialize: (n) => pt(n, e, t)
|
|
444
|
-
}), ft = (e) => e.quote !== void 0 && e.start !== void 0 && e.end !== void 0, gt = (e) => {
|
|
246
|
+
return rt(e, r.target, n), !0;
|
|
247
|
+
const d = Q(r.target, t), { range: f } = d.selector[0];
|
|
248
|
+
return f && !f.collapsed ? (rt(e, d, n), !0) : !1;
|
|
249
|
+
}, ke = (t, e) => ({
|
|
250
|
+
parse: (o) => te(o),
|
|
251
|
+
serialize: (o) => ee(o, t, e)
|
|
252
|
+
}), Zt = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, Jt = (t) => {
|
|
445
253
|
const {
|
|
446
|
-
id:
|
|
447
|
-
creator:
|
|
448
|
-
created:
|
|
254
|
+
id: e,
|
|
255
|
+
creator: o,
|
|
256
|
+
created: i,
|
|
449
257
|
modified: s,
|
|
450
|
-
target:
|
|
451
|
-
} =
|
|
452
|
-
if (
|
|
453
|
-
return { error: Error(`No targets found for annotation: ${
|
|
258
|
+
target: n
|
|
259
|
+
} = t, r = Array.isArray(n) ? n : [n];
|
|
260
|
+
if (r.length === 0)
|
|
261
|
+
return { error: Error(`No targets found for annotation: ${t.id}`) };
|
|
454
262
|
const c = {
|
|
455
|
-
creator:
|
|
456
|
-
created:
|
|
263
|
+
creator: At(o),
|
|
264
|
+
created: i ? new Date(i) : void 0,
|
|
457
265
|
updated: s ? new Date(s) : void 0,
|
|
458
|
-
annotation:
|
|
266
|
+
annotation: e,
|
|
459
267
|
selector: [],
|
|
460
268
|
// @ts-expect-error: `styleClass` is not part of the core `TextAnnotationTarget` type
|
|
461
|
-
styleClass: "styleClass" in
|
|
269
|
+
styleClass: "styleClass" in r[0] ? r[0].styleClass : void 0
|
|
462
270
|
};
|
|
463
|
-
for (const
|
|
464
|
-
const
|
|
465
|
-
switch (
|
|
271
|
+
for (const d of r) {
|
|
272
|
+
const p = (Array.isArray(d.selector) ? d.selector : [d.selector]).reduce((C, h) => {
|
|
273
|
+
switch (h.type) {
|
|
466
274
|
case "TextQuoteSelector":
|
|
467
|
-
|
|
275
|
+
C.quote = h.exact;
|
|
468
276
|
break;
|
|
469
277
|
case "TextPositionSelector":
|
|
470
|
-
|
|
278
|
+
C.start = h.start, C.end = h.end;
|
|
471
279
|
break;
|
|
472
280
|
}
|
|
473
|
-
return
|
|
281
|
+
return C;
|
|
474
282
|
}, {});
|
|
475
|
-
if (
|
|
283
|
+
if (Zt(p))
|
|
476
284
|
c.selector.push(
|
|
477
285
|
{
|
|
478
|
-
...
|
|
479
|
-
id:
|
|
286
|
+
...p,
|
|
287
|
+
id: d.id,
|
|
480
288
|
// @ts-expect-error: `scope` is not part of the core `TextSelector` type
|
|
481
|
-
scope:
|
|
289
|
+
scope: d.scope
|
|
482
290
|
}
|
|
483
291
|
);
|
|
484
292
|
else {
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
|
|
293
|
+
const C = [
|
|
294
|
+
p.start ? void 0 : "TextPositionSelector",
|
|
295
|
+
p.quote ? void 0 : "TextQuoteSelector"
|
|
488
296
|
].filter(Boolean);
|
|
489
|
-
return { error: Error(`Missing selector types: ${
|
|
297
|
+
return { error: Error(`Missing selector types: ${C.join(" and ")} for annotation: ${t.id}`) };
|
|
490
298
|
}
|
|
491
299
|
}
|
|
492
300
|
return { parsed: c };
|
|
493
|
-
},
|
|
494
|
-
const
|
|
495
|
-
creator:
|
|
496
|
-
created:
|
|
301
|
+
}, te = (t) => {
|
|
302
|
+
const e = t.id || lt(), {
|
|
303
|
+
creator: o,
|
|
304
|
+
created: i,
|
|
497
305
|
modified: s,
|
|
498
|
-
body:
|
|
499
|
-
...
|
|
500
|
-
} =
|
|
501
|
-
return "error" in
|
|
306
|
+
body: n,
|
|
307
|
+
...r
|
|
308
|
+
} = t, c = Ct(n, e), d = Jt(t);
|
|
309
|
+
return "error" in d ? { error: d.error } : {
|
|
502
310
|
parsed: {
|
|
503
|
-
...
|
|
504
|
-
id:
|
|
311
|
+
...r,
|
|
312
|
+
id: e,
|
|
505
313
|
bodies: c,
|
|
506
|
-
target:
|
|
314
|
+
target: d.parsed
|
|
507
315
|
}
|
|
508
316
|
};
|
|
509
|
-
},
|
|
510
|
-
const { bodies:
|
|
511
|
-
selector:
|
|
317
|
+
}, ee = (t, e, o) => {
|
|
318
|
+
const { bodies: i, target: s, ...n } = t, {
|
|
319
|
+
selector: r,
|
|
512
320
|
creator: c,
|
|
513
|
-
created:
|
|
321
|
+
created: d,
|
|
514
322
|
updated: f,
|
|
515
|
-
...
|
|
516
|
-
} = s,
|
|
517
|
-
const { id:
|
|
323
|
+
...p
|
|
324
|
+
} = s, C = r.map((h) => {
|
|
325
|
+
const { id: T, quote: u, start: L, end: x, range: v } = h, m = {
|
|
518
326
|
type: "TextQuoteSelector",
|
|
519
|
-
exact:
|
|
327
|
+
exact: u
|
|
520
328
|
};
|
|
521
|
-
if (
|
|
522
|
-
const { prefix:
|
|
523
|
-
|
|
329
|
+
if (o) {
|
|
330
|
+
const { prefix: w, suffix: a } = jt(v, o);
|
|
331
|
+
m.prefix = w, m.suffix = a;
|
|
524
332
|
}
|
|
525
|
-
const
|
|
333
|
+
const E = {
|
|
526
334
|
type: "TextPositionSelector",
|
|
527
|
-
start:
|
|
528
|
-
end:
|
|
335
|
+
start: L,
|
|
336
|
+
end: x
|
|
529
337
|
};
|
|
530
338
|
return {
|
|
531
|
-
...
|
|
532
|
-
id:
|
|
339
|
+
...p,
|
|
340
|
+
id: T,
|
|
533
341
|
// @ts-expect-error: `scope` is not part of the core `TextSelector` type
|
|
534
|
-
scope: "scope" in
|
|
535
|
-
source:
|
|
536
|
-
selector: [
|
|
342
|
+
scope: "scope" in h ? h.scope : void 0,
|
|
343
|
+
source: e,
|
|
344
|
+
selector: [m, E]
|
|
537
345
|
};
|
|
538
346
|
});
|
|
539
347
|
return {
|
|
540
|
-
...
|
|
348
|
+
...n,
|
|
541
349
|
"@context": "http://www.w3.org/ns/anno.jsonld",
|
|
542
|
-
id:
|
|
350
|
+
id: t.id,
|
|
543
351
|
type: "Annotation",
|
|
544
|
-
body:
|
|
352
|
+
body: bt(t.bodies),
|
|
545
353
|
creator: c,
|
|
546
|
-
created:
|
|
354
|
+
created: d?.toISOString(),
|
|
547
355
|
modified: f?.toISOString(),
|
|
548
|
-
target:
|
|
356
|
+
target: C
|
|
549
357
|
};
|
|
550
|
-
},
|
|
551
|
-
const
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
fill: w.appearance.color,
|
|
578
|
-
fillOpacity: y ? 0.45 : 0.18
|
|
579
|
-
};
|
|
580
|
-
}
|
|
581
|
-
},
|
|
582
|
-
reset: () => {
|
|
583
|
-
n.width = 2 * window.innerWidth, n.height = 2 * window.innerHeight;
|
|
584
|
-
const d = n.getContext("2d");
|
|
585
|
-
d.scale(2, 2), d.translate(0.5, 0.5);
|
|
358
|
+
}, ne = (t, e) => {
|
|
359
|
+
const o = (n, r) => n.x <= r.x + r.width && n.x + n.width >= r.x && n.y <= r.y + r.height && n.y + n.height >= r.y, i = (n) => n.rects.reduce((r, c) => r + c.width, 0), s = e.filter(({ rects: n }) => n.some((r) => o(t, r)));
|
|
360
|
+
return s.sort((n, r) => i(r) - i(n)), s.findIndex((n) => n.rects.includes(t));
|
|
361
|
+
}, oe = (t) => {
|
|
362
|
+
const e = [], o = document.createNodeIterator(
|
|
363
|
+
t.commonAncestorContainer,
|
|
364
|
+
NodeFilter.SHOW_TEXT
|
|
365
|
+
);
|
|
366
|
+
let i;
|
|
367
|
+
for (; i = o.nextNode(); )
|
|
368
|
+
t.intersectsNode(i) && e.push(i);
|
|
369
|
+
if (e.length < 2)
|
|
370
|
+
return Array.from(t.getClientRects());
|
|
371
|
+
{
|
|
372
|
+
const s = e[0], n = e[e.length - 1], r = document.createRange();
|
|
373
|
+
if (r.selectNode(s), t.startContainer.nodeType === Node.TEXT_NODE)
|
|
374
|
+
r.setStart(s, t.startOffset);
|
|
375
|
+
else {
|
|
376
|
+
const f = t.startContainer.childNodes[t.startOffset];
|
|
377
|
+
f ? r.setStartBefore(f) : r.setStartAfter(t.startContainer);
|
|
378
|
+
}
|
|
379
|
+
const c = document.createRange();
|
|
380
|
+
if (c.selectNode(n), t.endContainer.nodeType === Node.TEXT_NODE)
|
|
381
|
+
c.setEnd(n, t.endOffset);
|
|
382
|
+
else {
|
|
383
|
+
const f = t.endContainer.childNodes[t.endOffset];
|
|
384
|
+
f ? c.setEndBefore(f) : c.setEndAfter(t.endContainer);
|
|
586
385
|
}
|
|
386
|
+
const d = (f) => {
|
|
387
|
+
const p = document.createRange();
|
|
388
|
+
return p.selectNode(f), Array.from(p.getClientRects());
|
|
389
|
+
};
|
|
390
|
+
return [
|
|
391
|
+
...Array.from(r.getClientRects()),
|
|
392
|
+
...e.slice(1, -1).flatMap(d),
|
|
393
|
+
...Array.from(c.getClientRects())
|
|
394
|
+
];
|
|
395
|
+
}
|
|
396
|
+
}, se = (t, e, o, i) => {
|
|
397
|
+
const s = (c) => Math.round(c * 10) / 10, n = {
|
|
398
|
+
top: s(t.top),
|
|
399
|
+
bottom: s(t.bottom),
|
|
400
|
+
left: s(t.left),
|
|
401
|
+
right: s(t.right)
|
|
402
|
+
}, r = {
|
|
403
|
+
top: s(e.top),
|
|
404
|
+
bottom: s(e.bottom),
|
|
405
|
+
left: s(e.left),
|
|
406
|
+
right: s(e.right)
|
|
587
407
|
};
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
return
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
408
|
+
if (Math.abs(n.top - r.top) < i && Math.abs(n.bottom - r.bottom) < i) {
|
|
409
|
+
if (Math.abs(n.left - r.right) < o || Math.abs(n.right - r.left) < o)
|
|
410
|
+
return "inline-adjacent";
|
|
411
|
+
if (n.left >= r.left && n.right <= r.right)
|
|
412
|
+
return "inline-is-contained";
|
|
413
|
+
if (n.left <= r.left && n.right >= r.right)
|
|
414
|
+
return "inline-contains";
|
|
415
|
+
} else if (n.top <= r.top && n.bottom >= r.bottom) {
|
|
416
|
+
if (n.left <= r.left && n.right >= r.right)
|
|
417
|
+
return "block-contains";
|
|
418
|
+
} else if (n.top >= r.top && n.bottom <= r.bottom && n.left >= r.left && n.right <= r.right)
|
|
419
|
+
return "block-is-contained";
|
|
420
|
+
}, re = (t, e) => {
|
|
421
|
+
const o = Math.min(t.left, e.left), i = Math.max(t.right, e.right), s = Math.min(t.top, e.top), n = Math.max(t.bottom, e.bottom);
|
|
422
|
+
return new DOMRect(o, s, i - o, n - s);
|
|
423
|
+
}, ie = (t, e = 0.5, o = 0.5) => t.reduce((i, s) => {
|
|
424
|
+
if (s.width === 0 || s.height === 0)
|
|
425
|
+
return i;
|
|
426
|
+
let n = [...i], r = !1;
|
|
427
|
+
for (const c of i) {
|
|
428
|
+
const d = se(s, c, e, o);
|
|
429
|
+
if (d === "inline-adjacent") {
|
|
430
|
+
n = n.map((f) => f === c ? re(s, c) : f), r = !0;
|
|
431
|
+
break;
|
|
432
|
+
} else if (d === "inline-contains") {
|
|
433
|
+
n = n.map((f) => f === c ? s : f), r = !0;
|
|
434
|
+
break;
|
|
435
|
+
} else if (d === "inline-is-contained") {
|
|
436
|
+
r = !0;
|
|
437
|
+
break;
|
|
438
|
+
} else if (d === "block-contains" || d === "block-is-contained") {
|
|
439
|
+
s.width < c.width && (n = n.map((f) => f === c ? s : f)), s.width === c.width && s.height < c.width && (n = n.map((f) => f === c ? s : f)), r = !0;
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
return r ? n : [...n, s];
|
|
444
|
+
}, []), Me = (t) => ({
|
|
445
|
+
length: t.length,
|
|
446
|
+
item: (e) => t[e],
|
|
447
|
+
[Symbol.iterator]: function* () {
|
|
448
|
+
for (let e = 0; e < this.length; e++)
|
|
449
|
+
yield this.item(e);
|
|
450
|
+
}
|
|
451
|
+
}), ce = (t, e) => {
|
|
452
|
+
const { left: o, top: i, right: s, bottom: n } = t;
|
|
453
|
+
return new DOMRect(o - e.left, i - e.top, s - o, n - i);
|
|
454
|
+
}, Be = (t, e) => {
|
|
455
|
+
const { left: o, top: i, right: s, bottom: n } = t;
|
|
456
|
+
return new DOMRect(o + e.left, i + e.top, s - o, n - i);
|
|
457
|
+
}, ae = (t, e, o, i) => {
|
|
458
|
+
const s = new Bt(), n = /* @__PURE__ */ new Map(), r = at(), c = (a, l) => {
|
|
459
|
+
const A = a.selector.flatMap((N) => {
|
|
460
|
+
const y = D([N]) ? N.range : pt(N, e).range;
|
|
461
|
+
return oe(y);
|
|
462
|
+
}), R = ie(A, o, i).map((N) => ce(N, l));
|
|
463
|
+
return R.map((N) => {
|
|
464
|
+
const { x: y, y: b, width: O, height: B } = N;
|
|
596
465
|
return {
|
|
597
|
-
minX:
|
|
598
|
-
minY:
|
|
599
|
-
maxX:
|
|
600
|
-
maxY:
|
|
466
|
+
minX: y,
|
|
467
|
+
minY: b,
|
|
468
|
+
maxX: y + O,
|
|
469
|
+
maxY: b + B,
|
|
601
470
|
annotation: {
|
|
602
|
-
id:
|
|
603
|
-
rects:
|
|
471
|
+
id: a.annotation,
|
|
472
|
+
rects: R
|
|
604
473
|
}
|
|
605
474
|
};
|
|
606
475
|
});
|
|
607
|
-
},
|
|
608
|
-
s.clear(),
|
|
609
|
-
},
|
|
610
|
-
const
|
|
611
|
-
|
|
612
|
-
},
|
|
613
|
-
const
|
|
614
|
-
|
|
615
|
-
},
|
|
616
|
-
|
|
617
|
-
},
|
|
618
|
-
|
|
619
|
-
const
|
|
620
|
-
|
|
621
|
-
|
|
476
|
+
}, d = () => [...n.values()], f = () => {
|
|
477
|
+
s.clear(), n.clear();
|
|
478
|
+
}, p = (a) => {
|
|
479
|
+
const l = c(a, e.getBoundingClientRect());
|
|
480
|
+
l.length !== 0 && (l.forEach((A) => s.insert(A)), n.set(a.annotation, l));
|
|
481
|
+
}, C = (a) => {
|
|
482
|
+
const l = n.get(a.annotation);
|
|
483
|
+
l && (l.forEach((A) => s.remove(A)), n.delete(a.annotation));
|
|
484
|
+
}, h = (a) => {
|
|
485
|
+
C(a), p(a);
|
|
486
|
+
}, T = (a, l = !0) => {
|
|
487
|
+
l && f();
|
|
488
|
+
const A = e.getBoundingClientRect(), R = a.map((y) => ({ target: y, rects: c(y, A) }));
|
|
489
|
+
R.forEach(({ target: y, rects: b }) => {
|
|
490
|
+
b.length > 0 && n.set(y.annotation, b);
|
|
622
491
|
});
|
|
623
|
-
const
|
|
624
|
-
s.load(
|
|
625
|
-
},
|
|
626
|
-
const
|
|
627
|
-
minX:
|
|
628
|
-
minY:
|
|
629
|
-
maxX:
|
|
630
|
-
maxY:
|
|
631
|
-
}),
|
|
632
|
-
return
|
|
633
|
-
},
|
|
634
|
-
const
|
|
635
|
-
if (
|
|
492
|
+
const N = R.flatMap(({ rects: y }) => y);
|
|
493
|
+
s.load(N);
|
|
494
|
+
}, u = (a, l, A = !1) => {
|
|
495
|
+
const R = s.search({
|
|
496
|
+
minX: a,
|
|
497
|
+
minY: l,
|
|
498
|
+
maxX: a,
|
|
499
|
+
maxY: l
|
|
500
|
+
}), N = (y) => y.annotation.rects.reduce((b, O) => b + O.width * O.height, 0);
|
|
501
|
+
return R.length > 0 ? (R.sort((y, b) => N(y) - N(b)), A ? R.map((y) => y.annotation.id) : [R[0].annotation.id]) : [];
|
|
502
|
+
}, L = (a) => {
|
|
503
|
+
const l = x(a);
|
|
504
|
+
if (l.length === 0)
|
|
636
505
|
return;
|
|
637
|
-
let
|
|
638
|
-
for (let
|
|
639
|
-
const O =
|
|
640
|
-
|
|
506
|
+
let A = l[0].left, R = l[0].top, N = l[0].right, y = l[0].bottom;
|
|
507
|
+
for (let b = 1; b < l.length; b++) {
|
|
508
|
+
const O = l[b];
|
|
509
|
+
A = Math.min(A, O.left), R = Math.min(R, O.top), N = Math.max(N, O.right), y = Math.max(y, O.bottom);
|
|
641
510
|
}
|
|
642
|
-
return new DOMRect(
|
|
643
|
-
},
|
|
644
|
-
const
|
|
645
|
-
return
|
|
511
|
+
return new DOMRect(A, R, N - A, y - R);
|
|
512
|
+
}, x = (a) => {
|
|
513
|
+
const l = n.get(a);
|
|
514
|
+
return l ? l[0].annotation.rects : [];
|
|
646
515
|
};
|
|
647
516
|
return {
|
|
648
|
-
all:
|
|
517
|
+
all: d,
|
|
649
518
|
clear: f,
|
|
650
|
-
getAt:
|
|
651
|
-
getAnnotationBounds:
|
|
652
|
-
getAnnotationRects:
|
|
653
|
-
getIntersecting: (
|
|
654
|
-
const
|
|
655
|
-
return Array.from(
|
|
656
|
-
annotation:
|
|
657
|
-
rects:
|
|
658
|
-
})).filter((
|
|
519
|
+
getAt: u,
|
|
520
|
+
getAnnotationBounds: L,
|
|
521
|
+
getAnnotationRects: x,
|
|
522
|
+
getIntersecting: (a, l, A, R) => {
|
|
523
|
+
const N = s.search({ minX: a, minY: l, maxX: A, maxY: R }), y = new Set(N.map((b) => b.annotation.id));
|
|
524
|
+
return Array.from(y).map((b) => ({
|
|
525
|
+
annotation: t.getAnnotation(b),
|
|
526
|
+
rects: x(b)
|
|
527
|
+
})).filter((b) => !!b.annotation);
|
|
659
528
|
},
|
|
660
|
-
insert:
|
|
529
|
+
insert: p,
|
|
661
530
|
recalculate: () => {
|
|
662
|
-
|
|
531
|
+
T(t.all().map((a) => a.target), !0), r.emit("recalculate");
|
|
663
532
|
},
|
|
664
|
-
remove:
|
|
665
|
-
set:
|
|
533
|
+
remove: C,
|
|
534
|
+
set: T,
|
|
666
535
|
size: () => s.all().length,
|
|
667
|
-
update:
|
|
668
|
-
on: (
|
|
536
|
+
update: h,
|
|
537
|
+
on: (a, l) => r.on(a, l)
|
|
669
538
|
};
|
|
670
|
-
},
|
|
671
|
-
const
|
|
672
|
-
const
|
|
673
|
-
return
|
|
674
|
-
},
|
|
675
|
-
const
|
|
676
|
-
return
|
|
677
|
-
}, f = (
|
|
678
|
-
const
|
|
679
|
-
return
|
|
680
|
-
|
|
681
|
-
}),
|
|
682
|
-
},
|
|
683
|
-
const
|
|
684
|
-
|
|
685
|
-
},
|
|
686
|
-
const
|
|
687
|
-
|
|
539
|
+
}, le = (t, e) => {
|
|
540
|
+
const o = Tt(), i = ae(o, t, e.mergeHighlights?.horizontalTolerance, e.mergeHighlights?.verticalTolerance), s = Rt(o, e.userSelectAction, e.adapter), n = vt(o), r = wt(), c = (m, E = F.LOCAL) => {
|
|
541
|
+
const w = tt(m, t), a = D(w.target.selector);
|
|
542
|
+
return a && o.addAnnotation(w, E), a;
|
|
543
|
+
}, d = (m, E = !0, w = F.LOCAL) => {
|
|
544
|
+
const a = m.map((A) => tt(A, t)), l = a.filter((A) => !D(A.target.selector));
|
|
545
|
+
return o.bulkAddAnnotations(a, E, w), l;
|
|
546
|
+
}, f = (m, E = F.LOCAL) => {
|
|
547
|
+
const w = m.map((l) => tt(l, t)), a = w.filter((l) => !D(l.target.selector));
|
|
548
|
+
return w.forEach((l) => {
|
|
549
|
+
o.getAnnotation(l.id) ? o.updateAnnotation(l, E) : o.addAnnotation(l, E);
|
|
550
|
+
}), a;
|
|
551
|
+
}, p = (m, E = F.LOCAL) => {
|
|
552
|
+
const w = Q(m, t);
|
|
553
|
+
o.updateTarget(w, E);
|
|
554
|
+
}, C = (m, E = F.LOCAL) => {
|
|
555
|
+
const w = m.map((a) => Q(a, t));
|
|
556
|
+
o.bulkUpdateTargets(w, E);
|
|
688
557
|
};
|
|
689
|
-
function
|
|
690
|
-
const
|
|
691
|
-
if (
|
|
692
|
-
return
|
|
558
|
+
function h(m, E, w, a) {
|
|
559
|
+
const l = w || !!a, A = i.getAt(m, E, l).map((N) => o.getAnnotation(N)), R = a ? A.filter(a) : A;
|
|
560
|
+
if (R.length !== 0)
|
|
561
|
+
return w ? R : R[0];
|
|
693
562
|
}
|
|
694
|
-
const
|
|
695
|
-
return
|
|
696
|
-
const
|
|
697
|
-
|
|
563
|
+
const T = (m) => i.getAnnotationRects(m).length > 0 ? i.getAnnotationBounds(m) : void 0, u = (m, E, w, a) => i.getIntersecting(m, E, w, a), L = (m) => i.getAnnotationRects(m), x = () => i.recalculate(), v = (m) => i.on("recalculate", m);
|
|
564
|
+
return o.observe(({ changes: m }) => {
|
|
565
|
+
const E = (m.deleted || []).filter((l) => D(l.target.selector)), w = (m.created || []).filter((l) => D(l.target.selector)), a = (m.updated || []).filter((l) => D(l.newValue.target.selector));
|
|
566
|
+
E?.length > 0 && E.forEach((l) => i.remove(l.target)), w.length > 0 && i.set(w.map((l) => l.target), !1), a?.length > 0 && a.forEach(({ newValue: l }) => i.update(l.target));
|
|
698
567
|
}), {
|
|
699
568
|
store: {
|
|
700
|
-
...
|
|
569
|
+
...o,
|
|
701
570
|
addAnnotation: c,
|
|
702
|
-
bulkAddAnnotations:
|
|
703
|
-
bulkUpdateTargets:
|
|
571
|
+
bulkAddAnnotations: d,
|
|
572
|
+
bulkUpdateTargets: C,
|
|
704
573
|
bulkUpsertAnnotations: f,
|
|
705
|
-
getAnnotationBounds:
|
|
706
|
-
getAnnotationRects:
|
|
707
|
-
getIntersecting:
|
|
708
|
-
getAt:
|
|
709
|
-
recalculatePositions:
|
|
710
|
-
onRecalculatePositions:
|
|
711
|
-
updateTarget:
|
|
574
|
+
getAnnotationBounds: T,
|
|
575
|
+
getAnnotationRects: L,
|
|
576
|
+
getIntersecting: u,
|
|
577
|
+
getAt: h,
|
|
578
|
+
recalculatePositions: x,
|
|
579
|
+
onRecalculatePositions: v,
|
|
580
|
+
updateTarget: p
|
|
712
581
|
},
|
|
713
582
|
selection: s,
|
|
714
|
-
hover:
|
|
715
|
-
viewport:
|
|
583
|
+
hover: n,
|
|
584
|
+
viewport: r
|
|
716
585
|
};
|
|
717
|
-
},
|
|
718
|
-
...
|
|
719
|
-
|
|
720
|
-
],
|
|
721
|
-
const { store: s, selection:
|
|
722
|
-
let
|
|
586
|
+
}, it = 300, yt = ["up", "down", "left", "right"], St = dt ? "⌘+a" : "ctrl+a", de = [
|
|
587
|
+
...yt.map((t) => `shift+${t}`),
|
|
588
|
+
St
|
|
589
|
+
], ue = (t, e, o, i) => {
|
|
590
|
+
const { store: s, selection: n } = e;
|
|
591
|
+
let r;
|
|
723
592
|
const {
|
|
724
593
|
annotatingEnabled: c,
|
|
725
|
-
offsetReferenceSelector:
|
|
594
|
+
offsetReferenceSelector: d,
|
|
726
595
|
selectionMode: f,
|
|
727
|
-
dismissOnNotAnnotatable:
|
|
728
|
-
} =
|
|
729
|
-
let
|
|
730
|
-
const
|
|
731
|
-
|
|
732
|
-
},
|
|
733
|
-
if (
|
|
596
|
+
dismissOnNotAnnotatable: p = "NEVER"
|
|
597
|
+
} = i;
|
|
598
|
+
let C, h = c, T = "CREATE_NEW", u, L, x, v;
|
|
599
|
+
const m = (g) => {
|
|
600
|
+
h = g, R.clear(), g || (L = void 0, u = void 0, x = void 0, v = void 0);
|
|
601
|
+
}, E = (g) => T = g || "CREATE_NEW", w = (g) => C = g, a = (g) => r = g, l = (g) => {
|
|
602
|
+
if (T === "ADD_TO_CURRENT")
|
|
734
603
|
return !0;
|
|
735
|
-
if (
|
|
736
|
-
const
|
|
737
|
-
return
|
|
604
|
+
if (i.allowModifierSelect) {
|
|
605
|
+
const S = g;
|
|
606
|
+
return dt ? S.metaKey : S.ctrlKey;
|
|
738
607
|
} else
|
|
739
608
|
return !1;
|
|
740
|
-
},
|
|
741
|
-
if (!
|
|
742
|
-
const { selected:
|
|
743
|
-
if ((
|
|
744
|
-
const
|
|
745
|
-
if (
|
|
746
|
-
|
|
747
|
-
annotation:
|
|
609
|
+
}, A = () => {
|
|
610
|
+
if (!h || x === !1) return;
|
|
611
|
+
const { selected: g } = n;
|
|
612
|
+
if ((l(v) || T === "REPLACE_CURRENT") && g.length === 1 && g[0].editable) {
|
|
613
|
+
const M = s.getAnnotation(g[0].id);
|
|
614
|
+
if (M?.target) {
|
|
615
|
+
L = M.target, u = {
|
|
616
|
+
annotation: M.id,
|
|
748
617
|
selector: [],
|
|
749
|
-
created:
|
|
750
|
-
creator:
|
|
618
|
+
created: L.created,
|
|
619
|
+
creator: L.creator,
|
|
751
620
|
updated: /* @__PURE__ */ new Date(),
|
|
752
|
-
updatedBy:
|
|
621
|
+
updatedBy: r
|
|
753
622
|
};
|
|
754
623
|
return;
|
|
755
624
|
}
|
|
756
625
|
}
|
|
757
|
-
|
|
758
|
-
annotation:
|
|
626
|
+
L = void 0, u = {
|
|
627
|
+
annotation: lt(),
|
|
759
628
|
selector: [],
|
|
760
629
|
created: /* @__PURE__ */ new Date(),
|
|
761
|
-
creator:
|
|
630
|
+
creator: r
|
|
762
631
|
};
|
|
763
|
-
},
|
|
764
|
-
if (!
|
|
765
|
-
const
|
|
766
|
-
if (!
|
|
767
|
-
const
|
|
768
|
-
if (!
|
|
769
|
-
|
|
632
|
+
}, R = It((g) => {
|
|
633
|
+
if (!h) return;
|
|
634
|
+
const S = document.getSelection();
|
|
635
|
+
if (!S?.anchorNode) return;
|
|
636
|
+
const M = Array.from(Array(S.rangeCount).keys()).map((k) => S.getRangeAt(k));
|
|
637
|
+
if (!M.some((k) => k.intersectsNode(t))) {
|
|
638
|
+
u = void 0;
|
|
770
639
|
return;
|
|
771
640
|
}
|
|
772
|
-
const U =
|
|
773
|
-
if (
|
|
774
|
-
s.getAnnotation(
|
|
641
|
+
const U = g.timeStamp - (v?.timeStamp || g.timeStamp);
|
|
642
|
+
if (v?.type === "pointerdown" && (U < 1e3 && !u || S.isCollapsed && U < it) && A(), u || A(), S.isCollapsed) {
|
|
643
|
+
s.getAnnotation(u.annotation) && !(l(v) || T === "REPLACE_CURRENT") && (n.clear(), s.deleteAnnotation(u.annotation));
|
|
775
644
|
return;
|
|
776
645
|
}
|
|
777
|
-
const
|
|
778
|
-
if (
|
|
779
|
-
const
|
|
780
|
-
if (!(
|
|
781
|
-
const
|
|
782
|
-
...
|
|
783
|
-
...
|
|
784
|
-
]) :
|
|
785
|
-
|
|
786
|
-
...
|
|
787
|
-
selector:
|
|
646
|
+
const I = M.map((k) => Wt(k, t));
|
|
647
|
+
if (I.every((k) => Ut(k))) return;
|
|
648
|
+
const _ = I.flatMap((k) => Yt(t, k.cloneRange()));
|
|
649
|
+
if (!(_.length > 0 && !u || _.length !== u.selector.length || _.some((k, Y) => k.toString() !== u.selector[Y]?.quote))) return;
|
|
650
|
+
const z = l(v) && L ? Kt([
|
|
651
|
+
...L.selector.map((k) => k.range),
|
|
652
|
+
..._
|
|
653
|
+
]) : _;
|
|
654
|
+
u = {
|
|
655
|
+
...u,
|
|
656
|
+
selector: z.map((k) => Gt(k, t, d)),
|
|
788
657
|
updated: /* @__PURE__ */ new Date()
|
|
789
|
-
}, !(
|
|
790
|
-
}, 10),
|
|
791
|
-
|
|
792
|
-
},
|
|
793
|
-
if (!
|
|
794
|
-
const
|
|
795
|
-
const { x:
|
|
796
|
-
if (
|
|
797
|
-
(typeof
|
|
658
|
+
}, !(l(v) || T === "REPLACE_CURRENT") && (s.getAnnotation(u.annotation) ? s.updateTarget(u, F.LOCAL) : n.clear());
|
|
659
|
+
}, 10), N = (g) => {
|
|
660
|
+
v = Z(g), x = v.button === 0;
|
|
661
|
+
}, y = async (g) => {
|
|
662
|
+
if (!x) return;
|
|
663
|
+
const S = Z(g), M = () => {
|
|
664
|
+
const { x: I, y: _ } = t.getBoundingClientRect();
|
|
665
|
+
if (G(t, S.target)) {
|
|
666
|
+
(typeof p == "function" ? p(S, t) : p === "ALWAYS") && n.clear();
|
|
798
667
|
return;
|
|
799
668
|
}
|
|
800
|
-
const
|
|
801
|
-
|
|
802
|
-
|
|
669
|
+
const H = S.target instanceof Node && t.contains(S.target) && s.getAt(
|
|
670
|
+
S.clientX - I,
|
|
671
|
+
S.clientY - _,
|
|
803
672
|
f === "all",
|
|
804
|
-
|
|
673
|
+
C
|
|
805
674
|
);
|
|
806
|
-
if (
|
|
807
|
-
const { selected:
|
|
808
|
-
(
|
|
675
|
+
if (H) {
|
|
676
|
+
const { selected: z } = n, k = new Set(z.map((W) => W.id)), Y = Array.isArray(H) ? H.map((W) => W.id) : [H.id];
|
|
677
|
+
(k.size !== Y.length || !Y.every((W) => k.has(W))) && (o.emit("clickAnnotation", H), n.userSelect(Y, S));
|
|
809
678
|
} else
|
|
810
|
-
|
|
679
|
+
n.clear();
|
|
811
680
|
};
|
|
812
|
-
if (
|
|
813
|
-
await
|
|
814
|
-
const
|
|
815
|
-
if (
|
|
816
|
-
|
|
681
|
+
if (S.timeStamp - v.timeStamp < it) {
|
|
682
|
+
await b();
|
|
683
|
+
const I = document.getSelection(), _ = G(t, v.target), H = G(t, S.target);
|
|
684
|
+
if (I?.isCollapsed || _ && H) {
|
|
685
|
+
u = void 0, M();
|
|
817
686
|
return;
|
|
818
687
|
}
|
|
819
688
|
}
|
|
820
|
-
|
|
821
|
-
},
|
|
822
|
-
const
|
|
823
|
-
let
|
|
824
|
-
const U = () =>
|
|
825
|
-
return setTimeout(() =>
|
|
826
|
-
}, O = (
|
|
827
|
-
document.getSelection()?.isCollapsed || ((!
|
|
828
|
-
},
|
|
829
|
-
|
|
830
|
-
}, X = (
|
|
831
|
-
const
|
|
832
|
-
|
|
833
|
-
id:
|
|
689
|
+
u && u.selector.length > 0 && (K(), n.userSelect(u.annotation, S));
|
|
690
|
+
}, b = async () => {
|
|
691
|
+
const g = document.getSelection();
|
|
692
|
+
let S = !1, M = g?.isCollapsed;
|
|
693
|
+
const U = () => M || S, I = 1;
|
|
694
|
+
return setTimeout(() => S = !0, 50), _t(() => M = g?.isCollapsed, I, U);
|
|
695
|
+
}, O = (g) => {
|
|
696
|
+
document.getSelection()?.isCollapsed || ((!u || u.selector.length === 0) && R(g), u && (K(), n.userSelect(u.annotation, Z(g))));
|
|
697
|
+
}, B = (g) => {
|
|
698
|
+
h && g.key === "Shift" && u && (document.getSelection().isCollapsed || (K(), n.userSelect(u.annotation, j(g))));
|
|
699
|
+
}, X = (g) => {
|
|
700
|
+
const S = () => setTimeout(() => {
|
|
701
|
+
u?.selector.length > 0 && (n.clear(), s.addAnnotation({
|
|
702
|
+
id: u.annotation,
|
|
834
703
|
bodies: [],
|
|
835
|
-
target:
|
|
836
|
-
}),
|
|
704
|
+
target: u
|
|
705
|
+
}), n.userSelect(u.annotation, j(g))), document.removeEventListener("selectionchange", S);
|
|
837
706
|
}, 100);
|
|
838
|
-
document.addEventListener("selectionchange",
|
|
707
|
+
document.addEventListener("selectionchange", S), A();
|
|
839
708
|
};
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
}),
|
|
843
|
-
|
|
709
|
+
q(de.join(","), { element: t, keydown: !0, keyup: !1 }, (g) => {
|
|
710
|
+
g.repeat || (v = j(g));
|
|
711
|
+
}), q(St, { keydown: !0, keyup: !1 }, (g) => {
|
|
712
|
+
v = j(g), X(g);
|
|
844
713
|
});
|
|
845
|
-
const
|
|
846
|
-
|
|
714
|
+
const V = (g) => {
|
|
715
|
+
g.repeat || g.target !== t && g.target !== document.body || (u = void 0, n.clear());
|
|
847
716
|
};
|
|
848
|
-
|
|
849
|
-
const
|
|
850
|
-
const
|
|
851
|
-
if (!
|
|
717
|
+
q(yt.join(","), { keydown: !0, keyup: !1 }, V);
|
|
718
|
+
const K = () => {
|
|
719
|
+
const g = s.getAnnotation(u.annotation);
|
|
720
|
+
if (!g)
|
|
852
721
|
s.addAnnotation({
|
|
853
|
-
id:
|
|
722
|
+
id: u.annotation,
|
|
854
723
|
bodies: [],
|
|
855
|
-
target:
|
|
724
|
+
target: u
|
|
856
725
|
});
|
|
857
726
|
else {
|
|
858
|
-
const { target: { updated:
|
|
859
|
-
(!
|
|
727
|
+
const { target: { updated: S } } = g, { updated: M } = u;
|
|
728
|
+
(!S || !M || S < M) && s.updateTarget(u);
|
|
860
729
|
}
|
|
861
730
|
};
|
|
862
|
-
return document.addEventListener("pointerdown",
|
|
731
|
+
return document.addEventListener("pointerdown", N), document.addEventListener("pointerup", y), document.addEventListener("contextmenu", O), t.addEventListener("keyup", B), t.addEventListener("selectstart", A), document.addEventListener("selectionchange", R), {
|
|
863
732
|
destroy: () => {
|
|
864
|
-
|
|
733
|
+
u = void 0, L = void 0, x = void 0, v = void 0, R.clear(), document.removeEventListener("pointerdown", N), document.removeEventListener("pointerup", y), document.removeEventListener("contextmenu", O), t.removeEventListener("keyup", B), t.removeEventListener("selectstart", A), document.removeEventListener("selectionchange", R), q.unbind();
|
|
865
734
|
},
|
|
866
|
-
setFilter:
|
|
867
|
-
setUser:
|
|
868
|
-
setAnnotatingEnabled:
|
|
869
|
-
setAnnotatingMode:
|
|
735
|
+
setFilter: w,
|
|
736
|
+
setUser: a,
|
|
737
|
+
setAnnotatingEnabled: m,
|
|
738
|
+
setAnnotatingMode: E
|
|
739
|
+
};
|
|
740
|
+
}, fe = (t) => {
|
|
741
|
+
t.classList.add("r6o-annotatable");
|
|
742
|
+
const e = document.createElement("div");
|
|
743
|
+
e.className = "r6o-span-highlight-layer", t.insertBefore(e, t.firstChild);
|
|
744
|
+
let o = [];
|
|
745
|
+
return {
|
|
746
|
+
destroy: () => {
|
|
747
|
+
e.remove();
|
|
748
|
+
},
|
|
749
|
+
redraw: (r, c, d, f, p) => {
|
|
750
|
+
if (!(!Dt(o, r) || p)) return;
|
|
751
|
+
e.innerHTML = "", [...r].sort((u, L) => {
|
|
752
|
+
const { annotation: { target: { created: x } } } = u, { annotation: { target: { created: v } } } = L;
|
|
753
|
+
return x && v ? x.getTime() - v.getTime() : 0;
|
|
754
|
+
}).forEach((u) => {
|
|
755
|
+
const L = f.get(u.annotation.id) || d;
|
|
756
|
+
u.rects.map((x) => {
|
|
757
|
+
const v = ne(x, r), m = mt(u, L, v), E = document.createElement("span");
|
|
758
|
+
E.className = "r6o-annotation", E.dataset.annotation = u.annotation.id, E.style.left = `${x.x}px`, E.style.top = `${x.y}px`, E.style.width = `${x.width}px`, E.style.height = `${x.height}px`, E.style.backgroundColor = Vt(m), m.underlineStyle && (E.style.borderStyle = m.underlineStyle), m.underlineColor && (E.style.borderColor = m.underlineColor), m.underlineThickness && (E.style.borderBottomWidth = `${m.underlineThickness}px`), m.underlineOffset && (E.style.paddingBottom = `${m.underlineOffset}px`), e.appendChild(E);
|
|
759
|
+
});
|
|
760
|
+
}), o = r;
|
|
761
|
+
},
|
|
762
|
+
setVisible: (r) => {
|
|
763
|
+
r ? e.classList.remove("hidden") : e.classList.add("hidden");
|
|
764
|
+
}
|
|
870
765
|
};
|
|
871
|
-
},
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
766
|
+
}, ge = (t, e, o) => gt(fe(t), t, e, o), me = (t) => [
|
|
767
|
+
`background-color:${et(t?.fill || P.fill).alpha(t?.fillOpacity === void 0 ? P.fillOpacity : t.fillOpacity).toHex()}`,
|
|
768
|
+
t?.underlineThickness ? "text-decoration:underline" : void 0,
|
|
769
|
+
t?.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
|
|
770
|
+
t?.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
|
|
771
|
+
t?.underlineThickness ? `text-decoration-thickness:${t.underlineThickness}px` : void 0
|
|
772
|
+
].filter(Boolean).join(";"), pe = () => {
|
|
773
|
+
const t = document.createElement("style");
|
|
774
|
+
document.getElementsByTagName("head")[0].appendChild(t);
|
|
775
|
+
let e = /* @__PURE__ */ new Set();
|
|
776
|
+
return {
|
|
777
|
+
destroy: () => {
|
|
778
|
+
CSS.highlights.clear(), t.remove();
|
|
779
|
+
},
|
|
780
|
+
setVisible: (n) => {
|
|
781
|
+
console.log("setVisible not implemented on CSS Custom Highlights renderer");
|
|
782
|
+
},
|
|
783
|
+
redraw: (n, r, c, d, f) => {
|
|
784
|
+
const p = new Set(n.map((h) => h.annotation.id));
|
|
785
|
+
Array.from(e).filter((h) => !p.has(h));
|
|
786
|
+
const C = n.map((h) => {
|
|
787
|
+
c ? typeof c == "function" && c(h.annotation, h.state) : h.state?.selected;
|
|
788
|
+
const T = mt(h, c);
|
|
789
|
+
return `::highlight(_${h.annotation.id}) { ${me(T)} }`;
|
|
790
|
+
});
|
|
791
|
+
t.innerHTML = C.join(`
|
|
792
|
+
`), CSS.highlights.clear(), n.forEach(({ annotation: h }) => {
|
|
793
|
+
const T = h.target.selector.map((L) => L.range), u = new Highlight(...T);
|
|
794
|
+
CSS.highlights.set(`_${h.id}`, u);
|
|
795
|
+
}), e = p;
|
|
796
|
+
}
|
|
797
|
+
};
|
|
798
|
+
}, he = (t, e, o) => gt(pe(), t, e, o), ye = (t, e) => ({
|
|
799
|
+
...t,
|
|
800
|
+
annotatingEnabled: t.annotatingEnabled ?? e.annotatingEnabled,
|
|
801
|
+
user: t.user || e.user
|
|
802
|
+
}), ct = "SPANS", Ie = (t, e = {}) => {
|
|
803
|
+
Xt(t), Ft(t);
|
|
804
|
+
const o = ye(e, {
|
|
878
805
|
annotatingEnabled: !0,
|
|
879
|
-
user:
|
|
880
|
-
}),
|
|
881
|
-
let f =
|
|
882
|
-
const
|
|
883
|
-
if (!
|
|
884
|
-
throw `Unknown renderer implementation: ${
|
|
885
|
-
console.debug(
|
|
886
|
-
const
|
|
887
|
-
|
|
888
|
-
const
|
|
889
|
-
|
|
806
|
+
user: xt()
|
|
807
|
+
}), i = le(t, o), { selection: s, viewport: n } = i, r = i.store, c = Lt(r), d = Nt(i, c, o.adapter);
|
|
808
|
+
let f = o.user;
|
|
809
|
+
const p = typeof o.renderer != "function" ? o.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : ct : o.renderer || ct : null, C = p === null ? o.renderer(t, i, n) : p === "SPANS" ? ge(t, i, n) : p === "CSS_HIGHLIGHTS" ? he(t, i, n) : void 0;
|
|
810
|
+
if (!C)
|
|
811
|
+
throw `Unknown renderer implementation: ${o.renderer}`;
|
|
812
|
+
console.debug(p ? `Using ${p} renderer` : "Using custom renderer implementation"), o.style && C.setStyle(o.style);
|
|
813
|
+
const h = ue(t, i, d, o);
|
|
814
|
+
h.setUser(f);
|
|
815
|
+
const T = Ot(i, c, o.adapter), u = () => f, L = (a) => {
|
|
816
|
+
h.setAnnotatingEnabled(
|
|
890
817
|
a === void 0 ? !0 : a
|
|
891
818
|
);
|
|
892
|
-
},
|
|
893
|
-
|
|
894
|
-
},
|
|
895
|
-
|
|
896
|
-
},
|
|
897
|
-
f = a,
|
|
898
|
-
}, S = (a) => {
|
|
899
|
-
a && (u.setPainter(yt(a, n.presence)), a.on("selectionChange", () => u.redraw()));
|
|
819
|
+
}, x = (a) => {
|
|
820
|
+
h.setAnnotatingMode(a);
|
|
821
|
+
}, v = (a) => {
|
|
822
|
+
C.setFilter(a), h.setFilter(a);
|
|
823
|
+
}, m = (a) => {
|
|
824
|
+
f = a, h.setUser(a);
|
|
900
825
|
}, E = (a) => {
|
|
901
826
|
a ? s.setSelected(a) : s.clear();
|
|
902
827
|
};
|
|
903
828
|
return {
|
|
904
|
-
...
|
|
829
|
+
...T,
|
|
905
830
|
destroy: () => {
|
|
906
|
-
|
|
831
|
+
C.destroy(), h.destroy(), c.destroy();
|
|
907
832
|
},
|
|
908
|
-
element:
|
|
909
|
-
getUser:
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
setUser:
|
|
833
|
+
element: t,
|
|
834
|
+
getUser: u,
|
|
835
|
+
renderer: C,
|
|
836
|
+
setAnnotatingEnabled: L,
|
|
837
|
+
setAnnotatingMode: x,
|
|
838
|
+
setFilter: v,
|
|
839
|
+
setStyle: C.setStyle.bind(C),
|
|
840
|
+
setUser: m,
|
|
916
841
|
setSelected: E,
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
state: r
|
|
842
|
+
setVisible: C.setVisible.bind(C),
|
|
843
|
+
on: d.on,
|
|
844
|
+
off: d.off,
|
|
845
|
+
scrollIntoView: Qt(t, r),
|
|
846
|
+
state: i
|
|
923
847
|
};
|
|
924
848
|
};
|
|
925
849
|
export {
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
Je as trackViewport,
|
|
974
|
-
Ge as trimRangeToContainer,
|
|
975
|
-
fe as whitespaceOrEmptyRegex
|
|
850
|
+
ot as DEFAULT_SELECTED_STYLE,
|
|
851
|
+
P as DEFAULT_STYLE,
|
|
852
|
+
ut as NOT_ANNOTATABLE_CLASS,
|
|
853
|
+
$ as NOT_ANNOTATABLE_SELECTOR,
|
|
854
|
+
He as Origin,
|
|
855
|
+
Pe as UserSelectAction,
|
|
856
|
+
ke as W3CTextFormat,
|
|
857
|
+
Xt as cancelSingleClickEvents,
|
|
858
|
+
j as cloneKeyboardEvent,
|
|
859
|
+
Z as clonePointerEvent,
|
|
860
|
+
mt as computeStyle,
|
|
861
|
+
ne as computeZIndex,
|
|
862
|
+
Ue as createBody,
|
|
863
|
+
gt as createRenderer,
|
|
864
|
+
ue as createSelectionHandler,
|
|
865
|
+
Ie as createTextAnnotator,
|
|
866
|
+
le as createTextAnnotatorState,
|
|
867
|
+
J as debounce,
|
|
868
|
+
ye as fillDefaults,
|
|
869
|
+
Vt as getBackgroundColor,
|
|
870
|
+
oe as getHighlightClientRects,
|
|
871
|
+
jt as getQuoteContext,
|
|
872
|
+
nt as getRangeAnnotatableContents,
|
|
873
|
+
zt as getViewportBounds,
|
|
874
|
+
dt as isMac,
|
|
875
|
+
Oe as isNodeWhitespaceOrEmpty,
|
|
876
|
+
G as isNotAnnotatable,
|
|
877
|
+
Pt as isRangeAnnotatable,
|
|
878
|
+
Ut as isRangeWhitespaceOrEmpty,
|
|
879
|
+
D as isRevived,
|
|
880
|
+
ie as mergeClientRects,
|
|
881
|
+
Kt as mergeRanges,
|
|
882
|
+
te as parseW3CTextAnnotation,
|
|
883
|
+
Ft as programmaticallyFocusable,
|
|
884
|
+
Gt as rangeToSelector,
|
|
885
|
+
tt as reviveAnnotation,
|
|
886
|
+
pt as reviveSelector,
|
|
887
|
+
Q as reviveTarget,
|
|
888
|
+
Qt as scrollIntoView,
|
|
889
|
+
ee as serializeW3CTextAnnotation,
|
|
890
|
+
Yt as splitAnnotatableRanges,
|
|
891
|
+
Me as toDomRectList,
|
|
892
|
+
ce as toParentBounds,
|
|
893
|
+
Be as toViewportBounds,
|
|
894
|
+
qt as trackViewport,
|
|
895
|
+
Wt as trimRangeToContainer,
|
|
896
|
+
ft as whitespaceOrEmptyRegex
|
|
976
897
|
};
|
|
977
898
|
//# sourceMappingURL=text-annotator.es.js.map
|