“Text editing requires ordered Sequence CRDTs. Replicated Growable Array (RGA) and Yjs YATA model text not as string character arrays, but as a linked list of immutable Item nodes identified by (clientID, clock). Fractional Indexing generates dense mathematical identifiers (e.g. between "0.1" and "0.2" insert "0.15") to insert characters without shifting other item indices.”
How modern collaborative editors (Yjs, Automerge, Figma) model rich text as linked trees of immutable character nodes with fractional indices.
// Sequence CRDT Node Structure (RGA / YATA Style)
interface SequenceItem {
id: { client: string; clock: number };
originLeft: { client: string; clock: number } | null;
originRight: { client: string; clock: number } | null;
value: string;
deleted: boolean;
}
// Inserting between items generates unique immutable node ID
function createItem(client: string, clock: number, left: SequenceItem | null, val: string): SequenceItem {
return {
id: { client, clock },
originLeft: left ? left.id : null,
originRight: null,
value: val,
deleted: false,
};
}User types character "B" between node A (id: alice:1) and node C (id: bob:3)
Engine creates new Item node: id=(alice:2), leftOrigin=(alice:1), rightOrigin=(bob:3), val="B"
Transmits item to peers as a single compact binary struct
Peer receives item: executes YATA / RGA conflict resolution (orders by clientID if concurrent)
Inserts item into local linked list in constant time
Yjs Run-Length Encoding merges adjacent consecutive character insertions into single Block chunks, reducing memory footprint by 85%.