Unexpected GapCursor Appears Outside Custom Top-Level Node (<document>)

Hi Marijn,

I’m working with a custom schema where the top-level content of the doc is a single document node (instead of the default block+). Here’s the schema I’m using:

export const nodes = {
  doc: {
    content: 'document',
  },

  document: {
    group: 'block',
    content: 'block+',
    defining: true,
    isolating: true,
    allowGapCursor: false,
    parseDOM: [{ tag: 'document' }],
    toDOM: () => ['document', 0],
  },

  paragraph: {
    group: 'block',
    content: 'inline*',
    parseDOM: [{ tag: 'p' }],
    toDOM: () => ['p', 0],
  },

  text: {
    group: 'inline'
  }
};

The issue is that when I move the selection with arrow keys to the end of the content, a gap cursor appears outside the <document> node, and if I type at that point, a <p> node gets created outside of <document>, violating the schema.

This happens even though:

  • The schema explicitly defines docdocument
  • document is marked as isolating
  • allowGapCursor: false is set

This seems like a bug — ProseMirror should not allow selection or node creation outside the document node, especially if the schema restricts it that way.

Let me know if I’m missing something or if this is unintended behavior.

Thanks!

When I run an editor with your schema, I do not get gap cursors at the start and end of the document. Are you sure you’re running an up-to-date version of prosemirror-gapcursor?