Git Product home page Git Product logo

collaborative-text-editor's Introduction

Collaborative Realtime Texteditor Build Status

Collaborative realtime texteditor with gRPC using RGAs (Replicated Growable Arrays).

Screenshoot Collaborative Texteditor

With the collaborative realtime texteditor several users can edit documents together in realtime. Via Remote-Cursors the current editing positions of the other users are always visible.

The implementation of the collaborative realtime editor is using a variant of RGAs (Replicated Growable Arrays). The RGA-protocol is implemented as Timestamped Insertion Tree (TI Tree) and guarantees "Eventual Consistency".

For more details about the implementation see: documentation.md

Running the project

The project is built with docker-compose. Before getting started you have to install docker-compose.

You can start the production-configuration with the following docker-compose command:

docker-compose -f docker-compose.yml -f docker-compose.prod.yml up --build

Open a browser tab, and go to: http://localhost:8081/index.html

To shutdown the containers: docker-compose down

Local development

Remote debugging and hot reloads

The dev-configuration uses hot-reloads (for js and scss files) and offers remote debugging for go files via delve.

Create a "Go Remote Debugging"-Configuration in your IDE and listen to port 40000.

Start the dev-configuration with:

docker-compose -f docker-compose.yml -f docker-compose.dev.yml up --build

Compiling proto files for go

go get -u google.golang.org/grpc
go get -u github.com/golang/protobuf/protoc-gen-go

protoc -I collabTexteditorService/ collabTexteditorService/collabTexteditorService.proto --go_out=plugins=grpc:collabTexteditorService

Compiling proto files for js

protoc -I collabTexteditorService collabTexteditorService/collabTexteditorService.proto \
--js_out=import_style=commonjs:./frontend/src \
--grpc-web_out=import_style=commonjs,mode=grpcwebtext:./frontend/src

Debugging with docker

To open the console of a specific container run:

docker exec -it collaborative-text-editor_frontend-client_1 /bin/bash

The following command gives you a list of status of all containers:

docker-compose ps

Bundling and building js-Frontend

npm install
npm run build

collaborative-text-editor's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

collaborative-text-editor's Issues

Visible Remote Cursors of already left users

If a user leaves the collaborative editor, his remote cursors will stay in the editor.

The go backend knows when a replica leaves a session, the remote cursor of this replica should then be removed from the editor, because the replica is no longer active

Create unique links for group collaboration

At the moment only one editor exists which all collaborators use together. The content of the editor is present as long as the server is running.

A generator for unique links should be implemented. A user can create a new share-link and invite other users to this link to collaborate with him.

If all users leave the session, by closing the window or clicking on a button. The server deletes the session and its history. By organizing the requests in sessions its a good starting point to implement offline sessions of the users.

Host with unique access link/token
e.g.: localhost:8081/asdjf239023

  • create unique links
  • new users joining the link get the complete history
  • users can define nick names, which are displayed as remote cursors
  • improve UI of the session joining and creating process

Graceful shutdown

Implement graceful shutdown by:

  • cleaning/closing open streams
  • closing channels

Mass deletions/insertions

  • handle Mass insertions as one node per line
  • Split the node later if text is inserted/deleted
  • Read additional papers to this topic

Think about how to implement mass deletions, if the text is not inserted by mass insertions and each char is a single node.

CRDT Improvement

Reduce the time-/performance effort for CRDT

  • implement bulk deletion/insertion
  • enable login of new users. Go backend sends new users the stored event history
  • improve performance for inserting nodes to the end of the line (the length a line needs to be transferred to crdt-backend) see #27
  • handle offline sessions of individual replicas or of the go backend see #10
  • improve local storage for chars

local npm build is throws error

local bundle building with npm run build throws an error:

ERROR in ./node_modules/codemirror/theme/3024-night.css 11:0
Module parse failed: Unexpected token (11:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| */
| 
> .cm-s-3024-night.CodeMirror { background: #090300; color: #d6d5d4; }
| .cm-s-3024-night div.CodeMirror-selected { background: #3a3432; }
| .cm-s-3024-night .CodeMirror-line::selection, .cm-s-3024-night .CodeMirror-line > span::selection, .cm-s-3024-night .CodeMirror-line > span > span::selection { background: rgba(58, 52, 50, .99); }
 @ ./src/main.js 6:0-41

ERROR in ./node_modules/codemirror/lib/codemirror.css 3:0
Module parse failed: Unexpected token (3:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| /* BASICS */
| 
> .CodeMirror {
|   /* Set height, width, borders, and global font properties here */
|   font-family: monospace;
 @ ./src/main.js 5:0-39

Automated Deployment

  • find suitable cloud provider
  • activated automated deployment for master branch

CRDT Research

Find suitable implementations and optimizations in papers

First basic implementation

Transfer Input of one client to other client (other uses server-side-streaming for updates)

  • use simple test field as input and

    as output (both clients see the same result)

  • client subscribes at the server for updates
  • client uses send button to transfer text object (send by button several times possible)

CRDT Implementation

  • Determine the position as well as the character itself which has been inserted/deleted by the last user action
  • create separate class for managing CRDT
  • do transition function (a transition can be delete or insert)
  • receive transition function (receives transition by server-side streaming and calls do transition)
  • send transition function (sends transition by unary call)

Display Remote Cursor in CodeMirror

Display the cursors of all users in the editor

  • display a cursor object in CodeMirror with a unique user id
  • [ ] listen cursor events in CodeMirror and send the new positions to the backend
  • [ ] establish a server-side streaming connection to receive the cursor positions of the other users

stream timeout

Problem
The Server-side stream which serves the updates to all clients automatically closes after some time with the message "stream timeout". No automatic reconnection of the stream is happening.

Possible Solution
It would be an idea to send keep-alive pings from time to time from the go server to the clients.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.