rete-history-plugin
packageHistory plugin extensions
Adds keyboard shortcuts for history undo/redo
keyboard(plugin: HistoryPlugin<Schemes, A>): void
Parameter | Type | Description |
---|---|---|
plugin | HistoryPlugin<Schemes, A> | History plugin instance |
Returns void
Presets for the history plugin
Classic preset for the history plugin. Tracks node adding/removing/translating, connection adding/removing.
setup(props: { timing: number }): Preset<S, HistoryActions<S>>
Parameter | Type | Description |
---|---|---|
props | { timing: number } |
Returns Preset<S, HistoryActions<S>>
History plugin. Allows to undo/redo actions such as adding/removing nodes, connections, etc.
class HistoryPlugin<Schemes extends BaseSchemes, A extends HistoryAction>
Parameter | Extends | Description |
---|---|---|
Schemes | BaseSchemes | |
A | HistoryAction |
Extends Scope<never, BaseArea
constructor(props: { timing: number }): HistoryPlugin<Schemes, A>
Parameter | Type | Description |
---|---|---|
props | { timing: number } | History plugin properties |
Returns HistoryPlugin<Schemes, A>
Adds an action to the history
add(action: A): void
Parameter | Type | Description |
---|---|---|
action | A | Action instance |
Returns void
Adds a preset to the history plugin
addPreset(preset: Preset<Schemes, T>): void
Parameter | Type | Description |
---|---|---|
preset | Preset<Schemes, T> | Preset that manages some actions, e.g. classic preset for adding/removing nodes, connections, etc. |
Returns void
Clear history
clear(): void
Returns void
Get produced history records
getHistorySnapshot(): HistoryRecord<A>[]
Returns HistoryRecord<A>[]
History snapshot
Get recent history records produced in the last ms
milliseconds
getRecent(ms: number): HistoryRecord<A>[]
Parameter | Type | Description |
---|---|---|
ms | number | Delta time in milliseconds |
Returns HistoryRecord<A>[]
History records produced in the last
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
redo(): Promise<void>
Returns Promise<void>
separate(): void
Returns void
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
undo(): Promise<void>
Returns Promise<void>
Base interface for all actions
Examples
export class CustomAction<S extends BaseSchemes> implements HistoryAction {
async undo() {
// undo logic
}
async redo() {
// redo logic
}
}