Skip to content
Discussion options

You must be logged in to vote

The undo/redo functionality is available only in JointJS+ (https://resources.jointjs.com/docs/rappid/v3.5/dia.CommandManager.html).

The CommandManager plugin from JointJS+ 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).

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);
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Mohanakrishnan96
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants