function SourceCard({ block, index, onViewInCanvas, bookmarkColor, onSetBookmark, onMoveUp, onMoveDown, isFirst, isLast }) { const [copied, setCopied] = useState(false); const [showSource, setShowSource] = useState(false); const [showBookmarkPicker, setShowBookmarkPicker] = useState(false); const [isEditing, setIsEditing] = useState(false); const [editedContent, setEditedContent] = useState(block.extracted_text || ''); const getIconAndLabel = (type) => { switch (type) { case 'text': return { icon: '📝', label: 'Text Block' }; case 'image': return { icon: '🖼️', label: 'Image' }; case 'pdf': return { icon: '📄', label: 'PDF Document' }; case 'audio': return { icon: '🎤', label: 'Audio Recording' }; case 'link': return { icon: '🔗', label: 'Link' }; case 'canvas': return { icon: '✏️', label: 'Canvas Drawing' }; default: return { icon: '📦', label: 'Content' }; } }; const { icon, label } = getIconAndLabel(block.content_type); const hasExtraction = block.extracted_text && block.extracted_text.trim(); const copyToClipboard = () => { if (hasExtraction) { navigator.clipboard.writeText(block.extracted_text); setCopied(true); setTimeout(() => setCopied(false), 2000); } }; const colorMap = { gold: '#FFD700', blue: '#4A90E2', pink: '#FF69B4' }; return (
{/* Bookmark Ribbon Indicator */} {bookmarkColor && (
)} {/* Main Layout: Sidebar + Content */}
{/* Left Sidebar - Outside card, absolutely positioned */}
{/* Move Up Button */} {/* Move Down Button */} {/* Bookmark Button */} {/* Bookmark Color Picker */} {showBookmarkPicker && (
{['gold', 'blue', 'pink'].map(color => { const colorFilters = { gold: 'sepia(1) saturate(5) hue-rotate(-10deg)', blue: 'hue-rotate(200deg) saturate(1.5)', pink: 'hue-rotate(300deg) saturate(1.5)' }; const isSelected = bookmarkColor === color; return ( ); })}
)} {/* Copy Button */} {hasExtraction && ( )} {/* Edit Button */} {hasExtraction && ( )}
{/* Right Content Area */}
{/* Original Preview Toggle */} {((block.content_type === 'image' && block.file_path) || (block.content_type === 'link' && block.content_data?.url)) && (
{showSource && (
{block.content_type === 'image' && block.file_path && (
{block.filename}
)} {block.content_type === 'link' && block.content_data?.url && ( )} {/* View in RAW button inside Source */}
)}
)} {/* Extracted Content */}
Extracted Content:
{hasExtraction ? ( isEditing ? (