This repository contains implementation of a collaborative editor using Conflict Free Replicated Datatype.
git clone https://github.com/sumeetgajjar/NUpad
cd NUpad
git submodule update --init --recursive
docker build . -t nupad
docker run --rm nupad run_all_tests
Note: Requires docker-compose for running the app, installation instructions for docker-compose can be found here.
docker-compose up -d
This will start the following five docker containers:
- nupadapp: Run the app instance which publishes changes to nsq queue and consumes remote changes
- nupadwebui: Hosts the WebUI for editing
- nsqlookupd: Lookup service for nsq
- nsqd: nsq service
- nsqadmin: Admin interface to nsq
- Once all docker containers are up, goto http://localhost:8080
- enter a document name, e.g.
testing-doc-1
- Open a new browser window, goto http://localhost:8080
- enter the same document name you entered in the step 2. i.e.
testing-doc-1
- start editing in both the windows
Note: The vscode extension is just for demo purpose, it is not as robust as WebUI. It has following assumptions and violating any of the following assumptions will result into undefined behavior, might even crash all docker containers
- undo and redo does not work
- only single character should be inserted or deleted at a time, multi-character insertion and deletion(ctrl+v to insert more than one character, selecting more than one character and deleting) is not constrained via code. User should ensure only single character is edited at any given time.
- the name of the document collaborative editing is hard-coded to "demo-doc" inside extension, thus only "demo-doc" can be edited using vscode extension
- Once all docker containers are up, run the following command
- open extension code in vscode
# make sure you are in the NUpad directory # Goto the vscode extension source code cd user_interface/vscode-nupad/ # start vscode code .
- running extension using vscode
- press
F5
to compile and run the extension in a new "Extension Development Host" window - Once the new vscode window opens
- Open a new file; press
ctrl+N
- Click in the new file and make sure the cursor is blinking
- press
ctrl+shift+P
to open command palette - type "Start NUpad" in the command palette, select it and press
enter
; This will connect the vscode extension to the NUpad app running inside the docker container - open WebUI and enter document name as "demo-doc"; start typing in the content box
- You can see the changes in the vscode
- make changes in the vscode, you can see the changes in WebUI
- To stop the collaborative editing:
- press
ctrl+shift+P
to open command palette - type "Stop NUpad" in the command palette, select it and press
enter
; This will disconnect the vscode extension from the NUpad app running inside the docker container
- press
- Open a new file; press
- press