{
+ if (event.target !== event.currentTarget) return
+ const bounds = event.currentTarget.getBoundingClientRect()
+ const column = Math.min(props.cols - 1, Math.max(0, Math.floor(((event.clientX - bounds.left) / bounds.width) * props.cols)))
+ const row = Math.min(props.rows - 1, Math.max(0, Math.floor(((event.clientY - bounds.top) / bounds.height) * props.rows)))
+ setDraft({ row, column, note: "" })
+ }}
+ >
+ {props.annotations.map((annotation, index) => (
+
+ ))}
+ {draft ? (
+
props.rows / 2 ? " above" : ""}`}
+ style={{
+ left: `clamp(9rem, ${((draft.column + 0.5) / props.cols) * 100}%, calc(100% - 9rem))`,
+ top: `${((draft.row + 0.5) / props.rows) * 100}%`,
+ }}
+ onPointerDown={(event) => event.stopPropagation()}
+ >
+
+ {draft.id ? "Edit annotation" : "New annotation"}
+ R{draft.row + 1} · C{draft.column + 1}
+
+
+ ) : undefined}
+
+