How to control what is put into the dia.CommandManager undo stack? #1676
-
Hi i have use commandManager.undo() in my jointjs demo but is also undo the toFront action so when i want to undo a el I have to press undo btn many time so i have a question can i ignore or pass the toFront and toBack when i press undo or redo |
Beta Was this translation helpful? Give feedback.
Answered by
kumilingus
May 25, 2022
Replies: 1 comment
-
According to the documentation, you can ignore commands with the 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 commandManager.initBatchCommand();
element.set('a', true);
element.set('b', true);
commandManager.storeBatchCommand();
// Single undo() now reverts both changes
commandManager.undo();
element.get('a') !== true;
element.get('b') !== true; This is an equivalent to: // Assert: element was added to the `graph`
graph.startBatch('my-batch-name');
element.set('a', true);
element.set('b', true);
graph.stopBatch('my-batch-name'); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Ndmanh123
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
According to the documentation, you can ignore commands with the
cmdBeforeAdd
callback option.or
You can also group commands together with
initBatchCommand()
andstoreBatchCommand()
.