API for rete-history-plugin package - Rete.js

API for rete-history-plugin package

HistoryExtensions

extensions/index.ts

History plugin extensions

keyboard

extensions/keyboard.ts

Adds keyboard shortcuts for history undo/redo

ts
keyboard(plugin: HistoryPlugin<Schemes, A>): void
ParameterTypeDescription
pluginHistoryPlugin<Schemes, A>History plugin instance

Returns void

Presets

presets/index.ts

Presets for the history plugin

classic

presets/classic/index.ts

setup

presets/classic/index.ts

Classic preset for the history plugin. Tracks node adding/removing/translating, connection adding/removing.

ts
setup(props: { timing: number }): Preset<S, HistoryActions<S>>
ParameterTypeDescription
props{ timing: number }

Returns Preset<S, HistoryActions<S>>

HistoryPlugin

index.ts

History plugin. Allows to undo/redo actions such as adding/removing nodes, connections, etc.

ts
class HistoryPlugin<Schemes extends BaseSchemes, A extends HistoryAction>
ParameterExtendsDescription
SchemesBaseSchemes
AHistoryAction

Extends Scope<never, BaseArea, Root>

constructor

index.ts

ts
constructor(props: { timing: number }): HistoryPlugin<Schemes, A>
ParameterTypeDescription
props{ timing: number }History plugin properties

Returns HistoryPlugin<Schemes, A>

add

index.ts

Adds an action to the history

ts
add(action: A): void
ParameterTypeDescription
actionAAction instance

Returns void

addPreset

index.ts

Adds a preset to the history plugin

ts
addPreset(preset: Preset<Schemes, T>): void
ParameterTypeDescription
presetPreset<Schemes, T>Preset that manages some actions, e.g. classic preset for adding/removing nodes, connections, etc.

Returns void

clear

index.ts

Clear history

ts
clear(): void

Returns void

getHistorySnapshot

index.ts

Get produced history records

ts
getHistorySnapshot(): HistoryRecord<A>[]

Returns HistoryRecord<A>[] History snapshot

getRecent

index.ts

Get recent history records produced in the last ms milliseconds

ts
getRecent(ms: number): HistoryRecord<A>[]
ParameterTypeDescription
msnumberDelta time in milliseconds

Returns HistoryRecord<A>[] History records produced in the last

redo

index.ts

Asynchronously redoes an actions until the separated flag is encountered or the time between the current and previous action exceeds timing property which is 200ms by default

ts
redo(): Promise<void>

Returns Promise<void>

separate

index.ts

ts
separate(): void

Returns void

undo

index.ts

Asynchronously undoes an actions until the separated flag is encountered or the time between the current and previous action exceeds timing property which is 200ms by default

ts
undo(): Promise<void>

Returns Promise<void>

HistoryAction

types.ts

Base interface for all actions

Examples

ts
export class CustomAction<S extends BaseSchemes> implements HistoryAction {
 async undo() {
   // undo logic
 }
 async redo() {
   // redo logic
 }
}