Skip to content

Commit

Permalink
Added a closing prevention dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
notangelmario committed Nov 2, 2022
1 parent a7edc8e commit 7ac3781
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "marker",
"private": true,
"author": "Savin Angel-Mario ([email protected])",
"version": "1.2.3",
"version": "1.2.4",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
10 changes: 9 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -44,4 +52,4 @@ if (isCompat) {
const unsupportedWrapper = document.getElementById("unsupported")!;
editorWrapper.style.display = "none";
unsupportedWrapper.style.display = "block";
}
}

0 comments on commit 7ac3781

Please sign in to comment.