Vizel API / svelte/src / createVizelVersionHistory
Function: createVizelVersionHistory()
ts
function createVizelVersionHistory(getEditor, options?): CreateVizelVersionHistoryResult;Defined in: packages/svelte/src/runes/createVizelVersionHistory.svelte.ts:56
Svelte 5 rune for managing document version history.
Parameters
| Parameter | Type | Description |
|---|---|---|
getEditor | () => Editor | null | undefined | Function that returns the editor instance |
options | VizelVersionHistoryOptions | Version history configuration options |
Returns
CreateVizelVersionHistoryResult
Version history state and controls
Example
svelte
<script lang="ts">
import { createVizelEditor, createVizelVersionHistory } from '@vizel/svelte';
const editor = createVizelEditor({ ... });
const history = createVizelVersionHistory(() => editor.current, {
maxVersions: 20,
});
</script>
<button onclick={() => history.saveVersion("Manual save")}>Save Version</button>
{#each history.snapshots as snapshot}
<div>{snapshot.description} - {new Date(snapshot.timestamp).toLocaleString()}</div>
{/each}