import React, { useEffect, useState } from 'react'; import ReactDOM from 'react-dom'; import { BookmarkPlus, X } from 'lucide-react'; import '../styles/ConfirmDialog.css'; /** * Preview clipboard (or pasted) text before adding it to chat context. * Clipboard is only read from a user gesture in the parent. */ const ClipboardPreviewModal = ({ isOpen, title = 'Add copied references', initialText = '', clipboardError = '', onCancel, onApprove, }) => { const [draft, setDraft] = useState(initialText); useEffect(() => { if (!isOpen) return undefined; setDraft(initialText); const onKey = (e) => e.key === 'Escape' && onCancel?.(); window.addEventListener('keydown', onKey); return () => window.removeEventListener('keydown', onKey); }, [isOpen, initialText, onCancel]); if (!isOpen) return null; const canApprove = Boolean(draft.trim()); return ReactDOM.createPortal(
Preview what you copied, edit if needed, then add it to this chat. Advisors will see it on your next question.
{clipboardError ? ({clipboardError}
) : null}