import { useEffect, useRef } from "react"; interface Props { x: number; y: number; onCopyTrimmed: () => void; onCopyRaw: () => void; onDismiss: () => void; } export default function TerminalContextMenu({ x, y, onCopyTrimmed, onCopyRaw, onDismiss }: Props) { const menuRef = useRef(null); useEffect(() => { const handleOutsideClick = (e: MouseEvent) => { if (menuRef.current && !menuRef.current.contains(e.target as Node)) { onDismiss(); } }; const handleKey = (e: KeyboardEvent) => { if (e.key === "Escape") onDismiss(); }; document.addEventListener("mousedown", handleOutsideClick, true); document.addEventListener("keydown", handleKey); return () => { document.removeEventListener("mousedown", handleOutsideClick, true); document.removeEventListener("keydown", handleKey); }; }, [onDismiss]); return (
e.preventDefault()} >
); }