I wanted to introduce a project I’m working on. Here is the repository: GitHub - Tulip-Writer/yjs-orderedtree: Provides a class for yjs that lets you use a Y.Map like an ordered tree
A while ago, I was reading through CRDT: Mutable Tree Hierarchy - Made by Evan out of curiosity and the thought of using yjs to implement this came to my head and stayed in the back of my head until a week ago.
You can read about how it and how it works in the readme of the repo, but tldr: the provided class stores all the nodes of the tree in a ‘flat’ manner in a Y.Map. It maintains a virtual hierarchical map where every node has a link to its parent and children. Whenever there is an update to the ordered tree, the virtual map is updated using the logic for mutable tree hierarchy.
Ordering is done using fractional indexing from evan wallace’s site because why not.
I hope people find this useful and this is something of a first for me so I would appreciate feedback. Also I welcome anyone who wants to contribute/improve on this.