Skip to content

How to control what is put into the dia.CommandManager undo stack? #1676

Answered by kumilingus
Ndmanh123 asked this question in Q&A
Discussion options

You must be logged in to vote

According to the documentation, you can ignore commands with the cmdBeforeAdd callback option.

const commandManager = new dia.CommandManager({
    graph,
    cmdBeforeAdd: (cmdName, cell, graph, options = {}) => {
        return !options.ignoreCommandManager;
    }
});

element.toFront({ ignoreCommandManager: true });

or

const commandManager = new dia.CommandManager({
    graph,
    cmdBeforeAdd: (cmdName) => cmdName !== 'change:z'
});

element.toFront();

You can also group commands together with initBatchCommand() and storeBatchCommand().

commandManager.initBatchCommand();
element.set('a', true);
element.set('b', true);
commandManager.storeBatchCommand();
// Single undo() now reverts bo…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Ndmanh123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
jointjs+ The paid commercial extension to the JointJS
2 participants