Autoformat: Make match
result available in format
and preFormat
functions
#3844
whytspace
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I wanted to implement an autoformat rule that would allow users to start a list at a specific item.
So when the user types
1.
, the list would start at one, but if the user typed16.
, the list would start at 16.I wanted to use a regex for this, so that any number followed by
.
sets thestart
attribute. Most of the code is straightforward, although I am struggling to get the replaced number within theformat
function:Am I missing something? Is there any way to access the matched value?
I checked https://github.com/udecode/plate/blob/main/packages/autoformat/src/lib/transforms/autoformatBlock.ts#L93 and it seems that the value is already removed from the editor.
Could
match
be passed as an argument to theformat
(and mybe even thepreFormat
) function?The alternative I implemented now is to generate a rule for every single supported number, which I now limited to the numbers 1-99:
Beta Was this translation helpful? Give feedback.
All reactions