UNPKG

prism-code-editor

Version:

Lightweight, extensible code editor component for the web using Prism

36 lines (35 loc) 1.4 kB
import { PrismEditor } from "../../index.js"; import { SearchAPI } from "./search.js"; /** * 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 next match is returned. * If there's no selected match, the index of the closest match is returned. */ replace(str: string): number | undefined; /** * @param value Value * @param selection Does nothing. Kept for backwards compatibility. */ replaceAll(value: string, selection?: [number, number]): void; /** Removes the highlight container from the DOM and all potential event listeners. */ destroy(): void; } /** Function adding both search and replace functionality to an editor. */ declare const createReplaceAPI: (editor: PrismEditor) => ReplaceAPI; export { createReplaceAPI };