diff --git a/src/components/editor/ConfigPanel.tsx b/src/components/editor/ConfigPanel.tsx index 20429d4..e00795d 100644 --- a/src/components/editor/ConfigPanel.tsx +++ b/src/components/editor/ConfigPanel.tsx @@ -2,10 +2,11 @@ import React from 'react'; import { NewsletterModule, ProductItem, BadgeTemplate } from '@/types/newsletter'; -import { Plus, Trash2, Image as ImageIcon, Tag, Store, Globe, Palette, Check } from 'lucide-react'; +import { Plus, Trash2, Image as ImageIcon, Tag, Store, Globe, Palette, Check, Code } from 'lucide-react'; import { SUPABASE_ASSETS_BASE } from '@/lib/defaultCampaign'; import { ImageUploadInput } from './ImageUploadInput'; import { pickAlt } from '@/lib/altText'; +import { renderGeneratedModuleHtml, CUSTOM_HTML_MODULE_TYPES } from '@/lib/emailRenderer'; const PRODUCT_BG_PRESETS = [ { label: 'Červená', sub: 'Fantasticky', color: '#feeaea', border: '#f5d4d4' }, @@ -26,6 +27,69 @@ interface ConfigPanelProps { availableBadges?: BadgeTemplate[]; } +// Jednoduchý HTML editor: vlastné HTML nahradí modul vygenerovaný z formulára +const CustomHtmlEditor: React.FC<{ + module: NewsletterModule; + updateData: (patch: Record) => void; +}> = ({ module, updateData }) => { + const enabled = !!module.data.useCustomHtml; + + const toggle = () => { + if (enabled) { + // Neupravené HTML nedržíme, aby sa pri ďalšom zapnutí predvyplnilo aktuálne z formulára + const unchanged = (module.data.customHtml || '').trim() === renderGeneratedModuleHtml(module); + updateData({ useCustomHtml: false, ...(unchanged ? { customHtml: undefined } : {}) }); + } else { + // Pri prvom zapnutí predvyplníme aktuálne vygenerované HTML + updateData({ + useCustomHtml: true, + customHtml: module.data.customHtml || renderGeneratedModuleHtml(module) + }); + } + }; + + const reloadFromForm = () => { + if (confirm('Prepísať vlastné HTML aktuálnym HTML vygenerovaným z formulára?')) { + updateData({ customHtml: renderGeneratedModuleHtml(module) }); + } + }; + + return ( +
+ + + {enabled ? ( + <> +