@recogito/text-annotator 3.0.0-rc.52 → 3.0.0-rc.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/model/w3c/W3CTextFormatAdapter.d.ts +3 -3
- package/dist/src/state/TextAnnotationStore.d.ts +2 -1
- package/dist/src/utils/mergeClientRects.d.ts +1 -0
- package/dist/text-annotator.es.js +402 -396
- 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/package.json +2 -2
|
@@ -139,7 +139,14 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
return i ? o : [...o, n];
|
|
142
|
-
}, []),
|
|
142
|
+
}, []), wo = (t) => ({
|
|
143
|
+
length: t.length,
|
|
144
|
+
item: (e) => t[e],
|
|
145
|
+
[Symbol.iterator]: function* () {
|
|
146
|
+
for (let e = 0; e < this.length; e++)
|
|
147
|
+
yield this.item(e);
|
|
148
|
+
}
|
|
149
|
+
}), Ve = (t, e, n) => {
|
|
143
150
|
const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
|
|
144
151
|
o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
|
|
145
152
|
const s = Nt(o).textContent, a = t.toString(), r = s.length || 0, l = r + a.length;
|
|
@@ -195,7 +202,7 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
|
|
|
195
202
|
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : ce(t.parentElement);
|
|
196
203
|
}, Ke = (t, e) => (n) => {
|
|
197
204
|
const o = typeof n == "string" ? n : n.id, i = (a) => {
|
|
198
|
-
const r = s.getBoundingClientRect(), l = s.clientHeight, f = s.clientWidth, h = a.selector[0].range.getBoundingClientRect(), { width: u, height: p } = e.getAnnotationBounds(o), g = h.top - r.top,
|
|
205
|
+
const r = s.getBoundingClientRect(), l = s.clientHeight, f = s.clientWidth, h = a.selector[0].range.getBoundingClientRect(), { width: u, height: p } = e.getAnnotationBounds(o), g = h.top - r.top, y = h.left - r.left, b = s.parentElement ? s.scrollTop : 0, v = s.parentElement ? s.scrollLeft : 0, d = g + b - (l - p) / 2, c = y + v - (f - u) / 2;
|
|
199
206
|
s.scroll({ top: d, left: c, behavior: "smooth" });
|
|
200
207
|
}, s = ce(t);
|
|
201
208
|
if (s) {
|
|
@@ -232,43 +239,43 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
|
|
|
232
239
|
const { store: i, selection: s, hover: a } = e;
|
|
233
240
|
let r, l, f;
|
|
234
241
|
const h = Pe(n), u = (M) => {
|
|
235
|
-
const { x:
|
|
236
|
-
|
|
242
|
+
const { x: T, y: m } = t.getBoundingClientRect(), x = i.getAt(M.clientX - T, M.clientY - m, !1, l);
|
|
243
|
+
x ? a.current !== x.id && (t.classList.add("hovered"), a.set(x.id)) : a.current && (t.classList.remove("hovered"), a.set(null));
|
|
237
244
|
};
|
|
238
245
|
t.addEventListener("pointermove", u);
|
|
239
246
|
const p = (M = !1) => {
|
|
240
247
|
f && f.clear();
|
|
241
|
-
const
|
|
248
|
+
const T = Xe(t), { minX: m, minY: x, maxX: A, maxY: L } = T, B = l ? i.getIntersecting(m, x, A, L).filter(({ annotation: U }) => l(U)) : i.getIntersecting(m, x, A, L), R = s.selected.map(({ id: U }) => U), N = B.map(({ annotation: U, rects: et }) => {
|
|
242
249
|
const q = R.includes(U.id), Se = U.id === a.current;
|
|
243
250
|
return { annotation: U, rects: et, state: { selected: q, hover: Se } };
|
|
244
251
|
});
|
|
245
|
-
o.redraw(N,
|
|
252
|
+
o.redraw(N, T, r, f, M), setTimeout(() => h(B.map(({ annotation: U }) => U)), 1);
|
|
246
253
|
}, g = (M) => {
|
|
247
254
|
f = M, p();
|
|
248
|
-
},
|
|
255
|
+
}, y = (M) => {
|
|
249
256
|
r = M, p();
|
|
250
|
-
},
|
|
257
|
+
}, b = (M) => {
|
|
251
258
|
l = M, p(!1);
|
|
252
|
-
},
|
|
253
|
-
i.observe(
|
|
259
|
+
}, v = () => p();
|
|
260
|
+
i.observe(v);
|
|
254
261
|
const d = s.subscribe(() => p()), c = () => p(!0);
|
|
255
262
|
document.addEventListener("scroll", c, { capture: !0, passive: !0 });
|
|
256
|
-
const
|
|
263
|
+
const w = Yt(() => {
|
|
257
264
|
i.recalculatePositions(), f && f.reset(), p();
|
|
258
265
|
});
|
|
259
|
-
window.addEventListener("resize",
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
const
|
|
266
|
+
window.addEventListener("resize", w);
|
|
267
|
+
const S = new ResizeObserver(w);
|
|
268
|
+
S.observe(t);
|
|
269
|
+
const E = { attributes: !0, childList: !0, subtree: !0 }, C = new MutationObserver((M) => {
|
|
263
270
|
M.every((m) => m.target === t || t.contains(m.target)) || p(!0);
|
|
264
271
|
});
|
|
265
|
-
return
|
|
272
|
+
return C.observe(document.body, E), {
|
|
266
273
|
destroy: () => {
|
|
267
|
-
t.removeEventListener("pointermove", u), o.destroy(), i.unobserve(
|
|
274
|
+
t.removeEventListener("pointermove", u), o.destroy(), i.unobserve(v), d(), document.removeEventListener("scroll", c), window.removeEventListener("resize", w), S.disconnect(), C.disconnect();
|
|
268
275
|
},
|
|
269
276
|
redraw: p,
|
|
270
|
-
setStyle:
|
|
271
|
-
setFilter:
|
|
277
|
+
setStyle: y,
|
|
278
|
+
setFilter: b,
|
|
272
279
|
setPainter: g,
|
|
273
280
|
setVisible: o.setVisible
|
|
274
281
|
};
|
|
@@ -284,25 +291,25 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
|
|
|
284
291
|
const o = (r, l, f, h) => requestAnimationFrame(() => {
|
|
285
292
|
const { width: u, height: p } = e;
|
|
286
293
|
n.clearRect(-0.5, -0.5, u + 1, p + 1), h && h.clear();
|
|
287
|
-
const { top: g, left:
|
|
288
|
-
[...r].sort((
|
|
289
|
-
const { annotation: { target: { created: c } } } =
|
|
290
|
-
return c.getTime() -
|
|
291
|
-
}).forEach((
|
|
292
|
-
var
|
|
293
|
-
const d = f ? typeof f == "function" ? f(
|
|
294
|
-
x:
|
|
295
|
-
y:
|
|
294
|
+
const { top: g, left: y } = l;
|
|
295
|
+
[...r].sort((v, d) => {
|
|
296
|
+
const { annotation: { target: { created: c } } } = v, { annotation: { target: { created: w } } } = d;
|
|
297
|
+
return c.getTime() - w.getTime();
|
|
298
|
+
}).forEach((v) => {
|
|
299
|
+
var S;
|
|
300
|
+
const d = f ? typeof f == "function" ? f(v.annotation, v.state) : f : (S = v.state) != null && S.selected ? wt : W, c = h && h.paint(v, l) || d, w = v.rects.map(({ x: E, y: C, width: O, height: M }) => ({
|
|
301
|
+
x: E + y,
|
|
302
|
+
y: C + g,
|
|
296
303
|
width: O,
|
|
297
304
|
height: M
|
|
298
305
|
}));
|
|
299
|
-
if (n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1,
|
|
300
|
-
({ x:
|
|
306
|
+
if (n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1, w.forEach(
|
|
307
|
+
({ x: E, y: C, width: O, height: M }) => n.fillRect(E, C, O, M)
|
|
301
308
|
), c.underlineColor) {
|
|
302
309
|
n.globalAlpha = 1, n.strokeStyle = c.underlineColor, n.lineWidth = c.underlineThickness ?? 1;
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
n.beginPath(), n.moveTo(
|
|
310
|
+
const E = c.underlineOffset ?? 0;
|
|
311
|
+
w.forEach(({ x: C, y: O, width: M, height: T }) => {
|
|
312
|
+
n.beginPath(), n.moveTo(C, O + T + E), n.lineTo(C + M, O + T + E), n.stroke();
|
|
306
313
|
});
|
|
307
314
|
}
|
|
308
315
|
});
|
|
@@ -471,13 +478,13 @@ const tn = (t) => [
|
|
|
471
478
|
const f = new Set(s.map((u) => u.annotation.id));
|
|
472
479
|
Array.from(e).filter((u) => !f.has(u));
|
|
473
480
|
const h = s.map((u) => {
|
|
474
|
-
var
|
|
475
|
-
const p = r ? typeof r == "function" ? r(u.annotation, u.state) : r : (
|
|
481
|
+
var y;
|
|
482
|
+
const p = r ? typeof r == "function" ? r(u.annotation, u.state) : r : (y = u.state) != null && y.selected ? wt : W, g = l && l.paint(u, a) || p;
|
|
476
483
|
return `::highlight(_${u.annotation.id}) { ${tn(g)} }`;
|
|
477
484
|
});
|
|
478
485
|
t.innerHTML = h.join(`
|
|
479
486
|
`), CSS.highlights.clear(), s.forEach(({ annotation: u }) => {
|
|
480
|
-
const p = u.target.selector.map((
|
|
487
|
+
const p = u.target.selector.map((y) => y.range), g = new Highlight(...p);
|
|
481
488
|
CSS.highlights.set(`_${u.id}`, g);
|
|
482
489
|
}), e = f;
|
|
483
490
|
}
|
|
@@ -519,15 +526,15 @@ const on = (t, e) => {
|
|
|
519
526
|
redraw: (a, r, l, f, h) => {
|
|
520
527
|
const p = !(Ut(n, a) && h);
|
|
521
528
|
if (!f && !p) return;
|
|
522
|
-
p && (e.innerHTML = ""), [...a].sort((
|
|
523
|
-
const { annotation: { target: { created:
|
|
524
|
-
return
|
|
525
|
-
}).forEach((
|
|
526
|
-
|
|
527
|
-
const
|
|
529
|
+
p && (e.innerHTML = ""), [...a].sort((y, b) => {
|
|
530
|
+
const { annotation: { target: { created: v } } } = y, { annotation: { target: { created: d } } } = b;
|
|
531
|
+
return v && d ? v.getTime() - d.getTime() : 0;
|
|
532
|
+
}).forEach((y) => {
|
|
533
|
+
y.rects.map((b) => {
|
|
534
|
+
const v = on(b, a), d = De(y, r, l, f, v);
|
|
528
535
|
if (p) {
|
|
529
536
|
const c = document.createElement("span");
|
|
530
|
-
c.className = "r6o-annotation", c.dataset.annotation =
|
|
537
|
+
c.className = "r6o-annotation", c.dataset.annotation = y.annotation.id, c.style.left = `${b.x}px`, c.style.top = `${b.y}px`, c.style.width = `${b.width}px`, c.style.height = `${b.height}px`, c.style.backgroundColor = $((d == null ? void 0 : d.fill) || W.fill).alpha((d == null ? void 0 : d.fillOpacity) === void 0 ? W.fillOpacity : d.fillOpacity).toHex(), d.underlineStyle && (c.style.borderStyle = d.underlineStyle), d.underlineColor && (c.style.borderColor = d.underlineColor), d.underlineThickness && (c.style.borderBottomWidth = `${d.underlineThickness}px`), d.underlineOffset && (c.style.paddingBottom = `${d.underlineOffset}px`), e.appendChild(c);
|
|
531
538
|
}
|
|
532
539
|
});
|
|
533
540
|
}), n = a;
|
|
@@ -634,53 +641,53 @@ var hn = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE =
|
|
|
634
641
|
const pt = { selected: [] }, pn = (t, e, n) => {
|
|
635
642
|
const { subscribe: o, set: i } = Dt(pt);
|
|
636
643
|
let s = e, a = pt;
|
|
637
|
-
o((
|
|
644
|
+
o((y) => a = y);
|
|
638
645
|
const r = () => {
|
|
639
646
|
G(a, pt) || i(pt);
|
|
640
647
|
}, l = () => {
|
|
641
|
-
var
|
|
642
|
-
return ((
|
|
643
|
-
}, f = (
|
|
648
|
+
var y;
|
|
649
|
+
return ((y = a.selected) == null ? void 0 : y.length) === 0;
|
|
650
|
+
}, f = (y) => {
|
|
644
651
|
if (l())
|
|
645
652
|
return !1;
|
|
646
|
-
const
|
|
647
|
-
return a.selected.some((
|
|
648
|
-
}, h = (
|
|
649
|
-
let
|
|
650
|
-
if (Array.isArray(
|
|
651
|
-
if (
|
|
652
|
-
console.warn("Invalid selection: " +
|
|
653
|
+
const b = typeof y == "string" ? y : y.id;
|
|
654
|
+
return a.selected.some((v) => v.id === b);
|
|
655
|
+
}, h = (y, b) => {
|
|
656
|
+
let v;
|
|
657
|
+
if (Array.isArray(y)) {
|
|
658
|
+
if (v = y.map((c) => t.getAnnotation(c)).filter(Boolean), v.length < y.length) {
|
|
659
|
+
console.warn("Invalid selection: " + y.filter((c) => !v.some((w) => w.id === c)));
|
|
653
660
|
return;
|
|
654
661
|
}
|
|
655
662
|
} else {
|
|
656
|
-
const c = t.getAnnotation(
|
|
663
|
+
const c = t.getAnnotation(y);
|
|
657
664
|
if (!c) {
|
|
658
|
-
console.warn("Invalid selection: " +
|
|
665
|
+
console.warn("Invalid selection: " + y);
|
|
659
666
|
return;
|
|
660
667
|
}
|
|
661
|
-
|
|
668
|
+
v = [c];
|
|
662
669
|
}
|
|
663
|
-
const d =
|
|
664
|
-
const
|
|
665
|
-
return
|
|
670
|
+
const d = v.reduce((c, w) => {
|
|
671
|
+
const S = Zt(w, s);
|
|
672
|
+
return S === "EDIT" ? [...c, { id: w.id, editable: !0 }] : S === "SELECT" ? [...c, { id: w.id }] : c;
|
|
666
673
|
}, []);
|
|
667
|
-
i({ selected: d, event:
|
|
668
|
-
}, u = (
|
|
669
|
-
const
|
|
674
|
+
i({ selected: d, event: b });
|
|
675
|
+
}, u = (y, b) => {
|
|
676
|
+
const v = Array.isArray(y) ? y : [y], d = v.map((c) => t.getAnnotation(c)).filter((c) => !!c);
|
|
670
677
|
i({
|
|
671
678
|
selected: d.map((c) => {
|
|
672
|
-
const
|
|
673
|
-
return { id: c.id, editable:
|
|
679
|
+
const w = b === void 0 ? Zt(c, s) === "EDIT" : b;
|
|
680
|
+
return { id: c.id, editable: w };
|
|
674
681
|
})
|
|
675
|
-
}), d.length !==
|
|
676
|
-
}, p = (
|
|
682
|
+
}), d.length !== v.length && console.warn("Invalid selection", y);
|
|
683
|
+
}, p = (y) => {
|
|
677
684
|
if (l())
|
|
678
685
|
return !1;
|
|
679
|
-
const { selected:
|
|
680
|
-
|
|
681
|
-
}, g = (
|
|
686
|
+
const { selected: b } = a;
|
|
687
|
+
b.some(({ id: v }) => y.includes(v)) && i({ selected: b.filter(({ id: v }) => !y.includes(v)) });
|
|
688
|
+
}, g = (y) => s = y;
|
|
682
689
|
return t.observe(
|
|
683
|
-
({ changes:
|
|
690
|
+
({ changes: y }) => p((y.deleted || []).map((b) => b.id))
|
|
684
691
|
), {
|
|
685
692
|
get event() {
|
|
686
693
|
return a ? a.event : null;
|
|
@@ -733,7 +740,7 @@ const Ot = (t) => {
|
|
|
733
740
|
bodies: (t.bodies || []).map(e),
|
|
734
741
|
target: e(t.target)
|
|
735
742
|
};
|
|
736
|
-
},
|
|
743
|
+
}, Ao = (t, e, n, o) => ({
|
|
737
744
|
id: he(),
|
|
738
745
|
annotation: typeof t == "string" ? t : t.id,
|
|
739
746
|
created: n || /* @__PURE__ */ new Date(),
|
|
@@ -793,8 +800,8 @@ const En = (t, e) => {
|
|
|
793
800
|
...(t.updated || []).filter(({ newValue: u }) => !s.has(u.id)).map((u) => {
|
|
794
801
|
const { oldValue: p, newValue: g } = u;
|
|
795
802
|
if (a.has(g.id)) {
|
|
796
|
-
const
|
|
797
|
-
return pe(p,
|
|
803
|
+
const y = e.updated.find((b) => b.oldValue.id === g.id).newValue;
|
|
804
|
+
return pe(p, y);
|
|
798
805
|
} else
|
|
799
806
|
return u;
|
|
800
807
|
}),
|
|
@@ -816,71 +823,71 @@ const En = (t, e) => {
|
|
|
816
823
|
}
|
|
817
824
|
};
|
|
818
825
|
}, Cn = (t) => t.id !== void 0, Ln = () => {
|
|
819
|
-
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (m,
|
|
820
|
-
n.push({ onChange: m, options:
|
|
826
|
+
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (m, x = {}) => {
|
|
827
|
+
n.push({ onChange: m, options: x });
|
|
821
828
|
}, i = (m) => {
|
|
822
|
-
const
|
|
823
|
-
|
|
824
|
-
}, s = (m,
|
|
825
|
-
const
|
|
829
|
+
const x = n.findIndex((A) => A.onChange == m);
|
|
830
|
+
x > -1 && n.splice(x, 1);
|
|
831
|
+
}, s = (m, x) => {
|
|
832
|
+
const A = {
|
|
826
833
|
origin: m,
|
|
827
834
|
changes: {
|
|
828
|
-
created:
|
|
829
|
-
updated:
|
|
830
|
-
deleted:
|
|
835
|
+
created: x.created || [],
|
|
836
|
+
updated: x.updated || [],
|
|
837
|
+
deleted: x.deleted || []
|
|
831
838
|
},
|
|
832
839
|
state: [...t.values()]
|
|
833
840
|
};
|
|
834
|
-
n.forEach((
|
|
835
|
-
En(
|
|
841
|
+
n.forEach((L) => {
|
|
842
|
+
En(L, A) && L.onChange(A);
|
|
836
843
|
});
|
|
837
|
-
}, a = (m,
|
|
844
|
+
}, a = (m, x = k.LOCAL) => {
|
|
838
845
|
if (m.id && t.get(m.id))
|
|
839
846
|
throw Error(`Cannot add annotation ${m.id} - exists already`);
|
|
840
847
|
{
|
|
841
|
-
const
|
|
842
|
-
t.set(
|
|
848
|
+
const A = Mt(m);
|
|
849
|
+
t.set(A.id, A), A.bodies.forEach((L) => e.set(L.id, A.id)), s(x, { created: [A] });
|
|
843
850
|
}
|
|
844
|
-
}, r = (m,
|
|
845
|
-
const
|
|
851
|
+
}, r = (m, x) => {
|
|
852
|
+
const A = Mt(typeof m == "string" ? x : m), L = typeof m == "string" ? m : m.id, B = L && t.get(L);
|
|
846
853
|
if (B) {
|
|
847
|
-
const R = pe(B,
|
|
848
|
-
return
|
|
854
|
+
const R = pe(B, A);
|
|
855
|
+
return L === A.id ? t.set(L, A) : (t.delete(L), t.set(A.id, A)), B.bodies.forEach((N) => e.delete(N.id)), A.bodies.forEach((N) => e.set(N.id, A.id)), R;
|
|
849
856
|
} else
|
|
850
|
-
console.warn(`Cannot update annotation ${
|
|
851
|
-
}, l = (m,
|
|
852
|
-
const
|
|
853
|
-
B && s(
|
|
854
|
-
}, f = (m,
|
|
855
|
-
const
|
|
857
|
+
console.warn(`Cannot update annotation ${L} - does not exist`);
|
|
858
|
+
}, l = (m, x = k.LOCAL, A = k.LOCAL) => {
|
|
859
|
+
const L = Cn(x) ? A : x, B = r(m, x);
|
|
860
|
+
B && s(L, { updated: [B] });
|
|
861
|
+
}, f = (m, x = k.LOCAL) => {
|
|
862
|
+
const A = m.reduce((L, B) => {
|
|
856
863
|
const R = r(B);
|
|
857
|
-
return R ? [...
|
|
864
|
+
return R ? [...L, R] : L;
|
|
858
865
|
}, []);
|
|
859
|
-
|
|
860
|
-
}, h = (m,
|
|
861
|
-
const
|
|
862
|
-
if (
|
|
863
|
-
const
|
|
864
|
-
...
|
|
865
|
-
bodies: [...
|
|
866
|
+
A.length > 0 && s(x, { updated: A });
|
|
867
|
+
}, h = (m, x = k.LOCAL) => {
|
|
868
|
+
const A = t.get(m.annotation);
|
|
869
|
+
if (A) {
|
|
870
|
+
const L = {
|
|
871
|
+
...A,
|
|
872
|
+
bodies: [...A.bodies, m]
|
|
866
873
|
};
|
|
867
|
-
t.set(
|
|
868
|
-
oldValue:
|
|
869
|
-
newValue:
|
|
874
|
+
t.set(A.id, L), e.set(m.id, L.id), s(x, { updated: [{
|
|
875
|
+
oldValue: A,
|
|
876
|
+
newValue: L,
|
|
870
877
|
bodiesCreated: [m]
|
|
871
878
|
}] });
|
|
872
879
|
} else
|
|
873
880
|
console.warn(`Attempt to add body to missing annotation: ${m.annotation}`);
|
|
874
881
|
}, u = () => [...t.values()], p = (m = k.LOCAL) => {
|
|
875
|
-
const
|
|
876
|
-
t.clear(), e.clear(), s(m, { deleted:
|
|
877
|
-
}, g = (m,
|
|
878
|
-
const
|
|
879
|
-
if (
|
|
882
|
+
const x = [...t.values()];
|
|
883
|
+
t.clear(), e.clear(), s(m, { deleted: x });
|
|
884
|
+
}, g = (m, x = !0, A = k.LOCAL) => {
|
|
885
|
+
const L = m.map(Mt);
|
|
886
|
+
if (x) {
|
|
880
887
|
const B = [...t.values()];
|
|
881
|
-
t.clear(), e.clear(),
|
|
888
|
+
t.clear(), e.clear(), L.forEach((R) => {
|
|
882
889
|
t.set(R.id, R), R.bodies.forEach((N) => e.set(N.id, R.id));
|
|
883
|
-
}), s(
|
|
890
|
+
}), s(A, { created: L, deleted: B });
|
|
884
891
|
} else {
|
|
885
892
|
const B = m.reduce((R, N) => {
|
|
886
893
|
const U = N.id && t.get(N.id);
|
|
@@ -888,98 +895,98 @@ const En = (t, e) => {
|
|
|
888
895
|
}, []);
|
|
889
896
|
if (B.length > 0)
|
|
890
897
|
throw Error(`Bulk insert would overwrite the following annotations: ${B.map((R) => R.id).join(", ")}`);
|
|
891
|
-
|
|
898
|
+
L.forEach((R) => {
|
|
892
899
|
t.set(R.id, R), R.bodies.forEach((N) => e.set(N.id, R.id));
|
|
893
|
-
}), s(
|
|
900
|
+
}), s(A, { created: L });
|
|
894
901
|
}
|
|
895
|
-
},
|
|
896
|
-
const
|
|
897
|
-
if (
|
|
898
|
-
return t.delete(
|
|
899
|
-
console.warn(`Attempt to delete missing annotation: ${
|
|
900
|
-
},
|
|
901
|
-
const
|
|
902
|
-
|
|
903
|
-
},
|
|
904
|
-
const
|
|
905
|
-
const R =
|
|
906
|
-
return R ? [...
|
|
902
|
+
}, y = (m) => {
|
|
903
|
+
const x = typeof m == "string" ? m : m.id, A = t.get(x);
|
|
904
|
+
if (A)
|
|
905
|
+
return t.delete(x), A.bodies.forEach((L) => e.delete(L.id)), A;
|
|
906
|
+
console.warn(`Attempt to delete missing annotation: ${x}`);
|
|
907
|
+
}, b = (m, x = k.LOCAL) => {
|
|
908
|
+
const A = y(m);
|
|
909
|
+
A && s(x, { deleted: [A] });
|
|
910
|
+
}, v = (m, x = k.LOCAL) => {
|
|
911
|
+
const A = m.reduce((L, B) => {
|
|
912
|
+
const R = y(B);
|
|
913
|
+
return R ? [...L, R] : L;
|
|
907
914
|
}, []);
|
|
908
|
-
|
|
915
|
+
A.length > 0 && s(x, { deleted: A });
|
|
909
916
|
}, d = (m) => {
|
|
910
|
-
const
|
|
911
|
-
if (
|
|
912
|
-
const
|
|
913
|
-
if (
|
|
914
|
-
e.delete(
|
|
915
|
-
const
|
|
916
|
-
...
|
|
917
|
-
bodies:
|
|
917
|
+
const x = t.get(m.annotation);
|
|
918
|
+
if (x) {
|
|
919
|
+
const A = x.bodies.find((L) => L.id === m.id);
|
|
920
|
+
if (A) {
|
|
921
|
+
e.delete(A.id);
|
|
922
|
+
const L = {
|
|
923
|
+
...x,
|
|
924
|
+
bodies: x.bodies.filter((B) => B.id !== m.id)
|
|
918
925
|
};
|
|
919
|
-
return t.set(
|
|
920
|
-
oldValue:
|
|
921
|
-
newValue:
|
|
922
|
-
bodiesDeleted: [
|
|
926
|
+
return t.set(x.id, L), {
|
|
927
|
+
oldValue: x,
|
|
928
|
+
newValue: L,
|
|
929
|
+
bodiesDeleted: [A]
|
|
923
930
|
};
|
|
924
931
|
} else
|
|
925
932
|
console.warn(`Attempt to delete missing body ${m.id} from annotation ${m.annotation}`);
|
|
926
933
|
} else
|
|
927
934
|
console.warn(`Attempt to delete body from missing annotation ${m.annotation}`);
|
|
928
|
-
}, c = (m,
|
|
929
|
-
const
|
|
930
|
-
|
|
931
|
-
},
|
|
932
|
-
const
|
|
933
|
-
|
|
935
|
+
}, c = (m, x = k.LOCAL) => {
|
|
936
|
+
const A = d(m);
|
|
937
|
+
A && s(x, { updated: [A] });
|
|
938
|
+
}, w = (m, x = k.LOCAL) => {
|
|
939
|
+
const A = m.map((L) => d(L)).filter(Boolean);
|
|
940
|
+
A.length > 0 && s(x, { updated: A });
|
|
941
|
+
}, S = (m) => {
|
|
942
|
+
const x = t.get(m);
|
|
943
|
+
return x ? { ...x } : void 0;
|
|
934
944
|
}, E = (m) => {
|
|
935
|
-
const
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
const x = E(v).bodies.find((C) => C.id === m);
|
|
941
|
-
if (x)
|
|
942
|
-
return x;
|
|
945
|
+
const x = e.get(m);
|
|
946
|
+
if (x) {
|
|
947
|
+
const A = S(x).bodies.find((L) => L.id === m);
|
|
948
|
+
if (A)
|
|
949
|
+
return A;
|
|
943
950
|
console.error(`Store integrity error: body ${m} in index, but not in annotation`);
|
|
944
951
|
} else
|
|
945
952
|
console.warn(`Attempt to retrieve missing body: ${m}`);
|
|
946
|
-
},
|
|
947
|
-
if (m.annotation !==
|
|
953
|
+
}, C = (m, x) => {
|
|
954
|
+
if (m.annotation !== x.annotation)
|
|
948
955
|
throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
|
|
949
|
-
const
|
|
950
|
-
if (
|
|
951
|
-
const
|
|
952
|
-
...
|
|
953
|
-
bodies:
|
|
956
|
+
const A = t.get(m.annotation);
|
|
957
|
+
if (A) {
|
|
958
|
+
const L = A.bodies.find((R) => R.id === m.id), B = {
|
|
959
|
+
...A,
|
|
960
|
+
bodies: A.bodies.map((R) => R.id === L.id ? x : R)
|
|
954
961
|
};
|
|
955
|
-
return t.set(
|
|
956
|
-
oldValue:
|
|
962
|
+
return t.set(A.id, B), L.id !== x.id && (e.delete(L.id), e.set(x.id, B.id)), {
|
|
963
|
+
oldValue: A,
|
|
957
964
|
newValue: B,
|
|
958
|
-
bodiesUpdated: [{ oldBody:
|
|
965
|
+
bodiesUpdated: [{ oldBody: L, newBody: x }]
|
|
959
966
|
};
|
|
960
967
|
} else
|
|
961
968
|
console.warn(`Attempt to add body to missing annotation ${m.annotation}`);
|
|
962
|
-
}, O = (m,
|
|
963
|
-
const
|
|
964
|
-
|
|
965
|
-
}, M = (m,
|
|
966
|
-
const
|
|
967
|
-
s(
|
|
968
|
-
},
|
|
969
|
-
const
|
|
970
|
-
if (
|
|
971
|
-
const
|
|
972
|
-
...
|
|
969
|
+
}, O = (m, x, A = k.LOCAL) => {
|
|
970
|
+
const L = C(m, x);
|
|
971
|
+
L && s(A, { updated: [L] });
|
|
972
|
+
}, M = (m, x = k.LOCAL) => {
|
|
973
|
+
const A = m.map((L) => C({ id: L.id, annotation: L.annotation }, L)).filter(Boolean);
|
|
974
|
+
s(x, { updated: A });
|
|
975
|
+
}, T = (m) => {
|
|
976
|
+
const x = t.get(m.annotation);
|
|
977
|
+
if (x) {
|
|
978
|
+
const A = {
|
|
979
|
+
...x,
|
|
973
980
|
target: {
|
|
974
|
-
...
|
|
981
|
+
...x.target,
|
|
975
982
|
...m
|
|
976
983
|
}
|
|
977
984
|
};
|
|
978
|
-
return t.set(
|
|
979
|
-
oldValue:
|
|
980
|
-
newValue:
|
|
985
|
+
return t.set(x.id, A), {
|
|
986
|
+
oldValue: x,
|
|
987
|
+
newValue: A,
|
|
981
988
|
targetUpdated: {
|
|
982
|
-
oldTarget:
|
|
989
|
+
oldTarget: x.target,
|
|
983
990
|
newTarget: m
|
|
984
991
|
}
|
|
985
992
|
};
|
|
@@ -991,26 +998,26 @@ const En = (t, e) => {
|
|
|
991
998
|
addBody: h,
|
|
992
999
|
all: u,
|
|
993
1000
|
bulkAddAnnotation: g,
|
|
994
|
-
bulkDeleteAnnotation:
|
|
995
|
-
bulkDeleteBodies:
|
|
1001
|
+
bulkDeleteAnnotation: v,
|
|
1002
|
+
bulkDeleteBodies: w,
|
|
996
1003
|
bulkUpdateAnnotation: f,
|
|
997
1004
|
bulkUpdateBodies: M,
|
|
998
|
-
bulkUpdateTargets: (m,
|
|
999
|
-
const
|
|
1000
|
-
|
|
1005
|
+
bulkUpdateTargets: (m, x = k.LOCAL) => {
|
|
1006
|
+
const A = m.map((L) => T(L)).filter(Boolean);
|
|
1007
|
+
A.length > 0 && s(x, { updated: A });
|
|
1001
1008
|
},
|
|
1002
1009
|
clear: p,
|
|
1003
|
-
deleteAnnotation:
|
|
1010
|
+
deleteAnnotation: b,
|
|
1004
1011
|
deleteBody: c,
|
|
1005
|
-
getAnnotation:
|
|
1006
|
-
getBody:
|
|
1012
|
+
getAnnotation: S,
|
|
1013
|
+
getBody: E,
|
|
1007
1014
|
observe: o,
|
|
1008
1015
|
unobserve: i,
|
|
1009
1016
|
updateAnnotation: l,
|
|
1010
1017
|
updateBody: O,
|
|
1011
|
-
updateTarget: (m,
|
|
1012
|
-
const
|
|
1013
|
-
|
|
1018
|
+
updateTarget: (m, x = k.LOCAL) => {
|
|
1019
|
+
const A = T(m);
|
|
1020
|
+
A && s(x, { updated: [A] });
|
|
1014
1021
|
}
|
|
1015
1022
|
};
|
|
1016
1023
|
};
|
|
@@ -1033,36 +1040,36 @@ const On = 250, Mn = (t) => {
|
|
|
1033
1040
|
let o = -1, i = !1, s = 0;
|
|
1034
1041
|
const a = (g) => {
|
|
1035
1042
|
if (!i) {
|
|
1036
|
-
const { changes:
|
|
1037
|
-
if (
|
|
1038
|
-
n.splice(o + 1), n.push(
|
|
1043
|
+
const { changes: y } = g, b = performance.now();
|
|
1044
|
+
if (b - s > On)
|
|
1045
|
+
n.splice(o + 1), n.push(y), o = n.length - 1;
|
|
1039
1046
|
else {
|
|
1040
|
-
const
|
|
1041
|
-
n[
|
|
1047
|
+
const v = n.length - 1;
|
|
1048
|
+
n[v] = Sn(n[v], y);
|
|
1042
1049
|
}
|
|
1043
|
-
s =
|
|
1050
|
+
s = b;
|
|
1044
1051
|
}
|
|
1045
1052
|
i = !1;
|
|
1046
1053
|
};
|
|
1047
1054
|
t.observe(a, { origin: k.LOCAL });
|
|
1048
|
-
const r = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g), l = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), f = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ oldValue:
|
|
1055
|
+
const r = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g), l = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), f = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ oldValue: y }) => y)), h = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ newValue: y }) => y)), u = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), p = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g);
|
|
1049
1056
|
return {
|
|
1050
1057
|
canRedo: () => n.length - 1 > o,
|
|
1051
1058
|
canUndo: () => o > -1,
|
|
1052
1059
|
destroy: () => t.unobserve(a),
|
|
1053
|
-
on: (g,
|
|
1060
|
+
on: (g, y) => e.on(g, y),
|
|
1054
1061
|
redo: () => {
|
|
1055
1062
|
if (n.length - 1 > o) {
|
|
1056
1063
|
i = !0;
|
|
1057
|
-
const { created: g, updated:
|
|
1058
|
-
l(g), h(
|
|
1064
|
+
const { created: g, updated: y, deleted: b } = n[o + 1];
|
|
1065
|
+
l(g), h(y), p(b), e.emit("redo", n[o + 1]), o += 1;
|
|
1059
1066
|
}
|
|
1060
1067
|
},
|
|
1061
1068
|
undo: () => {
|
|
1062
1069
|
if (o > -1) {
|
|
1063
1070
|
i = !0;
|
|
1064
|
-
const { created: g, updated:
|
|
1065
|
-
r(g), f(
|
|
1071
|
+
const { created: g, updated: y, deleted: b } = n[o];
|
|
1072
|
+
r(g), f(y), u(b), e.emit("undo", n[o]), o -= 1;
|
|
1066
1073
|
}
|
|
1067
1074
|
}
|
|
1068
1075
|
};
|
|
@@ -1075,71 +1082,71 @@ const On = 250, Mn = (t) => {
|
|
|
1075
1082
|
}, Rn = (t, e, n, o) => {
|
|
1076
1083
|
const { hover: i, selection: s, store: a, viewport: r } = t, l = /* @__PURE__ */ new Map();
|
|
1077
1084
|
let f = [], h;
|
|
1078
|
-
const u = (
|
|
1079
|
-
l.has(
|
|
1080
|
-
}, p = (
|
|
1081
|
-
const d = l.get(
|
|
1085
|
+
const u = (b, v) => {
|
|
1086
|
+
l.has(b) ? l.get(b).push(v) : l.set(b, [v]);
|
|
1087
|
+
}, p = (b, v) => {
|
|
1088
|
+
const d = l.get(b);
|
|
1082
1089
|
if (d) {
|
|
1083
|
-
const c = d.indexOf(
|
|
1090
|
+
const c = d.indexOf(v);
|
|
1084
1091
|
c !== -1 && d.splice(c, 1);
|
|
1085
1092
|
}
|
|
1086
|
-
}, g = (
|
|
1087
|
-
l.has(
|
|
1088
|
-
l.get(
|
|
1093
|
+
}, g = (b, v, d) => {
|
|
1094
|
+
l.has(b) && setTimeout(() => {
|
|
1095
|
+
l.get(b).forEach((c) => {
|
|
1089
1096
|
if (n) {
|
|
1090
|
-
const
|
|
1091
|
-
c(
|
|
1097
|
+
const w = Array.isArray(v) ? v.map((E) => n.serialize(E)) : n.serialize(v), S = d ? d instanceof PointerEvent ? d : n.serialize(d) : void 0;
|
|
1098
|
+
c(w, S);
|
|
1092
1099
|
} else
|
|
1093
|
-
c(
|
|
1100
|
+
c(v, d);
|
|
1094
1101
|
});
|
|
1095
1102
|
}, 1);
|
|
1096
1103
|
};
|
|
1097
|
-
s.subscribe(({ selected:
|
|
1098
|
-
if (!(f.length === 0 &&
|
|
1099
|
-
if (f.length === 0 &&
|
|
1100
|
-
f =
|
|
1101
|
-
else if (f.length > 0 &&
|
|
1102
|
-
f.forEach((
|
|
1103
|
-
const d = a.getAnnotation(
|
|
1104
|
-
d && !G(d,
|
|
1104
|
+
s.subscribe(({ selected: b }) => {
|
|
1105
|
+
if (!(f.length === 0 && b.length === 0)) {
|
|
1106
|
+
if (f.length === 0 && b.length > 0)
|
|
1107
|
+
f = b.map(({ id: v }) => a.getAnnotation(v));
|
|
1108
|
+
else if (f.length > 0 && b.length === 0)
|
|
1109
|
+
f.forEach((v) => {
|
|
1110
|
+
const d = a.getAnnotation(v.id);
|
|
1111
|
+
d && !G(d, v) && g("updateAnnotation", d, v);
|
|
1105
1112
|
}), f = [];
|
|
1106
1113
|
else {
|
|
1107
|
-
const
|
|
1114
|
+
const v = new Set(f.map((c) => c.id)), d = new Set(b.map(({ id: c }) => c));
|
|
1108
1115
|
f.filter((c) => !d.has(c.id)).forEach((c) => {
|
|
1109
|
-
const
|
|
1110
|
-
|
|
1116
|
+
const w = a.getAnnotation(c.id);
|
|
1117
|
+
w && !G(w, c) && g("updateAnnotation", w, c);
|
|
1111
1118
|
}), f = [
|
|
1112
1119
|
// Remove annotations that were deselected
|
|
1113
1120
|
...f.filter((c) => d.has(c.id)),
|
|
1114
1121
|
// Add editable annotations that were selected
|
|
1115
|
-
...
|
|
1122
|
+
...b.filter(({ id: c }) => !v.has(c)).map(({ id: c }) => a.getAnnotation(c))
|
|
1116
1123
|
];
|
|
1117
1124
|
}
|
|
1118
1125
|
g("selectionChanged", f);
|
|
1119
1126
|
}
|
|
1120
|
-
}), i.subscribe((
|
|
1121
|
-
!h &&
|
|
1122
|
-
}), r == null || r.subscribe((
|
|
1123
|
-
const { created:
|
|
1124
|
-
(
|
|
1127
|
+
}), i.subscribe((b) => {
|
|
1128
|
+
!h && b ? g("mouseEnterAnnotation", a.getAnnotation(b)) : h && !b ? g("mouseLeaveAnnotation", a.getAnnotation(h)) : h && b && (g("mouseLeaveAnnotation", a.getAnnotation(h)), g("mouseEnterAnnotation", a.getAnnotation(b))), h = b;
|
|
1129
|
+
}), r == null || r.subscribe((b) => g("viewportIntersect", b.map((v) => a.getAnnotation(v)))), a.observe((b) => {
|
|
1130
|
+
const { created: v, deleted: d } = b.changes;
|
|
1131
|
+
(v || []).forEach((c) => g("createAnnotation", c)), (d || []).forEach((c) => g("deleteAnnotation", c)), (b.changes.updated || []).filter((c) => [
|
|
1125
1132
|
...c.bodiesCreated || [],
|
|
1126
1133
|
...c.bodiesDeleted || [],
|
|
1127
1134
|
...c.bodiesUpdated || []
|
|
1128
|
-
].length > 0).forEach(({ oldValue: c, newValue:
|
|
1129
|
-
const
|
|
1130
|
-
f = f.map((
|
|
1135
|
+
].length > 0).forEach(({ oldValue: c, newValue: w }) => {
|
|
1136
|
+
const S = f.find((E) => E.id === c.id) || c;
|
|
1137
|
+
f = f.map((E) => E.id === c.id ? w : E), g("updateAnnotation", w, S);
|
|
1131
1138
|
});
|
|
1132
|
-
}, { origin: k.LOCAL }), a.observe((
|
|
1139
|
+
}, { origin: k.LOCAL }), a.observe((b) => {
|
|
1133
1140
|
if (f) {
|
|
1134
|
-
const
|
|
1135
|
-
d.length > 0 && (f = f.map((c) => d.find((
|
|
1141
|
+
const v = new Set(f.map((c) => c.id)), d = (b.changes.updated || []).filter(({ newValue: c }) => v.has(c.id)).map(({ newValue: c }) => c);
|
|
1142
|
+
d.length > 0 && (f = f.map((c) => d.find((S) => S.id === c.id) || c));
|
|
1136
1143
|
}
|
|
1137
1144
|
}, { origin: k.REMOTE });
|
|
1138
|
-
const
|
|
1139
|
-
const { updated: d } =
|
|
1140
|
-
|
|
1145
|
+
const y = (b) => (v) => {
|
|
1146
|
+
const { updated: d } = v;
|
|
1147
|
+
b ? (d || []).forEach((c) => g("updateAnnotation", c.oldValue, c.newValue)) : (d || []).forEach((c) => g("updateAnnotation", c.newValue, c.oldValue));
|
|
1141
1148
|
};
|
|
1142
|
-
return e.on("undo",
|
|
1149
|
+
return e.on("undo", y(!0)), e.on("redo", y(!1)), { on: u, off: p, emit: g };
|
|
1143
1150
|
}, kn = (t) => (e) => e.reduce((n, o) => {
|
|
1144
1151
|
const { parsed: i, error: s } = t.parse(o);
|
|
1145
1152
|
return s ? {
|
|
@@ -1154,8 +1161,8 @@ const On = 250, Mn = (t) => {
|
|
|
1154
1161
|
}, { parsed: [], failed: [] }), In = (t, e, n) => {
|
|
1155
1162
|
const { store: o, selection: i } = t, s = (d) => {
|
|
1156
1163
|
if (n) {
|
|
1157
|
-
const { parsed: c, error:
|
|
1158
|
-
c ? o.addAnnotation(c, k.REMOTE) : console.error(
|
|
1164
|
+
const { parsed: c, error: w } = n.parse(d);
|
|
1165
|
+
c ? o.addAnnotation(c, k.REMOTE) : console.error(w);
|
|
1159
1166
|
} else
|
|
1160
1167
|
o.addAnnotation(Ot(d), k.REMOTE);
|
|
1161
1168
|
}, a = () => i.clear(), r = () => o.clear(), l = (d) => {
|
|
@@ -1163,9 +1170,9 @@ const On = 250, Mn = (t) => {
|
|
|
1163
1170
|
return n && c ? n.serialize(c) : c;
|
|
1164
1171
|
}, f = () => n ? o.all().map(n.serialize) : o.all(), h = () => {
|
|
1165
1172
|
var d;
|
|
1166
|
-
const c = (((d = i.selected) == null ? void 0 : d.map((
|
|
1173
|
+
const c = (((d = i.selected) == null ? void 0 : d.map((w) => w.id)) || []).map((w) => o.getAnnotation(w)).filter(Boolean);
|
|
1167
1174
|
return n ? c.map(n.serialize) : c;
|
|
1168
|
-
}, u = (d, c = !0) => fetch(d).then((
|
|
1175
|
+
}, u = (d, c = !0) => fetch(d).then((w) => w.json()).then((w) => (g(w, c), w)), p = (d) => {
|
|
1169
1176
|
if (typeof d == "string") {
|
|
1170
1177
|
const c = o.getAnnotation(d);
|
|
1171
1178
|
if (o.deleteAnnotation(d), c)
|
|
@@ -1177,18 +1184,18 @@ const On = 250, Mn = (t) => {
|
|
|
1177
1184
|
}
|
|
1178
1185
|
}, g = (d, c = !0) => {
|
|
1179
1186
|
if (n) {
|
|
1180
|
-
const
|
|
1181
|
-
|
|
1187
|
+
const w = n.parseAll || kn(n), { parsed: S, failed: E } = w(d);
|
|
1188
|
+
E.length > 0 && console.warn(`Discarded ${E.length} invalid annotations`, E), o.bulkAddAnnotation(S, c, k.REMOTE);
|
|
1182
1189
|
} else
|
|
1183
1190
|
o.bulkAddAnnotation(d.map(Ot), c, k.REMOTE);
|
|
1184
|
-
},
|
|
1191
|
+
}, y = (d, c) => {
|
|
1185
1192
|
d ? i.setSelected(d, c) : i.clear();
|
|
1186
|
-
},
|
|
1193
|
+
}, b = (d) => {
|
|
1187
1194
|
i.clear(), i.setUserSelectAction(d);
|
|
1188
|
-
},
|
|
1195
|
+
}, v = (d) => {
|
|
1189
1196
|
if (n) {
|
|
1190
|
-
const c = n.parse(d).parsed,
|
|
1191
|
-
return o.updateAnnotation(c),
|
|
1197
|
+
const c = n.parse(d).parsed, w = n.serialize(o.getAnnotation(c.id));
|
|
1198
|
+
return o.updateAnnotation(c), w;
|
|
1192
1199
|
} else {
|
|
1193
1200
|
const c = o.getAnnotation(d.id);
|
|
1194
1201
|
return o.updateAnnotation(Ot(d)), c;
|
|
@@ -1207,10 +1214,10 @@ const On = 250, Mn = (t) => {
|
|
|
1207
1214
|
redo: e.redo,
|
|
1208
1215
|
removeAnnotation: p,
|
|
1209
1216
|
setAnnotations: g,
|
|
1210
|
-
setSelected:
|
|
1211
|
-
setUserSelectAction:
|
|
1217
|
+
setSelected: y,
|
|
1218
|
+
setUserSelectAction: b,
|
|
1212
1219
|
undo: e.undo,
|
|
1213
|
-
updateAnnotation:
|
|
1220
|
+
updateAnnotation: v
|
|
1214
1221
|
};
|
|
1215
1222
|
}, _n = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
1216
1223
|
let Nn = (t) => crypto.getRandomValues(new Uint8Array(t)), Un = (t, e, n) => {
|
|
@@ -1260,7 +1267,7 @@ const Kn = () => ({ isGuest: !0, id: Vn("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1260
1267
|
return (n = r.id) != null && n.startsWith("temp-") && delete r.id, r;
|
|
1261
1268
|
});
|
|
1262
1269
|
Yn();
|
|
1263
|
-
const
|
|
1270
|
+
const xo = (t, e) => ({
|
|
1264
1271
|
parse: (n) => jn(n),
|
|
1265
1272
|
serialize: (n) => zn(n, t, e)
|
|
1266
1273
|
}), $n = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, Hn = (t) => {
|
|
@@ -1336,15 +1343,15 @@ const Ao = (t, e) => ({
|
|
|
1336
1343
|
updated: f,
|
|
1337
1344
|
...h
|
|
1338
1345
|
} = i, u = a.map((p) => {
|
|
1339
|
-
const { id: g, quote:
|
|
1346
|
+
const { id: g, quote: y, start: b, end: v, range: d } = p, { prefix: c, suffix: w } = Re(d, n), S = [{
|
|
1340
1347
|
type: "TextQuoteSelector",
|
|
1341
|
-
exact:
|
|
1348
|
+
exact: y,
|
|
1342
1349
|
prefix: c,
|
|
1343
|
-
suffix:
|
|
1350
|
+
suffix: w
|
|
1344
1351
|
}, {
|
|
1345
1352
|
type: "TextPositionSelector",
|
|
1346
|
-
start:
|
|
1347
|
-
end:
|
|
1353
|
+
start: b,
|
|
1354
|
+
end: v
|
|
1348
1355
|
}];
|
|
1349
1356
|
return {
|
|
1350
1357
|
...h,
|
|
@@ -1352,7 +1359,7 @@ const Ao = (t, e) => ({
|
|
|
1352
1359
|
// @ts-expect-error: `scope` is not part of the core `TextSelector` type
|
|
1353
1360
|
scope: "scope" in p ? p.scope : void 0,
|
|
1354
1361
|
source: e,
|
|
1355
|
-
selector:
|
|
1362
|
+
selector: S
|
|
1356
1363
|
};
|
|
1357
1364
|
});
|
|
1358
1365
|
return {
|
|
@@ -1370,8 +1377,8 @@ const Ao = (t, e) => ({
|
|
|
1370
1377
|
function me(t, e, n = 0, o = t.length - 1, i = Fn) {
|
|
1371
1378
|
for (; o > n; ) {
|
|
1372
1379
|
if (o - n > 600) {
|
|
1373
|
-
const l = o - n + 1, f = e - n + 1, h = Math.log(l), u = 0.5 * Math.exp(2 * h / 3), p = 0.5 * Math.sqrt(h * u * (l - u) / l) * (f - l / 2 < 0 ? -1 : 1), g = Math.max(n, Math.floor(e - f * u / l + p)),
|
|
1374
|
-
me(t, e, g,
|
|
1380
|
+
const l = o - n + 1, f = e - n + 1, h = Math.log(l), u = 0.5 * Math.exp(2 * h / 3), p = 0.5 * Math.sqrt(h * u * (l - u) / l) * (f - l / 2 < 0 ? -1 : 1), g = Math.max(n, Math.floor(e - f * u / l + p)), y = Math.min(o, Math.floor(e + (l - f) * u / l + p));
|
|
1381
|
+
me(t, e, g, y, i);
|
|
1375
1382
|
}
|
|
1376
1383
|
const s = t[e];
|
|
1377
1384
|
let a = n, r = o;
|
|
@@ -1637,20 +1644,20 @@ function ee(t, e, n, o, i) {
|
|
|
1637
1644
|
}
|
|
1638
1645
|
const to = (t, e) => {
|
|
1639
1646
|
const n = new Wn(), o = /* @__PURE__ */ new Map(), i = (d, c) => {
|
|
1640
|
-
const
|
|
1641
|
-
const
|
|
1642
|
-
return Array.from(
|
|
1643
|
-
}),
|
|
1644
|
-
return
|
|
1645
|
-
const { x:
|
|
1647
|
+
const w = d.selector.flatMap((E) => {
|
|
1648
|
+
const C = F([E]) ? E.range : ae(E, e).range;
|
|
1649
|
+
return Array.from(C.getClientRects());
|
|
1650
|
+
}), S = Ue(w).map(({ left: E, top: C, right: O, bottom: M }) => new DOMRect(E - c.left, C - c.top, O - E, M - C));
|
|
1651
|
+
return S.map((E) => {
|
|
1652
|
+
const { x: C, y: O, width: M, height: T } = E;
|
|
1646
1653
|
return {
|
|
1647
|
-
minX:
|
|
1654
|
+
minX: C,
|
|
1648
1655
|
minY: O,
|
|
1649
|
-
maxX:
|
|
1650
|
-
maxY: O +
|
|
1656
|
+
maxX: C + M,
|
|
1657
|
+
maxY: O + T,
|
|
1651
1658
|
annotation: {
|
|
1652
1659
|
id: d.annotation,
|
|
1653
|
-
rects:
|
|
1660
|
+
rects: S
|
|
1654
1661
|
}
|
|
1655
1662
|
};
|
|
1656
1663
|
});
|
|
@@ -1658,36 +1665,38 @@ const to = (t, e) => {
|
|
|
1658
1665
|
n.clear(), o.clear();
|
|
1659
1666
|
}, r = (d) => {
|
|
1660
1667
|
const c = i(d, e.getBoundingClientRect());
|
|
1661
|
-
c.forEach((
|
|
1668
|
+
c.length !== 0 && (c.forEach((w) => n.insert(w)), o.set(d.annotation, c));
|
|
1662
1669
|
}, l = (d) => {
|
|
1663
1670
|
const c = o.get(d.annotation);
|
|
1664
|
-
c && (c.forEach((
|
|
1671
|
+
c && (c.forEach((w) => n.remove(w)), o.delete(d.annotation));
|
|
1665
1672
|
}, f = (d) => {
|
|
1666
1673
|
l(d), r(d);
|
|
1667
1674
|
}, h = (d, c = !0) => {
|
|
1668
1675
|
c && a();
|
|
1669
|
-
const
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1676
|
+
const w = e.getBoundingClientRect(), S = d.map((C) => ({ target: C, rects: i(C, w) }));
|
|
1677
|
+
S.forEach(({ target: C, rects: O }) => {
|
|
1678
|
+
O.length > 0 && o.set(C.annotation, O);
|
|
1679
|
+
});
|
|
1680
|
+
const E = S.flatMap(({ rects: C }) => C);
|
|
1681
|
+
n.load(E);
|
|
1682
|
+
}, u = (d, c, w = !1) => {
|
|
1683
|
+
const S = n.search({
|
|
1675
1684
|
minX: d,
|
|
1676
1685
|
minY: c,
|
|
1677
1686
|
maxX: d,
|
|
1678
1687
|
maxY: c
|
|
1679
|
-
}),
|
|
1680
|
-
return
|
|
1688
|
+
}), E = (C) => C.annotation.rects.reduce((O, M) => O + M.width * M.height, 0);
|
|
1689
|
+
return S.length > 0 ? (S.sort((C, O) => E(C) - E(O)), w ? S.map((C) => C.annotation.id) : [S[0].annotation.id]) : [];
|
|
1681
1690
|
}, p = (d) => {
|
|
1682
1691
|
const c = g(d);
|
|
1683
1692
|
if (c.length === 0)
|
|
1684
1693
|
return;
|
|
1685
|
-
let
|
|
1694
|
+
let w = c[0].left, S = c[0].top, E = c[0].right, C = c[0].bottom;
|
|
1686
1695
|
for (let O = 1; O < c.length; O++) {
|
|
1687
1696
|
const M = c[O];
|
|
1688
|
-
|
|
1697
|
+
w = Math.min(w, M.left), S = Math.min(S, M.top), E = Math.max(E, M.right), C = Math.max(C, M.bottom);
|
|
1689
1698
|
}
|
|
1690
|
-
return new DOMRect(
|
|
1699
|
+
return new DOMRect(w, S, E - w, C - S);
|
|
1691
1700
|
}, g = (d) => {
|
|
1692
1701
|
const c = o.get(d);
|
|
1693
1702
|
return c ? c[0].annotation.rects : [];
|
|
@@ -1698,9 +1707,9 @@ const to = (t, e) => {
|
|
|
1698
1707
|
getAt: u,
|
|
1699
1708
|
getAnnotationBounds: p,
|
|
1700
1709
|
getAnnotationRects: g,
|
|
1701
|
-
getIntersecting: (d, c,
|
|
1702
|
-
const
|
|
1703
|
-
return Array.from(
|
|
1710
|
+
getIntersecting: (d, c, w, S) => {
|
|
1711
|
+
const E = n.search({ minX: d, minY: c, maxX: w, maxY: S }), C = new Set(E.map((O) => O.annotation.id));
|
|
1712
|
+
return Array.from(C).map((O) => ({
|
|
1704
1713
|
annotation: t.getAnnotation(O),
|
|
1705
1714
|
rects: g(O)
|
|
1706
1715
|
})).filter((O) => !!O.annotation);
|
|
@@ -1715,42 +1724,36 @@ const to = (t, e) => {
|
|
|
1715
1724
|
}, eo = (t, e) => {
|
|
1716
1725
|
const n = Ln(), o = to(n, t), i = pn(n);
|
|
1717
1726
|
i.setUserSelectAction(e);
|
|
1718
|
-
const s = fn(n), a = Bn(), r = (
|
|
1719
|
-
const
|
|
1720
|
-
return
|
|
1721
|
-
}, l = (
|
|
1722
|
-
const
|
|
1723
|
-
return n.bulkAddAnnotation(
|
|
1724
|
-
}, f = (
|
|
1725
|
-
const
|
|
1726
|
-
return
|
|
1727
|
-
n.getAnnotation(E.id) ? n.updateAnnotation(E,
|
|
1728
|
-
}),
|
|
1729
|
-
}, h = (
|
|
1730
|
-
const
|
|
1731
|
-
n.updateTarget(
|
|
1732
|
-
}, u = (
|
|
1733
|
-
const
|
|
1734
|
-
n.bulkUpdateTargets(
|
|
1727
|
+
const s = fn(n), a = Bn(), r = (d, c = k.LOCAL) => {
|
|
1728
|
+
const w = xt(d, t), S = F(w.target.selector);
|
|
1729
|
+
return S && n.addAnnotation(w, c), S;
|
|
1730
|
+
}, l = (d, c = !0, w = k.LOCAL) => {
|
|
1731
|
+
const S = d.map((C) => xt(C, t)), E = S.filter((C) => !F(C.target.selector));
|
|
1732
|
+
return n.bulkAddAnnotation(S, c, w), E;
|
|
1733
|
+
}, f = (d, c = k.LOCAL) => {
|
|
1734
|
+
const w = d.map((E) => xt(E, t)), S = w.filter((E) => !F(E.target.selector));
|
|
1735
|
+
return w.forEach((E) => {
|
|
1736
|
+
n.getAnnotation(E.id) ? n.updateAnnotation(E, c) : n.addAnnotation(E, c);
|
|
1737
|
+
}), S;
|
|
1738
|
+
}, h = (d, c = k.LOCAL) => {
|
|
1739
|
+
const w = bt(d, t);
|
|
1740
|
+
n.updateTarget(w, c);
|
|
1741
|
+
}, u = (d, c = k.LOCAL) => {
|
|
1742
|
+
const w = d.map((S) => bt(S, t));
|
|
1743
|
+
n.bulkUpdateTargets(w, c);
|
|
1735
1744
|
};
|
|
1736
|
-
function p(
|
|
1737
|
-
const E =
|
|
1738
|
-
if (
|
|
1739
|
-
return
|
|
1745
|
+
function p(d, c, w, S) {
|
|
1746
|
+
const E = w || !!S, C = o.getAt(d, c, E).map((M) => n.getAnnotation(M)), O = S ? C.filter(S) : C;
|
|
1747
|
+
if (O.length !== 0)
|
|
1748
|
+
return w ? O : O[0];
|
|
1740
1749
|
}
|
|
1741
|
-
const g = (
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
return o.getAnnotationBounds(y);
|
|
1749
|
-
}
|
|
1750
|
-
}, b = (y) => o.getAnnotationRects(y), w = () => o.recalculate();
|
|
1751
|
-
return n.observe(({ changes: y }) => {
|
|
1752
|
-
const d = (y.deleted || []).filter((E) => F(E.target.selector)), c = (y.created || []).filter((E) => F(E.target.selector)), A = (y.updated || []).filter((E) => F(E.newValue.target.selector));
|
|
1753
|
-
(d == null ? void 0 : d.length) > 0 && d.forEach((E) => o.remove(E.target)), c.length > 0 && o.set(c.map((E) => E.target), !1), (A == null ? void 0 : A.length) > 0 && A.forEach(({ newValue: E }) => o.update(E.target));
|
|
1750
|
+
const g = (d) => {
|
|
1751
|
+
if (o.getAnnotationRects(d).length !== 0)
|
|
1752
|
+
return o.getAnnotationBounds(d);
|
|
1753
|
+
}, y = (d, c, w, S) => o.getIntersecting(d, c, w, S), b = (d) => o.getAnnotationRects(d), v = () => o.recalculate();
|
|
1754
|
+
return n.observe(({ changes: d }) => {
|
|
1755
|
+
const c = (d.deleted || []).filter((E) => F(E.target.selector)), w = (d.created || []).filter((E) => F(E.target.selector)), S = (d.updated || []).filter((E) => F(E.newValue.target.selector));
|
|
1756
|
+
(c == null ? void 0 : c.length) > 0 && c.forEach((E) => o.remove(E.target)), w.length > 0 && o.set(w.map((E) => E.target), !1), (S == null ? void 0 : S.length) > 0 && S.forEach(({ newValue: E }) => o.update(E.target));
|
|
1754
1757
|
}), {
|
|
1755
1758
|
store: {
|
|
1756
1759
|
...n,
|
|
@@ -1760,9 +1763,9 @@ const to = (t, e) => {
|
|
|
1760
1763
|
bulkUpsertAnnotations: f,
|
|
1761
1764
|
getAnnotationBounds: g,
|
|
1762
1765
|
getAnnotationRects: b,
|
|
1766
|
+
getIntersecting: y,
|
|
1763
1767
|
getAt: p,
|
|
1764
|
-
|
|
1765
|
-
recalculatePositions: w,
|
|
1768
|
+
recalculatePositions: v,
|
|
1766
1769
|
updateTarget: h
|
|
1767
1770
|
},
|
|
1768
1771
|
selection: i,
|
|
@@ -1792,10 +1795,10 @@ const to = (t, e) => {
|
|
|
1792
1795
|
e.font && (o.font = e.font);
|
|
1793
1796
|
const g = i.get(h.annotation.id);
|
|
1794
1797
|
if (g) {
|
|
1795
|
-
const { height:
|
|
1796
|
-
o.fillStyle = g.appearance.color, o.fillRect(
|
|
1797
|
-
const d = o.measureText(g.appearance.label), c = d.width + 6,
|
|
1798
|
-
return o.fillRect(
|
|
1798
|
+
const { height: y } = h.rects[0], b = h.rects[0].x + u.left, v = h.rects[0].y + u.top;
|
|
1799
|
+
o.fillStyle = g.appearance.color, o.fillRect(b - 2, v - 2.5, 2, y + 5);
|
|
1800
|
+
const d = o.measureText(g.appearance.label), c = d.width + 6, w = d.actualBoundingBoxAscent + d.actualBoundingBoxDescent + 8, S = d.fontBoundingBoxAscent ? 8 : 6.5;
|
|
1801
|
+
return o.fillRect(b - 2, v - 2.5 - w, c, w), o.fillStyle = "#fff", o.fillText(g.appearance.label, b + 1, v - S), {
|
|
1799
1802
|
fill: g.appearance.color,
|
|
1800
1803
|
fillOpacity: p ? 0.45 : 0.18
|
|
1801
1804
|
};
|
|
@@ -2021,8 +2024,8 @@ const yt = (t) => {
|
|
|
2021
2024
|
n || (n = dt());
|
|
2022
2025
|
const u = l > 1 ? ye(H, r) : [], p = [];
|
|
2023
2026
|
_[h] = _[h].filter((g) => {
|
|
2024
|
-
const
|
|
2025
|
-
return
|
|
2027
|
+
const b = (o ? g.method === o : !0) && g.scope === n && io(g.mods, u);
|
|
2028
|
+
return b && p.push(g.element), !b;
|
|
2026
2029
|
}), p.forEach((g) => Xt(g));
|
|
2027
2030
|
});
|
|
2028
2031
|
};
|
|
@@ -2088,17 +2091,17 @@ function P(t, e, n) {
|
|
|
2088
2091
|
if (typeof a < "u" && window) {
|
|
2089
2092
|
if (!z.has(a)) {
|
|
2090
2093
|
const g = function() {
|
|
2091
|
-
let
|
|
2092
|
-
return oe(
|
|
2093
|
-
},
|
|
2094
|
-
let
|
|
2095
|
-
oe(
|
|
2094
|
+
let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2095
|
+
return oe(b, a);
|
|
2096
|
+
}, y = function() {
|
|
2097
|
+
let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2098
|
+
oe(b, a), po(b);
|
|
2096
2099
|
};
|
|
2097
2100
|
z.set(a, {
|
|
2098
2101
|
keydownListener: g,
|
|
2099
|
-
keyupListenr:
|
|
2102
|
+
keyupListenr: y,
|
|
2100
2103
|
capture: u
|
|
2101
|
-
}), It(a, "keydown", g, u), It(a, "keyup",
|
|
2104
|
+
}), It(a, "keydown", g, u), It(a, "keyup", y, u);
|
|
2102
2105
|
}
|
|
2103
2106
|
if (!ct) {
|
|
2104
2107
|
const g = () => {
|
|
@@ -2175,32 +2178,34 @@ const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+
|
|
|
2175
2178
|
Ee
|
|
2176
2179
|
], yo = (t, e, n) => {
|
|
2177
2180
|
let o;
|
|
2178
|
-
const { annotatingEnabled: i, offsetReferenceSelector: s, selectionMode: a } = n, r = (
|
|
2181
|
+
const { annotatingEnabled: i, offsetReferenceSelector: s, selectionMode: a } = n, r = (T) => o = T;
|
|
2179
2182
|
let l;
|
|
2180
|
-
const f = (
|
|
2181
|
-
let p, g,
|
|
2182
|
-
const
|
|
2183
|
-
g !== !1 && (p = it(
|
|
2183
|
+
const f = (T) => l = T, { store: h, selection: u } = e;
|
|
2184
|
+
let p, g, y;
|
|
2185
|
+
const b = (T) => {
|
|
2186
|
+
g !== !1 && (p = it(T.target) ? void 0 : {
|
|
2184
2187
|
annotation: fe(),
|
|
2185
2188
|
selector: [],
|
|
2186
2189
|
creator: o,
|
|
2187
2190
|
created: /* @__PURE__ */ new Date()
|
|
2188
2191
|
});
|
|
2189
|
-
},
|
|
2192
|
+
}, v = Yt((T) => {
|
|
2190
2193
|
const m = document.getSelection();
|
|
2194
|
+
if (!(m != null && m.anchorNode))
|
|
2195
|
+
return;
|
|
2191
2196
|
if (it(m.anchorNode)) {
|
|
2192
2197
|
p = void 0;
|
|
2193
2198
|
return;
|
|
2194
2199
|
}
|
|
2195
|
-
const
|
|
2196
|
-
if ((
|
|
2200
|
+
const x = T.timeStamp - ((y == null ? void 0 : y.timeStamp) || T.timeStamp);
|
|
2201
|
+
if ((y == null ? void 0 : y.type) === "pointerdown" && (x < 1e3 && !p || m.isCollapsed && x < ie) && b(y || T), !p) return;
|
|
2197
2202
|
if (m.isCollapsed) {
|
|
2198
2203
|
h.getAnnotation(p.annotation) && (u.clear(), h.deleteAnnotation(p.annotation));
|
|
2199
2204
|
return;
|
|
2200
2205
|
}
|
|
2201
|
-
const
|
|
2202
|
-
if (Ie(
|
|
2203
|
-
const B = Be(
|
|
2206
|
+
const A = m.getRangeAt(0), L = Ye(A, t);
|
|
2207
|
+
if (Ie(L)) return;
|
|
2208
|
+
const B = Be(L.cloneRange());
|
|
2204
2209
|
(B.length !== p.selector.length || B.some((N, U) => {
|
|
2205
2210
|
var et;
|
|
2206
2211
|
return N.toString() !== ((et = p.selector[U]) == null ? void 0 : et.quote);
|
|
@@ -2209,49 +2214,49 @@ const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+
|
|
|
2209
2214
|
selector: B.map((N) => Ve(N, t, s)),
|
|
2210
2215
|
updated: /* @__PURE__ */ new Date()
|
|
2211
2216
|
}, h.getAnnotation(p.annotation) ? h.updateTarget(p, k.LOCAL) : u.clear());
|
|
2212
|
-
}), d = (
|
|
2213
|
-
it(
|
|
2214
|
-
}, c = (
|
|
2215
|
-
if (it(
|
|
2217
|
+
}), d = (T) => {
|
|
2218
|
+
it(T.target) || (y = At(T), g = y.button === 0);
|
|
2219
|
+
}, c = (T) => {
|
|
2220
|
+
if (it(T.target) || !g) return;
|
|
2216
2221
|
const m = () => {
|
|
2217
|
-
const { x, y:
|
|
2222
|
+
const { x: A, y: L } = t.getBoundingClientRect(), B = T.target instanceof Node && t.contains(T.target) && h.getAt(T.clientX - A, T.clientY - L, a === "all", l);
|
|
2218
2223
|
if (B) {
|
|
2219
2224
|
const { selected: R } = u, N = new Set(R.map((q) => q.id)), U = Array.isArray(B) ? B.map((q) => q.id) : [B.id];
|
|
2220
|
-
(N.size !== U.length || !U.every((q) => N.has(q))) && u.userSelect(U,
|
|
2225
|
+
(N.size !== U.length || !U.every((q) => N.has(q))) && u.userSelect(U, T);
|
|
2221
2226
|
} else
|
|
2222
2227
|
u.clear();
|
|
2223
|
-
},
|
|
2228
|
+
}, x = T.timeStamp - y.timeStamp;
|
|
2224
2229
|
setTimeout(() => {
|
|
2225
|
-
const
|
|
2226
|
-
|
|
2230
|
+
const A = document.getSelection();
|
|
2231
|
+
A != null && A.isCollapsed && x < ie ? (p = void 0, m()) : p && p.selector.length > 0 && (O(), u.userSelect(p.annotation, At(T)));
|
|
2227
2232
|
});
|
|
2228
|
-
},
|
|
2233
|
+
}, w = (T) => {
|
|
2229
2234
|
const m = document.getSelection();
|
|
2230
|
-
m != null && m.isCollapsed || ((!p || p.selector.length === 0) &&
|
|
2231
|
-
},
|
|
2232
|
-
|
|
2233
|
-
},
|
|
2235
|
+
m != null && m.isCollapsed || ((!p || p.selector.length === 0) && v(T), O(), u.userSelect(p.annotation, At(T)));
|
|
2236
|
+
}, S = (T) => {
|
|
2237
|
+
T.key === "Shift" && p && (document.getSelection().isCollapsed || (O(), u.userSelect(p.annotation, ft(T))));
|
|
2238
|
+
}, E = (T) => {
|
|
2234
2239
|
const m = () => setTimeout(() => {
|
|
2235
2240
|
(p == null ? void 0 : p.selector.length) > 0 && (u.clear(), h.addAnnotation({
|
|
2236
2241
|
id: p.annotation,
|
|
2237
2242
|
bodies: [],
|
|
2238
2243
|
target: p
|
|
2239
|
-
}), u.userSelect(p.annotation, ft(
|
|
2244
|
+
}), u.userSelect(p.annotation, ft(T))), document.removeEventListener("selectionchange", m);
|
|
2240
2245
|
}, 100);
|
|
2241
|
-
document.addEventListener("selectionchange", m),
|
|
2246
|
+
document.addEventListener("selectionchange", m), b(T);
|
|
2242
2247
|
};
|
|
2243
|
-
P(mo.join(","), { element: t, keydown: !0, keyup: !1 }, (
|
|
2244
|
-
|
|
2245
|
-
}), P(Ee, { keydown: !0, keyup: !1 }, (
|
|
2246
|
-
|
|
2248
|
+
P(mo.join(","), { element: t, keydown: !0, keyup: !1 }, (T) => {
|
|
2249
|
+
T.repeat || (y = ft(T));
|
|
2250
|
+
}), P(Ee, { keydown: !0, keyup: !1 }, (T) => {
|
|
2251
|
+
y = ft(T), E(T);
|
|
2247
2252
|
});
|
|
2248
|
-
const
|
|
2249
|
-
|
|
2253
|
+
const C = (T) => {
|
|
2254
|
+
T.repeat || T.target !== t && T.target !== document.body || (p = void 0, u.clear());
|
|
2250
2255
|
};
|
|
2251
|
-
P(ve.join(","), { keydown: !0, keyup: !1 },
|
|
2256
|
+
P(ve.join(","), { keydown: !0, keyup: !1 }, C);
|
|
2252
2257
|
const O = () => {
|
|
2253
|
-
const
|
|
2254
|
-
if (!
|
|
2258
|
+
const T = h.getAnnotation(p.annotation);
|
|
2259
|
+
if (!T) {
|
|
2255
2260
|
h.addAnnotation({
|
|
2256
2261
|
id: p.annotation,
|
|
2257
2262
|
bodies: [],
|
|
@@ -2259,12 +2264,12 @@ const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+
|
|
|
2259
2264
|
});
|
|
2260
2265
|
return;
|
|
2261
2266
|
}
|
|
2262
|
-
const { target: { updated: m } } =
|
|
2263
|
-
(!m || !
|
|
2267
|
+
const { target: { updated: m } } = T, { updated: x } = p;
|
|
2268
|
+
(!m || !x || m < x) && h.updateTarget(p);
|
|
2264
2269
|
};
|
|
2265
|
-
return t.addEventListener("pointerdown", d), document.addEventListener("pointerup", c), document.addEventListener("contextmenu",
|
|
2270
|
+
return t.addEventListener("pointerdown", d), document.addEventListener("pointerup", c), document.addEventListener("contextmenu", w), i && (t.addEventListener("keyup", S), t.addEventListener("selectstart", b), document.addEventListener("selectionchange", v)), {
|
|
2266
2271
|
destroy: () => {
|
|
2267
|
-
t.removeEventListener("pointerdown", d), document.removeEventListener("pointerup", c), document.removeEventListener("contextmenu",
|
|
2272
|
+
t.removeEventListener("pointerdown", d), document.removeEventListener("pointerup", c), document.removeEventListener("contextmenu", w), t.removeEventListener("keyup", S), t.removeEventListener("selectstart", b), document.removeEventListener("selectionchange", v), P.unbind();
|
|
2268
2273
|
},
|
|
2269
2274
|
setFilter: f,
|
|
2270
2275
|
setUser: r
|
|
@@ -2273,7 +2278,7 @@ const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+
|
|
|
2273
2278
|
...t,
|
|
2274
2279
|
annotatingEnabled: t.annotatingEnabled ?? e.annotatingEnabled,
|
|
2275
2280
|
user: t.user || e.user
|
|
2276
|
-
}), se = "SPANS",
|
|
2281
|
+
}), se = "SPANS", vo = (t, e = {}) => {
|
|
2277
2282
|
Le(t), Oe(t);
|
|
2278
2283
|
const n = bo(e, {
|
|
2279
2284
|
annotatingEnabled: !0,
|
|
@@ -2292,20 +2297,20 @@ const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+
|
|
|
2292
2297
|
},
|
|
2293
2298
|
element: t,
|
|
2294
2299
|
getUser: () => f,
|
|
2295
|
-
setFilter: (
|
|
2296
|
-
u.setFilter(
|
|
2300
|
+
setFilter: (C) => {
|
|
2301
|
+
u.setFilter(C), p.setFilter(C);
|
|
2297
2302
|
},
|
|
2298
|
-
setStyle: (
|
|
2299
|
-
setUser: (
|
|
2300
|
-
f =
|
|
2303
|
+
setStyle: (C) => u.setStyle(C),
|
|
2304
|
+
setUser: (C) => {
|
|
2305
|
+
f = C, p.setUser(C);
|
|
2301
2306
|
},
|
|
2302
|
-
setSelected: (
|
|
2303
|
-
|
|
2307
|
+
setSelected: (C) => {
|
|
2308
|
+
C ? i.setSelected(C) : i.clear();
|
|
2304
2309
|
},
|
|
2305
|
-
setPresenceProvider: (
|
|
2306
|
-
|
|
2310
|
+
setPresenceProvider: (C) => {
|
|
2311
|
+
C && (u.setPainter(oo(C, n.presence)), C.on("selectionChange", () => u.redraw()));
|
|
2307
2312
|
},
|
|
2308
|
-
setVisible: (
|
|
2313
|
+
setVisible: (C) => u.setVisible(C),
|
|
2309
2314
|
on: l.on,
|
|
2310
2315
|
off: l.off,
|
|
2311
2316
|
scrollIntoView: Ke(t, a),
|
|
@@ -2320,17 +2325,17 @@ export {
|
|
|
2320
2325
|
k as Origin,
|
|
2321
2326
|
yo as SelectionHandler,
|
|
2322
2327
|
hn as UserSelectAction,
|
|
2323
|
-
|
|
2328
|
+
xo as W3CTextFormat,
|
|
2324
2329
|
Le as cancelSingleClickEvents,
|
|
2325
2330
|
ft as cloneKeyboardEvent,
|
|
2326
2331
|
At as clonePointerEvent,
|
|
2327
|
-
|
|
2332
|
+
Ao as createBody,
|
|
2328
2333
|
ze as createCanvasRenderer,
|
|
2329
2334
|
nn as createHighlightsRenderer,
|
|
2330
2335
|
oo as createPresencePainter,
|
|
2331
2336
|
en as createRenderer,
|
|
2332
2337
|
rn as createSpansRenderer,
|
|
2333
|
-
|
|
2338
|
+
vo as createTextAnnotator,
|
|
2334
2339
|
eo as createTextAnnotatorState,
|
|
2335
2340
|
Yt as debounce,
|
|
2336
2341
|
bo as fillDefaults,
|
|
@@ -2352,6 +2357,7 @@ export {
|
|
|
2352
2357
|
Ke as scrollIntoView,
|
|
2353
2358
|
zn as serializeW3CTextAnnotation,
|
|
2354
2359
|
Be as splitAnnotatableRanges,
|
|
2360
|
+
wo as toDomRectList,
|
|
2355
2361
|
Ye as trimRangeToContainer,
|
|
2356
2362
|
ke as whitespaceOrEmptyRegex
|
|
2357
2363
|
};
|