All files / roosterjs-content-model-plugins/lib/findReplace find.ts

100% Statements 6/6
100% Branches 0/0
100% Functions 1/1
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 261x                       1x             2x 2x 2x   2x    
import { updateHighlight } from './utils/updateHighlight';
import type { FindReplaceContext } from './types/FindReplaceContext';
import type { IEditor } from 'roosterjs-content-model-types';
 
/**
 * Start a find operation in the editor
 * @param editor The editor instance
 * @param context The FindReplaceContext to use
 * @param text The text to find
 * @param matchCase Whether to match case
 * @param wholeWord Whether to match whole words only
 */
export function find(
    editor: IEditor,
    context: FindReplaceContext,
    text: string | null,
    matchCase?: boolean,
    wholeWord?: boolean
): void {
    context.text = text;
    context.matchCase = !!matchCase;
    context.wholeWord = !!wholeWord;
 
    updateHighlight(editor, context);
}