import React, { useState } from 'react'; import { LayoutPanelLeft, LayoutPanelRight, LayoutTemplate } from 'lucide-react'; interface MarkdownEditorProps { value: string; onChange: (val: string) => void; placeholder?: string; } type ViewMode = 'edit' | 'preview' | 'split'; export default function MarkdownEditor({ value, onChange, placeholder }: MarkdownEditorProps) { const [mode, setMode] = useState('split'); const parseMarkdown = (text: string) => { if (!text) return

No content...

; return text.split('\n\n').map((paragraph, idx) => { let content = paragraph; // Headers if (content.startsWith('## ')) { return

{content.replace('## ', '')}

; } if (content.startsWith('# ')) { return

{content.replace('# ', '')}

; } // Lists if (content.startsWith('- ')) { const items = paragraph.split('\n').filter(line => line.startsWith('- ')); return ( ); } return

; }); }; const applyInlineFormatting = (text: string) => { return text .replace(/&/g, '&') .replace(//g, '>') .replace(/\*\*(.*?)\*\*/g, '$1') .replace(/\*(.*?)\*/g, '$1') .replace(/`(.*?)`/g, '$1'); }; return (

Markdown Editor
{(mode === 'edit' || mode === 'split') && (