prosekit/extensions/input-rule
MarkInputRuleOptions
Options for defineMarkInputRule.
Properties
attrs?
Attributes to set on the mark.
regex
regex:
RegExp
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.
type
type:
string
|MarkType
The type of mark to set.
defineInputRule()
defineInputRule(
rule
):PlainExtension
Defines an input rule extension.
Parameters
• rule: InputRule
The ProseMirror input rule to add.
Returns
PlainExtension
defineMarkInputRule()
defineMarkInputRule(
options
):PlainExtension
Defines an input rule for automatically adding inline marks when a given pattern is typed.
Parameters
• options: MarkInputRuleOptions
Returns
PlainExtension
defineTextBlockInputRule()
defineTextBlockInputRule(
options
):PlainExtension
Defines an input rule that changes the type of a textblock when the matched text is typed into it.
See also textblockTypeInputRule
Parameters
• options
• options.attrs?: null
| Attrs
| (match
) => null
| Attrs
Attributes to set on the node.
• options.regex: RegExp
The regular expression to match against, which should end with $
. It usually also starts with ^
to that it is only matched at the start of a textblock.
• options.type: string
| NodeType
The node type to replace the matched text with.
Returns
PlainExtension
defineWrappingInputRule()
defineWrappingInputRule(
options
):PlainExtension
Defines an input rule for automatically wrapping a textblock when a given string is typed.
See also wrappingInputRule
Parameters
• options
• options.attrs?: null
| Attrs
| (match
) => null
| Attrs
Attributes to set on the node.
• options.join?
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.
• options.regex: RegExp
The regular expression to match against, which should end with $
. It usually also starts with ^
to that it is only matched at the start of a textblock.
• options.type: string
| NodeType
The type of node to wrap in.
Returns
PlainExtension