@soomo/text-annotator 4.1.0-staging.0 → 4.1.1-staging.0
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.
|
@@ -293,11 +293,11 @@ const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft =
|
|
|
293
293
|
e.addEventListener("pointermove", h);
|
|
294
294
|
const A = tt((S = !1) => requestAnimationFrame(() => {
|
|
295
295
|
const C = ie(e), { minX: O, minY: B, maxX: V, maxY: z } = C, K = g ? s.getIntersecting(O, B, V, z).filter(({ annotation: y }) => g?.(y)) : s.getIntersecting(O, B, V, z), st = n.selected.map(({ id: y }) => y), f = K.map(({ annotation: y, rects: M }) => {
|
|
296
|
-
const
|
|
296
|
+
const P = st.includes(y.id), _ = y.id === r.current;
|
|
297
297
|
return {
|
|
298
298
|
annotation: y,
|
|
299
299
|
rects: M,
|
|
300
|
-
state: { selected:
|
|
300
|
+
state: { selected: P, hovered: _ }
|
|
301
301
|
};
|
|
302
302
|
});
|
|
303
303
|
t.redraw(f, C, l, m, S), setTimeout(() => {
|
|
@@ -338,13 +338,13 @@ const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft =
|
|
|
338
338
|
setFilter: L,
|
|
339
339
|
setVisible: t.setVisible.bind(t)
|
|
340
340
|
};
|
|
341
|
-
},
|
|
341
|
+
}, U = {
|
|
342
342
|
fill: "rgb(0, 128, 255)",
|
|
343
343
|
fillOpacity: 0.18
|
|
344
344
|
}, ot = {
|
|
345
345
|
fill: "rgb(0, 128, 255)",
|
|
346
346
|
fillOpacity: 0.45
|
|
347
|
-
}, Qt = (t) => t?.fillOpacity !== void 0 ? et(t?.fill ||
|
|
347
|
+
}, Qt = (t) => t?.fillOpacity !== void 0 ? et(t?.fill || U.fill).alpha(t.fillOpacity).toHex() : t?.fill ? t.fill : et(U.fill).alpha(U.fillOpacity).toHex(), St = (t, e, o) => e ? typeof e == "function" ? e(t.annotation, t.state, o) || (t.state?.selected ? ot : U) : e : t.state?.selected ? ot : U, Zt = (t, e) => {
|
|
348
348
|
const o = (n, r) => n.x <= r.x + r.width && n.x + n.width >= r.x && n.y <= r.y + r.height && n.y + n.height >= r.y, i = (n) => n.rects.reduce((r, a) => r + a.width, 0), s = e.filter(({ rects: n }) => n.some((r) => o(t, r)));
|
|
349
349
|
return s.sort((n, r) => i(r) - i(n)), s.findIndex((n) => n.rects.includes(t));
|
|
350
350
|
}, Jt = (t) => {
|
|
@@ -661,21 +661,20 @@ const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft =
|
|
|
661
661
|
if (!h) return;
|
|
662
662
|
const y = document.getSelection();
|
|
663
663
|
if (!y?.anchorNode) return;
|
|
664
|
-
const
|
|
665
|
-
if (
|
|
664
|
+
const P = Array.from(Array(y.rangeCount).keys()).map((k) => y.getRangeAt(k)).map((k) => Wt(k, t));
|
|
665
|
+
if (P.every((k) => !gt(t, k))) {
|
|
666
666
|
d = void 0;
|
|
667
667
|
return;
|
|
668
668
|
}
|
|
669
|
-
const
|
|
670
|
-
if (v?.type === "pointerdown" && (
|
|
669
|
+
const _ = f.timeStamp - (v?.timeStamp || f.timeStamp);
|
|
670
|
+
if (v?.type === "pointerdown" && (_ < 1e3 && !d || y.isCollapsed && _ < at) && T(), !d && (T(), !d))
|
|
671
671
|
return;
|
|
672
672
|
if (y.isCollapsed) {
|
|
673
673
|
s.getAnnotation(d.annotation) && !(u(v) || A === "REPLACE_CURRENT") && (n.clear(), s.deleteAnnotation(d.annotation));
|
|
674
674
|
return;
|
|
675
675
|
}
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
const I = _.flatMap((k) => Ft(t, k.cloneRange()));
|
|
676
|
+
if (P.every((k) => Pt(k))) return;
|
|
677
|
+
const I = P.flatMap((k) => Ft(t, k.cloneRange()));
|
|
679
678
|
if (!(I.length > 0 && !d || I.length !== d.selector.length || I.some((k, Y) => k.toString() !== d?.selector[Y]?.quote))) return;
|
|
680
679
|
const j = u(v) && L ? Ht([
|
|
681
680
|
...L.selector.map((k) => k.range),
|
|
@@ -696,22 +695,22 @@ const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft =
|
|
|
696
695
|
(typeof g == "function" ? g(y, t) : g === "ALWAYS") && n.clear();
|
|
697
696
|
return;
|
|
698
697
|
}
|
|
699
|
-
const
|
|
698
|
+
const H = y.target instanceof Node && t.contains(y.target) && s.getAt(
|
|
700
699
|
y.clientX - _,
|
|
701
700
|
y.clientY - I,
|
|
702
701
|
m === "all",
|
|
703
702
|
E
|
|
704
703
|
);
|
|
705
|
-
if (
|
|
706
|
-
const { selected: j } = n, k = new Set(j.map((X) => X.id)), Y = Array.isArray(
|
|
707
|
-
(k.size !== Y.length || !Y.every((X) => k.has(X))) && (o.emit("clickAnnotation",
|
|
704
|
+
if (H) {
|
|
705
|
+
const { selected: j } = n, k = new Set(j.map((X) => X.id)), Y = Array.isArray(H) ? H.map((X) => X.id) : [H.id];
|
|
706
|
+
(k.size !== Y.length || !Y.every((X) => k.has(X))) && (o.emit("clickAnnotation", H), n.userSelect(Y, y));
|
|
708
707
|
} else
|
|
709
708
|
n.clear();
|
|
710
709
|
};
|
|
711
710
|
if (y.timeStamp - (v?.timeStamp || 0) < at) {
|
|
712
711
|
await C();
|
|
713
|
-
const _ = document.getSelection(), I = W(t, v?.target),
|
|
714
|
-
if (_?.isCollapsed || I &&
|
|
712
|
+
const _ = document.getSelection(), I = W(t, v?.target), H = W(t, y.target);
|
|
713
|
+
if (_?.isCollapsed || I && H) {
|
|
715
714
|
d = void 0, M();
|
|
716
715
|
return;
|
|
717
716
|
}
|
|
@@ -720,8 +719,8 @@ const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft =
|
|
|
720
719
|
}, C = async () => {
|
|
721
720
|
const f = document.getSelection();
|
|
722
721
|
let y = !1, M = f?.isCollapsed;
|
|
723
|
-
const
|
|
724
|
-
return setTimeout(() => y = !0, 50), Dt(() => M = f?.isCollapsed, _,
|
|
722
|
+
const P = () => M || y, _ = 1;
|
|
723
|
+
return setTimeout(() => y = !0, 50), Dt(() => M = f?.isCollapsed, _, P);
|
|
725
724
|
}, O = (f) => {
|
|
726
725
|
document.getSelection()?.isCollapsed || ((!d || d.selector.length === 0) && R(f), d && (K(), n.userSelect(d.annotation, J(f))));
|
|
727
726
|
}, B = (f) => {
|
|
@@ -772,7 +771,7 @@ const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft =
|
|
|
772
771
|
setAnnotatingMode: b
|
|
773
772
|
};
|
|
774
773
|
}, fe = (t) => [
|
|
775
|
-
`background-color:${et(t?.fill ||
|
|
774
|
+
`background-color:${et(t?.fill || U.fill).alpha(t?.fillOpacity === void 0 ? U.fillOpacity : t.fillOpacity).toHex()}`,
|
|
776
775
|
t?.underlineThickness ? "text-decoration:underline" : void 0,
|
|
777
776
|
t?.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
|
|
778
777
|
t?.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
|
|
@@ -874,7 +873,7 @@ const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft =
|
|
|
874
873
|
};
|
|
875
874
|
export {
|
|
876
875
|
ot as DEFAULT_SELECTED_STYLE,
|
|
877
|
-
|
|
876
|
+
U as DEFAULT_STYLE,
|
|
878
877
|
ft as NOT_ANNOTATABLE_CLASS,
|
|
879
878
|
$ as NOT_ANNOTATABLE_SELECTOR,
|
|
880
879
|
Be as Origin,
|