Control wrapping of marks at the same range

Say I’m adding multiple marks at the same range like this:

tr.addMark(1, 4, state.schema.marks.em.create());
tr.addMark(1, 4, state.schema.marks.code_inline.create());

The result in the dom will be:

<code>
    <em>123</em>
</code>

But I would them to be:

<em>
    <code>123</code>
</em>

Adding the marks in reverse order also same results.

Appreciate any helps…

The order in which your marks are defined in your schema definition determines the order in which they wrap each other. Changing your schema definition to put code at the bottom should fix this.

1 Like