"use client" import { useState } from "react" interface HighlightPopoverProperties { highlightIdentifier: string note: string | null anchorRect: DOMRect containerRect: DOMRect onUpdateNote: (note: string | null) => void onDelete: () => void onDismiss: () => void } export function HighlightPopover({ note, anchorRect, onUpdateNote, onDelete, onDismiss, }: HighlightPopoverProperties) { const [isEditingNote, setIsEditingNote] = useState(false) const [editedNoteText, setEditedNoteText] = useState(note ?? "") const popoverLeft = anchorRect.left + anchorRect.width / 2 const popoverTop = anchorRect.bottom + 4 function handleSaveNote() { onUpdateNote(editedNoteText.trim() || null) setIsEditingNote(false) } return (
{isEditingNote ? (
setEditedNoteText(event.target.value)} onKeyDown={(event) => { if (event.key === "Enter") handleSaveNote() if (event.key === "Escape") onDismiss() }} placeholder="add a note..." className="w-full border border-border bg-background-primary px-2 py-1 text-xs text-text-primary outline-none" autoFocus />
) : (
{note && (

{note}

)}
)}
) }