Google Wave pioneered much of what google docs has, though the models are completely different. Start research there, as there is much to learn.
If you are just trying to do something simpler than structured documents, mobwrite, etherpad or one of its forks could suit.
The editor can be tricky and essentially involves building an entire word processor in javascript. Some examples of this are around.
With any kind of editor you have a line or element buffer, which you must mirror onto the realtime api of choice.
This can be done with Google drive's realtime API.
Modification events have to be handled in both directions. Local model changes propagating to the realtime model and vice versa. Modifications to the local model can get rendered as they happen.
Cursors can be handled by having pointers on the source buffer, such as Index Reference.
The server can be implemented in a number of ways, but will require an operational transformation model supporting common structures. Wave protocol's site has an example using an xml model.