UNPKG

ng-text-highlight

Version:

A lightweight standalone Angular 19 component/module for highlighting text.

46 lines (45 loc) 2.25 kB
import { TextChunk } from "../models/text-chunk"; /** * Finds all matching chunks of text based on the provided search words. * It processes the text using the provided options (e.g., case sensitivity, escaping). * @param autoEscape - Whether to escape special characters in search words. * @param caseSensitive - Whether the search should be case-sensitive. * @param findChunks - Custom function to find chunks (default is `defaultChunkFinder`). * @param sanitize - Function to sanitize the input text and search words. * @param searchWords - Array of keywords to search for in the text. * @param textToSearch - The main text where the search is performed. * @returns Array of `TextChunk` objects representing the highlighted and non-highlighted segments. */ export declare const findAllMatches: ({ autoEscape, caseSensitive, findChunks, sanitize, searchWords, textToSearch, }: { autoEscape?: boolean; caseSensitive?: boolean; findChunks?: typeof defaultChunkFinder; sanitize?: typeof defaultSanitize; searchWords: Array<string>; textToSearch: string; }) => Array<TextChunk>; /** * Finds chunks of text that match the search words. * Uses regular expressions to locate the matches in the text. * @param autoEscape - Whether to escape special characters in search words. * @param caseSensitive - Whether the search should be case-sensitive. * @param sanitize - Function to sanitize the input text and search words. * @param searchWords - Array of keywords to search for in the text. * @param textToSearch - The main text where the search is performed. * @returns Array of `TextChunk` objects representing the matching segments. */ declare const defaultChunkFinder: ({ autoEscape, caseSensitive, sanitize, searchWords, textToSearch, }: { autoEscape?: boolean; caseSensitive?: boolean; sanitize?: typeof defaultSanitize; searchWords: Array<string>; textToSearch: string; }) => Array<TextChunk>; /** * Default sanitization function that returns the input string as-is. * Can be overridden to implement custom sanitization logic. * @param string - The input string to sanitize. * @returns The sanitized string. */ declare function defaultSanitize(string: string): string; export {};