@recogito/text-annotator 3.0.0-rc.50 → 3.0.0-rc.51
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.
|
@@ -145,7 +145,7 @@ const se = "not-annotatable", Z = `.${se}`, nt = (t) => {
|
|
|
145
145
|
const s = _t(o).textContent, a = t.toString(), r = s.length || 0, l = r + a.length;
|
|
146
146
|
return n ? { quote: a, start: r, end: l, range: t, offsetReference: i } : { quote: a, start: r, end: l, range: t };
|
|
147
147
|
}, re = (t, e) => {
|
|
148
|
-
var
|
|
148
|
+
var d, h;
|
|
149
149
|
const { start: n, end: o } = t, i = t.offsetReference || e, s = document.createNodeIterator(
|
|
150
150
|
e,
|
|
151
151
|
NodeFilter.SHOW_TEXT,
|
|
@@ -161,7 +161,7 @@ const se = "not-annotatable", Z = `.${se}`, nt = (t) => {
|
|
|
161
161
|
let f = !i;
|
|
162
162
|
for (; l !== null; ) {
|
|
163
163
|
if (f || (f = i == null ? void 0 : i.contains(l)), f) {
|
|
164
|
-
const g = ((
|
|
164
|
+
const g = ((d = l.textContent) == null ? void 0 : d.length) || 0;
|
|
165
165
|
if (a + g > n) {
|
|
166
166
|
r.setStart(l, n - a);
|
|
167
167
|
break;
|
|
@@ -195,8 +195,8 @@ const se = "not-annotatable", Z = `.${se}`, nt = (t) => {
|
|
|
195
195
|
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : ae(t.parentElement);
|
|
196
196
|
}, De = (t, e) => (n) => {
|
|
197
197
|
const o = typeof n == "string" ? n : n.id, i = (a) => {
|
|
198
|
-
const r = s.getBoundingClientRect(), l = s.clientHeight, f = s.clientWidth,
|
|
199
|
-
s.scroll({ top:
|
|
198
|
+
const r = s.getBoundingClientRect(), l = s.clientHeight, f = s.clientWidth, d = a.selector[0].range.getBoundingClientRect(), { width: h, height: g } = e.getAnnotationBounds(o), p = d.top - r.top, A = d.left - r.left, y = s.parentElement ? s.scrollTop : 0, m = s.parentElement ? s.scrollLeft : 0, u = p + y - (l - g) / 2, c = A + m - (f - h) / 2;
|
|
199
|
+
s.scroll({ top: u, left: c, behavior: "smooth" });
|
|
200
200
|
}, s = ae(t);
|
|
201
201
|
if (s) {
|
|
202
202
|
const a = e.getAnnotation(o), { range: r } = a.target.selector[0];
|
|
@@ -231,43 +231,43 @@ const se = "not-annotatable", Z = `.${se}`, nt = (t) => {
|
|
|
231
231
|
}, Kt = (t, e, n, o) => {
|
|
232
232
|
const { store: i, selection: s, hover: a } = e;
|
|
233
233
|
let r, l, f;
|
|
234
|
-
const
|
|
235
|
-
const { x:
|
|
236
|
-
|
|
234
|
+
const d = $e(n), h = (O) => {
|
|
235
|
+
const { x: _, y: b } = t.getBoundingClientRect(), x = i.getAt(O.clientX - _, O.clientY - b, l);
|
|
236
|
+
x ? a.current !== x.id && (t.classList.add("hovered"), a.set(x.id)) : a.current && (t.classList.remove("hovered"), a.set(null));
|
|
237
237
|
};
|
|
238
238
|
t.addEventListener("pointermove", h);
|
|
239
|
-
const g = (
|
|
239
|
+
const g = (O = !1) => {
|
|
240
240
|
f && f.clear();
|
|
241
|
-
const
|
|
242
|
-
const Se = M.includes(
|
|
243
|
-
return { annotation:
|
|
241
|
+
const _ = Pe(t), { minX: b, minY: x, maxX: v, maxY: C } = _, B = l ? i.getIntersecting(b, x, v, C).filter(({ annotation: D }) => l(D)) : i.getIntersecting(b, x, v, C), M = s.selected.map(({ id: D }) => D), Y = B.map(({ annotation: D, rects: Ee }) => {
|
|
242
|
+
const Se = M.includes(D.id), Ce = D.id === a.current;
|
|
243
|
+
return { annotation: D, rects: Ee, state: { selected: Se, hover: Ce } };
|
|
244
244
|
});
|
|
245
|
-
o.redraw(
|
|
246
|
-
}, p = (
|
|
247
|
-
f =
|
|
248
|
-
},
|
|
249
|
-
r =
|
|
250
|
-
}, y = (
|
|
251
|
-
l =
|
|
245
|
+
o.redraw(Y, _, r, f, O), setTimeout(() => d(B.map(({ annotation: D }) => D)), 1);
|
|
246
|
+
}, p = (O) => {
|
|
247
|
+
f = O, g();
|
|
248
|
+
}, A = (O) => {
|
|
249
|
+
r = O, g();
|
|
250
|
+
}, y = (O) => {
|
|
251
|
+
l = O, g(!1);
|
|
252
252
|
}, m = () => g();
|
|
253
253
|
i.observe(m);
|
|
254
|
-
const
|
|
254
|
+
const u = s.subscribe(() => g()), c = () => g(!0);
|
|
255
255
|
document.addEventListener("scroll", c, { capture: !0, passive: !0 });
|
|
256
|
-
const
|
|
256
|
+
const w = Vt(() => {
|
|
257
257
|
i.recalculatePositions(), f && f.reset(), g();
|
|
258
258
|
});
|
|
259
|
-
window.addEventListener("resize",
|
|
260
|
-
const S = new ResizeObserver(
|
|
259
|
+
window.addEventListener("resize", w);
|
|
260
|
+
const S = new ResizeObserver(w);
|
|
261
261
|
S.observe(t);
|
|
262
|
-
const T = { attributes: !0, childList: !0, subtree: !0 }, L = new MutationObserver((
|
|
263
|
-
|
|
262
|
+
const T = { attributes: !0, childList: !0, subtree: !0 }, L = new MutationObserver((O) => {
|
|
263
|
+
O.every((b) => b.target === t || t.contains(b.target)) || g(!0);
|
|
264
264
|
});
|
|
265
265
|
return L.observe(document.body, T), {
|
|
266
266
|
destroy: () => {
|
|
267
|
-
t.removeEventListener("pointermove", h), o.destroy(), i.unobserve(m),
|
|
267
|
+
t.removeEventListener("pointermove", h), o.destroy(), i.unobserve(m), u(), document.removeEventListener("scroll", c), window.removeEventListener("resize", w), S.disconnect(), L.disconnect();
|
|
268
268
|
},
|
|
269
269
|
redraw: g,
|
|
270
|
-
setStyle:
|
|
270
|
+
setStyle: A,
|
|
271
271
|
setFilter: y,
|
|
272
272
|
setPainter: p,
|
|
273
273
|
setVisible: o.setVisible
|
|
@@ -281,28 +281,28 @@ const se = "not-annotatable", Z = `.${se}`, nt = (t) => {
|
|
|
281
281
|
t.classList.add("r6o-annotatable");
|
|
282
282
|
const e = He(), n = e.getContext("2d");
|
|
283
283
|
document.body.appendChild(e);
|
|
284
|
-
const o = (r, l, f,
|
|
284
|
+
const o = (r, l, f, d) => requestAnimationFrame(() => {
|
|
285
285
|
const { width: h, height: g } = e;
|
|
286
|
-
n.clearRect(-0.5, -0.5, h + 1, g + 1),
|
|
287
|
-
const { top: p, left:
|
|
288
|
-
[...r].sort((m,
|
|
289
|
-
const { annotation: { target: { created: c } } } = m, { annotation: { target: { created:
|
|
290
|
-
return c.getTime() -
|
|
286
|
+
n.clearRect(-0.5, -0.5, h + 1, g + 1), d && d.clear();
|
|
287
|
+
const { top: p, left: A } = l;
|
|
288
|
+
[...r].sort((m, u) => {
|
|
289
|
+
const { annotation: { target: { created: c } } } = m, { annotation: { target: { created: w } } } = u;
|
|
290
|
+
return c.getTime() - w.getTime();
|
|
291
291
|
}).forEach((m) => {
|
|
292
292
|
var S;
|
|
293
|
-
const
|
|
294
|
-
x: T +
|
|
293
|
+
const u = f ? typeof f == "function" ? f(m.annotation, m.state) : f : (S = m.state) != null && S.selected ? bt : W, c = d && d.paint(m, l) || u, w = m.rects.map(({ x: T, y: L, width: E, height: O }) => ({
|
|
294
|
+
x: T + A,
|
|
295
295
|
y: L + p,
|
|
296
|
-
width:
|
|
297
|
-
height:
|
|
296
|
+
width: E,
|
|
297
|
+
height: O
|
|
298
298
|
}));
|
|
299
|
-
if (n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1,
|
|
300
|
-
({ x: T, y: L, width:
|
|
299
|
+
if (n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1, w.forEach(
|
|
300
|
+
({ x: T, y: L, width: E, height: O }) => n.fillRect(T, L, E, O)
|
|
301
301
|
), c.underlineColor) {
|
|
302
302
|
n.globalAlpha = 1, n.strokeStyle = c.underlineColor, n.lineWidth = c.underlineThickness ?? 1;
|
|
303
303
|
const T = c.underlineOffset ?? 0;
|
|
304
|
-
|
|
305
|
-
n.beginPath(), n.moveTo(L,
|
|
304
|
+
w.forEach(({ x: L, y: E, width: O, height: _ }) => {
|
|
305
|
+
n.beginPath(), n.moveTo(L, E + _ + T), n.lineTo(L + O, E + _ + T), n.stroke();
|
|
306
306
|
});
|
|
307
307
|
}
|
|
308
308
|
});
|
|
@@ -470,14 +470,14 @@ const en = (t) => [
|
|
|
470
470
|
l && l.clear();
|
|
471
471
|
const f = new Set(s.map((h) => h.annotation.id));
|
|
472
472
|
Array.from(e).filter((h) => !f.has(h));
|
|
473
|
-
const
|
|
474
|
-
var
|
|
475
|
-
const g = r ? typeof r == "function" ? r(h.annotation, h.state) : r : (
|
|
473
|
+
const d = s.map((h) => {
|
|
474
|
+
var A;
|
|
475
|
+
const g = r ? typeof r == "function" ? r(h.annotation, h.state) : r : (A = h.state) != null && A.selected ? bt : W, p = l && l.paint(h, a) || g;
|
|
476
476
|
return `::highlight(_${h.annotation.id}) { ${en(p)} }`;
|
|
477
477
|
});
|
|
478
|
-
t.innerHTML =
|
|
478
|
+
t.innerHTML = d.join(`
|
|
479
479
|
`), CSS.highlights.clear(), s.forEach(({ annotation: h }) => {
|
|
480
|
-
const g = h.target.selector.map((
|
|
480
|
+
const g = h.target.selector.map((A) => A.range), p = new Highlight(...g);
|
|
481
481
|
CSS.highlights.set(`_${h.id}`, p);
|
|
482
482
|
}), e = f;
|
|
483
483
|
}
|
|
@@ -516,18 +516,18 @@ const sn = (t, e) => {
|
|
|
516
516
|
destroy: () => {
|
|
517
517
|
e.remove();
|
|
518
518
|
},
|
|
519
|
-
redraw: (a, r, l, f,
|
|
520
|
-
const g = !(Nt(n, a) &&
|
|
519
|
+
redraw: (a, r, l, f, d) => {
|
|
520
|
+
const g = !(Nt(n, a) && d);
|
|
521
521
|
if (!f && !g) return;
|
|
522
|
-
g && (e.innerHTML = ""), [...a].sort((
|
|
523
|
-
const { annotation: { target: { created: m } } } =
|
|
524
|
-
return m &&
|
|
525
|
-
}).forEach((
|
|
526
|
-
|
|
527
|
-
const m = sn(y, a),
|
|
522
|
+
g && (e.innerHTML = ""), [...a].sort((A, y) => {
|
|
523
|
+
const { annotation: { target: { created: m } } } = A, { annotation: { target: { created: u } } } = y;
|
|
524
|
+
return m && u ? m.getTime() - u.getTime() : 0;
|
|
525
|
+
}).forEach((A) => {
|
|
526
|
+
A.rects.map((y) => {
|
|
527
|
+
const m = sn(y, a), u = Xe(A, r, l, f, m);
|
|
528
528
|
if (g) {
|
|
529
529
|
const c = document.createElement("span");
|
|
530
|
-
c.className = "r6o-annotation", c.dataset.annotation =
|
|
530
|
+
c.className = "r6o-annotation", c.dataset.annotation = A.annotation.id, c.style.left = `${y.x}px`, c.style.top = `${y.y}px`, c.style.width = `${y.width}px`, c.style.height = `${y.height}px`, c.style.backgroundColor = $((u == null ? void 0 : u.fill) || W.fill).alpha((u == null ? void 0 : u.fillOpacity) === void 0 ? W.fillOpacity : u.fillOpacity).toHex(), u.underlineStyle && (c.style.borderStyle = u.underlineStyle), u.underlineColor && (c.style.borderColor = u.underlineColor), u.underlineThickness && (c.style.borderBottomWidth = `${u.underlineThickness}px`), u.underlineOffset && (c.style.paddingBottom = `${u.underlineOffset}px`), e.appendChild(c);
|
|
531
531
|
}
|
|
532
532
|
});
|
|
533
533
|
}), n = a;
|
|
@@ -634,49 +634,49 @@ var pn = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE =
|
|
|
634
634
|
const ft = { selected: [] }, gn = (t, e, n) => {
|
|
635
635
|
const { subscribe: o, set: i } = Yt(ft);
|
|
636
636
|
let s = e, a = ft;
|
|
637
|
-
o((
|
|
637
|
+
o((A) => a = A);
|
|
638
638
|
const r = () => {
|
|
639
639
|
q(a, ft) || i(ft);
|
|
640
640
|
}, l = () => {
|
|
641
|
-
var
|
|
642
|
-
return ((
|
|
643
|
-
}, f = (
|
|
641
|
+
var A;
|
|
642
|
+
return ((A = a.selected) == null ? void 0 : A.length) === 0;
|
|
643
|
+
}, f = (A) => {
|
|
644
644
|
if (l())
|
|
645
645
|
return !1;
|
|
646
|
-
const y = typeof
|
|
646
|
+
const y = typeof A == "string" ? A : A.id;
|
|
647
647
|
return a.selected.some((m) => m.id === y);
|
|
648
|
-
},
|
|
649
|
-
const m = t.getAnnotation(
|
|
648
|
+
}, d = (A, y) => {
|
|
649
|
+
const m = t.getAnnotation(A);
|
|
650
650
|
if (!m) {
|
|
651
|
-
console.warn("Invalid selection: " +
|
|
651
|
+
console.warn("Invalid selection: " + A);
|
|
652
652
|
return;
|
|
653
653
|
}
|
|
654
654
|
switch (Jt(m, s)) {
|
|
655
655
|
case "EDIT":
|
|
656
|
-
i({ selected: [{ id:
|
|
656
|
+
i({ selected: [{ id: A, editable: !0 }], event: y });
|
|
657
657
|
break;
|
|
658
658
|
case "SELECT":
|
|
659
|
-
i({ selected: [{ id:
|
|
659
|
+
i({ selected: [{ id: A }], event: y });
|
|
660
660
|
break;
|
|
661
661
|
default:
|
|
662
662
|
i({ selected: [], event: y });
|
|
663
663
|
}
|
|
664
|
-
}, h = (
|
|
665
|
-
const m = Array.isArray(
|
|
664
|
+
}, h = (A, y) => {
|
|
665
|
+
const m = Array.isArray(A) ? A : [A], u = m.map((c) => t.getAnnotation(c)).filter((c) => !!c);
|
|
666
666
|
i({
|
|
667
|
-
selected:
|
|
668
|
-
const
|
|
669
|
-
return { id: c.id, editable:
|
|
667
|
+
selected: u.map((c) => {
|
|
668
|
+
const w = y === void 0 ? Jt(c, s) === "EDIT" : y;
|
|
669
|
+
return { id: c.id, editable: w };
|
|
670
670
|
})
|
|
671
|
-
}),
|
|
672
|
-
}, g = (
|
|
671
|
+
}), u.length !== m.length && console.warn("Invalid selection", A);
|
|
672
|
+
}, g = (A) => {
|
|
673
673
|
if (l())
|
|
674
674
|
return !1;
|
|
675
675
|
const { selected: y } = a;
|
|
676
|
-
y.some(({ id: m }) =>
|
|
677
|
-
}, p = (
|
|
676
|
+
y.some(({ id: m }) => A.includes(m)) && i({ selected: y.filter(({ id: m }) => !A.includes(m)) });
|
|
677
|
+
}, p = (A) => s = A;
|
|
678
678
|
return t.observe(
|
|
679
|
-
({ changes:
|
|
679
|
+
({ changes: A }) => g((A.deleted || []).map((y) => y.id))
|
|
680
680
|
), {
|
|
681
681
|
get event() {
|
|
682
682
|
return a ? a.event : null;
|
|
@@ -693,7 +693,7 @@ const ft = { selected: [] }, gn = (t, e, n) => {
|
|
|
693
693
|
setSelected: h,
|
|
694
694
|
setUserSelectAction: p,
|
|
695
695
|
subscribe: o,
|
|
696
|
-
userSelect:
|
|
696
|
+
userSelect: d
|
|
697
697
|
};
|
|
698
698
|
}, Jt = (t, e, n) => typeof e == "function" ? e(t) : e || "EDIT";
|
|
699
699
|
var V = [];
|
|
@@ -755,7 +755,7 @@ const Tt = (t) => {
|
|
|
755
755
|
targetUpdated: En(t, e) ? { oldTarget: t.target, newTarget: e.target } : void 0
|
|
756
756
|
};
|
|
757
757
|
};
|
|
758
|
-
var
|
|
758
|
+
var R = /* @__PURE__ */ ((t) => (t.LOCAL = "LOCAL", t.REMOTE = "REMOTE", t.SILENT = "SILENT", t))(R || {});
|
|
759
759
|
const Sn = (t, e) => {
|
|
760
760
|
var n, o;
|
|
761
761
|
const { changes: i, origin: s } = e;
|
|
@@ -764,7 +764,7 @@ const Sn = (t, e) => {
|
|
|
764
764
|
if (t.options.ignore) {
|
|
765
765
|
const { ignore: a } = t.options, r = (l) => l && l.length > 0;
|
|
766
766
|
if (!(r(i.created) || r(i.deleted))) {
|
|
767
|
-
const l = (n = i.updated) == null ? void 0 : n.some((
|
|
767
|
+
const l = (n = i.updated) == null ? void 0 : n.some((d) => r(d.bodiesCreated) || r(d.bodiesDeleted) || r(d.bodiesUpdated)), f = (o = i.updated) == null ? void 0 : o.some((d) => d.targetUpdated);
|
|
768
768
|
if (a === "BODY_ONLY" && l && !f || a === "TARGET_ONLY" && f && !l)
|
|
769
769
|
return !1;
|
|
770
770
|
}
|
|
@@ -785,18 +785,18 @@ const Sn = (t, e) => {
|
|
|
785
785
|
], f = [
|
|
786
786
|
...(t.deleted || []).filter((h) => !i.has(h.id)),
|
|
787
787
|
...(e.deleted || []).filter((h) => !n.has(h.id))
|
|
788
|
-
],
|
|
788
|
+
], d = [
|
|
789
789
|
...(t.updated || []).filter(({ newValue: h }) => !s.has(h.id)).map((h) => {
|
|
790
790
|
const { oldValue: g, newValue: p } = h;
|
|
791
791
|
if (a.has(p.id)) {
|
|
792
|
-
const
|
|
793
|
-
return he(g,
|
|
792
|
+
const A = e.updated.find((y) => y.oldValue.id === p.id).newValue;
|
|
793
|
+
return he(g, A);
|
|
794
794
|
} else
|
|
795
795
|
return h;
|
|
796
796
|
}),
|
|
797
797
|
...(e.updated || []).filter(({ oldValue: h }) => !r.has(h.id))
|
|
798
798
|
];
|
|
799
|
-
return { created: l, deleted: f, updated:
|
|
799
|
+
return { created: l, deleted: f, updated: d };
|
|
800
800
|
}, Ot = (t) => {
|
|
801
801
|
const e = t.id === void 0 ? fe() : t.id;
|
|
802
802
|
return {
|
|
@@ -812,188 +812,188 @@ const Sn = (t, e) => {
|
|
|
812
812
|
}
|
|
813
813
|
};
|
|
814
814
|
}, Ln = (t) => t.id !== void 0, Tn = () => {
|
|
815
|
-
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (
|
|
816
|
-
n.push({ onChange:
|
|
817
|
-
}, i = (
|
|
818
|
-
const
|
|
819
|
-
|
|
820
|
-
}, s = (
|
|
821
|
-
const
|
|
822
|
-
origin:
|
|
815
|
+
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (b, x = {}) => {
|
|
816
|
+
n.push({ onChange: b, options: x });
|
|
817
|
+
}, i = (b) => {
|
|
818
|
+
const x = n.findIndex((v) => v.onChange == b);
|
|
819
|
+
x > -1 && n.splice(x, 1);
|
|
820
|
+
}, s = (b, x) => {
|
|
821
|
+
const v = {
|
|
822
|
+
origin: b,
|
|
823
823
|
changes: {
|
|
824
|
-
created:
|
|
825
|
-
updated:
|
|
826
|
-
deleted:
|
|
824
|
+
created: x.created || [],
|
|
825
|
+
updated: x.updated || [],
|
|
826
|
+
deleted: x.deleted || []
|
|
827
827
|
},
|
|
828
828
|
state: [...t.values()]
|
|
829
829
|
};
|
|
830
830
|
n.forEach((C) => {
|
|
831
|
-
Sn(C,
|
|
831
|
+
Sn(C, v) && C.onChange(v);
|
|
832
832
|
});
|
|
833
|
-
}, a = (
|
|
834
|
-
if (
|
|
835
|
-
throw Error(`Cannot add annotation ${
|
|
833
|
+
}, a = (b, x = R.LOCAL) => {
|
|
834
|
+
if (b.id && t.get(b.id))
|
|
835
|
+
throw Error(`Cannot add annotation ${b.id} - exists already`);
|
|
836
836
|
{
|
|
837
|
-
const
|
|
838
|
-
t.set(
|
|
837
|
+
const v = Ot(b);
|
|
838
|
+
t.set(v.id, v), v.bodies.forEach((C) => e.set(C.id, v.id)), s(x, { created: [v] });
|
|
839
839
|
}
|
|
840
|
-
}, r = (
|
|
841
|
-
const
|
|
842
|
-
if (
|
|
843
|
-
const M = he(
|
|
844
|
-
return C ===
|
|
840
|
+
}, r = (b, x) => {
|
|
841
|
+
const v = Ot(typeof b == "string" ? x : b), C = typeof b == "string" ? b : b.id, B = C && t.get(C);
|
|
842
|
+
if (B) {
|
|
843
|
+
const M = he(B, v);
|
|
844
|
+
return C === v.id ? t.set(C, v) : (t.delete(C), t.set(v.id, v)), B.bodies.forEach((Y) => e.delete(Y.id)), v.bodies.forEach((Y) => e.set(Y.id, v.id)), M;
|
|
845
845
|
} else
|
|
846
846
|
console.warn(`Cannot update annotation ${C} - does not exist`);
|
|
847
|
-
}, l = (
|
|
848
|
-
const C = Ln(
|
|
849
|
-
|
|
850
|
-
}, f = (
|
|
851
|
-
const
|
|
852
|
-
const M = r(
|
|
847
|
+
}, l = (b, x = R.LOCAL, v = R.LOCAL) => {
|
|
848
|
+
const C = Ln(x) ? v : x, B = r(b, x);
|
|
849
|
+
B && s(C, { updated: [B] });
|
|
850
|
+
}, f = (b, x = R.LOCAL) => {
|
|
851
|
+
const v = b.reduce((C, B) => {
|
|
852
|
+
const M = r(B);
|
|
853
853
|
return M ? [...C, M] : C;
|
|
854
854
|
}, []);
|
|
855
|
-
|
|
856
|
-
},
|
|
857
|
-
const
|
|
858
|
-
if (
|
|
855
|
+
v.length > 0 && s(x, { updated: v });
|
|
856
|
+
}, d = (b, x = R.LOCAL) => {
|
|
857
|
+
const v = t.get(b.annotation);
|
|
858
|
+
if (v) {
|
|
859
859
|
const C = {
|
|
860
|
-
...
|
|
861
|
-
bodies: [...
|
|
860
|
+
...v,
|
|
861
|
+
bodies: [...v.bodies, b]
|
|
862
862
|
};
|
|
863
|
-
t.set(
|
|
864
|
-
oldValue:
|
|
863
|
+
t.set(v.id, C), e.set(b.id, C.id), s(x, { updated: [{
|
|
864
|
+
oldValue: v,
|
|
865
865
|
newValue: C,
|
|
866
|
-
bodiesCreated: [
|
|
866
|
+
bodiesCreated: [b]
|
|
867
867
|
}] });
|
|
868
868
|
} else
|
|
869
|
-
console.warn(`Attempt to add body to missing annotation: ${
|
|
870
|
-
}, h = () => [...t.values()], g = (
|
|
871
|
-
const
|
|
872
|
-
t.clear(), e.clear(), s(
|
|
873
|
-
}, p = (
|
|
874
|
-
const C =
|
|
875
|
-
if (
|
|
876
|
-
const
|
|
869
|
+
console.warn(`Attempt to add body to missing annotation: ${b.annotation}`);
|
|
870
|
+
}, h = () => [...t.values()], g = (b = R.LOCAL) => {
|
|
871
|
+
const x = [...t.values()];
|
|
872
|
+
t.clear(), e.clear(), s(b, { deleted: x });
|
|
873
|
+
}, p = (b, x = !0, v = R.LOCAL) => {
|
|
874
|
+
const C = b.map(Ot);
|
|
875
|
+
if (x) {
|
|
876
|
+
const B = [...t.values()];
|
|
877
877
|
t.clear(), e.clear(), C.forEach((M) => {
|
|
878
|
-
t.set(M.id, M), M.bodies.forEach((
|
|
879
|
-
}), s(
|
|
878
|
+
t.set(M.id, M), M.bodies.forEach((Y) => e.set(Y.id, M.id));
|
|
879
|
+
}), s(v, { created: C, deleted: B });
|
|
880
880
|
} else {
|
|
881
|
-
const
|
|
882
|
-
const
|
|
883
|
-
return
|
|
881
|
+
const B = b.reduce((M, Y) => {
|
|
882
|
+
const D = Y.id && t.get(Y.id);
|
|
883
|
+
return D ? [...M, D] : M;
|
|
884
884
|
}, []);
|
|
885
|
-
if (
|
|
886
|
-
throw Error(`Bulk insert would overwrite the following annotations: ${
|
|
885
|
+
if (B.length > 0)
|
|
886
|
+
throw Error(`Bulk insert would overwrite the following annotations: ${B.map((M) => M.id).join(", ")}`);
|
|
887
887
|
C.forEach((M) => {
|
|
888
|
-
t.set(M.id, M), M.bodies.forEach((
|
|
889
|
-
}), s(
|
|
888
|
+
t.set(M.id, M), M.bodies.forEach((Y) => e.set(Y.id, M.id));
|
|
889
|
+
}), s(v, { created: C });
|
|
890
890
|
}
|
|
891
|
-
},
|
|
892
|
-
const
|
|
893
|
-
if (
|
|
894
|
-
return t.delete(
|
|
895
|
-
console.warn(`Attempt to delete missing annotation: ${
|
|
896
|
-
}, y = (
|
|
897
|
-
const
|
|
898
|
-
|
|
899
|
-
}, m = (
|
|
900
|
-
const
|
|
901
|
-
const M =
|
|
891
|
+
}, A = (b) => {
|
|
892
|
+
const x = typeof b == "string" ? b : b.id, v = t.get(x);
|
|
893
|
+
if (v)
|
|
894
|
+
return t.delete(x), v.bodies.forEach((C) => e.delete(C.id)), v;
|
|
895
|
+
console.warn(`Attempt to delete missing annotation: ${x}`);
|
|
896
|
+
}, y = (b, x = R.LOCAL) => {
|
|
897
|
+
const v = A(b);
|
|
898
|
+
v && s(x, { deleted: [v] });
|
|
899
|
+
}, m = (b, x = R.LOCAL) => {
|
|
900
|
+
const v = b.reduce((C, B) => {
|
|
901
|
+
const M = A(B);
|
|
902
902
|
return M ? [...C, M] : C;
|
|
903
903
|
}, []);
|
|
904
|
-
|
|
905
|
-
},
|
|
906
|
-
const
|
|
907
|
-
if (
|
|
908
|
-
const
|
|
909
|
-
if (
|
|
910
|
-
e.delete(
|
|
904
|
+
v.length > 0 && s(x, { deleted: v });
|
|
905
|
+
}, u = (b) => {
|
|
906
|
+
const x = t.get(b.annotation);
|
|
907
|
+
if (x) {
|
|
908
|
+
const v = x.bodies.find((C) => C.id === b.id);
|
|
909
|
+
if (v) {
|
|
910
|
+
e.delete(v.id);
|
|
911
911
|
const C = {
|
|
912
|
-
...
|
|
913
|
-
bodies:
|
|
912
|
+
...x,
|
|
913
|
+
bodies: x.bodies.filter((B) => B.id !== b.id)
|
|
914
914
|
};
|
|
915
|
-
return t.set(
|
|
916
|
-
oldValue:
|
|
915
|
+
return t.set(x.id, C), {
|
|
916
|
+
oldValue: x,
|
|
917
917
|
newValue: C,
|
|
918
|
-
bodiesDeleted: [
|
|
918
|
+
bodiesDeleted: [v]
|
|
919
919
|
};
|
|
920
920
|
} else
|
|
921
|
-
console.warn(`Attempt to delete missing body ${
|
|
921
|
+
console.warn(`Attempt to delete missing body ${b.id} from annotation ${b.annotation}`);
|
|
922
922
|
} else
|
|
923
|
-
console.warn(`Attempt to delete body from missing annotation ${
|
|
924
|
-
}, c = (
|
|
925
|
-
const
|
|
926
|
-
|
|
927
|
-
},
|
|
928
|
-
const
|
|
929
|
-
|
|
930
|
-
}, S = (
|
|
931
|
-
const
|
|
932
|
-
return
|
|
933
|
-
}, T = (
|
|
934
|
-
const
|
|
935
|
-
if (
|
|
936
|
-
const
|
|
937
|
-
if (
|
|
938
|
-
return
|
|
939
|
-
console.error(`Store integrity error: body ${
|
|
923
|
+
console.warn(`Attempt to delete body from missing annotation ${b.annotation}`);
|
|
924
|
+
}, c = (b, x = R.LOCAL) => {
|
|
925
|
+
const v = u(b);
|
|
926
|
+
v && s(x, { updated: [v] });
|
|
927
|
+
}, w = (b, x = R.LOCAL) => {
|
|
928
|
+
const v = b.map((C) => u(C)).filter(Boolean);
|
|
929
|
+
v.length > 0 && s(x, { updated: v });
|
|
930
|
+
}, S = (b) => {
|
|
931
|
+
const x = t.get(b);
|
|
932
|
+
return x ? { ...x } : void 0;
|
|
933
|
+
}, T = (b) => {
|
|
934
|
+
const x = e.get(b);
|
|
935
|
+
if (x) {
|
|
936
|
+
const v = S(x).bodies.find((C) => C.id === b);
|
|
937
|
+
if (v)
|
|
938
|
+
return v;
|
|
939
|
+
console.error(`Store integrity error: body ${b} in index, but not in annotation`);
|
|
940
940
|
} else
|
|
941
|
-
console.warn(`Attempt to retrieve missing body: ${
|
|
942
|
-
}, L = (
|
|
943
|
-
if (
|
|
941
|
+
console.warn(`Attempt to retrieve missing body: ${b}`);
|
|
942
|
+
}, L = (b, x) => {
|
|
943
|
+
if (b.annotation !== x.annotation)
|
|
944
944
|
throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
|
|
945
|
-
const
|
|
946
|
-
if (
|
|
947
|
-
const C =
|
|
948
|
-
...
|
|
949
|
-
bodies:
|
|
945
|
+
const v = t.get(b.annotation);
|
|
946
|
+
if (v) {
|
|
947
|
+
const C = v.bodies.find((M) => M.id === b.id), B = {
|
|
948
|
+
...v,
|
|
949
|
+
bodies: v.bodies.map((M) => M.id === C.id ? x : M)
|
|
950
950
|
};
|
|
951
|
-
return t.set(
|
|
952
|
-
oldValue:
|
|
953
|
-
newValue:
|
|
954
|
-
bodiesUpdated: [{ oldBody: C, newBody:
|
|
951
|
+
return t.set(v.id, B), C.id !== x.id && (e.delete(C.id), e.set(x.id, B.id)), {
|
|
952
|
+
oldValue: v,
|
|
953
|
+
newValue: B,
|
|
954
|
+
bodiesUpdated: [{ oldBody: C, newBody: x }]
|
|
955
955
|
};
|
|
956
956
|
} else
|
|
957
|
-
console.warn(`Attempt to add body to missing annotation ${
|
|
958
|
-
},
|
|
959
|
-
const C = L(
|
|
960
|
-
C && s(
|
|
961
|
-
},
|
|
962
|
-
const
|
|
963
|
-
s(
|
|
964
|
-
},
|
|
965
|
-
const
|
|
966
|
-
if (
|
|
967
|
-
const
|
|
968
|
-
...
|
|
957
|
+
console.warn(`Attempt to add body to missing annotation ${b.annotation}`);
|
|
958
|
+
}, E = (b, x, v = R.LOCAL) => {
|
|
959
|
+
const C = L(b, x);
|
|
960
|
+
C && s(v, { updated: [C] });
|
|
961
|
+
}, O = (b, x = R.LOCAL) => {
|
|
962
|
+
const v = b.map((C) => L({ id: C.id, annotation: C.annotation }, C)).filter(Boolean);
|
|
963
|
+
s(x, { updated: v });
|
|
964
|
+
}, _ = (b) => {
|
|
965
|
+
const x = t.get(b.annotation);
|
|
966
|
+
if (x) {
|
|
967
|
+
const v = {
|
|
968
|
+
...x,
|
|
969
969
|
target: {
|
|
970
|
-
...
|
|
971
|
-
...
|
|
970
|
+
...x.target,
|
|
971
|
+
...b
|
|
972
972
|
}
|
|
973
973
|
};
|
|
974
|
-
return t.set(
|
|
975
|
-
oldValue:
|
|
976
|
-
newValue:
|
|
974
|
+
return t.set(x.id, v), {
|
|
975
|
+
oldValue: x,
|
|
976
|
+
newValue: v,
|
|
977
977
|
targetUpdated: {
|
|
978
|
-
oldTarget:
|
|
979
|
-
newTarget:
|
|
978
|
+
oldTarget: x.target,
|
|
979
|
+
newTarget: b
|
|
980
980
|
}
|
|
981
981
|
};
|
|
982
982
|
} else
|
|
983
|
-
console.warn(`Attempt to update target on missing annotation: ${
|
|
983
|
+
console.warn(`Attempt to update target on missing annotation: ${b.annotation}`);
|
|
984
984
|
};
|
|
985
985
|
return {
|
|
986
986
|
addAnnotation: a,
|
|
987
|
-
addBody:
|
|
987
|
+
addBody: d,
|
|
988
988
|
all: h,
|
|
989
989
|
bulkAddAnnotation: p,
|
|
990
990
|
bulkDeleteAnnotation: m,
|
|
991
|
-
bulkDeleteBodies:
|
|
991
|
+
bulkDeleteBodies: w,
|
|
992
992
|
bulkUpdateAnnotation: f,
|
|
993
|
-
bulkUpdateBodies:
|
|
994
|
-
bulkUpdateTargets: (
|
|
995
|
-
const
|
|
996
|
-
|
|
993
|
+
bulkUpdateBodies: O,
|
|
994
|
+
bulkUpdateTargets: (b, x = R.LOCAL) => {
|
|
995
|
+
const v = b.map((C) => _(C)).filter(Boolean);
|
|
996
|
+
v.length > 0 && s(x, { updated: v });
|
|
997
997
|
},
|
|
998
998
|
clear: g,
|
|
999
999
|
deleteAnnotation: y,
|
|
@@ -1003,10 +1003,10 @@ const Sn = (t, e) => {
|
|
|
1003
1003
|
observe: o,
|
|
1004
1004
|
unobserve: i,
|
|
1005
1005
|
updateAnnotation: l,
|
|
1006
|
-
updateBody:
|
|
1007
|
-
updateTarget: (
|
|
1008
|
-
const
|
|
1009
|
-
|
|
1006
|
+
updateBody: E,
|
|
1007
|
+
updateTarget: (b, x = R.LOCAL) => {
|
|
1008
|
+
const v = _(b);
|
|
1009
|
+
v && s(x, { updated: [v] });
|
|
1010
1010
|
}
|
|
1011
1011
|
};
|
|
1012
1012
|
};
|
|
@@ -1029,36 +1029,36 @@ const Mn = 250, Rn = (t) => {
|
|
|
1029
1029
|
let o = -1, i = !1, s = 0;
|
|
1030
1030
|
const a = (p) => {
|
|
1031
1031
|
if (!i) {
|
|
1032
|
-
const { changes:
|
|
1032
|
+
const { changes: A } = p, y = performance.now();
|
|
1033
1033
|
if (y - s > Mn)
|
|
1034
|
-
n.splice(o + 1), n.push(
|
|
1034
|
+
n.splice(o + 1), n.push(A), o = n.length - 1;
|
|
1035
1035
|
else {
|
|
1036
1036
|
const m = n.length - 1;
|
|
1037
|
-
n[m] = Cn(n[m],
|
|
1037
|
+
n[m] = Cn(n[m], A);
|
|
1038
1038
|
}
|
|
1039
1039
|
s = y;
|
|
1040
1040
|
}
|
|
1041
1041
|
i = !1;
|
|
1042
1042
|
};
|
|
1043
|
-
t.observe(a, { origin:
|
|
1044
|
-
const r = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p), l = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), f = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ oldValue:
|
|
1043
|
+
t.observe(a, { origin: R.LOCAL });
|
|
1044
|
+
const r = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p), l = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), f = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ oldValue: A }) => A)), d = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ newValue: A }) => A)), h = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), g = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p);
|
|
1045
1045
|
return {
|
|
1046
1046
|
canRedo: () => n.length - 1 > o,
|
|
1047
1047
|
canUndo: () => o > -1,
|
|
1048
1048
|
destroy: () => t.unobserve(a),
|
|
1049
|
-
on: (p,
|
|
1049
|
+
on: (p, A) => e.on(p, A),
|
|
1050
1050
|
redo: () => {
|
|
1051
1051
|
if (n.length - 1 > o) {
|
|
1052
1052
|
i = !0;
|
|
1053
|
-
const { created: p, updated:
|
|
1054
|
-
l(p),
|
|
1053
|
+
const { created: p, updated: A, deleted: y } = n[o + 1];
|
|
1054
|
+
l(p), d(A), g(y), e.emit("redo", n[o + 1]), o += 1;
|
|
1055
1055
|
}
|
|
1056
1056
|
},
|
|
1057
1057
|
undo: () => {
|
|
1058
1058
|
if (o > -1) {
|
|
1059
1059
|
i = !0;
|
|
1060
|
-
const { created: p, updated:
|
|
1061
|
-
r(p), f(
|
|
1060
|
+
const { created: p, updated: A, deleted: y } = n[o];
|
|
1061
|
+
r(p), f(A), h(y), e.emit("undo", n[o]), o -= 1;
|
|
1062
1062
|
}
|
|
1063
1063
|
}
|
|
1064
1064
|
};
|
|
@@ -1070,23 +1070,23 @@ const Mn = 250, Rn = (t) => {
|
|
|
1070
1070
|
};
|
|
1071
1071
|
}, kn = (t, e, n, o) => {
|
|
1072
1072
|
const { hover: i, selection: s, store: a, viewport: r } = t, l = /* @__PURE__ */ new Map();
|
|
1073
|
-
let f = [],
|
|
1073
|
+
let f = [], d;
|
|
1074
1074
|
const h = (y, m) => {
|
|
1075
1075
|
l.has(y) ? l.get(y).push(m) : l.set(y, [m]);
|
|
1076
1076
|
}, g = (y, m) => {
|
|
1077
|
-
const
|
|
1078
|
-
if (
|
|
1079
|
-
const c =
|
|
1080
|
-
c !== -1 &&
|
|
1077
|
+
const u = l.get(y);
|
|
1078
|
+
if (u) {
|
|
1079
|
+
const c = u.indexOf(m);
|
|
1080
|
+
c !== -1 && u.splice(c, 1);
|
|
1081
1081
|
}
|
|
1082
|
-
}, p = (y, m,
|
|
1082
|
+
}, p = (y, m, u) => {
|
|
1083
1083
|
l.has(y) && setTimeout(() => {
|
|
1084
1084
|
l.get(y).forEach((c) => {
|
|
1085
1085
|
if (n) {
|
|
1086
|
-
const
|
|
1087
|
-
c(
|
|
1086
|
+
const w = Array.isArray(m) ? m.map((T) => n.serialize(T)) : n.serialize(m), S = u ? u instanceof PointerEvent ? u : n.serialize(u) : void 0;
|
|
1087
|
+
c(w, S);
|
|
1088
1088
|
} else
|
|
1089
|
-
c(m,
|
|
1089
|
+
c(m, u);
|
|
1090
1090
|
});
|
|
1091
1091
|
}, 1);
|
|
1092
1092
|
};
|
|
@@ -1096,17 +1096,17 @@ const Mn = 250, Rn = (t) => {
|
|
|
1096
1096
|
f = y.map(({ id: m }) => a.getAnnotation(m));
|
|
1097
1097
|
else if (f.length > 0 && y.length === 0)
|
|
1098
1098
|
f.forEach((m) => {
|
|
1099
|
-
const
|
|
1100
|
-
|
|
1099
|
+
const u = a.getAnnotation(m.id);
|
|
1100
|
+
u && !q(u, m) && p("updateAnnotation", u, m);
|
|
1101
1101
|
}), f = [];
|
|
1102
1102
|
else {
|
|
1103
|
-
const m = new Set(f.map((c) => c.id)),
|
|
1104
|
-
f.filter((c) => !
|
|
1105
|
-
const
|
|
1106
|
-
|
|
1103
|
+
const m = new Set(f.map((c) => c.id)), u = new Set(y.map(({ id: c }) => c));
|
|
1104
|
+
f.filter((c) => !u.has(c.id)).forEach((c) => {
|
|
1105
|
+
const w = a.getAnnotation(c.id);
|
|
1106
|
+
w && !q(w, c) && p("updateAnnotation", w, c);
|
|
1107
1107
|
}), f = [
|
|
1108
1108
|
// Remove annotations that were deselected
|
|
1109
|
-
...f.filter((c) =>
|
|
1109
|
+
...f.filter((c) => u.has(c.id)),
|
|
1110
1110
|
// Add editable annotations that were selected
|
|
1111
1111
|
...y.filter(({ id: c }) => !m.has(c)).map(({ id: c }) => a.getAnnotation(c))
|
|
1112
1112
|
];
|
|
@@ -1114,28 +1114,28 @@ const Mn = 250, Rn = (t) => {
|
|
|
1114
1114
|
p("selectionChanged", f);
|
|
1115
1115
|
}
|
|
1116
1116
|
}), i.subscribe((y) => {
|
|
1117
|
-
!
|
|
1117
|
+
!d && y ? p("mouseEnterAnnotation", a.getAnnotation(y)) : d && !y ? p("mouseLeaveAnnotation", a.getAnnotation(d)) : d && y && (p("mouseLeaveAnnotation", a.getAnnotation(d)), p("mouseEnterAnnotation", a.getAnnotation(y))), d = y;
|
|
1118
1118
|
}), r == null || r.subscribe((y) => p("viewportIntersect", y.map((m) => a.getAnnotation(m)))), a.observe((y) => {
|
|
1119
|
-
const { created: m, deleted:
|
|
1120
|
-
(m || []).forEach((c) => p("createAnnotation", c)), (
|
|
1119
|
+
const { created: m, deleted: u } = y.changes;
|
|
1120
|
+
(m || []).forEach((c) => p("createAnnotation", c)), (u || []).forEach((c) => p("deleteAnnotation", c)), (y.changes.updated || []).filter((c) => [
|
|
1121
1121
|
...c.bodiesCreated || [],
|
|
1122
1122
|
...c.bodiesDeleted || [],
|
|
1123
1123
|
...c.bodiesUpdated || []
|
|
1124
|
-
].length > 0).forEach(({ oldValue: c, newValue:
|
|
1124
|
+
].length > 0).forEach(({ oldValue: c, newValue: w }) => {
|
|
1125
1125
|
const S = f.find((T) => T.id === c.id) || c;
|
|
1126
|
-
f = f.map((T) => T.id === c.id ?
|
|
1126
|
+
f = f.map((T) => T.id === c.id ? w : T), p("updateAnnotation", w, S);
|
|
1127
1127
|
});
|
|
1128
|
-
}, { origin:
|
|
1128
|
+
}, { origin: R.LOCAL }), a.observe((y) => {
|
|
1129
1129
|
if (f) {
|
|
1130
|
-
const m = new Set(f.map((c) => c.id)),
|
|
1131
|
-
|
|
1130
|
+
const m = new Set(f.map((c) => c.id)), u = (y.changes.updated || []).filter(({ newValue: c }) => m.has(c.id)).map(({ newValue: c }) => c);
|
|
1131
|
+
u.length > 0 && (f = f.map((c) => u.find((S) => S.id === c.id) || c));
|
|
1132
1132
|
}
|
|
1133
|
-
}, { origin:
|
|
1134
|
-
const
|
|
1135
|
-
const { updated:
|
|
1136
|
-
y ? (
|
|
1133
|
+
}, { origin: R.REMOTE });
|
|
1134
|
+
const A = (y) => (m) => {
|
|
1135
|
+
const { updated: u } = m;
|
|
1136
|
+
y ? (u || []).forEach((c) => p("updateAnnotation", c.oldValue, c.newValue)) : (u || []).forEach((c) => p("updateAnnotation", c.newValue, c.oldValue));
|
|
1137
1137
|
};
|
|
1138
|
-
return e.on("undo",
|
|
1138
|
+
return e.on("undo", A(!0)), e.on("redo", A(!1)), { on: h, off: g, emit: p };
|
|
1139
1139
|
}, In = (t) => (e) => e.reduce((n, o) => {
|
|
1140
1140
|
const { parsed: i, error: s } = t.parse(o);
|
|
1141
1141
|
return s ? {
|
|
@@ -1148,46 +1148,46 @@ const Mn = 250, Rn = (t) => {
|
|
|
1148
1148
|
...n
|
|
1149
1149
|
};
|
|
1150
1150
|
}, { parsed: [], failed: [] }), _n = (t, e, n) => {
|
|
1151
|
-
const { store: o, selection: i } = t, s = (
|
|
1151
|
+
const { store: o, selection: i } = t, s = (u) => {
|
|
1152
1152
|
if (n) {
|
|
1153
|
-
const { parsed: c, error:
|
|
1154
|
-
c ? o.addAnnotation(c,
|
|
1153
|
+
const { parsed: c, error: w } = n.parse(u);
|
|
1154
|
+
c ? o.addAnnotation(c, R.REMOTE) : console.error(w);
|
|
1155
1155
|
} else
|
|
1156
|
-
o.addAnnotation(Tt(
|
|
1157
|
-
}, a = () => i.clear(), r = () => o.clear(), l = (
|
|
1158
|
-
const c = o.getAnnotation(
|
|
1156
|
+
o.addAnnotation(Tt(u), R.REMOTE);
|
|
1157
|
+
}, a = () => i.clear(), r = () => o.clear(), l = (u) => {
|
|
1158
|
+
const c = o.getAnnotation(u);
|
|
1159
1159
|
return n && c ? n.serialize(c) : c;
|
|
1160
|
-
}, f = () => n ? o.all().map(n.serialize) : o.all(),
|
|
1161
|
-
var
|
|
1162
|
-
const c = (((
|
|
1160
|
+
}, f = () => n ? o.all().map(n.serialize) : o.all(), d = () => {
|
|
1161
|
+
var u;
|
|
1162
|
+
const c = (((u = i.selected) == null ? void 0 : u.map((w) => w.id)) || []).map((w) => o.getAnnotation(w)).filter(Boolean);
|
|
1163
1163
|
return n ? c.map(n.serialize) : c;
|
|
1164
|
-
}, h = (
|
|
1165
|
-
if (typeof
|
|
1166
|
-
const c = o.getAnnotation(
|
|
1167
|
-
if (o.deleteAnnotation(
|
|
1164
|
+
}, h = (u, c = !0) => fetch(u).then((w) => w.json()).then((w) => (p(w, c), w)), g = (u) => {
|
|
1165
|
+
if (typeof u == "string") {
|
|
1166
|
+
const c = o.getAnnotation(u);
|
|
1167
|
+
if (o.deleteAnnotation(u), c)
|
|
1168
1168
|
return n ? n.serialize(c) : c;
|
|
1169
1169
|
} else {
|
|
1170
|
-
const c = n ? n.parse(
|
|
1170
|
+
const c = n ? n.parse(u).parsed : u;
|
|
1171
1171
|
if (c)
|
|
1172
|
-
return o.deleteAnnotation(c),
|
|
1172
|
+
return o.deleteAnnotation(c), u;
|
|
1173
1173
|
}
|
|
1174
|
-
}, p = (
|
|
1174
|
+
}, p = (u, c = !0) => {
|
|
1175
1175
|
if (n) {
|
|
1176
|
-
const
|
|
1177
|
-
T.length > 0 && console.warn(`Discarded ${T.length} invalid annotations`, T), o.bulkAddAnnotation(S, c,
|
|
1176
|
+
const w = n.parseAll || In(n), { parsed: S, failed: T } = w(u);
|
|
1177
|
+
T.length > 0 && console.warn(`Discarded ${T.length} invalid annotations`, T), o.bulkAddAnnotation(S, c, R.REMOTE);
|
|
1178
1178
|
} else
|
|
1179
|
-
o.bulkAddAnnotation(
|
|
1180
|
-
},
|
|
1181
|
-
|
|
1182
|
-
}, y = (
|
|
1183
|
-
i.clear(), i.setUserSelectAction(
|
|
1184
|
-
}, m = (
|
|
1179
|
+
o.bulkAddAnnotation(u.map(Tt), c, R.REMOTE);
|
|
1180
|
+
}, A = (u, c) => {
|
|
1181
|
+
u ? i.setSelected(u, c) : i.clear();
|
|
1182
|
+
}, y = (u) => {
|
|
1183
|
+
i.clear(), i.setUserSelectAction(u);
|
|
1184
|
+
}, m = (u) => {
|
|
1185
1185
|
if (n) {
|
|
1186
|
-
const c = n.parse(
|
|
1187
|
-
return o.updateAnnotation(c),
|
|
1186
|
+
const c = n.parse(u).parsed, w = n.serialize(o.getAnnotation(c.id));
|
|
1187
|
+
return o.updateAnnotation(c), w;
|
|
1188
1188
|
} else {
|
|
1189
|
-
const c = o.getAnnotation(
|
|
1190
|
-
return o.updateAnnotation(Tt(
|
|
1189
|
+
const c = o.getAnnotation(u.id);
|
|
1190
|
+
return o.updateAnnotation(Tt(u)), c;
|
|
1191
1191
|
}
|
|
1192
1192
|
};
|
|
1193
1193
|
return {
|
|
@@ -1198,12 +1198,12 @@ const Mn = 250, Rn = (t) => {
|
|
|
1198
1198
|
clearAnnotations: r,
|
|
1199
1199
|
getAnnotationById: l,
|
|
1200
1200
|
getAnnotations: f,
|
|
1201
|
-
getSelected:
|
|
1201
|
+
getSelected: d,
|
|
1202
1202
|
loadAnnotations: h,
|
|
1203
1203
|
redo: e.redo,
|
|
1204
1204
|
removeAnnotation: g,
|
|
1205
1205
|
setAnnotations: p,
|
|
1206
|
-
setSelected:
|
|
1206
|
+
setSelected: A,
|
|
1207
1207
|
setUserSelectAction: y,
|
|
1208
1208
|
undo: e.undo,
|
|
1209
1209
|
updateAnnotation: m
|
|
@@ -1234,7 +1234,7 @@ const Dn = () => ({ isGuest: !0, id: Kn("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1234
1234
|
}
|
|
1235
1235
|
return `${n}`;
|
|
1236
1236
|
}, pe = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, Pn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
|
|
1237
|
-
const { id: o, type: i, purpose: s, value: a, created: r, modified: l, creator: f, ...
|
|
1237
|
+
const { id: o, type: i, purpose: s, value: a, created: r, modified: l, creator: f, ...d } = n;
|
|
1238
1238
|
return {
|
|
1239
1239
|
id: o || `temp-${Xn(n)}`,
|
|
1240
1240
|
annotation: e,
|
|
@@ -1244,7 +1244,7 @@ const Dn = () => ({ isGuest: !0, id: Kn("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1244
1244
|
creator: pe(f),
|
|
1245
1245
|
created: r ? new Date(r) : void 0,
|
|
1246
1246
|
updated: l ? new Date(l) : void 0,
|
|
1247
|
-
...
|
|
1247
|
+
...d
|
|
1248
1248
|
};
|
|
1249
1249
|
}), $n = (t) => t.map((e) => {
|
|
1250
1250
|
var n;
|
|
@@ -1266,15 +1266,20 @@ const Ao = (t, e) => ({
|
|
|
1266
1266
|
created: o,
|
|
1267
1267
|
modified: i,
|
|
1268
1268
|
target: s
|
|
1269
|
-
} = t, a = Array.isArray(s) ? s : [s]
|
|
1269
|
+
} = t, a = Array.isArray(s) ? s : [s];
|
|
1270
|
+
if (a.length === 0)
|
|
1271
|
+
return { error: Error(`No targets found for annotation: ${t.id}`) };
|
|
1272
|
+
const r = {
|
|
1270
1273
|
creator: pe(n),
|
|
1271
1274
|
created: o ? new Date(o) : void 0,
|
|
1272
1275
|
updated: i ? new Date(i) : void 0,
|
|
1273
1276
|
annotation: e,
|
|
1274
|
-
selector: []
|
|
1277
|
+
selector: [],
|
|
1278
|
+
// @ts-expect-error: `styleClass` is not part of the core `TextAnnotationTarget` type
|
|
1279
|
+
styleClass: "styleClass" in a[0] ? a[0].styleClass : void 0
|
|
1275
1280
|
};
|
|
1276
1281
|
for (const l of a) {
|
|
1277
|
-
const
|
|
1282
|
+
const d = (Array.isArray(l.selector) ? l.selector : [l.selector]).reduce((h, g) => {
|
|
1278
1283
|
switch (g.type) {
|
|
1279
1284
|
case "TextQuoteSelector":
|
|
1280
1285
|
h.quote = g.exact;
|
|
@@ -1285,12 +1290,19 @@ const Ao = (t, e) => ({
|
|
|
1285
1290
|
}
|
|
1286
1291
|
return h;
|
|
1287
1292
|
}, {});
|
|
1288
|
-
if (Hn(
|
|
1289
|
-
r.selector.push(
|
|
1293
|
+
if (Hn(d))
|
|
1294
|
+
r.selector.push(
|
|
1295
|
+
{
|
|
1296
|
+
...d,
|
|
1297
|
+
id: l.id,
|
|
1298
|
+
// @ts-expect-error: `scope` is not part of the core `TextSelector` type
|
|
1299
|
+
scope: l.scope
|
|
1300
|
+
}
|
|
1301
|
+
);
|
|
1290
1302
|
else {
|
|
1291
1303
|
const h = [
|
|
1292
|
-
|
|
1293
|
-
|
|
1304
|
+
d.start ? void 0 : "TextPositionSelector",
|
|
1305
|
+
d.quote ? void 0 : "TextQuoteSelector"
|
|
1294
1306
|
].filter(Boolean);
|
|
1295
1307
|
return { error: Error(`Missing selector types: ${h.join(" and ")} for annotation: ${t.id}`) };
|
|
1296
1308
|
}
|
|
@@ -1318,23 +1330,25 @@ const Ao = (t, e) => ({
|
|
|
1318
1330
|
creator: r,
|
|
1319
1331
|
created: l,
|
|
1320
1332
|
updated: f,
|
|
1321
|
-
...
|
|
1333
|
+
...d
|
|
1322
1334
|
} = i, h = a.map((g) => {
|
|
1323
|
-
const {
|
|
1335
|
+
const { id: p, quote: A, start: y, end: m, range: u } = g, { prefix: c, suffix: w } = ke(u, n), S = [{
|
|
1324
1336
|
type: "TextQuoteSelector",
|
|
1325
|
-
exact:
|
|
1326
|
-
prefix:
|
|
1327
|
-
suffix:
|
|
1337
|
+
exact: A,
|
|
1338
|
+
prefix: c,
|
|
1339
|
+
suffix: w
|
|
1328
1340
|
}, {
|
|
1329
1341
|
type: "TextPositionSelector",
|
|
1330
|
-
start:
|
|
1331
|
-
end:
|
|
1342
|
+
start: y,
|
|
1343
|
+
end: m
|
|
1332
1344
|
}];
|
|
1333
1345
|
return {
|
|
1334
|
-
...
|
|
1335
|
-
id:
|
|
1346
|
+
...d,
|
|
1347
|
+
id: p,
|
|
1348
|
+
// @ts-expect-error: `scope` is not part of the core `TextSelector` type
|
|
1349
|
+
scope: "scope" in g ? g.scope : void 0,
|
|
1336
1350
|
source: e,
|
|
1337
|
-
selector:
|
|
1351
|
+
selector: S
|
|
1338
1352
|
};
|
|
1339
1353
|
});
|
|
1340
1354
|
return {
|
|
@@ -1352,8 +1366,8 @@ const Ao = (t, e) => ({
|
|
|
1352
1366
|
function ge(t, e, n = 0, o = t.length - 1, i = Wn) {
|
|
1353
1367
|
for (; o > n; ) {
|
|
1354
1368
|
if (o - n > 600) {
|
|
1355
|
-
const l = o - n + 1, f = e - n + 1,
|
|
1356
|
-
ge(t, e, p,
|
|
1369
|
+
const l = o - n + 1, f = e - n + 1, d = Math.log(l), h = 0.5 * Math.exp(2 * d / 3), g = 0.5 * Math.sqrt(d * h * (l - h) / l) * (f - l / 2 < 0 ? -1 : 1), p = Math.max(n, Math.floor(e - f * h / l + g)), A = Math.min(o, Math.floor(e + (l - f) * h / l + g));
|
|
1370
|
+
ge(t, e, p, A, i);
|
|
1357
1371
|
}
|
|
1358
1372
|
const s = t[e];
|
|
1359
1373
|
let a = n, r = o;
|
|
@@ -1442,9 +1456,9 @@ class qn {
|
|
|
1442
1456
|
let r, l, f;
|
|
1443
1457
|
for (; o || s.length; ) {
|
|
1444
1458
|
if (o || (o = s.pop(), l = s[s.length - 1], r = a.pop(), f = !0), o.leaf) {
|
|
1445
|
-
const
|
|
1446
|
-
if (
|
|
1447
|
-
return o.children.splice(
|
|
1459
|
+
const d = Gn(e, o.children, n);
|
|
1460
|
+
if (d !== -1)
|
|
1461
|
+
return o.children.splice(d, 1), s.push(o), this._condense(s), this;
|
|
1448
1462
|
}
|
|
1449
1463
|
!f && !o.leaf && Rt(o, i) ? (s.push(o), a.push(r), r = 0, l = o, o = o.children[0]) : l ? (r++, o = l.children[r], f = !1) : o = null;
|
|
1450
1464
|
}
|
|
@@ -1479,10 +1493,10 @@ class qn {
|
|
|
1479
1493
|
i || (i = Math.ceil(Math.log(s) / Math.log(a)), a = Math.ceil(s / Math.pow(a, i - 1))), r = J([]), r.leaf = !1, r.height = i;
|
|
1480
1494
|
const l = Math.ceil(s / a), f = l * Math.ceil(Math.sqrt(a));
|
|
1481
1495
|
te(e, n, o, f, this.compareMinX);
|
|
1482
|
-
for (let
|
|
1483
|
-
const h = Math.min(
|
|
1484
|
-
te(e,
|
|
1485
|
-
for (let g =
|
|
1496
|
+
for (let d = n; d <= o; d += f) {
|
|
1497
|
+
const h = Math.min(d + f - 1, o);
|
|
1498
|
+
te(e, d, h, l, this.compareMinY);
|
|
1499
|
+
for (let g = d; g <= h; g += l) {
|
|
1486
1500
|
const p = Math.min(g + l - 1, h);
|
|
1487
1501
|
r.children.push(this._build(e, g, p, i - 1));
|
|
1488
1502
|
}
|
|
@@ -1493,8 +1507,8 @@ class qn {
|
|
|
1493
1507
|
for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
|
|
1494
1508
|
let s = 1 / 0, a = 1 / 0, r;
|
|
1495
1509
|
for (let l = 0; l < n.children.length; l++) {
|
|
1496
|
-
const f = n.children[l],
|
|
1497
|
-
h < a ? (a = h, s =
|
|
1510
|
+
const f = n.children[l], d = Mt(f), h = Zn(e, f) - d;
|
|
1511
|
+
h < a ? (a = h, s = d < s ? d : s, r = f) : h === a && d < s && (s = d, r = f);
|
|
1498
1512
|
}
|
|
1499
1513
|
n = r || n.children[0];
|
|
1500
1514
|
}
|
|
@@ -1519,8 +1533,8 @@ class qn {
|
|
|
1519
1533
|
_chooseSplitIndex(e, n, o) {
|
|
1520
1534
|
let i, s = 1 / 0, a = 1 / 0;
|
|
1521
1535
|
for (let r = n; r <= o - n; r++) {
|
|
1522
|
-
const l = ot(e, 0, r, this.toBBox), f = ot(e, r, o, this.toBBox),
|
|
1523
|
-
|
|
1536
|
+
const l = ot(e, 0, r, this.toBBox), f = ot(e, r, o, this.toBBox), d = to(l, f), h = Mt(l) + Mt(f);
|
|
1537
|
+
d < s ? (s = d, i = r, a = h < a ? h : a) : d === s && h < a && (a = h, i = r);
|
|
1524
1538
|
}
|
|
1525
1539
|
return i || o - n;
|
|
1526
1540
|
}
|
|
@@ -1535,12 +1549,12 @@ class qn {
|
|
|
1535
1549
|
const s = this.toBBox, a = ot(e, 0, n, s), r = ot(e, o - n, o, s);
|
|
1536
1550
|
let l = pt(a) + pt(r);
|
|
1537
1551
|
for (let f = n; f < o - n; f++) {
|
|
1538
|
-
const
|
|
1539
|
-
it(a, e.leaf ? s(
|
|
1552
|
+
const d = e.children[f];
|
|
1553
|
+
it(a, e.leaf ? s(d) : d), l += pt(a);
|
|
1540
1554
|
}
|
|
1541
1555
|
for (let f = o - n - 1; f >= n; f--) {
|
|
1542
|
-
const
|
|
1543
|
-
it(r, e.leaf ? s(
|
|
1556
|
+
const d = e.children[f];
|
|
1557
|
+
it(r, e.leaf ? s(d) : d), l += pt(r);
|
|
1544
1558
|
}
|
|
1545
1559
|
return l;
|
|
1546
1560
|
}
|
|
@@ -1618,60 +1632,60 @@ function te(t, e, n, o, i) {
|
|
|
1618
1632
|
}
|
|
1619
1633
|
}
|
|
1620
1634
|
const eo = (t, e) => {
|
|
1621
|
-
const n = new qn(), o = /* @__PURE__ */ new Map(), i = (
|
|
1622
|
-
const
|
|
1635
|
+
const n = new qn(), o = /* @__PURE__ */ new Map(), i = (u, c) => {
|
|
1636
|
+
const w = u.selector.flatMap((T) => {
|
|
1623
1637
|
const L = F([T]) ? T.range : re(T, e).range;
|
|
1624
1638
|
return Array.from(L.getClientRects());
|
|
1625
|
-
}), S = Ve(
|
|
1639
|
+
}), S = Ve(w).map(({ left: T, top: L, right: E, bottom: O }) => new DOMRect(T - c.left, L - c.top, E - T, O - L));
|
|
1626
1640
|
return S.map((T) => {
|
|
1627
|
-
const { x: L, y:
|
|
1641
|
+
const { x: L, y: E, width: O, height: _ } = T;
|
|
1628
1642
|
return {
|
|
1629
1643
|
minX: L,
|
|
1630
|
-
minY:
|
|
1631
|
-
maxX: L +
|
|
1632
|
-
maxY:
|
|
1644
|
+
minY: E,
|
|
1645
|
+
maxX: L + O,
|
|
1646
|
+
maxY: E + _,
|
|
1633
1647
|
annotation: {
|
|
1634
|
-
id:
|
|
1648
|
+
id: u.annotation,
|
|
1635
1649
|
rects: S
|
|
1636
1650
|
}
|
|
1637
1651
|
};
|
|
1638
1652
|
});
|
|
1639
1653
|
}, s = () => [...o.values()], a = () => {
|
|
1640
1654
|
n.clear(), o.clear();
|
|
1641
|
-
}, r = (
|
|
1642
|
-
const c = i(
|
|
1643
|
-
c.forEach((
|
|
1644
|
-
}, l = (
|
|
1645
|
-
const c = o.get(
|
|
1646
|
-
c && (c.forEach((
|
|
1647
|
-
}, f = (
|
|
1648
|
-
l(
|
|
1649
|
-
},
|
|
1655
|
+
}, r = (u) => {
|
|
1656
|
+
const c = i(u, e.getBoundingClientRect());
|
|
1657
|
+
c.forEach((w) => n.insert(w)), o.set(u.annotation, c);
|
|
1658
|
+
}, l = (u) => {
|
|
1659
|
+
const c = o.get(u.annotation);
|
|
1660
|
+
c && (c.forEach((w) => n.remove(w)), o.delete(u.annotation));
|
|
1661
|
+
}, f = (u) => {
|
|
1662
|
+
l(u), r(u);
|
|
1663
|
+
}, d = (u, c = !0) => {
|
|
1650
1664
|
c && a();
|
|
1651
|
-
const
|
|
1652
|
-
S.forEach(({ target: L, rects:
|
|
1665
|
+
const w = e.getBoundingClientRect(), S = u.map((L) => ({ target: L, rects: i(L, w) }));
|
|
1666
|
+
S.forEach(({ target: L, rects: E }) => o.set(L.annotation, E));
|
|
1653
1667
|
const T = S.flatMap(({ rects: L }) => L);
|
|
1654
1668
|
n.load(T);
|
|
1655
|
-
}, h = (
|
|
1669
|
+
}, h = (u, c, w = !1) => {
|
|
1656
1670
|
const S = n.search({
|
|
1657
|
-
minX:
|
|
1671
|
+
minX: u,
|
|
1658
1672
|
minY: c,
|
|
1659
|
-
maxX:
|
|
1673
|
+
maxX: u,
|
|
1660
1674
|
maxY: c
|
|
1661
|
-
}), T = (L) => L.annotation.rects.reduce((
|
|
1662
|
-
return S.length > 0 ? (S.sort((L,
|
|
1663
|
-
}, g = (
|
|
1664
|
-
const c = p(
|
|
1675
|
+
}), T = (L) => L.annotation.rects.reduce((E, O) => E + O.width * O.height, 0);
|
|
1676
|
+
return S.length > 0 ? (S.sort((L, E) => T(L) - T(E)), w ? S.map((L) => L.annotation.id) : [S[0].annotation.id]) : [];
|
|
1677
|
+
}, g = (u) => {
|
|
1678
|
+
const c = p(u);
|
|
1665
1679
|
if (c.length === 0)
|
|
1666
1680
|
return;
|
|
1667
|
-
let
|
|
1668
|
-
for (let
|
|
1669
|
-
const
|
|
1670
|
-
|
|
1681
|
+
let w = c[0].left, S = c[0].top, T = c[0].right, L = c[0].bottom;
|
|
1682
|
+
for (let E = 1; E < c.length; E++) {
|
|
1683
|
+
const O = c[E];
|
|
1684
|
+
w = Math.min(w, O.left), S = Math.min(S, O.top), T = Math.max(T, O.right), L = Math.max(L, O.bottom);
|
|
1671
1685
|
}
|
|
1672
|
-
return new DOMRect(
|
|
1673
|
-
}, p = (
|
|
1674
|
-
const c = o.get(
|
|
1686
|
+
return new DOMRect(w, S, T - w, L - S);
|
|
1687
|
+
}, p = (u) => {
|
|
1688
|
+
const c = o.get(u);
|
|
1675
1689
|
return c ? c[0].annotation.rects : [];
|
|
1676
1690
|
};
|
|
1677
1691
|
return {
|
|
@@ -1680,56 +1694,56 @@ const eo = (t, e) => {
|
|
|
1680
1694
|
getAt: h,
|
|
1681
1695
|
getAnnotationBounds: g,
|
|
1682
1696
|
getAnnotationRects: p,
|
|
1683
|
-
getIntersecting: (
|
|
1684
|
-
const T = n.search({ minX:
|
|
1685
|
-
return Array.from(L).map((
|
|
1686
|
-
annotation: t.getAnnotation(
|
|
1687
|
-
rects: p(
|
|
1688
|
-
})).filter((
|
|
1697
|
+
getIntersecting: (u, c, w, S) => {
|
|
1698
|
+
const T = n.search({ minX: u, minY: c, maxX: w, maxY: S }), L = new Set(T.map((E) => E.annotation.id));
|
|
1699
|
+
return Array.from(L).map((E) => ({
|
|
1700
|
+
annotation: t.getAnnotation(E),
|
|
1701
|
+
rects: p(E)
|
|
1702
|
+
})).filter((E) => !!E.annotation);
|
|
1689
1703
|
},
|
|
1690
1704
|
insert: r,
|
|
1691
|
-
recalculate: () =>
|
|
1705
|
+
recalculate: () => d(t.all().map((u) => u.target), !0),
|
|
1692
1706
|
remove: l,
|
|
1693
|
-
set:
|
|
1707
|
+
set: d,
|
|
1694
1708
|
size: () => n.all().length,
|
|
1695
1709
|
update: f
|
|
1696
1710
|
};
|
|
1697
1711
|
}, no = (t, e) => {
|
|
1698
1712
|
const n = Tn(), o = eo(n, t), i = gn(n);
|
|
1699
1713
|
i.setUserSelectAction(e);
|
|
1700
|
-
const s = hn(n), a = Bn(), r = (m,
|
|
1701
|
-
const c = vt(m, t),
|
|
1702
|
-
return
|
|
1703
|
-
}, l = (m,
|
|
1704
|
-
const
|
|
1705
|
-
return
|
|
1706
|
-
}, f = (m,
|
|
1707
|
-
const c = m.map((S) => vt(S, t)),
|
|
1708
|
-
return
|
|
1709
|
-
n.getAnnotation(S.id) ? n.updateAnnotation(S,
|
|
1710
|
-
}),
|
|
1711
|
-
},
|
|
1714
|
+
const s = hn(n), a = Bn(), r = (m, u = R.LOCAL) => {
|
|
1715
|
+
const c = vt(m, t), w = F(c.target.selector);
|
|
1716
|
+
return w && n.addAnnotation(c, u), w;
|
|
1717
|
+
}, l = (m, u = !0, c = R.LOCAL) => {
|
|
1718
|
+
const w = m.map((T) => vt(T, t)), S = w.filter((T) => !F(T.target.selector));
|
|
1719
|
+
return n.bulkAddAnnotation(w, u, c), S;
|
|
1720
|
+
}, f = (m, u = R.LOCAL) => {
|
|
1721
|
+
const c = m.map((S) => vt(S, t)), w = c.filter((S) => !F(S.target.selector));
|
|
1722
|
+
return c.forEach((S) => {
|
|
1723
|
+
n.getAnnotation(S.id) ? n.updateAnnotation(S, u) : n.addAnnotation(S, u);
|
|
1724
|
+
}), w;
|
|
1725
|
+
}, d = (m, u = R.LOCAL) => {
|
|
1712
1726
|
const c = yt(m, t);
|
|
1713
|
-
n.updateTarget(c,
|
|
1714
|
-
}, h = (m,
|
|
1715
|
-
const c = m.map((
|
|
1716
|
-
n.bulkUpdateTargets(c,
|
|
1717
|
-
}, g = (m,
|
|
1718
|
-
const
|
|
1727
|
+
n.updateTarget(c, u);
|
|
1728
|
+
}, h = (m, u = R.LOCAL) => {
|
|
1729
|
+
const c = m.map((w) => yt(w, t));
|
|
1730
|
+
n.bulkUpdateTargets(c, u);
|
|
1731
|
+
}, g = (m, u, c) => {
|
|
1732
|
+
const w = o.getAt(m, u, !!c).map((T) => n.getAnnotation(T)), S = c ? w.filter(c) : w;
|
|
1719
1733
|
return S.length > 0 ? S[0] : void 0;
|
|
1720
|
-
}, p = (m,
|
|
1734
|
+
}, p = (m, u, c, w = 5) => {
|
|
1721
1735
|
const S = o.getAnnotationRects(m);
|
|
1722
1736
|
if (S.length !== 0) {
|
|
1723
|
-
if (
|
|
1724
|
-
const T = S.find(({ top: L, right:
|
|
1737
|
+
if (u && c) {
|
|
1738
|
+
const T = S.find(({ top: L, right: E, bottom: O, left: _ }) => u >= _ - w && u <= E + w && c >= L - w && c <= O + w);
|
|
1725
1739
|
if (T) return T;
|
|
1726
1740
|
}
|
|
1727
1741
|
return o.getAnnotationBounds(m);
|
|
1728
1742
|
}
|
|
1729
|
-
},
|
|
1743
|
+
}, A = (m) => o.getAnnotationRects(m), y = () => o.recalculate();
|
|
1730
1744
|
return n.observe(({ changes: m }) => {
|
|
1731
|
-
const
|
|
1732
|
-
(
|
|
1745
|
+
const u = (m.deleted || []).filter((S) => F(S.target.selector)), c = (m.created || []).filter((S) => F(S.target.selector)), w = (m.updated || []).filter((S) => F(S.newValue.target.selector));
|
|
1746
|
+
(u == null ? void 0 : u.length) > 0 && u.forEach((S) => o.remove(S.target)), c.length > 0 && o.set(c.map((S) => S.target), !1), (w == null ? void 0 : w.length) > 0 && w.forEach(({ newValue: S }) => o.update(S.target));
|
|
1733
1747
|
}), {
|
|
1734
1748
|
store: {
|
|
1735
1749
|
...n,
|
|
@@ -1738,11 +1752,11 @@ const eo = (t, e) => {
|
|
|
1738
1752
|
bulkUpdateTargets: h,
|
|
1739
1753
|
bulkUpsertAnnotations: f,
|
|
1740
1754
|
getAnnotationBounds: p,
|
|
1741
|
-
getAnnotationRects:
|
|
1755
|
+
getAnnotationRects: A,
|
|
1742
1756
|
getAt: g,
|
|
1743
1757
|
getIntersecting: o.getIntersecting,
|
|
1744
1758
|
recalculatePositions: y,
|
|
1745
|
-
updateTarget:
|
|
1759
|
+
updateTarget: d
|
|
1746
1760
|
},
|
|
1747
1761
|
selection: i,
|
|
1748
1762
|
hover: s,
|
|
@@ -1756,25 +1770,25 @@ const eo = (t, e) => {
|
|
|
1756
1770
|
}, io = (t, e = {}) => {
|
|
1757
1771
|
const n = oo(), o = n.getContext("2d");
|
|
1758
1772
|
document.body.appendChild(n);
|
|
1759
|
-
const i = /* @__PURE__ */ new Map(), s = (
|
|
1760
|
-
return t.on("selectionChange", (
|
|
1761
|
-
s(
|
|
1773
|
+
const i = /* @__PURE__ */ new Map(), s = (d) => Array.from(i.entries()).filter(([h, g]) => g.presenceKey === d.presenceKey).map(([h, g]) => h);
|
|
1774
|
+
return t.on("selectionChange", (d, h) => {
|
|
1775
|
+
s(d).forEach((p) => i.delete(p)), h && h.forEach((p) => i.set(p, d));
|
|
1762
1776
|
}), {
|
|
1763
1777
|
clear: () => {
|
|
1764
|
-
const { width:
|
|
1765
|
-
o.clearRect(-0.5, -0.5,
|
|
1778
|
+
const { width: d, height: h } = n;
|
|
1779
|
+
o.clearRect(-0.5, -0.5, d + 1, h + 1);
|
|
1766
1780
|
},
|
|
1767
1781
|
destroy: () => {
|
|
1768
1782
|
n.remove();
|
|
1769
1783
|
},
|
|
1770
|
-
paint: (
|
|
1784
|
+
paint: (d, h, g) => {
|
|
1771
1785
|
e.font && (o.font = e.font);
|
|
1772
|
-
const p = i.get(
|
|
1786
|
+
const p = i.get(d.annotation.id);
|
|
1773
1787
|
if (p) {
|
|
1774
|
-
const { height:
|
|
1775
|
-
o.fillStyle = p.appearance.color, o.fillRect(y - 2, m - 2.5, 2,
|
|
1776
|
-
const
|
|
1777
|
-
return o.fillRect(y - 2, m - 2.5 -
|
|
1788
|
+
const { height: A } = d.rects[0], y = d.rects[0].x + h.left, m = d.rects[0].y + h.top;
|
|
1789
|
+
o.fillStyle = p.appearance.color, o.fillRect(y - 2, m - 2.5, 2, A + 5);
|
|
1790
|
+
const u = o.measureText(p.appearance.label), c = u.width + 6, w = u.actualBoundingBoxAscent + u.actualBoundingBoxDescent + 8, S = u.fontBoundingBoxAscent ? 8 : 6.5;
|
|
1791
|
+
return o.fillRect(y - 2, m - 2.5 - w, c, w), o.fillStyle = "#fff", o.fillText(p.appearance.label, y + 1, m - S), {
|
|
1778
1792
|
fill: p.appearance.color,
|
|
1779
1793
|
fillOpacity: g ? 0.45 : 0.18
|
|
1780
1794
|
};
|
|
@@ -1782,8 +1796,8 @@ const eo = (t, e) => {
|
|
|
1782
1796
|
},
|
|
1783
1797
|
reset: () => {
|
|
1784
1798
|
n.width = 2 * window.innerWidth, n.height = 2 * window.innerHeight;
|
|
1785
|
-
const
|
|
1786
|
-
|
|
1799
|
+
const d = n.getContext("2d");
|
|
1800
|
+
d.scale(2, 2), d.translate(0.5, 0.5);
|
|
1787
1801
|
}
|
|
1788
1802
|
};
|
|
1789
1803
|
}, Bt = typeof navigator < "u" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : !1;
|
|
@@ -1895,10 +1909,10 @@ const at = {
|
|
|
1895
1909
|
18: !1,
|
|
1896
1910
|
17: !1,
|
|
1897
1911
|
91: !1
|
|
1898
|
-
},
|
|
1912
|
+
}, I = {};
|
|
1899
1913
|
for (let t = 1; t < 20; t++)
|
|
1900
1914
|
at["f".concat(t)] = 111 + t;
|
|
1901
|
-
let
|
|
1915
|
+
let k = [], rt = null, be = "all";
|
|
1902
1916
|
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);
|
|
1903
1917
|
function we(t) {
|
|
1904
1918
|
be = t || "all";
|
|
@@ -1907,15 +1921,15 @@ function ct() {
|
|
|
1907
1921
|
return be || "all";
|
|
1908
1922
|
}
|
|
1909
1923
|
function co() {
|
|
1910
|
-
return
|
|
1924
|
+
return k.slice(0);
|
|
1911
1925
|
}
|
|
1912
1926
|
function lo() {
|
|
1913
|
-
return
|
|
1927
|
+
return k.map((t) => ro(t) || ao(t) || String.fromCharCode(t));
|
|
1914
1928
|
}
|
|
1915
1929
|
function uo() {
|
|
1916
1930
|
const t = [];
|
|
1917
|
-
return Object.keys(
|
|
1918
|
-
|
|
1931
|
+
return Object.keys(I).forEach((e) => {
|
|
1932
|
+
I[e].forEach((n) => {
|
|
1919
1933
|
let {
|
|
1920
1934
|
key: o,
|
|
1921
1935
|
scope: i,
|
|
@@ -1940,14 +1954,14 @@ function fo(t) {
|
|
|
1940
1954
|
return (e.isContentEditable || (i || n === "TEXTAREA" || n === "SELECT") && !e.readOnly) && (o = !1), o;
|
|
1941
1955
|
}
|
|
1942
1956
|
function ho(t) {
|
|
1943
|
-
return typeof t == "string" && (t = lt(t)),
|
|
1957
|
+
return typeof t == "string" && (t = lt(t)), k.indexOf(t) !== -1;
|
|
1944
1958
|
}
|
|
1945
1959
|
function po(t, e) {
|
|
1946
1960
|
let n, o;
|
|
1947
1961
|
t || (t = ct());
|
|
1948
|
-
for (const i in
|
|
1949
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
1950
|
-
for (n =
|
|
1962
|
+
for (const i in I)
|
|
1963
|
+
if (Object.prototype.hasOwnProperty.call(I, i))
|
|
1964
|
+
for (n = I[i], o = 0; o < n.length; )
|
|
1951
1965
|
n[o].scope === t ? n.splice(o, 1).forEach((a) => {
|
|
1952
1966
|
let {
|
|
1953
1967
|
element: r
|
|
@@ -1958,16 +1972,16 @@ function po(t, e) {
|
|
|
1958
1972
|
}
|
|
1959
1973
|
function go(t) {
|
|
1960
1974
|
let e = t.keyCode || t.which || t.charCode;
|
|
1961
|
-
const n =
|
|
1962
|
-
if (n >= 0 &&
|
|
1975
|
+
const n = k.indexOf(e);
|
|
1976
|
+
if (n >= 0 && k.splice(n, 1), t.key && t.key.toLowerCase() === "meta" && k.splice(0, k.length), (e === 93 || e === 224) && (e = 91), e in K) {
|
|
1963
1977
|
K[e] = !1;
|
|
1964
1978
|
for (const o in H) H[o] === e && (P[o] = !1);
|
|
1965
1979
|
}
|
|
1966
1980
|
}
|
|
1967
1981
|
function ve(t) {
|
|
1968
1982
|
if (typeof t > "u")
|
|
1969
|
-
Object.keys(
|
|
1970
|
-
Array.isArray(
|
|
1983
|
+
Object.keys(I).forEach((i) => {
|
|
1984
|
+
Array.isArray(I[i]) && I[i].forEach((s) => mt(s)), delete I[i];
|
|
1971
1985
|
}), Dt(null);
|
|
1972
1986
|
else if (Array.isArray(t))
|
|
1973
1987
|
t.forEach((i) => {
|
|
@@ -1995,11 +2009,11 @@ const mt = (t) => {
|
|
|
1995
2009
|
splitKey: i = "+"
|
|
1996
2010
|
} = t;
|
|
1997
2011
|
ye(e).forEach((a) => {
|
|
1998
|
-
const r = a.split(i), l = r.length, f = r[l - 1],
|
|
1999
|
-
if (!
|
|
2012
|
+
const r = a.split(i), l = r.length, f = r[l - 1], d = f === "*" ? "*" : lt(f);
|
|
2013
|
+
if (!I[d]) return;
|
|
2000
2014
|
n || (n = ct());
|
|
2001
2015
|
const h = l > 1 ? me(H, r) : [], g = [];
|
|
2002
|
-
|
|
2016
|
+
I[d] = I[d].filter((p) => {
|
|
2003
2017
|
const y = (o ? p.method === o : !0) && p.scope === n && so(p.mods, h);
|
|
2004
2018
|
return y && g.push(p.element), !y;
|
|
2005
2019
|
}), g.forEach((p) => Dt(p));
|
|
@@ -2013,16 +2027,16 @@ function ee(t, e, n, o) {
|
|
|
2013
2027
|
i = e.mods.length > 0;
|
|
2014
2028
|
for (const s in K)
|
|
2015
2029
|
Object.prototype.hasOwnProperty.call(K, s) && (!K[s] && e.mods.indexOf(+s) > -1 || K[s] && e.mods.indexOf(+s) === -1) && (i = !1);
|
|
2016
|
-
(e.mods.length === 0 && !K[16] && !K[18] && !K[17] && !K[91] || i || e.shortcut === "*") && (e.keys = [], e.keys = e.keys.concat(
|
|
2030
|
+
(e.mods.length === 0 && !K[16] && !K[18] && !K[17] && !K[91] || i || e.shortcut === "*") && (e.keys = [], e.keys = e.keys.concat(k), e.method(t, e) === !1 && (t.preventDefault ? t.preventDefault() : t.returnValue = !1, t.stopPropagation && t.stopPropagation(), t.cancelBubble && (t.cancelBubble = !0)));
|
|
2017
2031
|
}
|
|
2018
2032
|
}
|
|
2019
2033
|
function ne(t, e) {
|
|
2020
|
-
const n =
|
|
2034
|
+
const n = I["*"];
|
|
2021
2035
|
let o = t.keyCode || t.which || t.charCode;
|
|
2022
2036
|
if (!P.filter.call(this, t)) return;
|
|
2023
|
-
if ((o === 93 || o === 224) && (o = 91),
|
|
2037
|
+
if ((o === 93 || o === 224) && (o = 91), k.indexOf(o) === -1 && o !== 229 && k.push(o), ["ctrlKey", "altKey", "shiftKey", "metaKey"].forEach((r) => {
|
|
2024
2038
|
const l = Ut[r];
|
|
2025
|
-
t[r] &&
|
|
2039
|
+
t[r] && k.indexOf(l) === -1 ? k.push(l) : !t[r] && k.indexOf(l) > -1 ? k.splice(k.indexOf(l), 1) : r === "metaKey" && t[r] && k.length === 3 && (t.ctrlKey || t.shiftKey || t.altKey || (k = k.slice(k.indexOf(l))));
|
|
2026
2040
|
}), o in K) {
|
|
2027
2041
|
K[o] = !0;
|
|
2028
2042
|
for (const r in H)
|
|
@@ -2031,29 +2045,29 @@ function ne(t, e) {
|
|
|
2031
2045
|
}
|
|
2032
2046
|
for (const r in K)
|
|
2033
2047
|
Object.prototype.hasOwnProperty.call(K, r) && (K[r] = t[Ut[r]]);
|
|
2034
|
-
t.getModifierState && !(t.altKey && !t.ctrlKey) && t.getModifierState("AltGraph") && (
|
|
2048
|
+
t.getModifierState && !(t.altKey && !t.ctrlKey) && t.getModifierState("AltGraph") && (k.indexOf(17) === -1 && k.push(17), k.indexOf(18) === -1 && k.push(18), K[17] = !0, K[18] = !0);
|
|
2035
2049
|
const i = ct();
|
|
2036
2050
|
if (n)
|
|
2037
2051
|
for (let r = 0; r < n.length; r++)
|
|
2038
2052
|
n[r].scope === i && (t.type === "keydown" && n[r].keydown || t.type === "keyup" && n[r].keyup) && ee(t, n[r], i, e);
|
|
2039
|
-
if (!(o in
|
|
2040
|
-
const s =
|
|
2053
|
+
if (!(o in I)) return;
|
|
2054
|
+
const s = I[o], a = s.length;
|
|
2041
2055
|
for (let r = 0; r < a; r++)
|
|
2042
2056
|
if ((t.type === "keydown" && s[r].keydown || t.type === "keyup" && s[r].keyup) && s[r].key) {
|
|
2043
2057
|
const l = s[r], {
|
|
2044
2058
|
splitKey: f
|
|
2045
|
-
} = l,
|
|
2046
|
-
for (let g = 0; g <
|
|
2047
|
-
h.push(lt(
|
|
2048
|
-
h.sort().join("") ===
|
|
2059
|
+
} = l, d = l.key.split(f), h = [];
|
|
2060
|
+
for (let g = 0; g < d.length; g++)
|
|
2061
|
+
h.push(lt(d[g]));
|
|
2062
|
+
h.sort().join("") === k.sort().join("") && ee(t, l, i, e);
|
|
2049
2063
|
}
|
|
2050
2064
|
}
|
|
2051
2065
|
function P(t, e, n) {
|
|
2052
|
-
|
|
2066
|
+
k = [];
|
|
2053
2067
|
const o = ye(t);
|
|
2054
|
-
let i = [], s = "all", a = document, r = 0, l = !1, f = !0,
|
|
2055
|
-
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" && (
|
|
2056
|
-
t = o[r].split(
|
|
2068
|
+
let i = [], s = "all", a = document, r = 0, l = !1, f = !0, d = "+", h = !1, g = !1;
|
|
2069
|
+
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" && (d = e.splitKey), e.single === !0 && (g = !0)), typeof e == "string" && (s = e), g && ve(t, s); r < o.length; r++)
|
|
2070
|
+
t = o[r].split(d), i = [], t.length > 1 && (i = me(H, t)), t = t[t.length - 1], t = t === "*" ? "*" : lt(t), t in I || (I[t] = []), I[t].push({
|
|
2057
2071
|
keyup: l,
|
|
2058
2072
|
keydown: f,
|
|
2059
2073
|
scope: s,
|
|
@@ -2061,7 +2075,7 @@ function P(t, e, n) {
|
|
|
2061
2075
|
shortcut: o[r],
|
|
2062
2076
|
method: n,
|
|
2063
2077
|
key: o[r],
|
|
2064
|
-
splitKey:
|
|
2078
|
+
splitKey: d,
|
|
2065
2079
|
element: a
|
|
2066
2080
|
});
|
|
2067
2081
|
if (typeof a < "u" && window) {
|
|
@@ -2069,19 +2083,19 @@ function P(t, e, n) {
|
|
|
2069
2083
|
const p = function() {
|
|
2070
2084
|
let y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2071
2085
|
return ne(y, a);
|
|
2072
|
-
},
|
|
2086
|
+
}, A = function() {
|
|
2073
2087
|
let y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2074
2088
|
ne(y, a), go(y);
|
|
2075
2089
|
};
|
|
2076
2090
|
z.set(a, {
|
|
2077
2091
|
keydownListener: p,
|
|
2078
|
-
keyupListenr:
|
|
2092
|
+
keyupListenr: A,
|
|
2079
2093
|
capture: h
|
|
2080
|
-
}), kt(a, "keydown", p, h), kt(a, "keyup",
|
|
2094
|
+
}), kt(a, "keydown", p, h), kt(a, "keyup", A, h);
|
|
2081
2095
|
}
|
|
2082
2096
|
if (!rt) {
|
|
2083
2097
|
const p = () => {
|
|
2084
|
-
|
|
2098
|
+
k = [];
|
|
2085
2099
|
};
|
|
2086
2100
|
rt = {
|
|
2087
2101
|
listener: p,
|
|
@@ -2092,14 +2106,14 @@ function P(t, e, n) {
|
|
|
2092
2106
|
}
|
|
2093
2107
|
function mo(t) {
|
|
2094
2108
|
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "all";
|
|
2095
|
-
Object.keys(
|
|
2096
|
-
|
|
2109
|
+
Object.keys(I).forEach((n) => {
|
|
2110
|
+
I[n].filter((i) => i.scope === e && i.shortcut === t).forEach((i) => {
|
|
2097
2111
|
i && i.method && i.method();
|
|
2098
2112
|
});
|
|
2099
2113
|
});
|
|
2100
2114
|
}
|
|
2101
2115
|
function Dt(t) {
|
|
2102
|
-
const e = Object.values(
|
|
2116
|
+
const e = Object.values(I).flat();
|
|
2103
2117
|
if (e.findIndex((o) => {
|
|
2104
2118
|
let {
|
|
2105
2119
|
element: i
|
|
@@ -2120,7 +2134,7 @@ function Dt(t) {
|
|
|
2120
2134
|
capture: r
|
|
2121
2135
|
} = z.get(i) || {};
|
|
2122
2136
|
s && a && (et(i, "keyup", a, r), et(i, "keydown", s, r), z.delete(i));
|
|
2123
|
-
}), z.clear(), Object.keys(
|
|
2137
|
+
}), z.clear(), Object.keys(I).forEach((i) => delete I[i]), rt)) {
|
|
2124
2138
|
const {
|
|
2125
2139
|
listener: i,
|
|
2126
2140
|
capture: s
|
|
@@ -2157,86 +2171,85 @@ const oe = 300, Ae = ["up", "down", "left", "right"], xe = Oe ? "⌘+a" : "ctrl+
|
|
|
2157
2171
|
const s = (E) => i = E;
|
|
2158
2172
|
let a;
|
|
2159
2173
|
const r = (E) => a = E, { store: l, selection: f } = e;
|
|
2160
|
-
let
|
|
2161
|
-
const
|
|
2162
|
-
|
|
2174
|
+
let d, h, g;
|
|
2175
|
+
const p = (E) => {
|
|
2176
|
+
h !== !1 && (d = nt(E.target) ? void 0 : {
|
|
2163
2177
|
annotation: ue(),
|
|
2164
2178
|
selector: [],
|
|
2165
2179
|
creator: i,
|
|
2166
2180
|
created: /* @__PURE__ */ new Date()
|
|
2167
2181
|
});
|
|
2168
|
-
},
|
|
2169
|
-
const
|
|
2170
|
-
if (nt(
|
|
2171
|
-
|
|
2182
|
+
}, A = Vt((E) => {
|
|
2183
|
+
const O = document.getSelection();
|
|
2184
|
+
if (nt(O.anchorNode)) {
|
|
2185
|
+
d = void 0;
|
|
2172
2186
|
return;
|
|
2173
2187
|
}
|
|
2174
|
-
const
|
|
2175
|
-
if ((g == null ? void 0 : g.type) === "pointerdown" && (
|
|
2176
|
-
if (
|
|
2177
|
-
l.getAnnotation(
|
|
2188
|
+
const _ = E.timeStamp - ((g == null ? void 0 : g.timeStamp) || E.timeStamp);
|
|
2189
|
+
if ((g == null ? void 0 : g.type) === "pointerdown" && (_ < 1e3 && !d || O.isCollapsed && _ < oe) && p(g || E), !d) return;
|
|
2190
|
+
if (O.isCollapsed) {
|
|
2191
|
+
l.getAnnotation(d.annotation) && (f.clear(), l.deleteAnnotation(d.annotation));
|
|
2178
2192
|
return;
|
|
2179
2193
|
}
|
|
2180
|
-
const
|
|
2194
|
+
const b = O.getRangeAt(0), x = Ye(b, t);
|
|
2181
2195
|
if (_e(x)) return;
|
|
2182
|
-
const
|
|
2183
|
-
(
|
|
2196
|
+
const v = Be(x.cloneRange());
|
|
2197
|
+
(v.length !== d.selector.length || v.some((B, M) => {
|
|
2184
2198
|
var Y;
|
|
2185
|
-
return
|
|
2186
|
-
})) && (
|
|
2187
|
-
...
|
|
2188
|
-
selector:
|
|
2199
|
+
return B.toString() !== ((Y = d.selector[M]) == null ? void 0 : Y.quote);
|
|
2200
|
+
})) && (d = {
|
|
2201
|
+
...d,
|
|
2202
|
+
selector: v.map((B) => Ke(B, t, o)),
|
|
2189
2203
|
updated: /* @__PURE__ */ new Date()
|
|
2190
|
-
}, l.getAnnotation(
|
|
2191
|
-
}),
|
|
2192
|
-
|
|
2193
|
-
},
|
|
2194
|
-
l.getAnnotation(
|
|
2195
|
-
id:
|
|
2204
|
+
}, l.getAnnotation(d.annotation) ? l.updateTarget(d, R.LOCAL) : f.clear());
|
|
2205
|
+
}), y = (E) => {
|
|
2206
|
+
nt(E.target) || (g = wt(E), h = g.button === 0);
|
|
2207
|
+
}, m = () => {
|
|
2208
|
+
l.getAnnotation(d.annotation) ? l.updateTarget(d) : l.addAnnotation({
|
|
2209
|
+
id: d.annotation,
|
|
2196
2210
|
bodies: [],
|
|
2197
|
-
target:
|
|
2211
|
+
target: d
|
|
2198
2212
|
});
|
|
2199
|
-
},
|
|
2200
|
-
if (
|
|
2201
|
-
const
|
|
2202
|
-
const { x:
|
|
2203
|
-
if (
|
|
2204
|
-
const { selected:
|
|
2205
|
-
(
|
|
2213
|
+
}, u = (E) => {
|
|
2214
|
+
if (nt(E.target) || !h) return;
|
|
2215
|
+
const O = () => {
|
|
2216
|
+
const { x: b, y: x } = t.getBoundingClientRect(), v = E.target instanceof Node && t.contains(E.target) && l.getAt(E.clientX - b, E.clientY - x, a);
|
|
2217
|
+
if (v) {
|
|
2218
|
+
const { selected: C } = f;
|
|
2219
|
+
(C.length !== 1 || C[0].id !== v.id) && f.userSelect(v.id, E);
|
|
2206
2220
|
} else
|
|
2207
2221
|
f.clear();
|
|
2208
|
-
},
|
|
2222
|
+
}, _ = E.timeStamp - g.timeStamp;
|
|
2209
2223
|
setTimeout(() => {
|
|
2210
|
-
const
|
|
2211
|
-
|
|
2224
|
+
const b = document.getSelection();
|
|
2225
|
+
b != null && b.isCollapsed && _ < oe ? (d = void 0, O()) : d && d.selector.length > 0 && (f.clear(), m(), f.userSelect(d.annotation, wt(E)));
|
|
2212
2226
|
});
|
|
2213
|
-
},
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2227
|
+
}, c = (E) => {
|
|
2228
|
+
const O = document.getSelection();
|
|
2229
|
+
O != null && O.isCollapsed || ((!d || d.selector.length === 0) && A(E), m(), f.userSelect(d.annotation, wt(E)));
|
|
2230
|
+
}, w = (E) => {
|
|
2231
|
+
E.key === "Shift" && d && (document.getSelection().isCollapsed || (f.clear(), m(), f.userSelect(d.annotation, dt(E))));
|
|
2217
2232
|
}, S = (E) => {
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
(u == null ? void 0 : u.selector.length) > 0 && (f.clear(), l.addAnnotation({
|
|
2222
|
-
id: u.annotation,
|
|
2233
|
+
const O = () => setTimeout(() => {
|
|
2234
|
+
(d == null ? void 0 : d.selector.length) > 0 && (f.clear(), l.addAnnotation({
|
|
2235
|
+
id: d.annotation,
|
|
2223
2236
|
bodies: [],
|
|
2224
|
-
target:
|
|
2225
|
-
}), f.userSelect(
|
|
2237
|
+
target: d
|
|
2238
|
+
}), f.userSelect(d.annotation, dt(E))), document.removeEventListener("selectionchange", O);
|
|
2226
2239
|
}, 100);
|
|
2227
|
-
document.addEventListener("selectionchange",
|
|
2240
|
+
document.addEventListener("selectionchange", O), p(E);
|
|
2228
2241
|
};
|
|
2229
2242
|
P(yo.join(","), { element: t, keydown: !0, keyup: !1 }, (E) => {
|
|
2230
2243
|
E.repeat || (g = dt(E));
|
|
2231
2244
|
}), P(xe, { keydown: !0, keyup: !1 }, (E) => {
|
|
2232
|
-
g = dt(E),
|
|
2245
|
+
g = dt(E), S(E);
|
|
2233
2246
|
});
|
|
2234
|
-
const
|
|
2235
|
-
E.repeat || E.target !== t && E.target !== document.body || (
|
|
2247
|
+
const T = (E) => {
|
|
2248
|
+
E.repeat || E.target !== t && E.target !== document.body || (d = void 0, f.clear());
|
|
2236
2249
|
};
|
|
2237
|
-
return P(Ae.join(","), { keydown: !0, keyup: !1 },
|
|
2250
|
+
return P(Ae.join(","), { keydown: !0, keyup: !1 }, T), t.addEventListener("pointerdown", y), document.addEventListener("pointerup", u), document.addEventListener("contextmenu", c), n && (t.addEventListener("keyup", w), t.addEventListener("selectstart", p), document.addEventListener("selectionchange", A)), {
|
|
2238
2251
|
destroy: () => {
|
|
2239
|
-
t.removeEventListener("pointerdown",
|
|
2252
|
+
t.removeEventListener("pointerdown", y), document.removeEventListener("pointerup", u), document.removeEventListener("contextmenu", c), t.removeEventListener("keyup", w), t.removeEventListener("selectstart", p), document.removeEventListener("selectionchange", A), P.unbind();
|
|
2240
2253
|
},
|
|
2241
2254
|
setFilter: r,
|
|
2242
2255
|
setUser: s
|
|
@@ -2252,10 +2265,10 @@ const oe = 300, Ae = ["up", "down", "left", "right"], xe = Oe ? "⌘+a" : "ctrl+
|
|
|
2252
2265
|
user: Dn()
|
|
2253
2266
|
}), o = no(t, n.userSelectAction), { selection: i, viewport: s } = o, a = o.store, r = Rn(a), l = kn(o, r, n.adapter);
|
|
2254
2267
|
let f = n.user;
|
|
2255
|
-
const
|
|
2268
|
+
const d = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : ie : n.renderer || ie, h = d === "SPANS" ? an(t, o, s) : d === "CSS_HIGHLIGHTS" ? on(t, o, s) : d === "CANVAS" ? Fe(t, o, s) : void 0;
|
|
2256
2269
|
if (!h)
|
|
2257
|
-
throw `Unknown renderer implementation: ${
|
|
2258
|
-
console.debug(`Using ${
|
|
2270
|
+
throw `Unknown renderer implementation: ${d}`;
|
|
2271
|
+
console.debug(`Using ${d} renderer`), n.style && h.setStyle(n.style);
|
|
2259
2272
|
const g = bo(t, o, n.annotatingEnabled, n.offsetReferenceSelector);
|
|
2260
2273
|
return g.setUser(f), {
|
|
2261
2274
|
..._n(o, r, n.adapter),
|
|
@@ -2289,7 +2302,7 @@ export {
|
|
|
2289
2302
|
W as DEFAULT_STYLE,
|
|
2290
2303
|
se as NOT_ANNOTATABLE_CLASS,
|
|
2291
2304
|
Z as NOT_ANNOTATABLE_SELECTOR,
|
|
2292
|
-
|
|
2305
|
+
R as Origin,
|
|
2293
2306
|
bo as SelectionHandler,
|
|
2294
2307
|
pn as UserSelectAction,
|
|
2295
2308
|
Ao as W3CTextFormat,
|