It's not terribly difficult, but it's hard to make it work nicely owing to the quirks of contenteditable regions. Personally, I think that if you're serious about writing a rich text editor for the browser you should avoid using contenteditable (as per Google Docs, for example) which lets you do pretty much anything. There are plenty of reasonably decent contenteditable-based editors out there, and they're all similarly broken when you get to difficult stuff.