3 ms·
Probably by - locate the text node containing the selected text - split the text node into 3 segment (the selected one in the middle) - replace the selected
by mmis1000 4y ago
Probably by
- locate the text node containing the selected text
- split the text node into 3 segment (the selected one in the middle)
- replace the selected segment with a span that has font style on it
?
I did something like this before to replace part of the text with a ruby tag.
https://codepen.io/mmis1000/pen/gOgKqba?editors=0010 https://codepen.io/mmis1000/pen/gOgKqba?editors=0010
Or probably you can do it the reverse the obfuscate the selected text and make it actually works like a black pen.
Although it will be definitely more complex because selection may cross multi text nodes. But the idea should apply.
- Vinnl 4y agoYeah, I was initially thinking block-level elements, but just selected text should be easier.