MD EDITOR | untitled.md
EXPORT THEME:
EDITOR 0W / 0L
PREVIEW MINIMAL
0 chars AUTOSAVED Ctrl+S save  |  Ctrl+E export
`; const blob = new Blob([html], {type:'text/html'}); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href=url; a.download = docTitle+'.html'; a.click(); URL.revokeObjectURL(url); toast('EXPORTED: '+docTitle+'.html ['+t.label+']'); } document.getElementById('btn-export').addEventListener('click', exportHTML); // ── Modal ───────────────────────────────────────────────────────────────── let modalCb = null; function showModal(title, msg, cb){ document.getElementById('modal-title').textContent = title; document.getElementById('modal-msg').textContent = msg; modalCb = cb; document.getElementById('modal-bg').classList.add('show'); } document.getElementById('modal-ok').addEventListener('click',()=>{ document.getElementById('modal-bg').classList.remove('show'); if(modalCb){ modalCb(); modalCb=null; } }); document.getElementById('modal-cancel').addEventListener('click',()=>{ document.getElementById('modal-bg').classList.remove('show'); modalCb=null; }); // ── Toast ───────────────────────────────────────────────────────────────── let toastTimer = null; function toast(msg){ const el = document.getElementById('toast'); el.textContent = msg; el.classList.add('show'); clearTimeout(toastTimer); toastTimer = setTimeout(()=>el.classList.remove('show'), 2500); } // ── Init ────────────────────────────────────────────────────────────────── const DEFAULT_MD = `# Welcome to MarkForge A **portable** Markdown editor — single HTML file, no install. ## Quick Start Edit here, see the result in the preview pane. Choose an export theme, then click **EXPORT HTML** for a self-contained output file. ## Markdown Support **Bold**, *italic*, ~~strikethrough~~, and \`inline code\`. > Blockquotes for callouts or cited text. ### Code Block \`\`\` function hello(name) { return "Hello, " + name; } \`\`\` ### Lists - Unordered item - Another item 1. Ordered list 2. Second item ### Links [Hylas Security](https://hylassecurity.co.uk) --- *Ctrl+S — save .md  |  Ctrl+E — export HTML  |  Ctrl+O — open file* `; // Restore from localStorage if available try{ const saved = localStorage.getItem('markforge_content'); const fname = localStorage.getItem('markforge_file'); const ltheme = localStorage.getItem('markforge_theme'); if(ltheme && THEMES[ltheme]){ themeSel.value=ltheme; } if(saved !== null){ editor.value = saved; currentFile = fname || 'untitled.md'; savedContent = saved; fileNameEl.textContent = currentFile; } else { editor.value = DEFAULT_MD; savedContent = DEFAULT_MD; } } catch(e){ editor.value = DEFAULT_MD; savedContent = DEFAULT_MD; } applyTheme(themeSel.value); render(); saveStatus.style.color='var(--green)'; saveStatus.textContent='AUTOSAVED';