Disable auto wrapping on joinBackward

I’m running into the following scenario (A):

<parentElement>
<p>hello</p>
</parentElement>
<p>paragraph 2</p>

In my schema, the following is also allowed (B):

<parentElement>
<p>hello</p>
<children><p>paragraph 2</p></children>
</parentElement>

Now, when I use joinBackward in state A by hitting backspace in front of “paragraph 2”, I end up with state B. I dived into this and it’s because joinBackward has some smart logic using findWrapping and discovers it can wrap the paragraph in a “children” element.

However, I would prefer this wrapping not to be automatically created, and merge the paragraphs instead. I.e. I would like to end up with (C):

<parentElement>
<p>helloparagraph 2</p>
</parentElement>

Is it possible to control the behavior of joinBackward for this? For example, can I set a property on “children” that would prevent it from being eligible as a wrapper?

Not really, but what you could do is create another command, bound to backspace with higher precedence, that recognizes this situation and implements the behavior you want.

Alright, thanks! That makes sense, wanted to make sure I didnt overlook a different option / best practice.

Any existing command / function you think is similar to this way of joining you can recommend as a starting point? If not no worries, should be able to figure it out