Currently I’ve got this setup:
import RuleProvider from 'diagram-js/lib/features/rules/RuleProvider';
import { ElementType, EventBus, Shape } from '../models/bpmn';
export class CustomRules extends RuleProvider {
[x: string]: any;
constructor(eventBus: EventBus) {
super(eventBus);
}
static inject$ = ['eventBus'];
addRule(actions: string | string[], priority: number, cb: Function) {
if (typeof actions === 'string') {
actions = [actions];
}
actions.forEach(action => {
this.canExecute(action, priority, (context, action, event) => {
return cb(context);
}, true)
})
}
init() {
// my rules
}
}
But I would like to inject element registry to get information about the elements on the diagram to add some extra rules. For example, I want to restrict users from adding start event from the pallette if it already exists on the diagram.
How do I do that?
Just adding elementRegistry to the constructor and to inject$ array didn’t work.