@eigenpal/docx-editor-core/managers/AutoSaveManager
AutoSaveManager
Framework-agnostic class for auto-saving documents to localStorage. Extracted from the React useAutoSave hook.
Usage with React:
ts
const snapshot = useSyncExternalStore(manager.subscribe, manager.getSnapshot);
Functions (5)
formatLastSaveTimefunctionSource ↗
Format last save time for display
declare function formatLastSaveTime(date: Date | null): string;formatStorageSizefunctionSource ↗
Format storage size for display
declare function formatStorageSize(bytes: number): string;getAutoSaveStatusLabelfunctionSource ↗
Get auto-save status label
declare function getAutoSaveStatusLabel(status: AutoSaveStatus): string;getAutoSaveStorageSizefunctionSource ↗
Get storage size used by auto-save
declare function getAutoSaveStorageSize(storageKey?: string): number;isAutoSaveSupportedfunctionSource ↗
Check if auto-save is supported
declare function isAutoSaveSupported(): boolean;Classes (1)
AutoSaveManagerclassSource ↗
AutoSaveManager
Framework-agnostic class for auto-saving documents to localStorage. Extracted from the React useAutoSave hook.
Usage with React:
ts
const snapshot = useSyncExternalStore(manager.subscribe, manager.getSnapshot);
declare class AutoSaveManager extends Subscribable<AutoSaveSnapshot>| Member | Type | Summary |
|---|---|---|
| (constructor) | | Constructs a new instance of the `AutoSaveManager` class |
| acceptRecovery | | Accept recovery and return the document. |
| clear | | Clear auto-saved data from storage. |
| destroy | | Save synchronously on destroy (best-effort). |
| disable | | Disable auto-save and stop all timers. |
| dismissRecovery | | Dismiss recovery and clear saved data. |
| enable | | Enable auto-save and start the interval timer. |
| getRecoveryData | | Get recovery data from storage. |
| onDocumentChanged | | Update the current document. Triggers debounced save if enabled. |
| save | | Manually trigger a save. |
| startInterval | | Start the interval timer. Call after enabling or on init. |