adblock-filter-analyzer
adblock-filter-analyzer copied to clipboard
hitting enter then typing types in the old spot - bad cursor position when hitting enter
Have you considered a parser like jquery's $(selector).text() instead of innerHTML? It strips tags. Using that might save the headache of trying to count how many tags you inserted or removed... it would just give the text content as opposed to the length of the HTML.
Can potentially solve this by using document.execCommand(hiliteColor, ??, "Orange"), instead of converting to string then adding spans
Try some of the ideas from Stack Overflow bounty
https://stackoverflow.com/questions/62705449/fix-cursor-position-when-replacing-innerhtml-of-div-contenteditable-true
This recent StackOverflow answer looks promising: https://stackoverflow.com/a/78955367/3480193