mirror of
https://github.com/sparksuite/simplemde-markdown-editor.git
synced 2024-06-09 09:22:16 +02:00
Fixed localStorage cleaning on a form submit denial of the autosave feature
This commit is contained in:
parent
b6b1f7c1ef
commit
ba403ebfa2
|
@ -14443,10 +14443,12 @@ SimpleMDE.prototype.autosave = function() {
|
|||
return;
|
||||
}
|
||||
|
||||
if(simplemde.element.form != null && simplemde.element.form != undefined) {
|
||||
if(this.element.form != null && this.element.form != undefined && !this.options.autosave.isEventListening) {
|
||||
simplemde.element.form.addEventListener("submit", function() {
|
||||
localStorage.removeItem("smde_" + simplemde.options.autosave.uniqueId);
|
||||
simplemde.options.autosave.stop = true;
|
||||
});
|
||||
this.options.autosave.isEventListening = true;
|
||||
}
|
||||
|
||||
if(this.options.autosave.loaded !== true) {
|
||||
|
@ -14458,6 +14460,9 @@ SimpleMDE.prototype.autosave = function() {
|
|||
this.options.autosave.loaded = true;
|
||||
}
|
||||
|
||||
if (this.options.autosave.stop)
|
||||
return;
|
||||
|
||||
localStorage.setItem("smde_" + this.options.autosave.uniqueId, simplemde.value());
|
||||
|
||||
var el = document.getElementById("autosaved");
|
||||
|
|
|
@ -14440,10 +14440,12 @@ SimpleMDE.prototype.autosave = function() {
|
|||
return;
|
||||
}
|
||||
|
||||
if(simplemde.element.form != null && simplemde.element.form != undefined) {
|
||||
if(this.element.form != null && this.element.form != undefined && !this.options.autosave.isEventListening) {
|
||||
simplemde.element.form.addEventListener("submit", function() {
|
||||
localStorage.removeItem("smde_" + simplemde.options.autosave.uniqueId);
|
||||
simplemde.options.autosave.stop = true;
|
||||
});
|
||||
this.options.autosave.isEventListening = true;
|
||||
}
|
||||
|
||||
if(this.options.autosave.loaded !== true) {
|
||||
|
@ -14455,6 +14457,9 @@ SimpleMDE.prototype.autosave = function() {
|
|||
this.options.autosave.loaded = true;
|
||||
}
|
||||
|
||||
if (this.options.autosave.stop)
|
||||
return;
|
||||
|
||||
localStorage.setItem("smde_" + this.options.autosave.uniqueId, simplemde.value());
|
||||
|
||||
var el = document.getElementById("autosaved");
|
||||
|
|
|
@ -1537,10 +1537,12 @@ SimpleMDE.prototype.autosave = function() {
|
|||
return;
|
||||
}
|
||||
|
||||
if(simplemde.element.form != null && simplemde.element.form != undefined) {
|
||||
if(this.element.form != null && this.element.form != undefined && !this.options.autosave.isEventListening) {
|
||||
simplemde.element.form.addEventListener("submit", function() {
|
||||
localStorage.removeItem("smde_" + simplemde.options.autosave.uniqueId);
|
||||
simplemde.options.autosave.stop = true;
|
||||
});
|
||||
this.options.autosave.isEventListening = true;
|
||||
}
|
||||
|
||||
if(this.options.autosave.loaded !== true) {
|
||||
|
@ -1552,6 +1554,9 @@ SimpleMDE.prototype.autosave = function() {
|
|||
this.options.autosave.loaded = true;
|
||||
}
|
||||
|
||||
if (this.options.autosave.stop)
|
||||
return;
|
||||
|
||||
localStorage.setItem("smde_" + this.options.autosave.uniqueId, simplemde.value());
|
||||
|
||||
var el = document.getElementById("autosaved");
|
||||
|
|
Loading…
Reference in a new issue