javascript - Highlighting in contenteditable div edge case -
i working on making contenteditable div text highlighted or unhighlighted. facing edge case in if drag mouse on text end end wild dragging, div getting selected. means if print range gives me parent element end container.
<div class = "xyz"> <span class = "highlighted">abcd</span> </div>
when log range.endcontainer prints xyz.
also using range.setstart() , range.setend() methods adjust range means fail in following scenario :
<div class = "xyz"> <span class = "unhighlighted">abcd</span> </div> range.setend(range.endcontainer, range.endcontainer.textcontent.length)
i sure have made mistake in setting end part of range cannot figure out ... can help?
Comments
Post a Comment