prosekit/extensions/enter-rule
Interfaces
Section titled “Interfaces”EnterRuleHandlerOptions
Section titled “EnterRuleHandlerOptions”Options for EnterRuleHandler.
Properties
Section titled “Properties”-
from:
number
-
The start position of the matched text.
-
match:
RegExpExecArray
-
The matched result from the regular expression.
-
The current editor state.
-
to:
number
-
The end position of the matched text.
TextBlockEnterRuleOptions
Section titled “TextBlockEnterRuleOptions”Options for defineTextBlockEnterRule.
Properties
Section titled “Properties”-
attrs?:
null
|Attrs
| (match
:RegExpMatchArray
) =>null
|Attrs
-
Attributes to set on the node. If a function is provided, it will be called with the matched result from the regular expression.
-
stop?:
boolean
-
Whether to stop further handlers from being called if this rule is triggered.
Default
Section titled “Default”true
Type Aliases
Section titled “Type Aliases”EnterRuleHandler()
Section titled “EnterRuleHandler()”-
type EnterRuleHandler = (
options
:EnterRuleHandlerOptions
) =>Transaction
|null
EnterRuleOptions
Section titled “EnterRuleOptions” type EnterRuleOptions = {
handler
: EnterRuleHandler
; regex
: RegExp
; stop?
: boolean
; }
Options for defineEnterRule.
Properties
Section titled “Properties”-
A function to be called when an enter rule is triggered.
-
stop?:
boolean
-
Whether to stop further handlers from being called if this rule is triggered.
Default
Section titled “Default”false
Functions
Section titled “Functions”defineEnterRule()
Section titled “defineEnterRule()”-
function defineEnterRule(
options
:EnterRuleOptions
):PlainExtension
-
Defines an enter rule. An enter rule applies when the text directly in front of the cursor matches
regex
and user presses Enter. Theregex
should end with$
.
defineTextBlockEnterRule()
Section titled “defineTextBlockEnterRule()”-
function defineTextBlockEnterRule(
options
:TextBlockEnterRuleOptions
):PlainExtension
-
Defines an enter rule that replaces the matched text with a block node.
See also defineEnterRule.