Join consecutive lists

I have the following scenario:

User creates an ordered list(wrapInList):

1. a
2. b
3. c
4. d
5. e

After that they outdent(liftListItem) the third item:

1. a
2. b
c
1. d
2. e

Then the user selects the third item(<p>c</p>) and using wrapInList expects to see this:

1. a
2. b
3. c
4. d
5. e

But instead the result is:

1. a
2. b
1. c
1. d
2. e

After inspecting the DOM, this is the generated result after applying wrapInList in the third step:

<ol>
   <li><p>a</p></li>
   <li><p>b</p></li>
</ol>
<ol>
   <li><p>c</p></li>
</ol>
<ol>
   <li><p>d</p></li>
   <li><p>e</p></li>
</ol>

The expected result should have the following HTML:

<ol>
   <li><p>a</p></li>
   <li><p>b</p></li>
   <li><p>c</p></li>
   <li><p>d</p></li>
   <li><p>e</p></li>
</ol>

Is there a way to achieve the needed result?

Thanks!

The autoJoin command wrapper might help with this.

Thanks! It worked. Now when inserting an ordered list for example, the command looks like this:

const insertOrderedList = autoJoin(wrapInList(schema.nodes.ordered_list), ['ordered_list']);