slate icon indicating copy to clipboard operation
slate copied to clipboard

Delete backward is replacing the previous node by the current node

Open zbeyens opened this issue 4 years ago • 3 comments

Do you want to request a feature or report a bug?

Bug

What's the current behavior?

hJj77Yhl15

li (with empty text) is replaced by a p on deleteBackward.

Workaround until it's fixed:

// ...
editor.deleteBackward = (...args) => {
    deleteBackward(...args); 

    const match = Editor.above(editor, {
      match: n => unwrapTypes.includes(n.type),
    });

    if (match) {
      // quick fix for list item
      Transforms.setNodes(editor, { type: ListType.LIST_ITEM });
    }
};

Slate: 0.57.1 Browser: Chrome / Safari / Firefox / Edge OS: Mac / Windows / Linux / iOS / Android

What's the expected behavior?

It should not replace the node

zbeyens avatar Jan 07 '20 19:01 zbeyens