import React, { useState, useRef, useEffect } from 'react'; import { Link, useNavigate } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { TagIcon, FolderIcon, EllipsisVerticalIcon, } from '@heroicons/react/24/outline'; import MarkdownRenderer from './MarkdownRenderer'; interface NoteCardProps { note: { id?: string | number; uid?: string; title: string; content?: string; tags?: { name: string; uid?: string }[]; Tags?: { name: string; uid?: string }[]; project?: { name: string; id?: number; uid?: string }; Project?: { name: string; id?: number; uid?: string }; }; onEdit?: (note: any) => void; onDelete?: (note: any) => void; showActions?: boolean; showProject?: boolean; } const NoteCard: React.FC = ({ note, onEdit, onDelete, showActions = true, showProject = true, }) => { const { t } = useTranslation(); const navigate = useNavigate(); const [dropdownOpen, setDropdownOpen] = useState(false); const dropdownRef = useRef(null); const tags = note.tags || note.Tags || []; const project = note.project || note.Project; useEffect(() => { const handleClickOutside = (event: MouseEvent) => { if ( dropdownRef.current && !dropdownRef.current.contains(event.target as Node) ) { setDropdownOpen(false); } }; if (dropdownOpen) { document.addEventListener('mousedown', handleClickOutside); } return () => { document.removeEventListener('mousedown', handleClickOutside); }; }, [dropdownOpen]); return (
{/* Note Content */}
{/* Title - Default Height with Trimming */}

{note.title || t('notes.untitled', 'Untitled Note')}

{/* Separator under title */}
{/* Content Summary - Main Area */}
{note.content ? ( 250 ? '...' : '') } summaryMode={true} /> ) : (

No content preview available...

)}
{/* Separator */}
{/* Footer - Project and Tags - Fixed Height */}
{showProject && project && ( )} {tags.length > 0 && (
{tags.map((tag, index) => ( {index < tags.length - 1 && ( ,{' '} )} ))}
)}
{/* Three Dots Dropdown - Outside Link */} {showActions && (onEdit || onDelete) && (
{dropdownOpen && (
{onEdit && ( )} {onDelete && ( )}
)}
)}
); }; export default NoteCard;