Vizel API / vue/src / useVizelState
Function: useVizelState()
ts
function useVizelState(getEditor): ComputedRef<number>;Defined in: packages/vue/src/composables/useVizelState.ts:26
Composable that forces a re-render whenever the editor's state changes.
Wraps @vizel/core's createVizelEditorTransactionStore so the subscribe/version-counter mechanics are shared with the React and Svelte adapters.
Parameters
| Parameter | Type | Description |
|---|---|---|
getEditor | () => Editor | null | undefined | A function that returns the editor instance |
Returns
ComputedRef<number>
A computed ref whose value changes on each editor state update (the numeric value itself is opaque and can be ignored)
Example
vue
<script setup>
const props = defineProps<{ editor: Editor }>();
useVizelState(() => props.editor);
</script>
<template>
<button :class="{ active: props.editor.isActive('bold') }">Bold</button>
</template>