Skip to main content

UndoService

Defined in: js-api/src/shell.ts:414

Multi-level undo/redo. Records are kept in memory only, are bounded by count and by size, and are dropped when the table or view they belong to is closed.

Example​

const before = column.get(0);
column.set(0, 42);
DG.UndoService.push('Set value', () => column.set(0, before), {
redo: () => column.set(0, 42),
context: column.dataFrame
});

Constructors​

Constructor​

new UndoService(): UndoService

Returns​

UndoService

Accessors​

redoName​

Get Signature​

get static redoName(): string | null

Defined in: js-api/src/shell.ts:429

Returns​

string | null


undoName​

Get Signature​

get static undoName(): string | null

Defined in: js-api/src/shell.ts:428

Returns​

string | null

Methods​

clear()​

static clear(): void

Defined in: js-api/src/shell.ts:432

Drops both stacks.

Returns​

void


ownScope()​

static ownScope(element): void

Defined in: js-api/src/shell.ts:437

Claims Ctrl+Z for [element]: while focus is inside it, the platform does not undo. Use it for embedded editors (sketchers, graph editors, notebooks) that keep their own history, instead of installing a document-level key handler.

Parameters​

ParameterType
elementHTMLElement

Returns​

void


push()​

static push(name, undo, options?): void

Defined in: js-api/src/shell.ts:417

Registers an undoable operation that has already been performed. Without [options.redo] the operation can be undone but not redone.

Parameters​

ParameterType
namestring
undo() => void
options?{ context?: any; redo?: () => void; }
options.context?any
options.redo?() => void

Returns​

void


releaseScope()​

static releaseScope(element): void

Defined in: js-api/src/shell.ts:440

Returns Ctrl+Z to the platform. See ownScope.

Parameters​

ParameterType
elementHTMLElement

Returns​

void


run()​

static run<T>(name, action, undo, options?): T

Defined in: js-api/src/shell.ts:422

Performs [action] and registers [undo] as its inverse.

Type Parameters​

Type Parameter
T

Parameters​

ParameterType
namestring
action() => T
undo() => void
options?{ context?: any; redo?: () => void; }
options.context?any
options.redo?() => void

Returns​

T