Skip to content

Vizel API / vue/src / useVizelMarkdown

Function: useVizelMarkdown()

ts
function useVizelMarkdown(getEditor, options?): UseVizelMarkdownResult;

Defined in: packages/vue/src/composables/useVizelMarkdown.ts:84

Vue composable for bidirectional Markdown synchronization with the editor.

Parameters

ParameterTypeDescription
getEditor() => Editor | null | undefinedFunction to get the editor instance
optionsUseVizelMarkdownOptionsSync options

Returns

UseVizelMarkdownResult

Markdown state and control functions

Examples

vue
<script setup lang="ts">
import { useVizelEditor, useVizelMarkdown, VizelEditor } from '@vizel/vue';

const editor = useVizelEditor();
const { markdown, setMarkdown, isPending } = useVizelMarkdown(() => editor.value, {
  debounceMs: 300,
});
</script>

<template>
  <VizelEditor :editor="editor" />
  <textarea
    :value="markdown"
    @input="setMarkdown(($event.target as HTMLTextAreaElement).value)"
  />
  <span v-if="isPending">Syncing...</span>
</template>
vue
<script setup lang="ts">
// With initial markdown value
const { markdown, setMarkdown } = useVizelMarkdown(() => editor.value, {
  initialValue: "# Hello World",
  transformDiagrams: true,
});
</script>

Released under the MIT License.