Prevent deletion of a node on backspace

We are trying to prevent deletion of a node on pressing backspace. For some reason, the node is getting deleted when the content becomes empty. Are we missing anything here? Is there a workaround that we can do to stop the deletion?

ezgif-1-1f248d6fdbda

This is how we have modeled our schema.

const nodes = {
  story: {
    content: "card*"
  },
  card: {
    selectable: false,
    atom: true,
    marks: "",
    isolating: true,
    content: "story_element*",
    attrs: {
      id: { default: "" },
      "content-version-id": { default: "" },
      "story-version-id": { default: "" },
      "client-id": { default: "" }
    },
    parseDOM: [{ tag: "div.card" }],
    toDOM() {
      return ["div", { class: "card" }, 0];
    }
  },
  story_element_text: {
    group: "story_element",
    content: "block*",
    atom: true,
    isolating: true,
    attrs: {
      id: { default: "" },
      "client-id": { default: "" },
      type: { default: "text" },
      subtype: { default: null },
      "story-version-id": { default: "" },
      "card-id": { default: "" }
    },
    parseDOM: [{ tag: "div.story-element.story-element-text" }],
    toDOM() {
      return ["div", { class: "story-element story-element-text" }, 0];
    }
  },
  paragraph: {
    content: "inline*",
    group: "block",
    parseDOM: [{ tag: "p" }],
    toDOM() {
      return ["p", 0];
    }
  },
  text: {
    group: "inline"
  }
};

const schema = new Schema({
  nodes: addListNodes(OrderedMap.from(nodes), "(paragraph | heading) block*", "block"),
  marks,
  topNode: "story"
});

I can’t make much of a screencast like that (describing what you’re doing, step by step, tends to be a lot more useful). The default command bound to backspace will delete the empty wrapping textblock node when possible. If you don’t want that, you might need to define a custom command.

@marijn We defined a custom command and it worked perfectly! Thank you!

Trying to achieve the same thing, would you mind sharing the command? @saiicharan