prosekit/extensions/enter-rule
EnterRuleHandler()
EnterRuleHandler: (
options
) =>Transaction
|null
Parameters
• options
• options.from: number
The start position of the matched text.
• options.match: RegExpExecArray
The matched result from the regular expression.
• options.state: EditorState
The current editor state.
• options.to: number
The end position of the matched text.
Returns
Transaction
| null
EnterRuleOptions
EnterRuleOptions:
object
Options for defineEnterRule.
Type declaration
Name | Type | Description |
---|---|---|
handler | EnterRuleHandler | A function to be called when an enter rule is triggered. |
regex | RegExp | The regular expression to match against. It should end with $ . |
stop ? | boolean | Whether to stop further handlers from being called if this rule is triggered. Default false |
TextBlockEnterRuleOptions
TextBlockEnterRuleOptions:
object
Options for defineTextBlockEnterRule.
Type declaration
Name | Type | Description |
---|---|---|
attrs ? | Attrs | null | (match ) => Attrs | null | Attributes to set on the node. If a function is provided, it will be called with the matched result from the regular expression. |
regex | RegExp | The regular expression to match against. It should end with $ . |
stop ? | boolean | Whether to stop further handlers from being called if this rule is triggered. Default true |
type | string | NodeType | The node type to replace the matched text with. |
defineEnterRule()
defineEnterRule(
options
):PlainExtension
Defines an enter rule. An enter rule applies when the text directly in front of the cursor matches regex
and user presses Enter. The regex
should end with $
.
Parameters
• options: EnterRuleOptions
Returns
PlainExtension
defineTextBlockEnterRule()
defineTextBlockEnterRule(
options
):PlainExtension
Defines an enter rule that replaces the matched text with a block node.
See also defineEnterRule.
Parameters
• options: TextBlockEnterRuleOptions
Returns
PlainExtension