Skip to content

prosekit/extensions/input-rule

MarkInputRuleOptions

Options for defineMarkInputRule.

attrs

Attributes to set on the mark.

Type: null | Attrs | ((match: RegExpMatchArray) => null | Attrs)

regex

The regular expression to match against, which should end with $ and has exactly one capture group. All other matched text outside the capture group will be deleted.

Type: RegExp

type

The type of mark to set.

Type: string | MarkType

defineInputRule

ts
function defineInputRule(rule: InputRule): PlainExtension

Defines an input rule extension.

defineMarkInputRule

ts
function defineMarkInputRule(options: MarkInputRuleOptions): PlainExtension

Defines an input rule for automatically adding inline marks when a given pattern is typed.

defineTextBlockInputRule

ts
function defineTextBlockInputRule(options: { attrs?: null | Attrs | ((match: RegExpMatchArray) => null | Attrs); regex: RegExp; type: string | NodeType }): PlainExtension

Defines an input rule that changes the type of a textblock when the matched text is typed into it.

See also textblockTypeInputRule

defineWrappingInputRule

ts
function defineWrappingInputRule(options: { attrs?: null | Attrs | ((match: RegExpMatchArray) => null | Attrs); join?: (match: RegExpMatchArray, node: Node) => boolean; regex: RegExp; type: string | NodeType }): PlainExtension

Defines an input rule for automatically wrapping a textblock when a given string is typed.

See also wrappingInputRule