Shameless plug: I worked on a similar tool mdocs [1]. The main difference is that is opensource, it supports authentication and authorization [2] similar to Google Docs. The authorization part allows you to share documents at company level.
It is a 100% client-side application, it uses Firebase as backend and Auth0 for authentication.
[1] was really confusing. It consistently errored when I tried to sign in, then when clicking the link for more details, walked me through creating an auth0 account. I did find [3] which made more sense.
It uses a theory called Operational Transformation [1] which is roughly the base for most collaborative tools like google docs.
My first attempt was using a library called ot.js [2], I changed it to support an async db since it only supported a in-memory store and I adapted to use mongodb. The experiment is in [3] and it has some bugs still.
Then I found out the guys at firebase adapted ot.js client side to work with their own db, and created something called Firepad [4]. So, I used that instead which was more stable and I added auth and authn.
[3] http://mdocs.io/