Skip to content

prosekit/extensions/enter-rule

EnterRuleHandler

Type: (options: { from: number; match: RegExpExecArray; state: EditorState; to: number }) => Transaction | null

EnterRuleOptions

Options for defineEnterRule.

Type: { handler: EnterRuleHandler; regex: RegExp; stop?: boolean }

TextBlockEnterRuleOptions

Options for defineTextBlockEnterRule.

Type: { attrs?: Attrs | null | ((match: RegExpMatchArray) => Attrs | null); regex: RegExp; stop?: boolean; type: string | NodeType }

defineEnterRule

ts
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. The regex should end with $.

defineTextBlockEnterRule

ts
function defineTextBlockEnterRule(options: TextBlockEnterRuleOptions): PlainExtension

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

See also defineEnterRule.