Foblex Flow
Introduction
Overview
Nodes
Custom Nodes
Drag Handle
Node Selection
Resize Handle
Rotate Handle
Grouping
Updated
Drag to Group
Updated
Stress Test
Stress Test with Connections
Connectors
Node as Connector
Connector Inside Node
Connector Outlet
Limiting Connections
Connectability Check
Connectable Side
Connections
Drag to Connect
Drag to Reassign
Updated
Create Node on Connection Drop
Remove Connection on Drop
Assign Node to Connection on Drop
Auto Snap
Connection Types
Custom Connection Type
Connection Behaviours
Connection Markers
Connection Text
Connection Center
Custom Connections
Extensions
Add Node from Palette
Selection Area
Help in Positioning
Grid System
Minimap
Zoom
Background
Advanced
Cut/Copy/Paste
New
Undo/Redo
Undo/Redo V2
New
Dagre Layout
ELKJS Layout
Drag Start/End Events
Custom Event Triggers
Pro Examples
Visual Programming
DB Management
UML Diagram
Tournament Bracket
Foblex Flow

Undo/Redo v2

Description

This example demonstrates how to add undo and redo functionality to a flow-based diagram built with Foblex Flow. Undo/redo gives users the ability to revert recent changes or reapply reverted actions, creating a smoother and more interactive editing experience.

The implementation is based on @foblex/mutator, a lightweight state management utility that tracks state changes, snapshots, and history. With it, you can maintain a stack of operations and easily implement time-travel behavior inside your editor.

Installation

Before running this example, install the additional package:

Practical tips

  • Use @foblex/mutator whenever your editor requires time-traveling operations.
  • Keep the state flat and serializable (no cyclic refs, functions, or DOM nodes).
  • Group multiple actions into one update() call when they should be undone as a single step.
  • Undo/redo is not limited to nodes and connections — you can also manage selections, canvas transforms, or custom properties.

Example

[component.html] <<< https://raw.githubusercontent.com/Foblex/f-flow/main/projects/f-examples/advanced/undo-redo-v2/undo-redo-v2.html [component.ts] <<< https://raw.githubusercontent.com/Foblex/f-flow/main/projects/f-examples/advanced/undo-redo-v2/undo-redo-v2.ts [component.scss] <<< https://raw.githubusercontent.com/Foblex/f-flow/main/projects/f-examples/advanced/undo-redo-v2/undo-redo-v2.scss [common.scss] <<< https://raw.githubusercontent.com/Foblex/f-flow/main/projects/f-examples/_flow-common.scss