yjs-orderedtree
Version:
An ordered tree class for yjs. Lets you use a Y.Map like an ordered tree with insert, delete, and move operations. The children are ordered and the position of a child amongst its sibling can be manipulated
33 lines (32 loc) • 932 B
TypeScript
/**
* @typedef {Object} ComputedMapNode
* @property {string} id
* @property {ComputedMapNode} parent
* @property {Array} children
* @property {Map} edges
*/
/**
*
* @param {ComputedMapNode} node
* @returns {string}
*
* @description
* The edge with the largest counter is considered to be the most recent one.
* If two edges are set simultaneously, the identifier breaks the tie.
*/
export function edgeWithLargestCounter(node: ComputedMapNode): string;
/**
*
* @param {string} before
* @param {string} after
* @returns {string}
* @description https://madebyevan.com/algos/crdt-fractional-indexing/
* TODO: Look into allowing logarithimic key growth for generating an appending or prepending order index
*/
export function insertBetween(before: string, after: string): string;
export type ComputedMapNode = {
id: string;
parent: ComputedMapNode;
children: any[];
edges: Map<any, any>;
};