Skip to content

Better escaping list item in editor v2 #5

Description

@qurle

Backspacing the empty list item should create simple empty paragraph.
Possible solution found here

const CustomListItem = ListItem.extend({
  addKeyboardShortcuts() {
    return {
      Enter: () => this.editor.commands.splitListItem(this.name),
      Backspace: ({ editor }) => {
        const { selection } = editor.state;
        const { empty, $anchor } = selection;
        const anchorPos = $anchor.pos;
        if (
          empty &&
          anchorPos === $anchor.start() &&
          editor.isActive('listItem')
        ) {
          editor.commands.toggleBulletList();
          return true;
        }
        return false;
      },
    };
  },
});```

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions