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:


But I would them to be:


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