Skip to content

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

ParameterTypeDescription
getEditor() => Editor | null | undefinedA function that returns the editor instance

Returns

ComputedRef&lt;number&gt;

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>

Released under the MIT License.