Hello @barmac, thank you for your reply
I have tried this but sadly I can’t find a way to make it work. (To be honest it is pretty difficult…)
If I understand it, this solution implies to have two distinct Modeling modules provided to the Modeler : the custom one that has the custom command stack and the default one. Is that correct ?
I can have two distinct command stacks with no problem
but as you expected that is useless without a second, custom modeling module.
As it turns out, you cannot have two modeling modules with different names in a modeler instance. This crashes when calling its constructor and returns an Error: overriding handler for command <shape.append> (see this post).
On the other hand, calling your custom modeling module “modeling” overrides the default one and it looks like you cannot use both.
Here is my code for the latter case :
In CustomModeling.js :
import Modeling from 'diagram-js/lib/features/modeling/Modeling.js'
import CommandStack from 'diagram-js/lib/command/CommandStack.js'
export var CustomCommandStackModule = {
__init__: [ 'customCommandStack' ],
customCommandStack: [ 'type', CommandStack ]
}
var CustomModeling = {
__init__: [ 'modeling' ],
customModeling: [ 'type', Modeling ]
}
CustomModeling.$inject = [ 'eventBus', 'elementFactory', 'customCommandStack' ]
export default CustomModeling
In my code using modeler :
import BpmnModeler from 'bpmn-js/lib/Modeler'
import CustomModelingModule, { CustomCommandStackModule } from '../../lib/custom-modeling/CustomModeling.js'
var modeler = new BpmnModeler({
additionalModules: [
CustomCommandStackModule,
CustomModelingModule,
]
})
var modeling = modeler.get('modeling')
var commandStack = modeler.get('commandStack')
var customCommandStack = modeler.get('customCommandStack')
console.log(commandStack === customCommandStack) // returns false
// we have two different stacks :)
// Then, all actions performed using modeling,
// programmatically and by the user,
// are added to the default command stack.
// The custom command stack is never changed :(
Did I make a mistake ?
Thank you for your time, sorry for asking for more help again.