Pass EditorState to getAttrs callback of rule builders #7

Closed
k15a wants to merge 1 commit from feature/rule-builders-callback-editor-state into master
k15a commented 2022-02-04 12:17:08 +01:00 (Migrated from github.com)

Hi,

I would like to have an input rule for headings that automatically uses the attributes of the first heading in the document (for example font-size and color). I figured the easiest solution would be to search for the first heading node in the getAttrs callback and return the attributes of that node. This PR will add a second state parameter to the getAttrs callback.

Hi, I would like to have an input rule for headings that automatically uses the attributes of the first heading in the document (for example font-size and color). I figured the easiest solution would be to search for the first heading node in the `getAttrs` callback and return the attributes of that node. This PR will add a second state parameter to the `getAttrs` callback.
marijnh commented 2022-02-04 15:31:55 +01:00 (Migrated from github.com)

Would it not be reasonable to write this rule using the InputRule constructor, rather than wrappingInputRule? The use case seems a bit too specific to extend the API for.

Would it not be reasonable to write this rule using the `InputRule` constructor, rather than `wrappingInputRule`? The use case seems a bit too specific to extend the API for.
k15a commented 2022-02-04 15:39:56 +01:00 (Migrated from github.com)

Yes, that's definitely possible. Probably the right call than to not extend the API. Thanks for the feedback!

Yes, that's definitely possible. Probably the right call than to not extend the API. Thanks for the feedback!

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
prosemirror/prosemirror-inputrules!7
No description provided.