apostil 0.1.6 → 0.1.7
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/index.cjs +34 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +34 -24
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -484,7 +484,11 @@ function OverlayPin({
|
|
|
484
484
|
(0, import_react2.useEffect)(() => {
|
|
485
485
|
updatePos();
|
|
486
486
|
window.addEventListener("resize", updatePos);
|
|
487
|
-
|
|
487
|
+
document.addEventListener("scroll", updatePos, true);
|
|
488
|
+
return () => {
|
|
489
|
+
window.removeEventListener("resize", updatePos);
|
|
490
|
+
document.removeEventListener("scroll", updatePos, true);
|
|
491
|
+
};
|
|
488
492
|
}, [updatePos]);
|
|
489
493
|
if (!pos) return null;
|
|
490
494
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
@@ -517,6 +521,7 @@ function CommentPin({
|
|
|
517
521
|
index,
|
|
518
522
|
overlayRef
|
|
519
523
|
}) {
|
|
524
|
+
if (thread.resolved) return null;
|
|
520
525
|
if (thread.targetId) {
|
|
521
526
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TargetedPin, { thread, index }, `targeted-${thread.id}`);
|
|
522
527
|
}
|
|
@@ -601,9 +606,10 @@ function CommentComposer({
|
|
|
601
606
|
const inputRef = (0, import_react3.useRef)(null);
|
|
602
607
|
(0, import_react3.useEffect)(() => {
|
|
603
608
|
if (autoFocus) {
|
|
604
|
-
|
|
609
|
+
const timer = setTimeout(() => {
|
|
605
610
|
inputRef.current?.focus();
|
|
606
|
-
});
|
|
611
|
+
}, 50);
|
|
612
|
+
return () => clearTimeout(timer);
|
|
607
613
|
}
|
|
608
614
|
}, [autoFocus]);
|
|
609
615
|
const handleSubmit = () => {
|
|
@@ -627,7 +633,7 @@ function CommentComposer({
|
|
|
627
633
|
},
|
|
628
634
|
placeholder,
|
|
629
635
|
rows: 1,
|
|
630
|
-
className: "flex-1 resize-none rounded-lg border border-neutral-200 bg-white px-3 py-
|
|
636
|
+
className: "flex-1 resize-none rounded-lg border border-neutral-200 bg-white px-3 py-1.5 text-sm\n placeholder:text-neutral-400 focus:outline-none focus:ring-2 focus:ring-neutral-300\n min-h-[36px] max-h-[120px]"
|
|
631
637
|
}
|
|
632
638
|
),
|
|
633
639
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
@@ -635,7 +641,7 @@ function CommentComposer({
|
|
|
635
641
|
{
|
|
636
642
|
onClick: handleSubmit,
|
|
637
643
|
disabled: !value.trim(),
|
|
638
|
-
className: "flex items-center justify-center w-
|
|
644
|
+
className: "flex items-center justify-center w-9 h-9 rounded-lg\n text-white disabled:opacity-30\n transition-colors shrink-0",
|
|
639
645
|
style: { backgroundColor: brandColor },
|
|
640
646
|
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Send, { className: "w-3.5 h-3.5" })
|
|
641
647
|
}
|
|
@@ -963,7 +969,7 @@ function findCommentTarget(el, boundary) {
|
|
|
963
969
|
};
|
|
964
970
|
}
|
|
965
971
|
function CommentOverlay() {
|
|
966
|
-
const { threads, commentMode, setCommentMode, user, addThread, setActiveThreadId, brandColor } = useApostil();
|
|
972
|
+
const { threads, commentMode, setCommentMode, user, addThread, activeThreadId, setActiveThreadId, brandColor } = useApostil();
|
|
967
973
|
const overlayRef = (0, import_react6.useRef)(null);
|
|
968
974
|
const [pendingPin, setPendingPin] = (0, import_react6.useState)(null);
|
|
969
975
|
const [pendingPixel, setPendingPixel] = (0, import_react6.useState)(null);
|
|
@@ -974,9 +980,15 @@ function CommentOverlay() {
|
|
|
974
980
|
if (!commentMode || !overlayRef.current) return;
|
|
975
981
|
const overlayRect = overlayRef.current.getBoundingClientRect();
|
|
976
982
|
const overlay = overlayRef.current;
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
983
|
+
const elements = document.elementsFromPoint(e.clientX, e.clientY);
|
|
984
|
+
let elementBelow = null;
|
|
985
|
+
for (const el of elements) {
|
|
986
|
+
if (el === overlay || overlay.contains(el)) continue;
|
|
987
|
+
if (el instanceof HTMLElement) {
|
|
988
|
+
elementBelow = el;
|
|
989
|
+
break;
|
|
990
|
+
}
|
|
991
|
+
}
|
|
980
992
|
debug.log(" click at", { clientX: e.clientX, clientY: e.clientY });
|
|
981
993
|
debug.log(" element below overlay:", elementBelow);
|
|
982
994
|
if (elementBelow) {
|
|
@@ -1046,16 +1058,15 @@ function CommentOverlay() {
|
|
|
1046
1058
|
setCommentMode(false);
|
|
1047
1059
|
}, [setCommentMode]);
|
|
1048
1060
|
(0, import_react6.useEffect)(() => {
|
|
1049
|
-
if (!
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
});
|
|
1061
|
+
if (!pendingPixel || !overlayRef.current) return;
|
|
1062
|
+
const overlayRect = overlayRef.current.getBoundingClientRect();
|
|
1063
|
+
const clickX = overlayRect.left + pendingPixel.left;
|
|
1064
|
+
const clickY = overlayRect.top + pendingPixel.top;
|
|
1065
|
+
setPendingFlip({
|
|
1066
|
+
x: clickX + 308 > window.innerWidth,
|
|
1067
|
+
y: clickY + 200 > window.innerHeight
|
|
1057
1068
|
});
|
|
1058
|
-
}, [
|
|
1069
|
+
}, [pendingPixel, overlayRef]);
|
|
1059
1070
|
(0, import_react6.useEffect)(() => {
|
|
1060
1071
|
const hash = window.location.hash;
|
|
1061
1072
|
console.log("[apostil] hash check:", hash, "threads:", threads.length, threads.map((t) => t.id));
|
|
@@ -1081,6 +1092,8 @@ function CommentOverlay() {
|
|
|
1081
1092
|
setPendingPin(null);
|
|
1082
1093
|
setPendingPixel(null);
|
|
1083
1094
|
setCommentMode(false);
|
|
1095
|
+
} else if (activeThreadId) {
|
|
1096
|
+
setActiveThreadId(null);
|
|
1084
1097
|
} else if (commentMode) {
|
|
1085
1098
|
setCommentMode(false);
|
|
1086
1099
|
}
|
|
@@ -1102,11 +1115,8 @@ function CommentOverlay() {
|
|
|
1102
1115
|
};
|
|
1103
1116
|
document.addEventListener("keydown", handler);
|
|
1104
1117
|
return () => document.removeEventListener("keydown", handler);
|
|
1105
|
-
}, [commentMode, pendingPin, setCommentMode, setActiveThreadId]);
|
|
1106
|
-
const
|
|
1107
|
-
if (a.resolved !== b.resolved) return a.resolved ? 1 : -1;
|
|
1108
|
-
return new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime();
|
|
1109
|
-
});
|
|
1118
|
+
}, [commentMode, pendingPin, activeThreadId, setCommentMode, setActiveThreadId]);
|
|
1119
|
+
const visibleThreads = threads.filter((t) => !t.resolved).sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
|
|
1110
1120
|
const showingUserPrompt = commentMode && !user;
|
|
1111
1121
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
1112
1122
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
@@ -1117,7 +1127,7 @@ function CommentOverlay() {
|
|
|
1117
1127
|
style: { zIndex: commentMode ? getHighestZIndex() + 10 : 55 },
|
|
1118
1128
|
onMouseDown: handleClick,
|
|
1119
1129
|
children: [
|
|
1120
|
-
|
|
1130
|
+
visibleThreads.map((thread, i) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "pointer-events-auto", children: [
|
|
1121
1131
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CommentPin, { thread, index: i, overlayRef }),
|
|
1122
1132
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ApostilThreadPopover, { thread, overlayRef })
|
|
1123
1133
|
] }, thread.id)),
|