InputRule
Input rules are regular expressions describing a piece of text
that, when typed, causes something to happen. This might be
changing two dashes into an emdash, wrapping a paragraph starting
with "> " into a blockquote, or something entirely different.
class InputRule {}
constructor(
match: RegExp,
handler: string | ((
state: EditorState,
match: RegExpMatchArray,
start: number,
end: number,
) => Transaction | null),options?: {
);undoable?: boolean;
inCode?: boolean | "only";
inCodeMark?: boolean;
},inCode: boolean | "only";
inCodeMark: boolean | "only";
§Constructors
§
new InputRule(match: RegExp, handler: string | ((
[src]state: EditorState,
match: RegExpMatchArray,
start: number,
end: number,
) => Transaction | null), options?: {undoable?: boolean;
inCode?: boolean | "only";
inCodeMark?: boolean;
})Create an input rule. The rule applies when the user typed
something and the text directly in front of the cursor matches
match, which should end with $.
The `handler` can be a string, in which case the matched text, or
the first matched group in the regexp, is replaced by that
string.
Or a it can be a function, which will be called with the match
array produced by
[`RegExp.exec`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec),
as well as the start and end of the matched range, and which can
return a [transaction](https://prosemirror.net/docs/ref/#state.Transaction) that describes the
rule's effect, or null to indicate the input was not handled.