|
|
|
|
@ -818,8 +818,28 @@ m.mount(document.getElementById("sections-wrap")!, SectionsList); |
|
|
|
|
m.mount(document.getElementById("demo-btns")!, DemoButtons); |
|
|
|
|
m.mount(document.getElementById("sec-meta")!, MetaPanel); |
|
|
|
|
|
|
|
|
|
async function clearAll() { |
|
|
|
|
if (isDirty && file.sections.length) { |
|
|
|
|
const ok = await showConfirm("Clear all sections?", [ |
|
|
|
|
{ label: "Cancel", action: false }, |
|
|
|
|
{ label: "Clear", primary: true, action: true }, |
|
|
|
|
]); |
|
|
|
|
if (!ok) return; |
|
|
|
|
} |
|
|
|
|
file = new MonoDisplayFile([]); |
|
|
|
|
activeSecIndex = null; |
|
|
|
|
activeElIndex = null; |
|
|
|
|
currentFilename = "untitled"; |
|
|
|
|
const filenameEl = document.getElementById("filename"); |
|
|
|
|
if (filenameEl) filenameEl.textContent = "untitled"; |
|
|
|
|
localStorage.removeItem(STORAGE_KEY); |
|
|
|
|
markClean(); |
|
|
|
|
triggerPreview(); |
|
|
|
|
m.redraw(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Expose globals referenced by topbar inline handlers
|
|
|
|
|
Object.assign(window, { loadBin, exportBin, addSection, cycleTheme }); |
|
|
|
|
Object.assign(window, { loadBin, exportBin, addSection, clearAll, cycleTheme }); |
|
|
|
|
|
|
|
|
|
window.addEventListener("beforeunload", (e) => { |
|
|
|
|
if (isDirty) e.preventDefault(); |
|
|
|
|
|