upd: handle onbeforeunload on electron for drawio editor

This commit is contained in:
purocean
2022-01-12 09:36:39 +08:00
parent 7694064ef0
commit fc22f2e2ea
+6
View File
@@ -276,6 +276,12 @@ function buildEditorSrcdoc (file: Doc) {
iframe.style.border = 'none'
iframe.setAttribute('frameborder', '0')
${isElectron ? `
window.onbeforeunload = evt => {
iframe.contentWindow.postMessage(JSON.stringify({ action: 'exit' }), '*');
}
` : ''}
const asPng = doc.path.endsWith('.png')
const receive = async function (evt) {