diff --git a/src/client/editor/index.js b/src/client/editor/index.js index d78acdd1..96ee4811 100644 --- a/src/client/editor/index.js +++ b/src/client/editor/index.js @@ -102,7 +102,10 @@ class Editor { this.grid = true this.unsavedSession = false - + window.onbeforeunload = ()=>{ + if (editor.unsavedSession) return true + } + this.history = [] this.historyState = -1 this.historySession = null diff --git a/src/client/index.js b/src/client/index.js index f70563ef..bf932fbf 100644 --- a/src/client/index.js +++ b/src/client/index.js @@ -22,14 +22,12 @@ document.addEventListener('DOMContentLoaded', function(event) { require('./ui/init') - var editor = require('./editor') document.title = TITLE ipc.send('open', {hotReload: backup.exists}) - window.onbeforeunload = ()=>{ - if (editor.unsavedSession) return true + window.onunload = ()=>{ ipc.send('close') }