I use this javascript code to get the currently highlighted selection.
var selection = window.getSelection()
If the highlight is a section of text all within a <div>
, how can I get the offset from the beginning of the <div>
and the length of the highlight? (the length is not just the length of the text, it should be the actual length of the html code for that text)