New

docx-editor 1.x has shipped. Vue support, i18n, agents. Read the migration guide →

API Referencev1.0.2

@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)

Format last save time for display

declare function formatLastSaveTime(date: Date | null): string;

Format storage size for display

declare function formatStorageSize(bytes: number): string;

Get auto-save status label

declare function getAutoSaveStatusLabel(status: AutoSaveStatus): string;

Get storage size used by auto-save

declare function getAutoSaveStorageSize(storageKey?: string): number;

Check if auto-save is supported

declare function isAutoSaveSupported(): boolean;

Classes(1)

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.