Skip to content

Instantly share code, notes, and snippets.

View Andrew3005's full-sized avatar
🌴
On vacation

Andrii Piddubniak Andrew3005

🌴
On vacation
View GitHub Profile
@Gozala
Gozala / Readme.md
Last active January 12, 2021 13:52
Range hilighting code by wrapping text nodes of the range & replacing images.

Highlight Selection Ranges

Code here takes a DOM Selection Range instance and starts traversing a DOM starting from startContainer up to endContainer and wraps Text elements with elements that have semi-transparent background & swaps img elements with clones that are styled to have semi-transparent yellow overlay.

Issues

  • Only handles selecting text and images & would not cover divs with backgrounds for instance.