question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Collaborative editing

See original GitHub issue

@yatskevich and me did a research and tried to design an appropriate architecture for supporting collaborative editing. There are some key points with explanation below.

The main idea is to implement a kind of Redux-like behavior within Slate. <Editor store={Store} … /> The goal of having Store is ability to have clear separation and understandable flow.

UseCase:

  • User press key (types symbol)
  • Action is generated
  • Action is dispatched to Store
  • Store updates State
  • setState called
  • Editor re-rendered

This way allows us to have ability to manage operations in any suitable way (CRDT, OT, etc.) within Store.

Let’s see how to handle text paste operation in more details:

  1. Action pasteText dispatched to Store (data: {position, text}) No need to get current state, call transform() and return new state. Just dispatch an Action.
  2. Store has a Reducer for handling such an Action If we’re talking about ColloborativeStore - one type, if about SimpleStore - another one. We can even have few implementation of CollaborativeStores (CRDT and OT).

CollaborativeStore:

  • Splits pasteText operation into a set of atomic insertCharacter operations
  • Applies operations to State
  • Translates this operations set to server
  • Listens for updates from server (i.e. smb else is editing this doc and generates the same type of operations set)

SimpleStore:

  • Applies operations to State (no need to split to atomic operations)

In our mind such architecture allows Slate to be more flexible and extensible. But this is not a completely analyzed proposal - just an idea.

And a few pictures for clarification.

Workflow Chart: fullsizerender

Implementation example fullsizerender 5

pastText in depth: fullsizerender 3

P.S. Possibly, Store should send Transfroms (not Actions) to Server and get Transforms back.

@ianstormtaylor: Could you please take a look at this and share your opinion?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:29
  • Comments:125 (25 by maintainers)

github_iconTop GitHub Comments

43reactions
cudrcommented, Oct 28, 2019

Created plugin for co-editing: https://github.com/cudr/slate-collaborative

Hope, this will help for someone

38reactions
ianstormtaylorcommented, Sep 6, 2017

Hey all, the OT branch was merged in 0.22.0 so everything that unlocks OT should now be present in Slate’s core! More specifically:

  • All changes are composed of low-level operations.
  • The Change objects are available for each change, with the exact operations that occurred.
  • The operations contain all information and are sufficiently invertible for OT transforming.
  • The apply and invert operation helpers are exposed.

I don’t think Slate’s core will actually add the OT logic itself, since it isn’t used for all use cases and would add bloat. So instead, it would live in another package. If anyone wants to start collaborating on creating that package that would be amazing!

If you’re working on that, and you run into any places that Slate’s core is still missing functionality required, let me know and we can get it fixed. But I’m pretty sure it’s all there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Collaborative editing - Wikipedia
Collaborative editing is the process of multiple people editing the same document simultaneously. This technique may engage expertise from different ...
Read more >
9 Best Collaborative Document Editing Software in 2022
List of Best Collaborative Document Editing Software: · #1: Bit.ai · #2. Google Docs · #3: Microsoft Word Online · #4: Quip ·...
Read more >
Collaborate on Word documents with real-time co-authoring
We call this coauthoring, or real-time collaboration. Real-time collaboration. From here, if you'd rather work in your Word app, switch from Editing to...
Read more >
What Is Collaborative Editing? - Language Humanities
Collaborative editing is an editing method in which more than one person contributes to the process of editing a text document or lines...
Read more >
Collaborative editing - Atlassian Developer
Collaborative editing allows multiple people to concurrently edit a single Confluence page or blog post (we'll just call them pages from ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found