@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.
Files changed (46) hide show
  1. package/dist/TextAnnotationPopup/TextAnnotationPopup.d.ts +21 -0
  2. package/dist/TextAnnotationPopup/TextAnnotationPopup.d.ts.map +1 -0
  3. package/dist/TextAnnotationPopup/index.d.ts +2 -0
  4. package/dist/TextAnnotationPopup/index.d.ts.map +1 -0
  5. package/dist/TextAnnotationPopup/isMobile.d.ts.map +1 -0
  6. package/dist/index.d.ts +1 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/react-text-annotator.es.js +2 -1
  9. package/dist/react-text-annotator.es11.js.map +1 -1
  10. package/dist/react-text-annotator.es12.js.map +1 -1
  11. package/dist/react-text-annotator.es13.js.map +1 -1
  12. package/dist/react-text-annotator.es14.js +116 -2
  13. package/dist/react-text-annotator.es14.js.map +1 -1
  14. package/dist/react-text-annotator.es15.js.map +1 -1
  15. package/dist/react-text-annotator.es17.js +37 -1
  16. package/dist/react-text-annotator.es17.js.map +1 -1
  17. package/dist/react-text-annotator.es18.js +3 -1
  18. package/dist/react-text-annotator.es18.js.map +1 -1
  19. package/dist/react-text-annotator.es2.js.map +1 -1
  20. package/dist/react-text-annotator.es21.js.map +1 -1
  21. package/dist/react-text-annotator.es24.js.map +1 -1
  22. package/dist/react-text-annotator.es25.js.map +1 -1
  23. package/dist/react-text-annotator.es26.js.map +1 -1
  24. package/dist/react-text-annotator.es27.js.map +1 -1
  25. package/dist/react-text-annotator.es28.js.map +1 -1
  26. package/dist/react-text-annotator.es29.js.map +1 -1
  27. package/dist/react-text-annotator.es3.js.map +1 -1
  28. package/dist/react-text-annotator.es30.js.map +1 -1
  29. package/dist/react-text-annotator.es31.js.map +1 -1
  30. package/dist/react-text-annotator.es32.js +63 -0
  31. package/dist/react-text-annotator.es32.js.map +1 -1
  32. package/dist/react-text-annotator.es4.js.map +1 -1
  33. package/dist/react-text-annotator.es5.js.map +1 -1
  34. package/dist/react-text-annotator.es6.js.map +1 -1
  35. package/dist/react-text-annotator.es7.js +24 -7
  36. package/dist/react-text-annotator.es7.js.map +1 -1
  37. package/dist/react-text-annotator.es8.js +197 -183
  38. package/dist/react-text-annotator.es8.js.map +1 -1
  39. package/dist/react-text-annotator.es9.js.map +1 -1
  40. package/package.json +7 -7
  41. package/dist/TextAnnotatorPopup/TextAnnotatorPopup.d.ts +0 -15
  42. package/dist/TextAnnotatorPopup/TextAnnotatorPopup.d.ts.map +0 -1
  43. package/dist/TextAnnotatorPopup/index.d.ts +0 -2
  44. package/dist/TextAnnotatorPopup/index.d.ts.map +0 -1
  45. package/dist/TextAnnotatorPopup/isMobile.d.ts.map +0 -1
  46. /package/dist/{TextAnnotatorPopup → TextAnnotationPopup}/isMobile.d.ts +0 -0
@@ -1,55 +1,55 @@
1
- const se = "not-annotatable", Z = `.${se}`;
1
+ const re = "not-annotatable", tt = `.${re}`;
2
2
  /mac/i.test(navigator.userAgentData ? navigator.userAgentData.platform : navigator.platform);
3
- const _t = (t) => {
3
+ const Nt = (t) => {
4
4
  const e = t.cloneContents();
5
- return e.querySelectorAll(Z).forEach((n) => n.remove()), e;
6
- }, ke = (t, e, n = 10, o) => {
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 = _t(s).textContent, r = document.createRange();
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 = _t(r).textContent;
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 U = [];
17
+ const Y = [];
18
18
  for (let t = 0; t < 256; ++t)
19
- U.push((t + 256).toString(16).slice(1));
20
- function cn(t, e = 0) {
21
- return (U[t[e + 0]] + U[t[e + 1]] + U[t[e + 2]] + U[t[e + 3]] + "-" + U[t[e + 4]] + U[t[e + 5]] + "-" + U[t[e + 6]] + U[t[e + 7]] + "-" + U[t[e + 8]] + U[t[e + 9]] + "-" + U[t[e + 10]] + U[t[e + 11]] + U[t[e + 12]] + U[t[e + 13]] + U[t[e + 14]] + U[t[e + 15]]).toLowerCase();
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 St;
24
- const ln = new Uint8Array(16);
25
- function dn() {
26
- if (!St) {
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
- St = crypto.getRandomValues.bind(crypto);
29
+ Ct = crypto.getRandomValues.bind(crypto);
30
30
  }
31
- return St(ln);
31
+ return Ct(cn);
32
32
  }
33
- const un = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Gt = { randomUUID: un };
34
- function ue(t, e, n) {
35
- if (Gt.randomUUID && !e && !t)
36
- return Gt.randomUUID();
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 || dn)();
39
- return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, cn(o);
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
- var V = [];
42
- for (var Lt = 0; Lt < 256; ++Lt)
43
- V.push((Lt + 256).toString(16).slice(1));
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 Nn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
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 += Nn[n[t] & 63];
49
+ e += _n[n[t] & 63];
50
50
  return e;
51
51
  };
52
- const Xn = (t) => {
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
- }, pe = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, Pn = (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, ...u } = n;
60
+ }, ge = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, Xn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
61
+ const { id: o, type: i, purpose: s, value: a, created: r, modified: l, creator: f, ...h } = n;
62
62
  return {
63
- id: o || `temp-${Xn(n)}`,
63
+ id: o || `temp-${Dn(n)}`,
64
64
  annotation: e,
65
65
  type: i,
66
66
  purpose: s,
67
67
  value: a,
68
- creator: pe(f),
68
+ creator: ge(f),
69
69
  created: r ? new Date(r) : void 0,
70
70
  updated: l ? new Date(l) : void 0,
71
- ...u
71
+ ...h
72
72
  };
73
- }), $n = (t) => t.map((e) => {
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) => zn(n),
85
- serialize: (n) => Fn(n, t, e)
86
- }), Hn = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, jn = (t) => {
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], r = {
94
- creator: pe(n),
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 u = (Array.isArray(l.selector) ? l.selector : [l.selector]).reduce((h, g) => {
102
- switch (g.type) {
106
+ const h = (Array.isArray(l.selector) ? l.selector : [l.selector]).reduce((u, p) => {
107
+ switch (p.type) {
103
108
  case "TextQuoteSelector":
104
- h.quote = g.exact;
109
+ u.quote = p.exact;
105
110
  break;
106
111
  case "TextPositionSelector":
107
- h.start = g.start, h.end = g.end;
112
+ u.start = p.start, u.end = p.end;
108
113
  break;
109
114
  }
110
- return h;
115
+ return u;
111
116
  }, {});
112
- if (Hn(u))
113
- r.selector.push({ id: l.id, ...u });
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 h = [
116
- u.start ? void 0 : "TextPositionSelector",
117
- u.quote ? void 0 : "TextQuoteSelector"
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: ${h.join(" and ")} for annotation: ${t.id}`) };
131
+ return { error: Error(`Missing selector types: ${u.join(" and ")} for annotation: ${t.id}`) };
120
132
  }
121
133
  }
122
134
  return { parsed: r };
123
- }, zn = (t) => {
124
- const e = t.id || ue(), {
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 = Pn(s, e), l = jn(t);
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
- }, Fn = (t, e, n) => {
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
- ...u
146
- } = i, h = a.map((g) => {
147
- const { quote: p, start: v, end: y, range: m } = g, { prefix: d, suffix: c } = ke(m, n), b = [{
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: p,
150
- prefix: d,
151
- suffix: c
161
+ exact: b,
162
+ prefix: c,
163
+ suffix: A
152
164
  }, {
153
165
  type: "TextPositionSelector",
154
- start: v,
166
+ start: w,
155
167
  end: y
156
168
  }];
157
169
  return {
158
- ...u,
159
- id: g.id,
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: b
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: $n(t.bodies),
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: h
187
+ target: u
174
188
  };
175
189
  };
176
- const Bt = typeof navigator < "u" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : false;
177
- function kt(t, e, n, o) {
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 et(t, e, n, o) {
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 me(t, e) {
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 ye(t) {
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 so(t, e) {
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 at = {
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
- "-": Bt ? 173 : 189,
249
- "=": Bt ? 61 : 187,
250
- ";": Bt ? 59 : 186,
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
- }, Ut = {
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
- }, K = {
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
- at["f".concat(t)] = 111 + t;
288
- let I = [], rt = null, be = "all";
289
- const z = /* @__PURE__ */ new Map(), lt = (t) => at[t.toLowerCase()] || H[t.toLowerCase()] || t.toUpperCase().charCodeAt(0), ro = (t) => Object.keys(at).find((e) => at[e] === t), ao = (t) => Object.keys(H).find((e) => H[e] === t);
290
- function we(t) {
291
- be = t || "all";
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 ct() {
294
- return be || "all";
307
+ function dt() {
308
+ return we || "all";
295
309
  }
296
- function co() {
310
+ function ao() {
297
311
  return I.slice(0);
298
312
  }
299
- function lo() {
300
- return I.map((t) => ro(t) || ao(t) || String.fromCharCode(t));
313
+ function co() {
314
+ return I.map((t) => so(t) || ro(t) || String.fromCharCode(t));
301
315
  }
302
- function uo() {
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) => lt(r))
330
+ keys: o.split("+").map((r) => ut(r))
317
331
  });
318
332
  });
319
333
  }), t;
320
334
  }
321
- function fo(t) {
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 ho(t) {
330
- return typeof t == "string" && (t = lt(t)), I.indexOf(t) !== -1;
343
+ function fo(t) {
344
+ return typeof t == "string" && (t = ut(t)), I.indexOf(t) !== -1;
331
345
  }
332
- function po(t, e) {
346
+ function ho(t, e) {
333
347
  let n, o;
334
- t || (t = ct());
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 Dt(r);
356
+ return Xt(r);
343
357
  }) : o++;
344
- ct() === t && we(e || "all");
358
+ dt() === t && Ae(e || "all");
345
359
  }
346
- function go(t) {
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 K) {
350
- K[e] = false;
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 ve(t) {
368
+ function xe(t) {
355
369
  if (typeof t > "u")
356
370
  Object.keys(_).forEach((i) => {
357
- Array.isArray(_[i]) && _[i].forEach((s) => mt(s)), delete _[i];
358
- }), Dt(null);
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 && mt(i);
375
+ i.key && yt(i);
362
376
  });
363
377
  else if (typeof t == "object")
364
- t.key && mt(t);
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 = ""), mt({
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 mt = (t) => {
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
- ye(e).forEach((a) => {
385
- const r = a.split(i), l = r.length, f = r[l - 1], u = f === "*" ? "*" : lt(f);
386
- if (!_[u]) return;
387
- n || (n = ct());
388
- const h = l > 1 ? me(H, r) : [], g = [];
389
- _[u] = _[u].filter((p) => {
390
- const y = (o ? p.method === o : true) && p.scope === n && so(p.mods, h);
391
- return y && g.push(p.element), !y;
392
- }), g.forEach((p) => Dt(p));
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 ee(t, e, n, o) {
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 K)
402
- Object.prototype.hasOwnProperty.call(K, s) && (!K[s] && e.mods.indexOf(+s) > -1 || K[s] && e.mods.indexOf(+s) === -1) && (i = false);
403
- (e.mods.length === 0 && !K[16] && !K[18] && !K[17] && !K[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)));
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 ne(t, e) {
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 = Ut[r];
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 K) {
414
- K[o] = true;
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 K)
420
- Object.prototype.hasOwnProperty.call(K, r) && (K[r] = t[Ut[r]]);
421
- t.getModifierState && !(t.altKey && !t.ctrlKey) && t.getModifierState("AltGraph") && (I.indexOf(17) === -1 && I.push(17), I.indexOf(18) === -1 && I.push(18), K[17] = true, K[18] = true);
422
- const i = ct();
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) && ee(t, n[r], i, e);
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, u = l.key.split(f), h = [];
433
- for (let g = 0; g < u.length; g++)
434
- h.push(lt(u[g]));
435
- h.sort().join("") === I.sort().join("") && ee(t, l, i, e);
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 = ye(t);
441
- let i = [], s = "all", a = document, r = 0, l = false, f = true, u = "+", h = false, g = false;
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 && (h = e.capture), typeof e.splitKey == "string" && (u = e.splitKey), e.single === true && (g = true)), typeof e == "string" && (s = e), g && ve(t, s); r < o.length; r++)
443
- t = o[r].split(u), i = [], t.length > 1 && (i = me(H, t)), t = t[t.length - 1], t = t === "*" ? "*" : lt(t), t in _ || (_[t] = []), _[t].push({
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: u,
465
+ splitKey: h,
452
466
  element: a
453
467
  });
454
468
  if (typeof a < "u" && window) {
455
469
  if (!z.has(a)) {
456
- const p = function() {
457
- let y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
458
- return ne(y, a);
459
- }, v = function() {
460
- let y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
461
- ne(y, a), go(y);
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: p,
465
- keyupListenr: v,
466
- capture: h
467
- }), kt(a, "keydown", p, h), kt(a, "keyup", v, h);
478
+ keydownListener: g,
479
+ keyupListenr: b,
480
+ capture: u
481
+ }), It(a, "keydown", g, u), It(a, "keyup", b, u);
468
482
  }
469
- if (!rt) {
470
- const p = () => {
483
+ if (!ct) {
484
+ const g = () => {
471
485
  I = [];
472
486
  };
473
- rt = {
474
- listener: p,
475
- capture: h
476
- }, kt(window, "focus", p, h);
487
+ ct = {
488
+ listener: g,
489
+ capture: u
490
+ }, It(window, "focus", g, u);
477
491
  }
478
492
  }
479
493
  }
480
- function mo(t) {
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 Dt(t) {
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 && (et(t, "keyup", i, s), et(t, "keydown", o, s), z.delete(t));
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 && (et(i, "keyup", a, r), et(i, "keydown", s, r), z.delete(i));
510
- }), z.clear(), Object.keys(_).forEach((i) => delete _[i]), rt)) {
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
- } = rt;
515
- et(window, "focus", i, s), rt = null;
528
+ } = ct;
529
+ ot(window, "focus", i, s), ct = null;
516
530
  }
517
531
  }
518
- const It = {
519
- getPressedKeyString: lo,
520
- setScope: we,
521
- getScope: ct,
522
- deleteScope: po,
523
- getPressedKeyCodes: co,
524
- getAllKeyCodes: uo,
525
- isPressed: ho,
526
- filter: fo,
527
- trigger: mo,
528
- unbind: ve,
529
- keyMap: at,
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: Ut
545
+ modifierMap: Vt
532
546
  };
533
- for (const t in It)
534
- Object.prototype.hasOwnProperty.call(It, t) && (P[t] = It[t]);
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
- se as NOT_ANNOTATABLE_CLASS,
541
- Z as NOT_ANNOTATABLE_SELECTOR,
554
+ re as NOT_ANNOTATABLE_CLASS,
555
+ tt as NOT_ANNOTATABLE_SELECTOR,
542
556
  Ao as W3CTextFormat,
543
- ke as getQuoteContext,
544
- _t as getRangeAnnotatableContents,
545
- zn as parseW3CTextAnnotation,
546
- Fn as serializeW3CTextAnnotation
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