Coder Social home page Coder Social logo

immortalin / slate-operational-transform Goto Github PK

View Code? Open in Web Editor NEW
36.0 3.0 1.0 1.16 MB

Slate Operational Transform Demo (used in production at Narration Box)

Home Page: https://narrationbox.com

HTML 5.86% CSS 6.25% JavaScript 87.88%
operational-transform slatejs slate-editor operational-transformation collaborative-editing crdt sharedb semilattice google-wave

slate-operational-transform's Introduction

Slate JS Editor Operational Transform Example using ShareDB

Instructions

Cursors are WIP, for testing please use https://github.com/Immortalin/slate-operational-transform/tree/00e56152355535416a1007ffca296b7bfcfd7b22

cd slate-operational-transform
npm install
npm start

And in another shell

cd slate-operational-transform/collab_editor 
yarn install
yarn start

Open two different browsers and navigate to localhost:3000, all changes in one browser should be mirrored in another.

Caveat Emptor

  • This is a demo, there are a lot of optimizations and features missing.
  • Invoking JSON0-ot-diff on every edit is not very efficient.
  • A better way would be to either manually annotate the various slate operations or to add a debounce of some sort. A debounce would trade off between granularity (important for good UX) versus performance. Of course there are other ways such as separate thread of computing operations using WebWorkers, or perhaps rewrite the core algorithm in WebAssembly. If you paste a large body of text there is a second or two of lag as diff function has to catch up. The holy grail would be to implement the transformation function using Slate's native Operation type. (there are 9 operations, but that takes a lot of time to build and debug so it is faster to piggy back off ShareDB unless you have a team of engineers willing to build a solution from ground up.)
  • Multi-cursors, presence, live chat etc. are left as an exercise to the reader.

Literature

https://www.tiny.cloud/blog/real-time-collaborative-editing-slate-js/ https://blog.aha.io/text-editor/ https://ckeditor.com/blog/Lessons-learned-from-creating-a-rich-text-editor-with-real-time-collaboration/

https://medium.com/@david.roegiers/building-a-real-time-collaborative-text-editor-for-the-web-draftjs-sharedb-1dd8e8826295 https://hackernoon.com/operational-transformation-the-real-time-collaborative-editing-algorithm-bf8756683f66 https://hackernoon.com/analysing-different-operational-transformation-algorithms-for-collaborative-editing-60fcc49ef24b https://medium.com/@srijancse/how-real-time-collaborative-editing-work-operational-transformation-ac4902d75682 https://medium.com/coinmonks/operational-transformations-as-an-algorithm-for-automatic-conflict-resolution-3bf8920ea447 https://github.com/qqwee/slate-ottype https://github.com/ksimons/ot-slatejs https://github.com/quilljs/delta/blob/e5517726f6665e293e851457b1cc0c7a17576e50/src/Delta.ts#L390

slate-operational-transform's People

Contributors

immortalin avatar

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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

pirtlj

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.