Skip to content

Find and replace in the Vue 3 editor ​

Enable the find-replace plugin and the Vue 3 editor gets a dialog for searching and replacing text in the current document. Replacements are ordinary edits, so the updated HTML flows back through your v-model binding.


Configuration ​

Enable the find-replace plugin:

ts
const editorConfig: EditorInit = {
    plugins: ['find-replace'],
    menubar: ['edit'],
    toolbar: 'undo redo | bold italic | removeformat',
};

Inside a single-file component it looks like this:

vue
<script setup lang="ts">
import { shallowRef } from 'vue';
import { Editor, type EditorInit } from '@erag/text-editor-vue';

const content = shallowRef('<p>Search this draft.</p>');
const editorConfig: EditorInit = {
    plugins: ['history', 'formatting', 'find-replace'],
    menubar: ['edit'],
};
</script>

<template>
    <Editor v-model="content" :init="editorConfig" />
</template>

The configuration reference explains how an explicit plugins array filters the other controls.


Interactive Find and Replace Dialog ​

Navigate to Edit → Find and replace or press Ctrl+F / Cmd+F while the editor is focused to open the dialog. find-replace is a plugin and menu action; it is not a toolbar keyword.

  1. Find Input: Enter search term.
  2. Replace With Input: Enter replacement string.
  3. Match Case Checkbox: Toggle case-sensitive matching.
  4. Whole Word Checkbox: Exclude partial-word matches.
  5. Find Next / Previous: Step through matching occurrences in the document canvas.
  6. Replace: Replaces the current occurrence.
  7. Replace All: Replaces all matching occurrences and updates the document.

Previous and Next use the browser selection to show the active match. The editor does not insert permanent highlight spans into the saved HTML.

The shortcut also appears in the keyboard shortcut table. Dividers and timestamps are switched on the same way, as shown in horizontal rules and date-time.