Is there a way to check if a node A is allowed in a node B?
I know there is allowsMarkType
method but can’t find a allowsNodeType
.
Is there a way to check if a node A is allowed in a node B?
I know there is allowsMarkType
method but can’t find a allowsNodeType
.
Thank you for your answer. Indeed, it could work. But not convinient.
My question is misleading: I would test if a node type is allowed, instead of a node.
There’s no single answer to ‘can this node type appear in this node’, since content expression can, for example, allow a single such node it at the start of the parent node, but not later on (as in "heading paragraph*"
).
You can create a content match with contentMatchAt
or contentMatch
to get the match at the start, from a type. And then call matchType
on that to figure out whether a given node type is allowed at that point.
Okay, thank you, that makes sense!