declare global {
interface JQueryStatic {
highlightText: HighlightText;
}
interface JQuery {
/**
* Highlight certain text in current nodes (by wrapping it in `...`).
*
* To use this {@link jQuery} plugin, load the `jquery.highlightText` module with {@link mw.loader}.
*
* @example
* ```js
* mw.loader.using( 'jquery.highlightText' ).then( () => {
* // no styling is provided by default.
* mw.util.addCSS( `.highlight { background: yellow; }` )
* $( '#bodyContent' ).highlightText( 'bear' );
* } );
* ```
* @param matchString String to match
* @param options
* @see https://doc.wikimedia.org/mediawiki-core/master/js/module-jquery.highlightText.html#.$.fn.highlightText
*/
highlightText(matchString: string, options?: Options): this;
}
}
type Method = "prefixHighlight" | "prefixPlusComboHighlight" | "splitAndHighlight";
interface HighlightText {
innerHighlight(node: Node, pat: string | RegExp): void;
prefixHighlight(node: Node, prefix: string): void;
prefixPlusComboHighlight(node: Node, prefix: string): void;
splitAndHighlight(node: T, text: string): T;
}
interface Options {
/**
* Method of matching to use, one of:
*
* - 'splitAndHighlight': Split `matchString` on spaces, then match each word separately.
* - 'prefixHighlight': Match `matchString` at the beginning of text only.
* - 'prefixPlusComboHighlight': Match `matchString` plus any combining characters at
* the beginning of text only.
*/
method?: Method;
}
export {};