# Collaborative Editing in ProseMirror - marijnhaverbeke.nl
Synced: [[2024_07_03]] 7:10 PM
Last Highlighted: [[2024_07_03]]

Summary: A real-time collaborative editing system is one where multiple people may work on a document at the same time.
## Highlights
[[2024_07_03]] [View Highlight](https://read.readwise.io/read/01j1vpw2zfchpjs1wxb66hw9q3)
> ProseMirror's algorithm is centralized, in that it has a single node (that all users are connected to) making decisions about the order in which changes are applied. This makes it relatively easy to implement and to reason about.
[[2024_07_03]] [View Highlight](https://read.readwise.io/read/01j1vpwjdzx0x8p0esvjc8mhpy)
> First, we apply R1 and R2 to our representation of that original version (clients must track both the document version they are currently displaying, which includes unsent changes, and the version that does not yet include those changes). This creates two position maps *mR1* and *mR2*.
> We can simply map *L1* forward through those maps to arrive at *L1⋆*, the remapped version of *L1*. But *L2* was based on the document that existed after applying *L1*, so we first have to map it *backwards* through *mL1*, the original map created by applying *L1*. Now it refers to the same version that *R1* starts in, so we can map it forward through *mR1* and *mR2*, and then finally though *mL1⋆*, the map created by applying *L1⋆*. Now we have *L2⋆*, and can apply it to the output of applying *L1⋆*, and *voila*, we have rebased two changes onto two other changes.