How do I control the behavior of findWrapping?

I’ve got an issue where, when a user tries to input an invalid node as a child of another node, Prosemirror allows it by wrapping it in a nonsensical block; a block that’s only used elsewhere for other stuff. FindWrapping seems to iterate over possible nodes to wrap it in, and then chooses one. In my case, it’s one that doesn’t make sense, and the result is a document that’s technically correct, but looks broken.

How can I prevent it from doing this? The schema is legacy and cannot be changed under any circumstances.

You can’t. Wrapping nodes is one of the ways in which the schema constraints are preserved, and it’s not something that can be turned off. You can influence which node is picked by changing the order of the nodes in the schema definition, if that helps.

1 Like

Great; the schema ordering was the missing insight for me. Thank you!