mirror of
https://github.com/Ionaru/easy-markdown-editor
synced 2025-07-23 01:44:31 -06:00
Merge pull request #182 from firm1/fix_181
fix #181 : allow saving only on change content
This commit is contained in:
commit
8212d4901a
@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
### Fixed
|
||||
- Fix cursor displayed position on activity ([#183]).
|
||||
- Checkboxes always have bullets in front of them ([#136]).
|
||||
- Save the text only when modifying the content of the easymde instance (Thanks to [@firm1], [#181]).
|
||||
|
||||
## [2.10.1] - 2020-04-06
|
||||
### Fixed
|
||||
|
@ -2039,7 +2039,13 @@ EasyMDE.prototype.render = function (el) {
|
||||
this.gui.statusbar = this.createStatusbar();
|
||||
}
|
||||
if (options.autosave != undefined && options.autosave.enabled === true) {
|
||||
this.autosave();
|
||||
this.autosave(); // use to load localstorage content
|
||||
this.codemirror.on('change', function () {
|
||||
clearTimeout(self._autosave_timeout);
|
||||
self._autosave_timeout = setTimeout(function () {
|
||||
self.autosave();
|
||||
}, self.options.autosave.submit_delay || self.options.autosave.delay || 1000);
|
||||
});
|
||||
}
|
||||
|
||||
this.gui.sideBySide = this.createSideBySide();
|
||||
@ -2071,6 +2077,7 @@ function isLocalStorageAvailable() {
|
||||
}
|
||||
|
||||
EasyMDE.prototype.autosave = function () {
|
||||
console.log('save');
|
||||
if (isLocalStorageAvailable()) {
|
||||
var easyMDE = this;
|
||||
|
||||
@ -2086,11 +2093,6 @@ EasyMDE.prototype.autosave = function () {
|
||||
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();
|
||||
}, easyMDE.options.autosave.submit_delay || easyMDE.options.autosave.delay || 10000);
|
||||
});
|
||||
}
|
||||
|
||||
@ -2121,10 +2123,6 @@ EasyMDE.prototype.autosave = function () {
|
||||
|
||||
el.innerHTML = save + dd;
|
||||
}
|
||||
|
||||
this.autosaveTimeoutId = setTimeout(function () {
|
||||
easyMDE.autosave();
|
||||
}, this.options.autosave.delay || 10000);
|
||||
} else {
|
||||
console.log('EasyMDE: localStorage not available, cannot autosave');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user