Skip to content

Vizel API / vue/src / useVizelContext

Function: useVizelContext()

ts
function useVizelContext(): ShallowRef<Editor | null>;

Defined in: packages/vue/src/components/VizelContext.ts:39

Composable to access the editor instance from VizelProvider context.

Returns the ShallowRef<Editor | null> provided by VizelProvider so that templates can read editor.value and effects can track the reactive source. Mirrors the shape returned by useVizelEditor.

Returns

ShallowRef&lt;Editor | null&gt;

Throws

Error if used outside of VizelProvider

Example

vue
<script setup lang="ts">
import { useVizelContext } from '@vizel/vue';

const editor = useVizelContext();
</script>

<template>
  <button @click="editor?.chain().focus().toggleBold().run()">
    Bold
  </button>
</template>

Released under the MIT License.