prosekit/extensions/input-rule
Interfaces
Section titled “Interfaces”MarkInputRuleOptions
Section titled “MarkInputRuleOptions”Options for defineMarkInputRule.
Properties
Section titled “Properties”-
The regular expression to match against, which should end with
$and has exactly one capture group. All other matched text outside the capture group will be deleted.Input rules only see the last 500 characters before the cursor. Keep the longest possible match under 500 characters (e.g.
[^*]{0,490}instead of[^*]*), so that lookbehind assertions test the real text before it.
-
inCodeMark?:boolean -
Whether this rule should fire inside marks marked as code.
Default
Section titled “Default”false
TextBlockInputRuleOptions
Section titled “TextBlockInputRuleOptions”Options for defineTextBlockInputRule.
Properties
Section titled “Properties”-
The regular expression to match against, which should end with
$. It usually also starts with^so that it is only matched at the start of a textblock.Input rules only see the last 500 characters before the cursor, so
^means the start of the textblock only when the longest possible match is under 500 characters (e.g.\S{0,50}instead of\S*).
WrappingInputRuleOptions
Section titled “WrappingInputRuleOptions”Options for defineWrappingInputRule.
Properties
Section titled “Properties”-
The regular expression to match against, which should end with
$. It usually also starts with^so that it is only matched at the start of a textblock.Input rules only see the last 500 characters before the cursor, so
^means the start of the textblock only when the longest possible match is under 500 characters (e.g.\S{0,50}instead of\S*).
-
join?: (match:RegExpMatchArray,node:EditorNode) =>boolean -
By default, if there’s a node with the same type above the newly wrapped node, the rule will try to join those two nodes. You can pass a join predicate, which takes a regular expression match and the node before the wrapped node, and can return a boolean to indicate whether a join should happen.
Functions
Section titled “Functions”defineInputRule()
Section titled “defineInputRule()”-
function defineInputRule(rule:InputRule):PlainExtension -
Defines an input rule extension.
defineMarkInputRule()
Section titled “defineMarkInputRule()”-
function defineMarkInputRule(options:MarkInputRuleOptions):PlainExtension -
Defines an input rule for automatically adding inline marks when a given pattern is typed.
defineTextBlockInputRule()
Section titled “defineTextBlockInputRule()”-
function defineTextBlockInputRule(options:TextBlockInputRuleOptions):PlainExtension -
Defines an input rule that changes the type of a textblock when the matched text is typed into it.
See also textblockTypeInputRule
defineWrappingInputRule()
Section titled “defineWrappingInputRule()”-
function defineWrappingInputRule(options:WrappingInputRuleOptions):PlainExtension -
Defines an input rule for automatically wrapping a textblock when a given string is typed.
See also wrappingInputRule