Page Builder – Content2HTML
🧱
PageBuilder
Documento senza titolo

Trascina qui gli elementi

Scegli un componente dalla sidebar sinistra e trascinalo qui

`; }function showExportModal() { const code = generateExportHTML(); document.getElementById('exportCode').textContent = code; document.getElementById('exportModal').classList.add('show'); }function closeExportModal() { document.getElementById('exportModal').classList.remove('show'); }function copyExportCode() { const code = generateExportHTML(); navigator.clipboard.writeText(code).then(() => showToast('Codice copiato!', 'success')); }function togglePreview() { const code = generateExportHTML(); const frame = document.getElementById('previewFrame'); frame.srcdoc = code; document.getElementById('previewModal').classList.add('show'); }function closePreview() { document.getElementById('previewModal').classList.remove('show'); }function downloadPage() { const code = generateExportHTML(); const blob = new Blob([code], { type: 'text/html' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = 'pagina.html'; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); showToast('Pagina scaricata!', 'success'); closePreview(); closeExportModal(); }// File upload handlers function uploadImageForBlock(blockId) { const input = document.createElement('input'); input.type = 'file'; input.accept = 'image/*'; input.onchange = (e) => { const file = e.target.files[0]; if (!file) return; const reader = new FileReader(); reader.onload = (ev) => { const block = blocks.find(b => b.id === blockId); if (block) { saveUndo(); block.src = ev.target.result; renderCanvas(); renderProperties(); showToast('Immagine caricata', 'success'); } }; reader.readAsDataURL(file); }; input.click(); }function uploadVideoForBlock(blockId) { const input = document.createElement('input'); input.type = 'file'; input.accept = 'video/*'; input.onchange = (e) => { const file = e.target.files[0]; if (!file) return; const reader = new FileReader(); reader.onload = (ev) => { const block = blocks.find(b => b.id === blockId); if (block) { saveUndo(); block.src = ev.target.result; renderCanvas(); renderProperties(); showToast('Video caricato', 'success'); } }; reader.readAsDataURL(file); }; input.click(); }function uploadPdfForBlock(blockId) { const input = document.createElement('input'); input.type = 'file'; input.accept = '.pdf'; input.onchange = (e) => { const file = e.target.files[0]; if (!file) return; const reader = new FileReader(); reader.onload = (ev) => { const block = blocks.find(b => b.id === blockId); if (block) { saveUndo(); block.src = ev.target.result; renderCanvas(); renderProperties(); showToast('PDF caricato', 'success'); } }; reader.readAsDataURL(file); }; input.click(); }function uploadAudioForBlock(blockId) { const input = document.createElement('input'); input.type = 'file'; input.accept = 'audio/*'; input.onchange = (e) => { const file = e.target.files[0]; if (!file) return; const reader = new FileReader(); reader.onload = (ev) => { const block = blocks.find(b => b.id === blockId); if (block) { saveUndo(); block.src = ev.target.result; renderCanvas(); renderProperties(); showToast('Audio caricato', 'success'); } }; reader.readAsDataURL(file); }; input.click(); }// Toast function showToast(msg, type) { const toast = document.getElementById('toast'); toast.textContent = (type === 'success' ? 'βœ… ' : '❌ ') + msg; toast.className = 'toast ' + type + ' show'; setTimeout(() => toast.classList.remove('show'), 3000); }// Helpers function escapeHTML(str) { return String(str).replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"'); } function escapeAttr(str) { return String(str).replace(/"/g,'"').replace(/'/g,'''); }// Keyboard shortcuts document.addEventListener('keydown', e => { if (e.ctrlKey || e.metaKey) { if (e.key === 'z') { e.preventDefault(); undo(); } if (e.key === 'y') { e.preventDefault(); redo(); } if (e.key === 's') { e.preventDefault(); downloadPage(); } } if (e.key === 'Delete' && selectedBlockId && document.activeElement.tagName !== 'INPUT' && document.activeElement.tagName !== 'TEXTAREA') { deleteBlock(selectedBlockId); } });// Init renderCanvas(); renderProperties();