I’m working with prosemirror-schema-list
to add bullet list functionality. There’s one aspect of the schema-list-item
behavior that seems odd to me. When you press the Backspace
key at the beginning of the second list item, it merges this child node with the preceding list item.
What I want to happen is for the list item to become a separate paragraph node when I press Backspace
. I thought I had this working until I pressed Backspace
again, moving the cursor to the end of the previous list item. Surprisingly, this action recreated the list item node.
Could you review my Backspace
key command and offer any suggestions for resolving this issue?
Backspace: (state, dispatch) => {
if (
state.selection.empty &&
state.selection.$anchor.parentOffset === 0 &&
state.selection.anchor !== 1
) {
const node = state.doc.nodeAt(state.selection.$anchor.pos - 2)
if (node && node.type.name === this.name) {
return liftListItem(this.schema.nodes[this.name])(state, dispatch)
}
}
return false
},