import React from 'react'; import { EmailBlock } from './types'; import { __ } from '@/lib/i18n'; import { parseMarkdownBasics } from '@/lib/markdown-utils'; interface BlockRendererProps { block: EmailBlock; isEditing: boolean; onEdit: () => void; onDelete: () => void; onMoveUp: () => void; onMoveDown: () => void; isFirst: boolean; isLast: boolean; } export function BlockRenderer({ block, isEditing, onEdit, onDelete, onMoveUp, onMoveDown, isFirst, isLast }: BlockRendererProps) { // Prevent navigation in builder const handleClick = (e: React.MouseEvent) => { const target = e.target as HTMLElement; if ( target.tagName === 'A' || target.tagName === 'BUTTON' || target.closest('a') || target.closest('button') || target.classList.contains('button') || target.classList.contains('button-outline') || target.closest('.button') || target.closest('.button-outline') ) { e.preventDefault(); e.stopPropagation(); } }; const renderBlockContent = () => { switch (block.type) { case 'card': const cardStyles: { [key: string]: React.CSSProperties } = { default: { background: '#ffffff', borderRadius: '8px', padding: '32px 40px', marginBottom: '24px' }, success: { background: '#e8f5e9', border: '1px solid #4caf50', borderRadius: '8px', padding: '32px 40px', marginBottom: '24px' }, info: { background: '#f0f7ff', border: '1px solid #0071e3', borderRadius: '8px', padding: '32px 40px', marginBottom: '24px' }, warning: { background: '#fff8e1', border: '1px solid #ff9800', borderRadius: '8px', padding: '32px 40px', marginBottom: '24px' }, hero: { background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)', color: '#fff', borderRadius: '8px', padding: '32px 40px', marginBottom: '24px' } }; // Convert markdown to HTML for visual rendering const htmlContent = parseMarkdownBasics(block.content); return (