@soomo/react-text-annotator 3.1.0-staging.15 → 3.1.0-staging.16
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 +21 -0
- package/dist/TextAnnotationPopup/TextAnnotationPopup.d.ts.map +1 -0
- package/dist/TextAnnotationPopup/index.d.ts +2 -0
- package/dist/TextAnnotationPopup/index.d.ts.map +1 -0
- package/dist/TextAnnotationPopup/isMobile.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/react-text-annotator.es.js +2 -1
- package/dist/react-text-annotator.es11.js.map +1 -1
- package/dist/react-text-annotator.es12.js.map +1 -1
- package/dist/react-text-annotator.es13.js.map +1 -1
- package/dist/react-text-annotator.es14.js +116 -2
- package/dist/react-text-annotator.es14.js.map +1 -1
- package/dist/react-text-annotator.es15.js.map +1 -1
- package/dist/react-text-annotator.es17.js +37 -1
- package/dist/react-text-annotator.es17.js.map +1 -1
- package/dist/react-text-annotator.es18.js +3 -1
- package/dist/react-text-annotator.es18.js.map +1 -1
- package/dist/react-text-annotator.es2.js.map +1 -1
- package/dist/react-text-annotator.es21.js.map +1 -1
- package/dist/react-text-annotator.es24.js.map +1 -1
- package/dist/react-text-annotator.es25.js.map +1 -1
- package/dist/react-text-annotator.es26.js.map +1 -1
- package/dist/react-text-annotator.es27.js.map +1 -1
- package/dist/react-text-annotator.es28.js.map +1 -1
- package/dist/react-text-annotator.es29.js.map +1 -1
- package/dist/react-text-annotator.es3.js.map +1 -1
- package/dist/react-text-annotator.es30.js.map +1 -1
- package/dist/react-text-annotator.es31.js.map +1 -1
- package/dist/react-text-annotator.es32.js +63 -0
- package/dist/react-text-annotator.es32.js.map +1 -1
- package/dist/react-text-annotator.es4.js.map +1 -1
- package/dist/react-text-annotator.es5.js.map +1 -1
- package/dist/react-text-annotator.es6.js.map +1 -1
- package/dist/react-text-annotator.es7.js +24 -7
- package/dist/react-text-annotator.es7.js.map +1 -1
- package/dist/react-text-annotator.es8.js +197 -183
- package/dist/react-text-annotator.es8.js.map +1 -1
- package/dist/react-text-annotator.es9.js.map +1 -1
- package/package.json +7 -7
- package/dist/TextAnnotatorPopup/TextAnnotatorPopup.d.ts +0 -15
- package/dist/TextAnnotatorPopup/TextAnnotatorPopup.d.ts.map +0 -1
- package/dist/TextAnnotatorPopup/index.d.ts +0 -2
- package/dist/TextAnnotatorPopup/index.d.ts.map +0 -1
- package/dist/TextAnnotatorPopup/isMobile.d.ts.map +0 -1
- /package/dist/{TextAnnotatorPopup → TextAnnotationPopup}/isMobile.d.ts +0 -0
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
const
|
|
1
|
+
const re = "not-annotatable", tt = `.${re}`;
|
|
2
2
|
/mac/i.test(navigator.userAgentData ? navigator.userAgentData.platform : navigator.platform);
|
|
3
|
-
const
|
|
3
|
+
const Nt = (t) => {
|
|
4
4
|
const e = t.cloneContents();
|
|
5
|
-
return e.querySelectorAll(
|
|
6
|
-
},
|
|
5
|
+
return e.querySelectorAll(tt).forEach((n) => n.remove()), e;
|
|
6
|
+
}, Re = (t, e, n = 10, o) => {
|
|
7
7
|
const i = e, s = document.createRange();
|
|
8
8
|
s.setStart(i, 0), s.setEnd(t.startContainer, t.startOffset);
|
|
9
|
-
const a =
|
|
9
|
+
const a = Nt(s).textContent, r = document.createRange();
|
|
10
10
|
r.setStart(t.endContainer, t.endOffset), i === document.body ? r.setEnd(i, i.childNodes.length) : r.setEndAfter(i);
|
|
11
|
-
const l =
|
|
11
|
+
const l = Nt(r).textContent;
|
|
12
12
|
return {
|
|
13
13
|
prefix: a.substring(a.length - n),
|
|
14
14
|
suffix: l.substring(0, n)
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
|
-
const
|
|
17
|
+
const Y = [];
|
|
18
18
|
for (let t = 0; t < 256; ++t)
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
return (
|
|
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
22
|
}
|
|
23
|
-
let
|
|
24
|
-
const
|
|
25
|
-
function
|
|
26
|
-
if (!
|
|
23
|
+
let Ct;
|
|
24
|
+
const cn = new Uint8Array(16);
|
|
25
|
+
function ln() {
|
|
26
|
+
if (!Ct) {
|
|
27
27
|
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
28
28
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
29
|
-
|
|
29
|
+
Ct = crypto.getRandomValues.bind(crypto);
|
|
30
30
|
}
|
|
31
|
-
return
|
|
31
|
+
return Ct(cn);
|
|
32
32
|
}
|
|
33
|
-
const
|
|
34
|
-
function
|
|
35
|
-
if (
|
|
36
|
-
return
|
|
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
37
|
t = t || {};
|
|
38
|
-
const o = t.random || (t.rng ||
|
|
39
|
-
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128,
|
|
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
40
|
}
|
|
41
|
-
|
|
42
|
-
for (
|
|
43
|
-
|
|
41
|
+
const K = [];
|
|
42
|
+
for (let t = 0; t < 256; ++t)
|
|
43
|
+
K.push((t + 256).toString(16).slice(1));
|
|
44
44
|
typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
45
|
-
const
|
|
45
|
+
const _n = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
46
46
|
let Yn = (t = 21) => {
|
|
47
47
|
let e = "", n = crypto.getRandomValues(new Uint8Array(t));
|
|
48
48
|
for (; t--; )
|
|
49
|
-
e +=
|
|
49
|
+
e += _n[n[t] & 63];
|
|
50
50
|
return e;
|
|
51
51
|
};
|
|
52
|
-
const
|
|
52
|
+
const Dn = (t) => {
|
|
53
53
|
const e = JSON.stringify(t);
|
|
54
54
|
let n = 0;
|
|
55
55
|
for (let o = 0, i = e.length; o < i; o++) {
|
|
@@ -57,20 +57,20 @@ const Xn = (t) => {
|
|
|
57
57
|
n = (n << 5) - n + s, n |= 0;
|
|
58
58
|
}
|
|
59
59
|
return `${n}`;
|
|
60
|
-
},
|
|
61
|
-
const { id: o, type: i, purpose: s, value: a, created: r, modified: l, creator: f, ...
|
|
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
62
|
return {
|
|
63
|
-
id: o || `temp-${
|
|
63
|
+
id: o || `temp-${Dn(n)}`,
|
|
64
64
|
annotation: e,
|
|
65
65
|
type: i,
|
|
66
66
|
purpose: s,
|
|
67
67
|
value: a,
|
|
68
|
-
creator:
|
|
68
|
+
creator: ge(f),
|
|
69
69
|
created: r ? new Date(r) : void 0,
|
|
70
70
|
updated: l ? new Date(l) : void 0,
|
|
71
|
-
...
|
|
71
|
+
...h
|
|
72
72
|
};
|
|
73
|
-
}),
|
|
73
|
+
}), Pn = (t) => t.map((e) => {
|
|
74
74
|
var n;
|
|
75
75
|
const { annotation: o, created: i, updated: s, ...a } = e, r = {
|
|
76
76
|
...a,
|
|
@@ -81,53 +81,65 @@ const Xn = (t) => {
|
|
|
81
81
|
});
|
|
82
82
|
Yn();
|
|
83
83
|
const Ao = (t, e) => ({
|
|
84
|
-
parse: (n) =>
|
|
85
|
-
serialize: (n) =>
|
|
86
|
-
}),
|
|
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
87
|
const {
|
|
88
88
|
id: e,
|
|
89
89
|
creator: n,
|
|
90
90
|
created: o,
|
|
91
91
|
modified: i,
|
|
92
92
|
target: s
|
|
93
|
-
} = t, a = Array.isArray(s) ? s : [s]
|
|
94
|
-
|
|
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),
|
|
95
98
|
created: o ? new Date(o) : void 0,
|
|
96
99
|
updated: i ? new Date(i) : void 0,
|
|
97
100
|
annotation: e,
|
|
98
|
-
selector: []
|
|
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
|
|
99
104
|
};
|
|
100
105
|
for (const l of a) {
|
|
101
|
-
const
|
|
102
|
-
switch (
|
|
106
|
+
const h = (Array.isArray(l.selector) ? l.selector : [l.selector]).reduce((u, p) => {
|
|
107
|
+
switch (p.type) {
|
|
103
108
|
case "TextQuoteSelector":
|
|
104
|
-
|
|
109
|
+
u.quote = p.exact;
|
|
105
110
|
break;
|
|
106
111
|
case "TextPositionSelector":
|
|
107
|
-
|
|
112
|
+
u.start = p.start, u.end = p.end;
|
|
108
113
|
break;
|
|
109
114
|
}
|
|
110
|
-
return
|
|
115
|
+
return u;
|
|
111
116
|
}, {});
|
|
112
|
-
if (
|
|
113
|
-
r.selector.push(
|
|
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
|
+
);
|
|
114
126
|
else {
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
127
|
+
const u = [
|
|
128
|
+
h.start ? void 0 : "TextPositionSelector",
|
|
129
|
+
h.quote ? void 0 : "TextQuoteSelector"
|
|
118
130
|
].filter(Boolean);
|
|
119
|
-
return { error: Error(`Missing selector types: ${
|
|
131
|
+
return { error: Error(`Missing selector types: ${u.join(" and ")} for annotation: ${t.id}`) };
|
|
120
132
|
}
|
|
121
133
|
}
|
|
122
134
|
return { parsed: r };
|
|
123
|
-
},
|
|
124
|
-
const e = t.id ||
|
|
135
|
+
}, jn = (t) => {
|
|
136
|
+
const e = t.id || fe(), {
|
|
125
137
|
creator: n,
|
|
126
138
|
created: o,
|
|
127
139
|
modified: i,
|
|
128
140
|
body: s,
|
|
129
141
|
...a
|
|
130
|
-
} = t, r =
|
|
142
|
+
} = t, r = Xn(s, e), l = Hn(t);
|
|
131
143
|
return "error" in l ? { error: l.error } : {
|
|
132
144
|
parsed: {
|
|
133
145
|
...a,
|
|
@@ -136,29 +148,31 @@ const Ao = (t, e) => ({
|
|
|
136
148
|
target: l.parsed
|
|
137
149
|
}
|
|
138
150
|
};
|
|
139
|
-
},
|
|
151
|
+
}, zn = (t, e, n) => {
|
|
140
152
|
const { bodies: o, target: i, ...s } = t, {
|
|
141
153
|
selector: a,
|
|
142
154
|
creator: r,
|
|
143
155
|
created: l,
|
|
144
156
|
updated: f,
|
|
145
|
-
...
|
|
146
|
-
} = i,
|
|
147
|
-
const { quote:
|
|
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 = [{
|
|
148
160
|
type: "TextQuoteSelector",
|
|
149
|
-
exact:
|
|
150
|
-
prefix:
|
|
151
|
-
suffix:
|
|
161
|
+
exact: b,
|
|
162
|
+
prefix: c,
|
|
163
|
+
suffix: A
|
|
152
164
|
}, {
|
|
153
165
|
type: "TextPositionSelector",
|
|
154
|
-
start:
|
|
166
|
+
start: w,
|
|
155
167
|
end: y
|
|
156
168
|
}];
|
|
157
169
|
return {
|
|
158
|
-
...
|
|
159
|
-
id: g
|
|
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,
|
|
160
174
|
source: e,
|
|
161
|
-
selector:
|
|
175
|
+
selector: E
|
|
162
176
|
};
|
|
163
177
|
});
|
|
164
178
|
return {
|
|
@@ -166,26 +180,26 @@ const Ao = (t, e) => ({
|
|
|
166
180
|
"@context": "http://www.w3.org/ns/anno.jsonld",
|
|
167
181
|
id: t.id,
|
|
168
182
|
type: "Annotation",
|
|
169
|
-
body:
|
|
183
|
+
body: Pn(t.bodies),
|
|
170
184
|
creator: r,
|
|
171
185
|
created: l == null ? void 0 : l.toISOString(),
|
|
172
186
|
modified: f == null ? void 0 : f.toISOString(),
|
|
173
|
-
target:
|
|
187
|
+
target: u
|
|
174
188
|
};
|
|
175
189
|
};
|
|
176
|
-
const
|
|
177
|
-
function
|
|
190
|
+
const kt = typeof navigator < "u" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : false;
|
|
191
|
+
function It(t, e, n, o) {
|
|
178
192
|
t.addEventListener ? t.addEventListener(e, n, o) : t.attachEvent && t.attachEvent("on".concat(e), n);
|
|
179
193
|
}
|
|
180
|
-
function
|
|
194
|
+
function ot(t, e, n, o) {
|
|
181
195
|
t.removeEventListener ? t.removeEventListener(e, n, o) : t.detachEvent && t.detachEvent("on".concat(e), n);
|
|
182
196
|
}
|
|
183
|
-
function
|
|
197
|
+
function ye(t, e) {
|
|
184
198
|
const n = e.slice(0, e.length - 1);
|
|
185
199
|
for (let o = 0; o < n.length; o++) n[o] = t[n[o].toLowerCase()];
|
|
186
200
|
return n;
|
|
187
201
|
}
|
|
188
|
-
function
|
|
202
|
+
function be(t) {
|
|
189
203
|
typeof t != "string" && (t = ""), t = t.replace(/\s/g, "");
|
|
190
204
|
const e = t.split(",");
|
|
191
205
|
let n = e.lastIndexOf("");
|
|
@@ -193,14 +207,14 @@ function ye(t) {
|
|
|
193
207
|
e[n - 1] += ",", e.splice(n, 1), n = e.lastIndexOf("");
|
|
194
208
|
return e;
|
|
195
209
|
}
|
|
196
|
-
function
|
|
210
|
+
function io(t, e) {
|
|
197
211
|
const n = t.length >= e.length ? t : e, o = t.length >= e.length ? e : t;
|
|
198
212
|
let i = true;
|
|
199
213
|
for (let s = 0; s < n.length; s++)
|
|
200
214
|
o.indexOf(n[s]) === -1 && (i = false);
|
|
201
215
|
return i;
|
|
202
216
|
}
|
|
203
|
-
const
|
|
217
|
+
const lt = {
|
|
204
218
|
backspace: 8,
|
|
205
219
|
"⌫": 8,
|
|
206
220
|
tab: 9,
|
|
@@ -245,9 +259,9 @@ const at = {
|
|
|
245
259
|
".": 190,
|
|
246
260
|
"/": 191,
|
|
247
261
|
"`": 192,
|
|
248
|
-
"-":
|
|
249
|
-
"=":
|
|
250
|
-
";":
|
|
262
|
+
"-": kt ? 173 : 189,
|
|
263
|
+
"=": kt ? 61 : 187,
|
|
264
|
+
";": kt ? 59 : 186,
|
|
251
265
|
"'": 222,
|
|
252
266
|
"[": 219,
|
|
253
267
|
"]": 221,
|
|
@@ -268,7 +282,7 @@ const at = {
|
|
|
268
282
|
"⌘": 91,
|
|
269
283
|
cmd: 91,
|
|
270
284
|
command: 91
|
|
271
|
-
},
|
|
285
|
+
}, Vt = {
|
|
272
286
|
16: "shiftKey",
|
|
273
287
|
18: "altKey",
|
|
274
288
|
17: "ctrlKey",
|
|
@@ -277,29 +291,29 @@ const at = {
|
|
|
277
291
|
ctrlKey: 17,
|
|
278
292
|
altKey: 18,
|
|
279
293
|
metaKey: 91
|
|
280
|
-
},
|
|
294
|
+
}, D = {
|
|
281
295
|
16: false,
|
|
282
296
|
18: false,
|
|
283
297
|
17: false,
|
|
284
298
|
91: false
|
|
285
299
|
}, _ = {};
|
|
286
300
|
for (let t = 1; t < 20; t++)
|
|
287
|
-
|
|
288
|
-
let I = [],
|
|
289
|
-
const z = /* @__PURE__ */ new Map(),
|
|
290
|
-
function
|
|
291
|
-
|
|
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";
|
|
292
306
|
}
|
|
293
|
-
function
|
|
294
|
-
return
|
|
307
|
+
function dt() {
|
|
308
|
+
return we || "all";
|
|
295
309
|
}
|
|
296
|
-
function
|
|
310
|
+
function ao() {
|
|
297
311
|
return I.slice(0);
|
|
298
312
|
}
|
|
299
|
-
function
|
|
300
|
-
return I.map((t) =>
|
|
313
|
+
function co() {
|
|
314
|
+
return I.map((t) => so(t) || ro(t) || String.fromCharCode(t));
|
|
301
315
|
}
|
|
302
|
-
function
|
|
316
|
+
function lo() {
|
|
303
317
|
const t = [];
|
|
304
318
|
return Object.keys(_).forEach((e) => {
|
|
305
319
|
_[e].forEach((n) => {
|
|
@@ -313,12 +327,12 @@ function uo() {
|
|
|
313
327
|
scope: i,
|
|
314
328
|
shortcut: a,
|
|
315
329
|
mods: s,
|
|
316
|
-
keys: o.split("+").map((r) =>
|
|
330
|
+
keys: o.split("+").map((r) => ut(r))
|
|
317
331
|
});
|
|
318
332
|
});
|
|
319
333
|
}), t;
|
|
320
334
|
}
|
|
321
|
-
function
|
|
335
|
+
function uo(t) {
|
|
322
336
|
const e = t.target || t.srcElement, {
|
|
323
337
|
tagName: n
|
|
324
338
|
} = e;
|
|
@@ -326,12 +340,12 @@ function fo(t) {
|
|
|
326
340
|
const i = n === "INPUT" && !["checkbox", "radio", "range", "button", "file", "reset", "submit", "color"].includes(e.type);
|
|
327
341
|
return (e.isContentEditable || (i || n === "TEXTAREA" || n === "SELECT") && !e.readOnly) && (o = false), o;
|
|
328
342
|
}
|
|
329
|
-
function
|
|
330
|
-
return typeof t == "string" && (t =
|
|
343
|
+
function fo(t) {
|
|
344
|
+
return typeof t == "string" && (t = ut(t)), I.indexOf(t) !== -1;
|
|
331
345
|
}
|
|
332
|
-
function
|
|
346
|
+
function ho(t, e) {
|
|
333
347
|
let n, o;
|
|
334
|
-
t || (t =
|
|
348
|
+
t || (t = dt());
|
|
335
349
|
for (const i in _)
|
|
336
350
|
if (Object.prototype.hasOwnProperty.call(_, i))
|
|
337
351
|
for (n = _[i], o = 0; o < n.length; )
|
|
@@ -339,34 +353,34 @@ function po(t, e) {
|
|
|
339
353
|
let {
|
|
340
354
|
element: r
|
|
341
355
|
} = a;
|
|
342
|
-
return
|
|
356
|
+
return Xt(r);
|
|
343
357
|
}) : o++;
|
|
344
|
-
|
|
358
|
+
dt() === t && Ae(e || "all");
|
|
345
359
|
}
|
|
346
|
-
function
|
|
360
|
+
function po(t) {
|
|
347
361
|
let e = t.keyCode || t.which || t.charCode;
|
|
348
362
|
const n = I.indexOf(e);
|
|
349
|
-
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
|
|
350
|
-
|
|
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;
|
|
351
365
|
for (const o in H) H[o] === e && (P[o] = false);
|
|
352
366
|
}
|
|
353
367
|
}
|
|
354
|
-
function
|
|
368
|
+
function xe(t) {
|
|
355
369
|
if (typeof t > "u")
|
|
356
370
|
Object.keys(_).forEach((i) => {
|
|
357
|
-
Array.isArray(_[i]) && _[i].forEach((s) =>
|
|
358
|
-
}),
|
|
371
|
+
Array.isArray(_[i]) && _[i].forEach((s) => yt(s)), delete _[i];
|
|
372
|
+
}), Xt(null);
|
|
359
373
|
else if (Array.isArray(t))
|
|
360
374
|
t.forEach((i) => {
|
|
361
|
-
i.key &&
|
|
375
|
+
i.key && yt(i);
|
|
362
376
|
});
|
|
363
377
|
else if (typeof t == "object")
|
|
364
|
-
t.key &&
|
|
378
|
+
t.key && yt(t);
|
|
365
379
|
else if (typeof t == "string") {
|
|
366
380
|
for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), o = 1; o < e; o++)
|
|
367
381
|
n[o - 1] = arguments[o];
|
|
368
382
|
let [i, s] = n;
|
|
369
|
-
typeof i == "function" && (s = i, i = ""),
|
|
383
|
+
typeof i == "function" && (s = i, i = ""), yt({
|
|
370
384
|
key: t,
|
|
371
385
|
scope: i,
|
|
372
386
|
method: s,
|
|
@@ -374,73 +388,73 @@ function ve(t) {
|
|
|
374
388
|
});
|
|
375
389
|
}
|
|
376
390
|
}
|
|
377
|
-
const
|
|
391
|
+
const yt = (t) => {
|
|
378
392
|
let {
|
|
379
393
|
key: e,
|
|
380
394
|
scope: n,
|
|
381
395
|
method: o,
|
|
382
396
|
splitKey: i = "+"
|
|
383
397
|
} = t;
|
|
384
|
-
|
|
385
|
-
const r = a.split(i), l = r.length, f = r[l - 1],
|
|
386
|
-
if (!_[
|
|
387
|
-
n || (n =
|
|
388
|
-
const
|
|
389
|
-
_[
|
|
390
|
-
const
|
|
391
|
-
return
|
|
392
|
-
}),
|
|
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));
|
|
393
407
|
});
|
|
394
408
|
};
|
|
395
|
-
function
|
|
409
|
+
function ne(t, e, n, o) {
|
|
396
410
|
if (e.element !== o)
|
|
397
411
|
return;
|
|
398
412
|
let i;
|
|
399
413
|
if (e.scope === n || e.scope === "all") {
|
|
400
414
|
i = e.mods.length > 0;
|
|
401
|
-
for (const s in
|
|
402
|
-
Object.prototype.hasOwnProperty.call(
|
|
403
|
-
(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)));
|
|
404
418
|
}
|
|
405
419
|
}
|
|
406
|
-
function
|
|
420
|
+
function oe(t, e) {
|
|
407
421
|
const n = _["*"];
|
|
408
422
|
let o = t.keyCode || t.which || t.charCode;
|
|
409
423
|
if (!P.filter.call(this, t)) return;
|
|
410
424
|
if ((o === 93 || o === 224) && (o = 91), I.indexOf(o) === -1 && o !== 229 && I.push(o), ["ctrlKey", "altKey", "shiftKey", "metaKey"].forEach((r) => {
|
|
411
|
-
const l =
|
|
425
|
+
const l = Vt[r];
|
|
412
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))));
|
|
413
|
-
}), o in
|
|
414
|
-
|
|
427
|
+
}), o in D) {
|
|
428
|
+
D[o] = true;
|
|
415
429
|
for (const r in H)
|
|
416
430
|
H[r] === o && (P[r] = true);
|
|
417
431
|
if (!n) return;
|
|
418
432
|
}
|
|
419
|
-
for (const r in
|
|
420
|
-
Object.prototype.hasOwnProperty.call(
|
|
421
|
-
t.getModifierState && !(t.altKey && !t.ctrlKey) && t.getModifierState("AltGraph") && (I.indexOf(17) === -1 && I.push(17), I.indexOf(18) === -1 && I.push(18),
|
|
422
|
-
const i =
|
|
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();
|
|
423
437
|
if (n)
|
|
424
438
|
for (let r = 0; r < n.length; r++)
|
|
425
|
-
n[r].scope === i && (t.type === "keydown" && n[r].keydown || t.type === "keyup" && n[r].keyup) &&
|
|
439
|
+
n[r].scope === i && (t.type === "keydown" && n[r].keydown || t.type === "keyup" && n[r].keyup) && ne(t, n[r], i, e);
|
|
426
440
|
if (!(o in _)) return;
|
|
427
441
|
const s = _[o], a = s.length;
|
|
428
442
|
for (let r = 0; r < a; r++)
|
|
429
443
|
if ((t.type === "keydown" && s[r].keydown || t.type === "keyup" && s[r].keyup) && s[r].key) {
|
|
430
444
|
const l = s[r], {
|
|
431
445
|
splitKey: f
|
|
432
|
-
} = l,
|
|
433
|
-
for (let
|
|
434
|
-
|
|
435
|
-
|
|
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);
|
|
436
450
|
}
|
|
437
451
|
}
|
|
438
452
|
function P(t, e, n) {
|
|
439
453
|
I = [];
|
|
440
|
-
const o =
|
|
441
|
-
let i = [], s = "all", a = document, r = 0, l = false, f = true,
|
|
442
|
-
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 && (
|
|
443
|
-
t = o[r].split(
|
|
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({
|
|
444
458
|
keyup: l,
|
|
445
459
|
keydown: f,
|
|
446
460
|
scope: s,
|
|
@@ -448,36 +462,36 @@ function P(t, e, n) {
|
|
|
448
462
|
shortcut: o[r],
|
|
449
463
|
method: n,
|
|
450
464
|
key: o[r],
|
|
451
|
-
splitKey:
|
|
465
|
+
splitKey: h,
|
|
452
466
|
element: a
|
|
453
467
|
});
|
|
454
468
|
if (typeof a < "u" && window) {
|
|
455
469
|
if (!z.has(a)) {
|
|
456
|
-
const
|
|
457
|
-
let
|
|
458
|
-
return
|
|
459
|
-
},
|
|
460
|
-
let
|
|
461
|
-
|
|
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);
|
|
462
476
|
};
|
|
463
477
|
z.set(a, {
|
|
464
|
-
keydownListener:
|
|
465
|
-
keyupListenr:
|
|
466
|
-
capture:
|
|
467
|
-
}),
|
|
478
|
+
keydownListener: g,
|
|
479
|
+
keyupListenr: b,
|
|
480
|
+
capture: u
|
|
481
|
+
}), It(a, "keydown", g, u), It(a, "keyup", b, u);
|
|
468
482
|
}
|
|
469
|
-
if (!
|
|
470
|
-
const
|
|
483
|
+
if (!ct) {
|
|
484
|
+
const g = () => {
|
|
471
485
|
I = [];
|
|
472
486
|
};
|
|
473
|
-
|
|
474
|
-
listener:
|
|
475
|
-
capture:
|
|
476
|
-
},
|
|
487
|
+
ct = {
|
|
488
|
+
listener: g,
|
|
489
|
+
capture: u
|
|
490
|
+
}, It(window, "focus", g, u);
|
|
477
491
|
}
|
|
478
492
|
}
|
|
479
493
|
}
|
|
480
|
-
function
|
|
494
|
+
function go(t) {
|
|
481
495
|
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "all";
|
|
482
496
|
Object.keys(_).forEach((n) => {
|
|
483
497
|
_[n].filter((i) => i.scope === e && i.shortcut === t).forEach((i) => {
|
|
@@ -485,7 +499,7 @@ function mo(t) {
|
|
|
485
499
|
});
|
|
486
500
|
});
|
|
487
501
|
}
|
|
488
|
-
function
|
|
502
|
+
function Xt(t) {
|
|
489
503
|
const e = Object.values(_).flat();
|
|
490
504
|
if (e.findIndex((o) => {
|
|
491
505
|
let {
|
|
@@ -498,7 +512,7 @@ function Dt(t) {
|
|
|
498
512
|
keyupListenr: i,
|
|
499
513
|
capture: s
|
|
500
514
|
} = z.get(t) || {};
|
|
501
|
-
o && i && (
|
|
515
|
+
o && i && (ot(t, "keyup", i, s), ot(t, "keydown", o, s), z.delete(t));
|
|
502
516
|
}
|
|
503
517
|
if ((e.length <= 0 || z.size <= 0) && (Object.keys(z).forEach((i) => {
|
|
504
518
|
const {
|
|
@@ -506,43 +520,43 @@ function Dt(t) {
|
|
|
506
520
|
keyupListenr: a,
|
|
507
521
|
capture: r
|
|
508
522
|
} = z.get(i) || {};
|
|
509
|
-
s && a && (
|
|
510
|
-
}), z.clear(), Object.keys(_).forEach((i) => delete _[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)) {
|
|
511
525
|
const {
|
|
512
526
|
listener: i,
|
|
513
527
|
capture: s
|
|
514
|
-
} =
|
|
515
|
-
|
|
528
|
+
} = ct;
|
|
529
|
+
ot(window, "focus", i, s), ct = null;
|
|
516
530
|
}
|
|
517
531
|
}
|
|
518
|
-
const
|
|
519
|
-
getPressedKeyString:
|
|
520
|
-
setScope:
|
|
521
|
-
getScope:
|
|
522
|
-
deleteScope:
|
|
523
|
-
getPressedKeyCodes:
|
|
524
|
-
getAllKeyCodes:
|
|
525
|
-
isPressed:
|
|
526
|
-
filter:
|
|
527
|
-
trigger:
|
|
528
|
-
unbind:
|
|
529
|
-
keyMap:
|
|
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,
|
|
530
544
|
modifier: H,
|
|
531
|
-
modifierMap:
|
|
545
|
+
modifierMap: Vt
|
|
532
546
|
};
|
|
533
|
-
for (const t in
|
|
534
|
-
Object.prototype.hasOwnProperty.call(
|
|
547
|
+
for (const t in _t)
|
|
548
|
+
Object.prototype.hasOwnProperty.call(_t, t) && (P[t] = _t[t]);
|
|
535
549
|
if (typeof window < "u") {
|
|
536
550
|
const t = window.hotkeys;
|
|
537
551
|
P.noConflict = (e) => (e && window.hotkeys === P && (window.hotkeys = t), P), window.hotkeys = P;
|
|
538
552
|
}
|
|
539
553
|
export {
|
|
540
|
-
|
|
541
|
-
|
|
554
|
+
re as NOT_ANNOTATABLE_CLASS,
|
|
555
|
+
tt as NOT_ANNOTATABLE_SELECTOR,
|
|
542
556
|
Ao as W3CTextFormat,
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
557
|
+
Re as getQuoteContext,
|
|
558
|
+
Nt as getRangeAnnotatableContents,
|
|
559
|
+
jn as parseW3CTextAnnotation,
|
|
560
|
+
zn as serializeW3CTextAnnotation
|
|
547
561
|
};
|
|
548
562
|
//# sourceMappingURL=react-text-annotator.es8.js.map
|