json-joy
Version:
Collection of libraries for building collaborative editing apps.
33 lines (32 loc) • 957 B
TypeScript
import type { Patch } from '../../json-crdt-patch';
import type { Model } from '../model';
/**
* Terminology:
*
* - `remote`: the state of the document that is known to the remote server/peers.
* - `base`: the next state of the document which is in the process of being saved to the remote server.
* - `head`: the current state of the document which is being edited by the user.
* - `tip`: the future state of the document, ahead of `head`, could be due to undo/redo.
*
* The `log` starts at `remote` and ends at `tip`, the `base` and `head` pointers
* are in the middle of the `log`.
*/
export interface DraftOptions {
base: Model;
head: Patch[];
tip: Patch[];
}
export declare class Draft {
base: Model;
head: Model;
tip: Patch[];
constructor(opts: DraftOptions);
/**
*
* @param patches
*/
rebase(patches: Patch[]): void;
advance(index: number): void;
undo(): void;
redo(): void;
}