'use client'; import React, { useState, useEffect } from 'react'; import { Textarea } from '@/components/ui/textarea'; import { Label } from '@/components/ui/label'; import { Alert, AlertDescription } from '@/components/ui/alert'; import { Eye, Edit3, AlertCircle, HelpCircle } from 'lucide-react'; import { previewMarkdown, validateMarkdown } from '@/lib/markdown'; interface MarkdownEditorProps { value: string; onChange: (value: string) => void; placeholder?: string; label?: string; maxLength?: number; className?: string; } export function MarkdownEditor({ value, onChange, placeholder = "Écrivez votre description...", label = "Description", maxLength = 5000, className = "" }: MarkdownEditorProps) { const [activeTab, setActiveTab] = useState<'edit' | 'preview'>('edit'); const [validation, setValidation] = useState<{ isValid: boolean; errors: string[] }>({ isValid: true, errors: [] }); const [showHelp, setShowHelp] = useState(false); // Validation en temps réel useEffect(() => { const validationResult = validateMarkdown(value); setValidation(validationResult); }, [value]); const handleChange = (newValue: string) => { if (newValue.length <= maxLength) { onChange(newValue); } }; const previewContent = previewMarkdown(value); return (
{value.length}/{maxLength}
{activeTab === 'edit' && (