Skip to content

prosekit/extensions/enter-rule

Options for EnterRuleHandler.

state: EditorState

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.

type EnterRuleOptions = EnterRule

Options for defineEnterRule.


type TextBlockEnterRuleOptions = _TextBlockEnterRuleOptions

Options for defineTextBlockEnterRule.


type EnterRuleHandler = (options: EnterRuleHandlerOptions) => Transaction | null | undefined

function defineEnterRule(options: EnterRule): 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 $.


function defineTextBlockEnterRule(options: TextBlockEnterRuleOptions): PlainExtension

Defines an enter rule that replaces the matched text with a block node.

See also defineEnterRule.