Can not insert paragraphs in a `paragraph+` node

I am testing on the example setup. Firstly I add into the schema a NodeSpec

const myblock = {
            content: "paragraph+",
            group: 'block',
            parseDOM: [
                {
                    tag: 'div.block',
                },
            ],
            toDOM: () => ['div', {class: 'block'}, 0],
        }

Everything works fine. I can insert paragraphs as I hit “Enter” key in “myblock” nodes.

Then I add another child NodeSpec

const mytag = {
            content: "text*",
            parseDOM: [
                {
                    tag: 'div.tag',
                },
            ],
            toDOM: () => ['div', {class: 'tag'}, 0],
}

const myblock = {
            content: "paragraph+ mytag",       // myblock ends with 1 mytag
            // ... other stuff remains the same
        }

Now hitting “Enter” key in “myblock” nodes has no effect.

BTW, the initial doc content is parsed from

<div class="block">
</div>

I made an example at https://glitch.com/edit/#!/empty-ten-library?path=index.js%3A1%3A0

Could someone help me out? It bothers me for two days. What is wrong with this schema?

Your content spec is not working right. I have created solution for you.

@mrfambo Thanks a lot!

You emploied an intermediate Node bundlep, and it works.

And I want to figure out why my content spec is not working. It seems your content spec is equivalent to mine in respect to content expressions. So I guess there must be some rule on how to organize the schema to make it work. I checked the content expressions part in https://prosemirror.net/docs/guide/ , but found nothing.

Your content spec was like value1+ value2 and content expressions says value1 value2+. Seems like your content spec is not supported. I gave you a workaround till you further investigate.

I am not quite understand here. In myblock the content expressions is paragraph+ mytag. What is the difference between content spec and content expressions?

Oops i meant content expressions. If you see in docs there isn’t any example of value1+ value2 rather the examples says value1 value2+. So apparently you can’t add multi block on the first of content expressions.

P.S: I am so much stuck on my nodespecs so i mistakenly wrote content spec instead of content expressions.

Yes, the examples just show value1 value2+.

But if multi block on the first of content expressions does not work, then I think it must be specified in the guide. It is not apparent (at least to me).

Agreed. May be there is a bug @marijn. Please have a look at it. If it’s not a bug, and the way it is made then i will submit a PR with updated docs.

This has nothing to do with + operators not being supported in certain positions.

What is going on is that the main default Enter command (splitBlock) doesn’t know how to handle the case where the cursor is in a block that has to be the last element of its parent. It can’t split the block or create a new block after it.

So what you’ll have to do is add a custom command, which does whatever you want to happen in this situation (which isn’t obvious—I guess escaping the parent myblock node and creating a block after it would be the only workable approach), and bind it to Enter (along with, and with a lower predecence than, the standard commands bound to Enter), so that it can handle this situation.

@marijn Thank you for your explanation.