Find & Replace
ProA 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.
import { SvRteFindReplaceComponent } from '@styloviz-pro/rich-editor';Demo & usage
Basic usage
Usage example — open the gallery for the full interactive demo.
An interactive demo for this component lives in the gallery.
Open live demoMore examples
Ctrl/Cmd+F opens it
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
`[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
| Name | Type | Default | Description |
|---|---|---|---|
| editorrequired | SvRichTextEditorComponent | — | The editor to search. |
| open | boolean (two-way) | false | Whether the bar is shown. Ctrl/Cmd+F in the editor sets it. |
| query | string (two-way) | '' | The search text. |
| replacement | string (two-way) | '' | The replacement text. |
| caseSensitive | boolean (two-way) | false | Match letter case exactly. |
| wholeWord | boolean (two-way) | false | Match whole words only. |
| allowReplace | boolean | true | Show the replace row; `false` makes this a find-only bar. |
Outputs
| Event | Payload type | Description |
|---|---|---|
| replaced | SvRteReplaceEvent | Emitted after a replace or replace all, with how many matches changed. |
| openChange | boolean | Emits the new `open` whenever it changes — the output half of `[(open)]`. |
| queryChange | string | Emits the new `query` whenever it changes — the output half of `[(query)]`. |
| replacementChange | string | Emits the new `replacement` whenever it changes — the output half of `[(replacement)]`. |
| caseSensitiveChange | boolean | Emits the new `caseSensitive` whenever it changes — the output half of `[(caseSensitive)]`. |
| wholeWordChange | boolean | Emits 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.