I am developing a real-time text editor with paragraph locking property similar to https://quip.com/. in socket.io and nodejs
Paragraph lock can be easily achieved by adding a class to the currently editing paragraph. Transfer this paragraph with the class to the other user. so that if the user tries to write over that prevent him by validate with the class.
Generate a class name look like - className_userid (className_1).