How to create an undeletable "header" node that has editable content?

Hi,

We were trying to have a fixed “header” node in the editor, that is always the first node and has predefined fields that you can edit - like “description”, etc. The predefined fields are retrieved from the DB and the idea was that we should add the header node according to the retrieved data during the document initialization.

How can we enforce that in prosemirror? We will probably have to handle delete transactions and backspace, but I’m not sure how to keep the node always as a first node.

We are using yjs for collaboration so there may also be a problem with the always on top node when we are emerging the documents.

Have you tried making your schema require these nodes? It sounds like that should cover most of your requirements without further effort.

I’m not 100% sure how to use the schema constraints - something along these lines?

const schema = new Schema({
  nodes: {
    doc: {content: "fixedHeaderGroup block+"},
    headerField: {group: "headerContent", content: "text*"},
    fixedHeader: {group: "fixedHeaderGroup" content: "headerContent*"},
    text: {},
  },
})