Vizel API / vue/src / useVizelAutoSave
Function: useVizelAutoSave()
ts
function useVizelAutoSave(getEditor, options?): UseVizelAutoSaveResult;Defined in: packages/vue/src/composables/useVizelAutoSave.ts:56
Composable for auto-saving editor content with debouncing.
Parameters
| Parameter | Type | Description |
|---|---|---|
getEditor | () => Editor | null | undefined | Function that returns the editor instance |
options | VizelAutoSaveOptions | Auto-save configuration options |
Returns
Auto-save state and controls
Example
vue
<script setup lang="ts">
import { useVizelEditor, useVizelAutoSave, VizelEditor, VizelSaveIndicator } from '@vizel/vue';
const editor = useVizelEditor({ ... });
const { status, lastSaved, save } = useVizelAutoSave(() => editor.value, {
debounceMs: 2000,
storage: 'localStorage',
key: 'my-document',
});
</script>
<template>
<VizelEditor :editor="editor" />
<VizelSaveIndicator :status="status" :lastSaved="lastSaved" />
</template>