I should start by saying that ProseMirror is an amazing library with admirable maintainer (and a nice community, too). Kudos!
It is well-known that block and inline content cannot be mixed within one PM node. I wonder if there is a way to determine, if I have a node and its node type, which of the two it would accept. I know there is a way to check whether a node type allows specific content through .validContent()
, but is there a way to just check whether it allows inline or block content?
Context, if of use:
I’m programmatically creating PM documents (perhaps not the primary usage that it was optimized for, I would be the first to acknowledge that). I process incoming data and generate an hierarchy of nodes recursively, and may not know the full contents of the surrounding fragment. I know there are other issues I could run into than just text/inline distinction, of course, but in my simple schema usually it’s either text content or any block, and other things (like starting a section with a title) I take care of as a special case…
I guess my logic could be refactored so that instead of having to the “content generator consults a separately defined PM schema to output correct nodes” kind of process I could instead have “some higher-level X programmatically creates a PM schema and a processor tailored for that schema”, but in the meantime I decided to ask anyway.