Merge bba551333a5e9c83204e45a79bfa7629b1a20cd7 into e32fe3f91c2d45f27f72a3662133b1c0e1a5bda1

This commit is contained in:
Tomasz Sawicki 2017-05-17 21:26:06 +00:00 committed by GitHub
commit 4447dc5adf

View File

@ -1601,12 +1601,24 @@ SimpleMDE.prototype.autosave = function() {
return;
}
if(this.options.autosave.binded !== true) {
if(simplemde.element.form != null && simplemde.element.form != undefined) {
simplemde.element.form.addEventListener("submit", function() {
clearTimeout(simplemde.autosaveTimeoutId);
simplemde.autosaveTimeoutId = undefined;
localStorage.removeItem("smde_" + simplemde.options.autosave.uniqueId);
// Restart autosaving in case the submit will be cancelled down the line
setTimeout(function() {
simplemde.autosave();
}, 10000);
});
}
this.options.autosave.binded = true;
}
if(this.options.autosave.loaded !== true) {
if(typeof localStorage.getItem("smde_" + this.options.autosave.uniqueId) == "string" && localStorage.getItem("smde_" + this.options.autosave.uniqueId) != "") {
this.codemirror.setValue(localStorage.getItem("smde_" + this.options.autosave.uniqueId));