Skip to content

Better escaping list item in editor v2 #5

@qurle

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;
      },
    };
  },
});```

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