Make sure saveFunction() is called when the page is unloaded

This commit is contained in:
Jonatan Heyman 2023-12-24 22:21:41 +01:00
parent 96440b28ba
commit bbb6387581

View File

@ -86,6 +86,13 @@ export class HeynoteEditor {
],
})
// make sure saveFunction is called when page is unloaded
if (saveFunction) {
window.addEventListener("beforeunload", () => {
saveFunction(this.getContent())
})
}
this.view = new EditorView({
state: state,
parent: element,