2/19/2023 0 Comments Online rich text editor![]() ![]() Pseudo OT with client-side only transformations Let’s try to break down the following example when both Alice and Bob loaded the same doc with version V1 that contains “Foo”: In the same way, ProseMirror, a very popular framework for building rich text editors, implements Pseudo OT (I call it that way). There is no single conventional way to implement both CRDT and OT.įigma, for example, implements real-time design collaboration by using Pseudo CRDT. Operational Transformation is one of the most popular approaches for building real-time rich text editors that was first researched in the 20th century. Alice and Bob wanted to change “Foo” to have another word, but they’ll end up with something like “WBar” instead.Ĥ. CRDT will split these replace operations into simple delete + add. For example, Alice wanted to replace “F” in “Foo” with “W” to have “Woo”. CRDT simplifies conflict resolution, but it sacrifices intention-preservation.For example, CRDT with JSON, CRDT with extensible data types, etc. Since it’s a relatively new approach, it’s not used very often for building real-time text editors, especially rich text editors beyond plain text.Usually, your server becomes just one of the P2P nodes and may not have the latest data. Doesn’t play well if you want to have your server to be a single source of truth.If you already have a rich text editor with docs in the DB, it may mean a complete rewrite. Requires using specific data structures.There are a few useful open-source tools such as Yjs, Automerge, GUN.But it has to be implemented on a separate layer. Text cursor/selection positions are simpler to implement by using unique IDs.Relatively simple to reason about and easy to implement.Great for peer-to-peer communication in distributed systems, doesn’t require a central server.And when both Alice and Bob deleted “o”, it works the same way as only one of them did that (idempotence). Now, if we change the order of these operations, the result will be still the same (commutativeness). Bob added “A” between ID 1 and ID 2 with ID 1.5 (fractional index).Simplified text editing with CRDT and fractional indexes With these IDs, we can now correctly identify characters’ positions in the text. When building a text editor, it is possible to split the content into separate characters and make sure that each of them has a unique ID. Idempotence, applying the same change multiple times produces the same result as it was applied only once.Commutativeness, changing the order shouldn’t change the result.To achieve this, operations on these data types should satisfy the following mathematical properties: The basic idea behind CRDT is to use some data types that make resolving conflicts extremely simple. Since real-time doc editing usually represents a distributed system with multiple clients and servers, it also makes sense to use this approach for building a real-time text editor.Īpple Notes app uses CRDT for syncing offline edits between devices. For example, databases such as Redis Enterprise or Riak, cross node syncing in Elixir Phoenix, building privacy-centric alternatives to Zoom or YouTube with GUN. It is used for building various types of distributed systems. ![]() Conflict-free Replicated Data Type (CRDT)ĬRDT is a relatively new concept that was created to solve some problems in distributed computing. ![]() Hard to maintain users’ local text cursor/selection positions.ģ.Requires users’ input that might be frustrating if that happens very often. It’s not always possible to diff and merge changes correctly.Great for merging changes made offline or asynchronously (like Git).That’s why Git, for example, delegates resolving some conflicts to developers, as there is not enough context for it to know what the expected outcome is. Here it’s hard to tell exactly what’s going to happen, whether we should make the added character bold “ Foio” or keep it not bold “ Foi o” or merge everything “Foio Foo”. For example, Alice added a character “i” to have “Foio” and Bob made the whole word bold “ Foo”. One disadvantage is that it’s sometimes impossible to properly merge conflicting changes. The initial Google Docs version used the “diff and merge” approach until it was rewritten by using operational transformation (OT). Find a diff between changes and then merge them ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |