UNPKG

prism-react-editor

Version:

Lightweight, extensible code editor component for React apps

36 lines (35 loc) 1.37 kB
import { PrismEditor } from '../../types'; import { SearchAPI } from './search'; /** * Object with methods useful for performing a search * and both highlighting and replacing the matches. */ export interface ReplaceAPI extends SearchAPI { /** Index of the match ahead of the cursor. */ next(): number; /** Index of the match behind the cursor. */ prev(): number; /** Index of the closest match. */ closest(): number; /** * Selects the match with the passed index and scrolls * it into view with the specified scroll padding. */ selectMatch(index: number, scrollPadding?: number): void; /** * If a match is selected and it's different to the provided string, it's replaced, * else the index of the closest match is returned. * If there's no selected match, the index of the closest match is returned. */ replace(replacement: string): number | undefined; /** * Replaces all search matches with the specified string. * @param replacement String to replace all matches with. */ replaceAll(replacement: string): void; } /** * Same as {@link useEditorSearch}, but the returned object has some extra methods for * selecting and replacing matches. */ export declare const useEditorReplace: (editor: PrismEditor, initClassName?: string, initZIndex?: number) => ReplaceAPI;