Inline nodes are not split when Enter is pressed between the node

I have the following schema for span node:

    content: 'inline*',
    group: 'inline',
    inline: true,

When I press enter by having the cursor between Prose and Mirror in the following text, it is not working.

<p>Hello <span>ProseMirror</span>!</p>

The issue is with the span node. Without the span node, the enter key works as expected. I am facing a similar problem with other nodes, such as the one for the sub tag, using the configuration above.

Is it not possible to split such inline tags, or am I missing something? Or do we need to write custom code for it?

The built-in commands don’t handle inline nodes with content very well. You’ll often have to provide your own custom commands. This patch extends splitBlock to be a bit more clever about wrapping inline nodes.

@marijn Thank you. When will this patch get published?

I’ve tagged prosemirror-commands 1.6.2

1 Like

Thanks a lot :sparkles:

Hey I’ve run into issue because of this new version. I have some nodes that cannot be split but with this new version they now do which causes my schema to be invalid. I think there is a missing return statement (Make splitBlock capable of splitting inline nodes · ProseMirror/prosemirror-commands@8cbb694 · GitHub). If you need a reproducable example I can create one.

An example would be useful, yes.

Here is the example, it works in 1.6.1 but not in 1.6.2.

1.6.1: Bug ProseMirror-Command splitBlock (1.6.1) - StackBlitz

1.6.2: Bug ProseMirror-Command splitBlock (1.6.2) - StackBlitz

How to reproduce is to put the cursor in the “fixedControlValue” node and press enter.

Steps:

  • place cursor as indicated above
  • press enter

Expected:

  • No crash and content does not change

Actual

That was indeed a regression! This patch restores the relevant line.

2 Likes

Thanks so much :heart_hands: