fixing some bug caused by lazyness

This commit is contained in:
2023-11-13 00:27:09 +01:00
parent a2dcfbad7d
commit 32f6d2cbf2
4 changed files with 52 additions and 70 deletions

View File

@ -17,8 +17,6 @@ const handleResize = (canvas: HTMLCanvasElement) => {
};
export const saveBeforeExit = (app: Editor): null => {
// @ts-ignore
event.preventDefault();
// Iterate over all local files and set the candidate to the committed
app.currentFile().candidate = app.view.state.doc.toString();
app.currentFile().committed = app.view.state.doc.toString();
@ -38,10 +36,12 @@ export const installWindowBehaviors = (
window.addEventListener("resize", () =>
handleResize(app.interface.feedback as HTMLCanvasElement)
);
window.addEventListener("beforeunload", () => {
window.addEventListener("beforeunload", (event) => {
event.preventDefault()
saveBeforeExit(app)
});
window.addEventListener("visibilitychange", () => {
window.addEventListener("visibilitychange", (event) => {
event.preventDefault();
saveBeforeExit(app)
});