undo and redo in jointJs #1654
-
|
Hi, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
The undo/redo functionality is available only in The const changes = [];
graph.on('change', cell => changes.push([cell.id, cell.changed]));
function undo() {
if (changes.length === 0) return;
const [id, change] = changes.pop();
graph.getCell(id).set(change);
} |
Beta Was this translation helpful? Give feedback.
The undo/redo functionality is available only in
JointJS+(https://resources.jointjs.com/docs/rappid/v3.5/dia.CommandManager.html).The
CommandManagerplugin fromJointJS+listens for all changes to the graph and saves the deltas of the changes. Here's a simplified example (the plugin also handles cell addition/removal, recognizes batch changes and filters redundant changes).