@eigenpal/docx-editor-core/utils/findReplace
Find & Replace Utility Functions
Pure utility functions for text search, pattern matching, and document search. Lifted from packages/react/src/components/dialogs/ findReplaceUtils.ts so the React adapter and the Vue adapter share one implementation.
Functions (12)
createDefaultFindOptionsfunctionSource ↗
Create default find options
declare function createDefaultFindOptions(): FindOptions;createSearchPatternfunctionSource ↗
Create a regex pattern from search text and options
declare function createSearchPattern(searchText: string, options: FindOptions): RegExp | null;escapeRegexStringfunctionSource ↗
Escape string for use in regex pattern
declare function escapeRegexString(str: string): string;findAllMatchesfunctionSource ↗
Find all matches of search text in content
declare function findAllMatches(content: string, searchText: string, options: FindOptions): Array<{
start: number;
end: number;
}>;findInDocumentfunctionSource ↗
Find all matches in a document
declare function findInDocument(document: any, searchText: string, options: FindOptions): FindMatch[];findInParagraphfunctionSource ↗
Find matches in a single paragraph
declare function findInParagraph(paragraph: any, searchText: string, options: FindOptions, paragraphIndex: number): FindMatch[];getDefaultHighlightOptionsfunctionSource ↗
Get default highlight options
declare function getDefaultHighlightOptions(): HighlightOptions;getMatchCountTextfunctionSource ↗
Get match count for status display
declare function getMatchCountText(result: FindResult | null): string;isEmptySearchfunctionSource ↗
Check if search text is empty or whitespace-only
declare function isEmptySearch(searchText: string): boolean;replaceAllInContentfunctionSource ↗
Replace text in content
declare function replaceAllInContent(content: string, searchText: string, replaceText: string, options: FindOptions): string;replaceFirstInContentfunctionSource ↗
Replace first match in content
declare function replaceFirstInContent(content: string, searchText: string, replaceText: string, options: FindOptions, startIndex?: number): {
content: string;
replaced: boolean;
matchStart: number;
matchEnd: number;
};scrollToMatchfunctionSource ↗
Scroll to a match in the document
declare function scrollToMatch(containerElement: HTMLElement | null, match: FindMatch): void;Interfaces (4)
FindMatchinterfaceSource ↗
A single match result in the document
interface FindMatch| Member | Type | Summary |
|---|---|---|
| contentIndex | number | Index of the run/content within the paragraph |
| endOffset | number | Character offset for end of match |
| paragraphIndex | number | Index of the paragraph containing the match |
| startOffset | number | Character offset within the content |
| text | string | The matched text |
FindOptionsinterfaceSource ↗
Find options for controlling search behavior
interface FindOptions| Member | Type | Summary |
|---|---|---|
| matchCase | boolean | Whether to match case |
| matchWholeWord | boolean | Whether to match whole words only |
| useRegex? | boolean | Whether to use regular expressions (future) |
FindResultinterfaceSource ↗
Find result with all matches
interface FindResult| Member | Type | Summary |
|---|---|---|
| currentIndex | number | Current match index (0-based) |
| matches | FindMatch[] | All matches found |
| totalCount | number | Total match count |
HighlightOptionsinterfaceSource ↗
Highlight options for document rendering
interface HighlightOptions| Member | Type | Summary |
|---|---|---|
| currentMatchColor | string | Background color for current match |
| otherMatchColor | string | Background color for other matches |