TEXT SEARCH API
Find and replace document text
Use the built-in dialog for a complete editing experience, or run focused search and replacement operations directly from JavaScript.
Complete editing dialog
Open the standard TX Text Control dialog with additional search options.
Ready to tryUse the controls above to interact with this demo.
What this demonstrates
Search the live document
TX Text Control can find any text range in the document. Once a match has been selected, the same selection API can replace the text while preserving the surrounding document formatting.
Search text
FormattedText.find
Select a match
TXTextControl.select
Replace selected text
Selection.setText
Built-in tools
TXTextControl.sendCommand
How it works
FormattedText.find searches from a supplied text position and returns the zero-based start position of the next match. The demo tracks that position so repeated clicks on Find next advance through the document and wrap back to the beginning.
After a match is found, TXTextControl.select highlights the exact range in the editor. Replace current then calls Selection.setText, which changes only the selected characters. Replace all repeats the same callback-based operation and advances past the replacement to avoid processing the same result again.
The built-in dialog remains available through TXTextControl.sendCommand. It is useful when end users need the complete standard workflow, while the programmatic path is better when an application owns the search UI or needs a predictable automated operation.
const start = await request(TXTextControl.selection, "getStart");
const position = await request(
TXTextControl,
"find",
searchText,
start,
TXTextControl.FindOptions.NoMessageBox);
await request(TXTextControl, "select", position, searchText.length);
await request(
TXTextControl.selection,
"setText",
replacementText);
NuGet packages
TXTextControl.TextControl.Core.SDK
34.0.4
Provides the core document model and server-side document processing APIs.
dotnet add package TXTextControl.TextControl.Core.SDK --version 34.0.4
Provides the browser-based TX Text Control document editor and JavaScript API.
dotnet add package TXTextControl.Web --version 34.4.0
TXTextControl.Web.DocumentEditor.Backend
34.4.0
Hosts the WebSocket-based backend used by the browser document editor.
dotnet add package TXTextControl.Web.DocumentEditor.Backend --version 34.4.0