For AI agents: the complete documentation index is available at /vue-codemirror6/llms.txt, the full documentation bundle is available at /vue-codemirror6/llms-full.txt, and this page is available as Markdown at /vue-codemirror6/api/events.md.
  • English
  • Events

    EventPayloadEmitted when
    update:modelValuestring | TextThe document changed. Used by v-model.
    ready{ view: EditorView; state: EditorState; container: HTMLElement }The editor has been created (after mount, client side only).
    focusbooleanThe editor gained (true) or lost (false) focus.
    updateViewUpdateAny update of the view: document, selection, focus, viewport, …
    changeEditorStateThe document changed. Receives the new state.
    destroy—The editor was destroyed (component unmounted).
    <script lang="ts" setup vapor>
    import type { EditorState } from '@codemirror/state';
    import type { ViewUpdate } from '@codemirror/view';
    import CodeMirror from 'vue-codemirror6';
    
    const onUpdate = (update: ViewUpdate) => {
      if (update.selectionSet) {
        console.log('selection', update.state.selection.main);
      }
    };
    
    const onChange = (state: EditorState) => {
      console.log('lines', state.doc.lines);
    };
    </script>
    
    <template>
      <code-mirror basic @update="onUpdate" @change="onChange" />
    </template>

    When the component is used as a Web Component, these are dispatched as native CustomEvents and the payload is available as event.detail[0]. The model event is named update:model-value.