Hi all,
I’m running into an issue with overlapping decorations in ProseMirror. I have two plugins:
- One that colors every other letter of a word in a different color.
- Another that adds a tooltip in the middle of each word, always visible.
Ideally, this would be simple using two inline decorations – one for coloring every other letter, and one for marking each word (allowing me to position a tooltip via ::before
or ::after
). However, these two decorations collide, interleaving and creating multiple DOM elements of the tooltip. This seems pretty expected.
I tried using a widget decoration for the tooltip, approximating the size. While it mostly worked, the tooltips weren’t perfectly centered, and worse, it caused issues on Android phones, making the keyboard hide and reappear when backspacing / deleting the widget character.
I also attempted modifying toDOM() for the text node to wrap words in a <span>
, like this:
text: {
group: "inline",
toDOM(node) {
return ["span", { class: "text-wrapper" }, node.text];
}
}
But I couldn’t get it working as expected.
Is there another approach I might be missing? It seems like inline decorations could be the cleanest solution, but alas, don’t work. Any suggestions?
Thanks!