Markdown
Preview
0 words 0 chars 0 lines Saved
`; const blob = new Blob([fullHTML], { type: 'text/html' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = 'document.html'; a.click(); URL.revokeObjectURL(url); showToast('HTML exported'); } function copyHTML() { const html = preview.innerHTML; navigator.clipboard.writeText(html).then(() => { showToast('HTML copied to clipboard'); }).catch(() => { // Fallback const ta = document.createElement('textarea'); ta.value = html; document.body.appendChild(ta); ta.select(); document.execCommand('copy'); document.body.removeChild(ta); showToast('HTML copied to clipboard'); }); } // ============================================================ // Toast Notification // ============================================================ let toastTimeout = null; function showToast(msg) { toastEl.textContent = msg; toastEl.classList.add('show'); clearTimeout(toastTimeout); toastTimeout = setTimeout(() => { toastEl.classList.remove('show'); }, 2000); } // ============================================================ // Resizable Divider // ============================================================ const divider = document.getElementById('divider'); let isDragging = false; divider.addEventListener('mousedown', function(e) { isDragging = true; divider.classList.add('dragging'); e.preventDefault(); }); document.addEventListener('mousemove', function(e) { if (!isDragging) return; const mainEl = document.getElementById('main'); const rect = mainEl.getBoundingClientRect(); const pct = ((e.clientX - rect.left) / rect.width) * 100; const clamped = Math.max(20, Math.min(80, pct)); document.getElementById('editor-pane').style.flex = 'none'; document.getElementById('editor-pane').style.width = clamped + '%'; document.getElementById('preview-pane').style.flex = '1'; }); document.addEventListener('mouseup', function() { if (isDragging) { isDragging = false; divider.classList.remove('dragging'); } }); // ============================================================ // Init // ============================================================ init();