Commit ab55f33d authored by Nick's avatar Nick

feat: editor - warn on leave without save

parent 74e7316c
......@@ -118,6 +118,7 @@ export default {
dialogProgress: false,
dialogEditorSelector: false,
dialogUnsaved: false,
exitConfirmed: false,
initContentParsed: ''
}
},
......@@ -161,6 +162,14 @@ export default {
} else {
this.currentEditor = `editor${_.startCase(this.initEditor || 'markdown')}`
}
window.onbeforeunload = () => {
if (!this.exitConfirmed && this.initContentParsed !== this.$store.get('editor/content')) {
return 'You have unsaved edits. Are you sure you want to leave the editor?'
} else {
return undefined
}
}
},
methods: {
openPropsModal(name) {
......@@ -263,6 +272,7 @@ export default {
exitGo() {
this.$store.commit(`loadingStart`, 'editor-close')
this.currentEditor = ''
this.exitConfirmed = true
_.delay(() => {
if (this.$store.get('editor/mode') === 'create') {
window.location.assign(`/`)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment