Find and replace in the built-in UI
Enable SuperDoc's find surface, navigate visible matches, and replace document text.
The built-in find surface searches the open document, highlights visible matches, and moves the Editor to the active result. In editable modes it can also replace the current match or every match in the session.
Enable the find surface
Add toolbar and Editor containers:
<div id="toolbar"></div>
<div id="editor" style="height: 70vh"></div>
<script type="module" src="/src/main.ts"></script>
Copy the tracked-changes fixture to your app's public directory as contract.docx, or use another DOCX.
Enable the surface explicitly:
import { SuperDoc } from 'superdoc';
import 'superdoc/style.css';
const superdoc = new SuperDoc({
selector: '#editor',
document: '/contract.docx',
toolbar: '#toolbar',
modules: {
surfaces: {
findReplace: true,
},
},
});
window.addEventListener('beforeunload', () => superdoc.destroy());
modules.surfaces.findReplace: true connects the toolbar Search button and Ctrl+F or Command+F to SuperDoc's document-aware find surface. Without that setting, the browser keeps its native page search shortcut.
Find and navigate matches
Enter a query, then use the previous and next controls to move through the document. The surface keeps the active result visible across paginated and virtualized pages.
Match-case and regular-expression controls appear when the active v2 search host supports them. An invalid regular expression produces an inline error instead of running a partial search.
Replace only when the document can mutate
Replace controls are available in editing and suggesting modes when the current search session can enumerate and change its matches. They are hidden in viewing or read-only sessions.
Replacing text changes the DOCX. Export or save the document after the workflow. Search highlights and the active match are temporary Editor state and are not written into the file.
Verify the workflow
- Open the find surface from the toolbar and from the keyboard shortcut.
- Search for text that appears more than once.
- Navigate across matches and pages.
- Replace one match, then search again.
- Switch to viewing mode and confirm that find remains available while replace does not.
Use custom search controls when the product needs to own the search layout. Use Document API queries when code needs mutation-ready document targets instead of a visual search session.