import React, { useState } from 'react'; import { Button } from './button'; import { Bold, Italic, Heading1, Heading2, Link, List, ListOrdered, Quote, Code, Square, Plus, Image, MousePointer } from 'lucide-react'; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger, } from './dialog'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from './select'; interface MarkdownToolbarProps { onInsert: (before: string, after?: string) => void; } export function MarkdownToolbar({ onInsert }: MarkdownToolbarProps) { const [showCardDialog, setShowCardDialog] = useState(false); const [selectedCardType, setSelectedCardType] = useState('default'); const [showButtonDialog, setShowButtonDialog] = useState(false); const [buttonStyle, setButtonStyle] = useState('solid'); const [showImageDialog, setShowImageDialog] = useState(false); const tools = [ { icon: Bold, label: 'Bold', before: '**', after: '**' }, { icon: Italic, label: 'Italic', before: '*', after: '*' }, { icon: Heading1, label: 'Heading 1', before: '# ', after: '' }, { icon: Heading2, label: 'Heading 2', before: '## ', after: '' }, { icon: Link, label: 'Link', before: '[', after: '](url)' }, { icon: List, label: 'Bullet List', before: '- ', after: '' }, { icon: ListOrdered, label: 'Numbered List', before: '1. ', after: '' }, { icon: Quote, label: 'Quote', before: '> ', after: '' }, { icon: Code, label: 'Code', before: '`', after: '`' }, ]; const cardTypes = [ { value: 'default', label: 'Default', description: 'Standard white card' }, { value: 'hero', label: 'Hero', description: 'Large header card with gradient' }, { value: 'success', label: 'Success', description: 'Green success message' }, { value: 'warning', label: 'Warning', description: 'Yellow warning message' }, { value: 'info', label: 'Info', description: 'Blue information card' }, { value: 'basic', label: 'Basic', description: 'Minimal styling' }, ]; const handleInsertCard = () => { const cardTemplate = selectedCardType === 'default' ? '[card]\n\n## Your heading here\n\nYour content here...\n\n[/card]' : `[card:${selectedCardType}]\n\n## Your heading here\n\nYour content here...\n\n[/card]`; onInsert(cardTemplate, ''); setShowCardDialog(false); }; const handleInsertButton = () => { const buttonTemplate = `[button:${buttonStyle}](https://example.com)Click me[/button]`; onInsert(buttonTemplate, ''); setShowButtonDialog(false); }; const handleInsertImage = () => { const imageTemplate = `![Image description](https://example.com/image.jpg)`; onInsert(imageTemplate, ''); setShowImageDialog(false); }; return (
{/* Card Insert Button with Dialog */} Insert Card Choose a card type to insert into your template
{/* Button Insert Dialog */} Insert Button Choose a button style to insert
{/* Image Insert Dialog */} Insert Image Insert an image using standard Markdown syntax

Syntax: ![Alt text](image-url)

Example: ![Logo](https://example.com/logo.png)

{/* Separator */}
{/* Other formatting tools */} {tools.map((tool) => ( ))}
Quick formatting: **bold** ## heading
); }