Can I make a decoration have a higher rank than a mark in HTML?

I hope my decoration can wrap around my mark during rendering. For example, I want <span class="my-decoration"><code>text</code><span>, not <code><span class="my-decoration">text</span></code>.

After reading other discussions, I realized that this seems impossible, as inline decorations are drawn inside the wrapper elements added for marks. However, I still want to explain my scenario to see if there are other ways to achieve this.

When I edit a link, the focus moves to my input box. To make the selection clearly visible to the user, I used a decoration to create a fake selection.

s2 s1

However, due to the DOM structure generated by the decoration, it’s hard for me to adjust the style of this fake selection. As you can see, in my example, my selection differs somewhat from the real selection.

1 Like