'use client' import { useState } from 'react' import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog' import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs' import { Label } from '@/components/ui/label' import { Input } from '@/components/ui/input' import { Button } from '@/components/ui/button' import { Settings } from 'lucide-react' import { type RendererOptions } from '@/lib/markdown' const stylePresets = { default: { name: '默认样式', options: { fontSize: { h1: '24px', h2: '20px', h3: '18px', paragraph: '15px', code: '14px' }, colors: { text: '#333333', heading: '#1a1a1a', link: '#576b95', code: '#333333', quote: '#666666' }, spacing: { paragraph: '20px', heading: '30px', list: '20px', quote: '20px' } } }, modern: { name: '现代简约', options: { fontSize: { h1: '28px', h2: '24px', h3: '20px', paragraph: '16px', code: '15px' }, colors: { text: '#2d3748', heading: '#1a202c', link: '#4299e1', code: '#2d3748', quote: '#718096' }, spacing: { paragraph: '24px', heading: '36px', list: '24px', quote: '24px' } } } } interface StyleConfigDialogProps { value: RendererOptions onChange: (options: RendererOptions) => void } export function StyleConfigDialog({ value, onChange }: StyleConfigDialogProps) { const [currentOptions, setCurrentOptions] = useState(value) const handlePresetChange = (preset: keyof typeof stylePresets) => { const newOptions = stylePresets[preset].options setCurrentOptions(newOptions) onChange(newOptions) } const handleOptionChange = ( category: keyof RendererOptions, subcategory: string, value: string ) => { const newOptions = { ...currentOptions, [category]: { ...currentOptions[category], [subcategory]: value } } setCurrentOptions(newOptions) onChange(newOptions) } return ( 样式配置 预设样式 字体 颜色 间距
{Object.entries(stylePresets).map(([key, preset]) => (
handlePresetChange(key as keyof typeof stylePresets)} >

{preset.name}

正文示例

标题示例

))}
{Object.entries(currentOptions.fontSize || {}).map(([key, value]) => (
handleOptionChange('fontSize', key, e.target.value)} />
))}
{Object.entries(currentOptions.colors || {}).map(([key, value]) => (
handleOptionChange('colors', key, e.target.value)} /> handleOptionChange('colors', key, e.target.value)} />
))}
{Object.entries(currentOptions.spacing || {}).map(([key, value]) => (
handleOptionChange('spacing', key, e.target.value)} />
))}
) }