-
Notifications
You must be signed in to change notification settings - Fork 58
feat: provide word style list creation #634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| // Returns an inputRules plugin for list formatting (bullet and ordered lists) | ||
| export function getListInputRulesPlugin(schema) { | ||
| const rules = [getBulletListInputRule(schema), getOrderedListInputRule(schema)].filter(Boolean); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there's ever a time where schema.nodes will NOT have bullet_list and ordered_list, so it should be safe to assume that they will be present.
I think that all of the listInputRule code can be consolidated into this function:
export function getListInputRulesPlugin(schema) {
const { ordered_list: orderedList, bullet_list: bulletList } = schema.nodes;
const rules = [];
if (orderedList) rules.push(wrappingInputRule(/^\s*1[.)]\s$/, orderedList));
if (bulletList) rules.push(wrappingInputRule(/^\s*([-*])\s$/, bulletList));
return inputRules({ rules });
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense to me, but if schema.nodes.bullet_list and schema.nodes.ordered_list will always be defined, then we don't need the if statements at all right?
Assuming that's true, I simplified it to just:
export function getListInputRulesPlugin(schema) {
const rules = [
wrappingInputRule(/^\s*1[.)]\s$/, schema.nodes.ordered_list),
wrappingInputRule(/^\s*([-*])\s$/, schema.nodes.bullet_list),
];
return inputRules({ rules });
}
If you think the ifs are needed, let me know and happy to update to the suggestion your provided.
Description
This allows more of the muscle memory users have from word to be re-used in DA.
full disclosure, this was largely vibecoded, but looking over the code it makes sense to me and works when tested.
Related Issue
Motivation and Context
Because I get annoyed when authoring that this doesn't work :)
How Has This Been Tested?
tested locally in the editor at http://localhost:3000/edit#/aem-sandbox/block-collection/drafts/shsteimer/testing
contemplated unit tests, but no other key handlers seemed to have them, assume there is a reason for that.
Screenshots (if appropriate):
Types of changes
Checklist: