This idea I've had kicking around for ages.
This could be based on Operational Transforms. demo libraries
I saw multiple articles on Conflict-free replicated data types (CRDT) that might also help. Article Article