|
953 | 953 | if (!self._canSave) {
|
954 | 954 | return;
|
955 | 955 | }
|
956 |
| - self.save(); |
| 956 | + self.save(false, true); |
957 | 957 | }, self.settings.file.autoSave);
|
958 | 958 | }
|
959 | 959 |
|
|
1024 | 1024 | if (!self._canSave) {
|
1025 | 1025 | return;
|
1026 | 1026 | }
|
1027 |
| - self.save(true); |
| 1027 | + self.save(true, true); |
1028 | 1028 | }, 100);
|
1029 | 1029 |
|
1030 | 1030 | _syncTextarea = function () {
|
|
1057 | 1057 | // manually save draft after import so there is no delay between the
|
1058 | 1058 | // import and exporting in _syncTextarea. Without this, _syncTextarea
|
1059 | 1059 | // will pull the saved data from localStorage which will be <=100ms old.
|
1060 |
| - self.save(true); |
| 1060 | + self.save(true, true); |
1061 | 1061 | }
|
1062 | 1062 |
|
1063 | 1063 | // Update the textarea on load and pull from drafts
|
|
1194 | 1194 | }
|
1195 | 1195 |
|
1196 | 1196 | // Save a preview draft since it might not be saved to the real file yet
|
1197 |
| - self.save(true); |
| 1197 | + self.save(true, true); |
1198 | 1198 |
|
1199 | 1199 | // Add the generated draft HTML into the previewer
|
1200 | 1200 | self.previewer.innerHTML = self.exportFile(null, 'html', true);
|
|
1340 | 1340 | }
|
1341 | 1341 | else {
|
1342 | 1342 | _setText(self.editor, defaultContent);
|
1343 |
| - self.save(); // ensure a save |
| 1343 | + self.save(false, true); // ensure a save |
1344 | 1344 | self.emit('create');
|
1345 | 1345 | }
|
1346 | 1346 | self.previewer.innerHTML = self.exportFile(null, 'html');
|
|
1353 | 1353 | * Saves content for offline use
|
1354 | 1354 | * @returns {object} EpicEditor will be returned
|
1355 | 1355 | */
|
1356 |
| - EpicEditor.prototype.save = function (_isPreviewDraft) { |
| 1356 | + EpicEditor.prototype.save = function (_isPreviewDraft, _isAuto) { |
1357 | 1357 | var self = this
|
1358 | 1358 | , storage
|
1359 | 1359 | , isUpdate = false
|
|
1396 | 1396 | // Emit a private update event so it can't get accidentally removed
|
1397 | 1397 | self.emit('__update');
|
1398 | 1398 | }
|
1399 |
| - |
1400 |
| - this.emit('save'); |
| 1399 | + if (_isAuto) { |
| 1400 | + this.emit('autosave'); |
| 1401 | + } |
| 1402 | + else { |
| 1403 | + this.emit('save'); |
| 1404 | + } |
1401 | 1405 | }
|
1402 | 1406 |
|
1403 | 1407 | return this;
|
|
1470 | 1474 | self.emit('create');
|
1471 | 1475 | }
|
1472 | 1476 |
|
1473 |
| - self.save(); |
| 1477 | + self.save(false, true); |
1474 | 1478 |
|
1475 | 1479 | if (self.is('fullscreen')) {
|
1476 | 1480 | self.preview();
|
|
0 commit comments