Search and replace
Find, match count, next/previous and replace-all
Usage
import { SearchReplace } from "@gpuixui/editor";
<SearchReplace value={value} onValueChange={setValue} />;API
| Prop | Type | Default | Notes |
|---|---|---|---|
value | string | — | The controlled document text. |
onValueChange | (value: string) => void | — | Reports a single replace and a replace-all. |
placeholder | string | "Find" | The find field's hint. |
replacePlaceholder | string | "Replace with" | The replacement field's hint. |
findLabel | string | "Find" | The find field's accessible name; a blank or non-text name reads as the default. |
replaceFieldLabel | string | "Replace with" | The replacement field's accessible name; a blank or non-text name reads as the default. |
replaceLabel / replaceAllLabel | string | "Replace" / "Replace all" | The actions' names; a blank one reads as its default. |
nextLabel / previousLabel | string | "Next match" / "Previous match" | The navigation names; a blank one reads as its default. |
disabled | boolean | false | Refuse every route, F3 included: a read-only host still receives keys. |
className | string | — | A Tailwind class string, merged last. |
testId | string | "search-replace" | The address an automation host locates the bar by; its parts append their own suffix. |
Matching
The scan is literal: a regex character in the query matches itself, and there is no pattern mode. Two toggles narrow it:
Aa— match case (on by default). Off, the query runs as the escaped literal in a case-insensitive pattern rather than a lowered copy of the text: lowering can change a string's length, and therefore its offsets.W— match whole word (off by default). A match must not touch a letter, digit or underscore on either side.
Both options feed the count, the single replace and replace-all, so the n / m
readout is the number of replacements a replace-all would make. Matches never
overlap — a candidate that starts inside the match before it is skipped — and
the word rule is applied first, so a whole-word match that begins inside an
occurrence the rule rejects is still found.
A changed query, or a flipped option, starts at its first match: the active index numbers one range set, so it cannot name a match in the next one. A document edit is different — after a single replace the bar stays on the match that moved into the active slot, which is the one the reader is working through.
Edit this page on GitHubpackages/editor/docs/search-replace.mdx