File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -1656,11 +1656,23 @@ EasyMDE.prototype.autosave = function () {
16561656 console . log ( 'EasyMDE: You must set a uniqueId to use the autosave feature' ) ;
16571657 return ;
16581658 }
1659-
1660- if ( easyMDE . element . form != null && easyMDE . element . form != undefined ) {
1661- easyMDE . element . form . addEventListener ( 'submit' , function ( ) {
1662- localStorage . removeItem ( 'smde_' + easyMDE . options . autosave . uniqueId ) ;
1663- } ) ;
1659+
1660+ if ( this . options . autosave . binded !== true ) {
1661+ if ( easyMDE . element . form != null && easyMDE . element . form != undefined ) {
1662+ easyMDE . element . form . addEventListener ( 'submit' , function ( ) {
1663+ clearTimeout ( easyMDE . autosaveTimeoutId ) ;
1664+ easyMDE . autosaveTimeoutId = undefined ;
1665+
1666+ localStorage . removeItem ( 'smde_' + easyMDE . options . autosave . uniqueId ) ;
1667+
1668+ // Restart autosaving in case the submit will be cancelled down the line
1669+ setTimeout ( function ( ) {
1670+ easyMDE . autosave ( ) ;
1671+ } , easyMDE . options . autosave . delay || 10000 ) ;
1672+ } ) ;
1673+ }
1674+
1675+ this . options . autosave . binded = true ;
16641676 }
16651677
16661678 if ( this . options . autosave . loaded !== true ) {
You can’t perform that action at this time.
0 commit comments