@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>
MemberTypeSummary
(constructor)Constructs a new instance of the `AutoSaveManager` class
acceptRecoveryAccept recovery and return the document.
clearClear auto-saved data from storage.
destroySave synchronously on destroy (best-effort).
disableDisable auto-save and stop all timers.
dismissRecoveryDismiss recovery and clear saved data.
enableEnable auto-save and start the interval timer.
getRecoveryDataGet recovery data from storage.
onDocumentChangedUpdate the current document. Triggers debounced save if enabled.
saveManually trigger a save.
startIntervalStart the interval timer. Call after enabling or on init.

On this page