I Have written a method to highlight the matching words in the large file using TinyMce 4.7 version plugin.
Expected: To highlight the matching word and cursor to next to that similar like MS Word.
Issue: By the below method only for the first instance is highlighting and all the remaining are not highlighting.
Ex: if I search a word like chapter which is present in page 1, 4,6,7,8,9... now only the page 1 matching word is showing in yellow colour. In the same page if we have the word more than 1 time even after it is not showing.
function customhighlight(searchWord) {
// debugger;
var searchvalue = searchWord;
var str2 = '';
var insensitiveStr = searchvalue.toLowerCase();
var strnew = '';
var strTo = "<span style='background-color:Yellow; font-weight:bold;' ><b>" + searchvalue + "</b></span>";
str2 = $("#editor_ifr").contents()[0].documentElement.childNodes[1].innerHTML.replace(searchvalue, strTo, "gi");
$("#editor_ifr").contents()[0].documentElement.childNodes[1].innerHTML = str2;
}