@odoo/o-spreadsheet
Version:
A spreadsheet component
64 lines (63 loc) • 2.25 kB
TypeScript
import { Transformation, TransformationFactory } from "../types/history";
import { UID } from "../types/misc";
import { Operation } from "./operation";
/**
* A branch holds a sequence of operations.
* It can be represented as "A - B - C - D" if A, B, C and D are executed one
* after the other.
*
* @param buildTransformation Factory to build transformations
* @param operations initial operations
*/
export declare class Branch<T> {
private readonly buildTransformation;
private operations;
constructor(buildTransformation: TransformationFactory<T>, operations?: Operation<T>[]);
getOperations(): readonly Operation<T>[];
getOperation(operationId: UID): Operation<T>;
getLastOperationId(): UID | undefined;
/**
* Get the id of the operation appears first in the list of operations
*/
getFirstOperationAmong(op1: UID, op2: UID): UID;
contains(operationId: UID): boolean;
/**
* Add the given operation as the first operation
*/
prepend(operation: Operation<T>): void;
/**
* add the given operation after the given predecessorOpId
*/
insert(newOperation: Operation<T>, predecessorOpId: UID): void;
/**
* Add the given operation as the last operation
*/
append(operation: Operation<T>): void;
/**
* Append operations in the given branch to this branch.
*/
appendBranch(branch: Branch<T>): void;
/**
* Create and return a copy of this branch, starting after the given operationId
*/
fork(operationId: UID): Branch<T>;
/**
* Transform all the operations in this branch with the given transformation
*/
transform(transformation: Transformation<T>): void;
/**
* Cut the branch before the operation, meaning the operation
* and all following operations are dropped.
*/
cutBefore(operationId: UID): void;
/**
* Cut the branch after the operation, meaning all following operations are dropped.
*/
cutAfter(operationId: UID): void;
/**
* Find an operation in this branch based on its id.
* This returns the operation itself, operations which comes before it
* and operation which comes after it.
*/
private locateOperation;
}