Nemo

Drop components here to start building
${content} `; } // --- Preview --- previewBtn.addEventListener('click', () => { const pageHtml = generateFullHtml(getCleanHtml()); // Use srcdoc to inject the HTML into the iframe previewIframe.srcdoc = pageHtml; previewModal.classList.remove('hidden'); previewModal.classList.add('flex'); }); closePreviewBtn.addEventListener('click', () => { previewModal.classList.add('hidden'); previewModal.classList.remove('flex'); previewIframe.srcdoc = ''; // Clear iframe content }); // --- Export --- exportBtn.addEventListener('click', () => { const pageHtml = generateFullHtml(getCleanHtml()); // Beautify the HTML for the textarea exportTextarea.value = pageHtml.replace(/^\s+/gm, ''); // Simple trim for indentation exportModal.classList.remove('hidden'); exportModal.classList.add('flex'); }); closeExportBtn.addEventListener('click', () => { exportModal.classList.add('hidden'); exportModal.classList.remove('flex'); }); // --- Copy to Clipboard --- copyHtmlBtn.addEventListener('click', () => { exportTextarea.select(); // Use execCommand for broader compatibility in iframes try { document.execCommand('copy'); copyHtmlBtn.innerHTML = ` Copied! `; setTimeout(() => { copyHtmlBtn.innerHTML = ` Copy to Clipboard `; }, 2000); } catch (err) { console.error('Failed to copy HTML: ', err); alert('Failed to copy. Please copy manually.'); } }); // --- SAVE TO SERVER (PHP) --- saveBtn.addEventListener('click', () => { const pageHtml = generateFullHtml(getCleanHtml()); showSaveStatus('Saving...', 'bg-blue-500'); fetch('save_page.php', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, body: `page_html=${encodeURIComponent(pageHtml)}` }) .then(response => response.json()) .then(data => { if (data.success) { showSaveStatus('Page saved successfully!', 'bg-green-500'); } else { showSaveStatus(`Error: ${data.message}`, 'bg-red-500'); } }) .catch(error => { console.error('Error:', error); showSaveStatus('Save failed. Check console or server logs.', 'bg-red-500'); }); }); function showSaveStatus(message, bgColor) { saveStatus.textContent = message; saveStatus.className = `show ${bgColor}`; setTimeout(() => { saveStatus.classList.remove('show'); }, 3000); } });