Skip to content

Lists input rules#432

Merged
harbournick merged 3 commits intomainfrom
har-8792_list-input-rules
Apr 2, 2025
Merged

Lists input rules#432
harbournick merged 3 commits intomainfrom
har-8792_list-input-rules

Conversation

@VladaHarbour
Copy link
Copy Markdown
Contributor

  1. Creates bullet list by typing '- '
  2. Creates ordered list by typing '1. + Enter'

@harbournick
Copy link
Copy Markdown
Collaborator

@artem-harbour mind reviewing this one as well pls?

}
if (config.keepAttributes) {
/** If the nodeType is `bulletList` or `orderedList` set the `nodeType` as `listItem` */
const nodeType = config.type.name === 'bulletList' || config.type.name === 'orderedList' ? 'listItem' : 'taskList';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not have taskList node type, please fix this.

@@ -0,0 +1,32 @@
export const undoInputRule = () => ({ state, dispatch }) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer not do undoInputRule and keep it as simple as possible.

@harbournick, what do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When used with ordered list it’s more essential (from my point of view) to undo the rule on delete to leave the initial typing
If not the initial typing will be removed

Copy link
Copy Markdown
Contributor

@artem-harbour artem-harbour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added my comments.

FYI @harbournick

Copy link
Copy Markdown
Collaborator

@harbournick harbournick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


const handleBackspace = () =>
this.editor.commands.first(({ commands, tr }) => [
() => commands.undoInputRule(),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice !

@harbournick harbournick merged commit d441d8f into main Apr 2, 2025
6 checks passed
@harbournick harbournick deleted the har-8792_list-input-rules branch April 2, 2025 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants