Please find this JSfiddle which basically works without using Rangy library. I am not using this JSfiddle approach for my application and hence trying to apply rangy library in the JSfiddle as shown below:
`rangy.init();
highlighter = rangy.createHighlighter();
highlighter.addClassApplier(rangy.createClassApplier(“highlight”));
function highlight(){
highlighter.highlightSelection(‘highlight’);
var selTxt = rangy.getSelection();
console.log(‘selTxt: ‘+selTxt);
rangy.getSelection().removeAllRanges();
}
function removeHighlights() {
highlighter.removeAllHighlights();
}
document.getElementById(‘docContentPanel’).addEventListener(‘click’, highlight);`
Now in this JSFiddle, I am trying to use Rangy, referring to one of the online code demonstrating Rangy usage here. I am wondering what would go in place of document.getElementById('docContentPanel').addEventListener('click', highlight);
because I am already inside click handler and I am highlighting words when a user clicks on a particular cell.
P.S: I am using raw links from github for adding rangy libraries and JSfiddle is refusing to accept the scripts as strict MIME type is enabled by the author. So, second JSFiddle with Rangy library may not run for you in JSFiddle.