Here is my code that works well for coloring the numbers in editable div but the cursor is going to the start of the div and it should work normal when I press keyboard arrow buttons to traverse the string, also when i click "home" and "end" buttons, cursor should go as expected
jQuery(document).ready(function(){
$("#richTextField").keyup(function() {
var divContent = $(this).text();
var pattern = /(\d)/g;
var replaceWith = '<span class="numberClass"'+ '>$1</span>';
var highlighted = divContent.replace(pattern,replaceWith);
$(this).html(highlighted);
});
});