reablocks
Version:
Component library for React
16 lines (15 loc) • 686 B
TypeScript
export interface HighlightChunk {
/** A contiguous segment of the original text. */
text: string;
/** Whether this segment is a case-insensitive match of the keyword. */
highlight: boolean;
}
/**
* Splits `text` into ordered chunks covering the full string, flagging every
* non-overlapping, case-insensitive occurrence of `keyword` as highlighted.
*
* The keyword is matched as a literal substring (no regex), so characters like
* `(` or `.` are treated literally. Matches advance by `keyword.length`,
* mirroring the 'g' flag semantics used by react-highlight-words.
*/
export declare const highlightChunks: (text: string, keyword: string) => HighlightChunk[];