prosekit/extensions/enter-rule
Interfaces
Section titled “Interfaces”EnterRuleHandlerOptions
Section titled “EnterRuleHandlerOptions”Options for EnterRuleHandler.
Properties
Section titled “Properties”-
The current editor state.
-
from:number -
The start position of the matched text.
-
to:number -
The end position of the matched text.
-
match:RegExpExecArray -
The matched result from the regular expression.
TextBlockEnterRuleOptions
Section titled “TextBlockEnterRuleOptions”Options for defineTextBlockEnterRule.
Properties
Section titled “Properties”-
attrs?:Attrs| (match:RegExpMatchArray) =>Attrs|null|null -
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 = { regex: RegExp; handler: EnterRuleHandler; 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
regexand user presses Enter. Theregexshould 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.