Protect window from accidental closure if the notebook is not empty as it is not saved

This commit is contained in:
Leszek Hanusz 2026-02-02 21:15:24 +01:00
parent 301c3fec7e
commit 11e3cd81ce
2 changed files with 9 additions and 0 deletions

Binary file not shown.

View File

@ -177,8 +177,17 @@
scrollInterval = undefined;
}
});
function handleBeforeUnload(event: BeforeUnloadEvent) {
if (inputContent.length > 0) {
event.preventDefault();
event.returnValue = '';
}
}
</script>
<svelte:window onbeforeunload={handleBeforeUnload} />
<div class="flex h-full flex-col">
<header
class="flex items-center justify-between border-b border-border/40 bg-background/95 px-6 py-3 backdrop-blur supports-[backdrop-filter]:bg-background/60"