import { EditorState } from "@prosekit/pm/state"; import { Extension } from "@prosekit/core"; /** * Options for the {@link MatchHandler} callback. */ interface MatchHandlerOptions { /** * The editor state. */ state: EditorState; /** * The result of `RegExp.exec`. */ match: RegExpExecArray; /** * The start position of the matched text. */ from: number; /** * The end position of the matched text. */ to: number; /** * Call this function to ignore the match. You probably want to call this * function when the user presses the `Escape` key. */ ignoreMatch: () => void; /** * Call this function to delete the matched text. For example, in a slash * menu, you might want to delete the matched text first then do something * else when the user presses the `Enter` key. */ deleteMatch: () => void; } /** * A callback that is called when the rule starts to match, and also on * subsequent updates while the rule continues to match. */ type MatchHandler = (options: MatchHandlerOptions) => void; /** * Options for the {@link CanMatchPredicate} callback. */ interface CanMatchOptions { /** * The editor state. */ state: EditorState; } /** * A predicate to determine if the rule can be applied in the current editor state. */ type CanMatchPredicate = (options: CanMatchOptions) => boolean; /** * Options for creating an {@link AutocompleteRule} */ interface AutocompleteRuleOptions { /** * The regular expression to match against the text before the cursor. The * last match before the cursor is used. * * For a slash menu, you might use `/(? boolean; constructor(options: AutocompleteRuleOptions); } /** * Defines an autocomplete extension that executes logic when the text before * the cursor matches the given regular expression. * * When a match is found, an inline decoration is applied to the matched text * with the class `prosekit-autocomplete-match` and a `data-autocomplete-match-text` * attribute containing the full matched string. */ declare function defineAutocomplete(rule: AutocompleteRule): Extension; export { AutocompleteRule, type AutocompleteRuleOptions, type CanMatchOptions, type CanMatchPredicate, type MatchHandler, type MatchHandlerOptions, defineAutocomplete }; //# sourceMappingURL=autocomplete.d.ts.map