This example demonstrates how to add undo and redo functionality to a flow-based diagram built with Foblex Flow. It uses @foblex/mutator, a lightweight state management utility for snapshots, history, and predictable state transitions.
Use this version when your editor already has enough state complexity that you want a dedicated history layer instead of ad hoc manual stacks.
[example.html] <<< https://raw.githubusercontent.com/Foblex/f-flow/main/libs/f-examples/advanced/undo-redo-v2/example.html [example.ts] <<< https://raw.githubusercontent.com/Foblex/f-flow/main/libs/f-examples/advanced/undo-redo-v2/example.ts [example.scss] <<< https://raw.githubusercontent.com/Foblex/f-flow/main/libs/f-examples/advanced/undo-redo-v2/example.scss
Before running this example, install the additional package:
update() call when they should be undone as a single step.This version is a better fit for editors that already have complex state and need a more disciplined history model.