DefinitelyTyped/types/ot/index.d.ts
2020-04-06 10:14:55 -07:00

42 lines
1.3 KiB
TypeScript

// Type definitions for ot 0.0
// Project: https://github.com/Operational-Transformation/ot.js
// Definitions by: Christian Alfoni <https://github.com/christianalfoni>
// Ives van Hoorne <https://github.com/CompuIves>
// Michaël De Boey <https://github.com/MichaelDeBoey>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export class Selection {
createCursor(position: number): Selection;
}
export namespace Selection {
class Range {
constructor(anchor: number, head: number);
transform(operation: TextOperation): Range;
anchor: number;
head: number;
}
}
export type SerializedTextOperation = Array<string | number>;
export class TextOperation {
delete(length: number): TextOperation;
insert(str: string): TextOperation;
retain(length: number): TextOperation;
baseLength: number;
targetLength: number;
apply(code: string): string;
compose(operation: TextOperation): TextOperation;
static transform(left: TextOperation, right: TextOperation): TextOperation;
static isRetain(operation: TextOperation): boolean;
static isInsert(operation: TextOperation): boolean;
static isDelete(operation: TextOperation): boolean;
static fromJSON(operation: SerializedTextOperation): TextOperation;
toJSON(): SerializedTextOperation;
}