Skip to content

Commit

Permalink
feat(lists): added input rule for ordered lists with parenthesis (#461)
Browse files Browse the repository at this point in the history
  • Loading branch information
u4aew authored Nov 8, 2024
1 parent 844667d commit 05ba62d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/extensions/markdown/Lists/inputrules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ export const ListsInputRulesExtension: ExtensionWithOptions<ListsInputRulesOptio

/**
* Given a list node type, returns an input rule that turns a number
* followed by a dot at the start of a textblock into an ordered list.
* followed by a dot or parenthesis at the start of a textblock into an ordered list.
*/
export function orderedListRule(nodeType: NodeType) {
return wrappingInputRule(
/^(\d+)\.\s$/,
/^(\d+)([.)])\s$/,
nodeType,
(match) => ({[ListsAttr.Order]: Number(match[1])}),
(match) => ({
[ListsAttr.Order]: Number(match[1]),
[ListsAttr.Markup]: match[2],
}),
(match, node) => node.childCount + node.attrs[ListsAttr.Order] === Number(match[1]),
);
}
Expand Down

0 comments on commit 05ba62d

Please sign in to comment.