Are all these editors based on contenteditable?
https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Edit...
https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Edit...
[0]: I suggest you to take a look in Chrome debugger how it works. Quite funny piece of code. It is written in jQuery + vanilla JS, so it will be very easy to spot the whole algorithm.