import React, { useEffect, useRef, useState } from "react"; import { ActionButton } from "@/components/ui/action-button"; import { Button } from "@/components/ui/button"; import { Popover, PopoverContent } from "@/components/ui/popover"; import { Textarea } from "@/components/ui/textarea"; import { cn } from "@/lib/utils"; import { PopoverAnchor } from "@radix-ui/react-popover"; import { Check, Trash2 } from "lucide-react"; import { SUPPORTED_HIGHLIGHT_COLORS, ZHighlightColor, } from "@karakeep/shared/types/highlights"; import { HIGHLIGHT_COLOR_MAP } from "./highlights"; interface HighlightFormProps { position: { x: number; y: number } | null; selectedHighlight: Highlight | null; onClose: () => void; onSave: (color: ZHighlightColor, note: string | null) => void; onDelete?: () => void; isMobile: boolean; } const HighlightForm: React.FC = ({ position, selectedHighlight, onClose, onSave, onDelete, isMobile, }) => { const [selectedColor, setSelectedColor] = useState( selectedHighlight?.color || "yellow", ); const [noteText, setNoteText] = useState(selectedHighlight?.note || ""); // Update state when selectedHighlight changes useEffect(() => { setSelectedColor(selectedHighlight?.color || "yellow"); setNoteText(selectedHighlight?.note || ""); }, [selectedHighlight]); const handleSave = () => { onSave(selectedColor, noteText || null); }; return ( { if (!val) { onClose(); } }} >
{SUPPORTED_HIGHLIGHT_COLORS.map((color) => ( ))}