2 ms·
Have you thought of intercepting keyboard strokes to maintain your own internal state of the text ? Instead of having Keyboard-->HTML-(extract)->innerText yo
by zimbatm 12y ago
Have you thought of intercepting keyboard strokes to maintain
your own internal state of the text ?
Instead of having Keyboard-->HTML-(extract)->innerText you would have Keyboard-->innerText-(render)->HTML. Contenteditable is a honey pot, it makes you think that implementing a text editor will be easy, until you hit all the corner cases.
- kangax 12y agoUnfortunately not possible since the editor is part of a browser extension and is activated on any page with textarea/contenteditable. Text could change at any time by other scripts, and the only way to intercept those changes is via MutationObserver. MutationObserver gives you changed node and its text (without getting entire plain text, we can't really "transposition" this all onto a global text to figure out what changed).