Merge pull request #2 from adamb70/fix-autosave-submit-handler

Update src/js/easymde.js
pull/31/head
adamb70 6 years ago committed by GitHub
commit 613fb0fcad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1656,12 +1656,24 @@ EasyMDE.prototype.autosave = function () {
return;
}
if(this.options.autosave.binded !== true) {
if (easyMDE.element.form != null && easyMDE.element.form != undefined) {
easyMDE.element.form.addEventListener('submit', function () {
clearTimeout(easyMDE.autosaveTimeoutId);
easyMDE.autosaveTimeoutId = undefined;
localStorage.removeItem('smde_' + easyMDE.options.autosave.uniqueId);
// Restart autosaving in case the submit will be cancelled down the line
setTimeout(function() {
easyMDE.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));

Loading…
Cancel
Save