-
Notifications
You must be signed in to change notification settings - Fork 366
Description
Hello!
First off, thank you for creating a kickass project :)
I am currently using rangy to analyze sentences (such as grammar, etc) within contenteditables and highlighting the text. Here are my steps:
Every time a user enters text into a contenteditable...
- Get the text of a contenteditable from
rangy.innerText(el)and analyze it, returning an array of start & end tuples marking which characters should be highlighted - Clear already highlighted elements using
range.selectNode(el)andapplier.undoToRange(range) - Rehighlighting the text I specify using
range.selectCharacters
I noticed that as the number of highlights increase, the performance gets exponentially worse. I ran a Chrome profiler and it seems that the selectCharacters call is the culprit. I dug into the code a bit, and noticed you use caches extensively — could it be one of the caches are no longer being hit?

If it helps, I've created a JSFiddle! Start typing some text into the contenteditable and you'll see what I mean. https://jsfiddle.net/3zz5pLgx/
1 — Do you know why selectCharacters might have this performance issue?
2 — In general, do you think that my approach to this problem (highlighting characters in text based on start & end values) is correct?
Thanks in advance!