'use client'; import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; import { X, Maximize2, Minimize2, Folder, Tag } from 'lucide-react'; import ReactMarkdown from 'react-markdown'; import remarkGfm from 'remark-gfm'; import { useEffect, useState } from 'react'; import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'; import { vscDarkPlus } from 'react-syntax-highlighter/dist/esm/styles/prism'; interface MarkdownPreviewDialogProps { isOpen: boolean; onClose: () => void; title: string; content: string; folder?: string; tags?: string[]; } export function MarkdownPreviewDialog({ isOpen, onClose, title, content, folder, tags, }: MarkdownPreviewDialogProps) { const [isFullscreen, setIsFullscreen] = useState(false); useEffect(() => { if (!isOpen) { setIsFullscreen(false); } }, [isOpen]); return ( !open && onClose()}> {/* Header */}
{title}
{/* Metadata row: Folder and Tags */}
{folder && (
{folder}
)} {tags && tags.length > 0 && (
{tags.map((tag) => ( #{tag} ))}
)}
{/* Content */}
{match[1]}
{String(children).replace(/\n$/, '')}
) : ( {children} ); }, pre({ children }) { return <>{children}; }, }} > {content}
{/* Footer with line count */}
{content.split(/\r?\n/).length} lines
{/* Custom styles for markdown content */}
); }