Find & Replace

Pro

A find & replace bar for one rich text editor — matches across formatting, never across paragraphs, painted without touching the document; replace all is one undo step.

</>sv-rte-find-replace editorsearchreplace
import { SvRteFindReplaceComponent } from '@styloviz-pro/rich-editor';

Demo & usage

Basic usage

Pro

Usage example — open the gallery for the full interactive demo.

Pro

An interactive demo for this component lives in the gallery.

Open live demo

More examples

Ctrl/Cmd+F opens it

Pro

Bound to an editor, the bar registers itself for Ctrl/Cmd+F inside that editor — the browser's own find cannot replace, and cannot see a word split across `<strong>`.

Find only

Pro

`[allowReplace]="false"` drops the replace row — the bar for a read-only document.

When to use

  • Long documents where authors rename a term, fix a repeated typo or check a word is gone.
  • Not for searching ACROSS documents — that is your search index.

Async states

None — this component has nothing to load, so it has no loading, empty or error state to drive.

Inputs

NameTypeDefaultDescription
editorrequiredSvRichTextEditorComponent—The editor to search.
openboolean (two-way)falseWhether the bar is shown. Ctrl/Cmd+F in the editor sets it.
querystring (two-way)''The search text.
replacementstring (two-way)''The replacement text.
caseSensitiveboolean (two-way)falseMatch letter case exactly.
wholeWordboolean (two-way)falseMatch whole words only.
allowReplacebooleantrueShow the replace row; `false` makes this a find-only bar.

Outputs

EventPayload typeDescription
replacedSvRteReplaceEventEmitted after a replace or replace all, with how many matches changed.
openChangebooleanEmits the new `open` whenever it changes — the output half of `[(open)]`.
queryChangestringEmits the new `query` whenever it changes — the output half of `[(query)]`.
replacementChangestringEmits the new `replacement` whenever it changes — the output half of `[(replacement)]`.
caseSensitiveChangebooleanEmits the new `caseSensitive` whenever it changes — the output half of `[(caseSensitive)]`.
wholeWordChangebooleanEmits the new `wholeWord` whenever it changes — the output half of `[(wholeWord)]`.

Customization & theming

  • `[(open)]`, `[(query)]`, `[(replacement)]`, `[(caseSensitive)]` and `[(wholeWord)]` are all two-way, so a host can prefill or persist them; `show()` and `close()` are public.

Forms integration

  • sv-rte-find-replace — Output-driven, not a ControlValueAccessor. It edits a document it does not own: the editor holds the value and its form control, and the bar changes it through `commitEdit()`, so a second value accessor here would be a second source of truth for the same text.

Best practices

  • Do: Put the bar above the editor so it reads before the document in the tab order.
  • Tip: Replace all is one undo step, so an over-eager replacement is one Ctrl/Cmd+Z away.
  • Don't: Don't wrap matches in your own `<mark>`s — that changes the value and the undo history; the bar paints with the CSS Custom Highlight API instead.

Accessibility

  • A `role="search"` landmark with labelled fields; the match count is a `role="status"` tied to the search box by `aria-describedby`.
  • Enter / Shift+Enter step through matches, Ctrl/Cmd+Enter in Replace replaces all, and Escape closes and returns the caret to the current match.

Feedback on Find & Replace

Spotted a gap in this page, or something that didn't work as described? Comments are GitHub Discussions in the public styloviz/community repo, so posting needs a GitHub account.

Loads giscus.app and GitHub — nothing is fetched until you click.