diff --git a/package.json b/package.json index 4298f79..5dd4fb3 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "marker", "private": true, "author": "Savin Angel-Mario (savin@fructo.land)", - "version": "1.2.3", + "version": "1.2.4", "type": "module", "scripts": { "dev": "vite", diff --git a/src/main.ts b/src/main.ts index a44f45c..dbac750 100644 --- a/src/main.ts +++ b/src/main.ts @@ -15,6 +15,14 @@ if (isCompat) { const editor = initEditor(editorWrapper, store); initStatus(editor); + window.onbeforeunload = () => { + if (editor.getValue() !== "") { + return "You have unsaved changes. Are you sure you want to leave?"; + } + + return; + } + registerSW({ onNeedRefresh() { createNotice("Marker will update at the next restart"); @@ -44,4 +52,4 @@ if (isCompat) { const unsupportedWrapper = document.getElementById("unsupported")!; editorWrapper.style.display = "none"; unsupportedWrapper.style.display = "block"; -} \ No newline at end of file +}