@sequent-org/moodboard 1.2.75 → 1.2.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/core/SaveManager.js +25 -0
package/package.json
CHANGED
package/src/core/SaveManager.js
CHANGED
|
@@ -98,6 +98,31 @@ export class SaveManager {
|
|
|
98
98
|
e.returnValue = '';
|
|
99
99
|
return '';
|
|
100
100
|
}, { capture: true });
|
|
101
|
+
|
|
102
|
+
// Дополнительно: обработка быстрого ухода со страницы (pagehide надёжнее в части браузеров)
|
|
103
|
+
window.addEventListener('pagehide', () => {
|
|
104
|
+
if (!this.hasUnsavedChanges) return;
|
|
105
|
+
try {
|
|
106
|
+
if (!this.options || this.options.useBeaconOnUnload) {
|
|
107
|
+
this._flushOnUnload();
|
|
108
|
+
} else {
|
|
109
|
+
this._flushSyncFallback();
|
|
110
|
+
}
|
|
111
|
+
} catch (_) { /* игнорируем */ }
|
|
112
|
+
}, { capture: true });
|
|
113
|
+
|
|
114
|
+
// Подстраховка на случай, когда вкладка просто уходит в фон без beforeunload/pagehide
|
|
115
|
+
document.addEventListener('visibilitychange', () => {
|
|
116
|
+
if (document.visibilityState !== 'hidden') return;
|
|
117
|
+
if (!this.hasUnsavedChanges) return;
|
|
118
|
+
try {
|
|
119
|
+
if (!this.options || this.options.useBeaconOnUnload) {
|
|
120
|
+
this._flushOnUnload();
|
|
121
|
+
} else {
|
|
122
|
+
this._flushSyncFallback();
|
|
123
|
+
}
|
|
124
|
+
} catch (_) { /* игнорируем */ }
|
|
125
|
+
});
|
|
101
126
|
|
|
102
127
|
// Периодическое автосохранение
|
|
103
128
|
if (this.options.autoSave) {
|