Skip to Content

撤消和重做

本示例演示了如何为 React Flow 图表实现撤消和重做功能。用户可以在移动、添加或删除节点和边时跟踪和恢复更改。该实现使用基于快照的方法,并使用 useUndoRedo hook 管理过去和未来的状态,允许用户通过点击按钮或键盘快捷键(Ctrl+Z 和 Ctrl+Shift+Z)浏览编辑历史记录。

¥This example demonstrates how to implement undo and redo functionality for a React Flow graph. Users can track and revert changes when moving, adding, or deleting nodes and edges. The implementation uses a snapshot-based approach with the useUndoRedo hook that manages past and future states, allowing users to navigate through their editing history with button clicks or keyboard shortcuts (Ctrl+Z and Ctrl+Shift+Z).

This is a Pro example. Get all pro examples, templates, 1:1 support from the xyflow team and prioritized Github issues with a React Flow Pro subscription.

关于此 Pro 示例

¥About this Pro Example

Last updated on