"use client" import { useState } from "react" interface HighlightSelectionToolbarProperties { selectionRect: DOMRect containerRect: DOMRect onHighlight: (note: string | null) => void onShare: () => void onDismiss: () => void } export function HighlightSelectionToolbar({ selectionRect, onHighlight, onShare, onDismiss, }: HighlightSelectionToolbarProperties) { const [showNoteInput, setShowNoteInput] = useState(false) const [noteText, setNoteText] = useState("") const toolbarLeft = selectionRect.left + selectionRect.width / 2 const toolbarTop = selectionRect.top - 8 function handleHighlightClick() { if (showNoteInput) { onHighlight(noteText.trim() || null) } else { onHighlight(null) } } return (
{showNoteInput ? (
setNoteText(event.target.value)} onKeyDown={(event) => { if (event.key === "Enter") handleHighlightClick() if (event.key === "Escape") onDismiss() }} placeholder="add a note..." className="border border-border bg-background-primary px-2 py-1 text-xs text-text-primary outline-none" autoFocus />
) : (
)}
) }