I would like to register a custom menu action for a menu entry and execute a bpmnjs plugin when this event is emitted.
This is related to Listen to menu event with client plugin in Camunda Modeler. I don’t quite get how to register a new event. What I have so far:
menu.js:
module.exports = function(electronApp, menuState) {
return [{
label: 'Do Something',
enabled: function() {
return menuState.bpmn;
},
action: function() {
electronApp.emit('menu:action', "do-something");
}
}];
};
ClientPlugin.js:
export default function ClientPlugin(eventBus) {
eventBus.on("do-something", (event) => {
console.log(event)
})
}
ClientPlugin.$inject = [
'eventBus'
];
The plugin as well as the menu entry are correctly loaded.
However, when I click the ‘Do Something’ I get the error message:
do-something is not a registered action
at o (webpack:///node_modules/diagram-js/lib/features/editor-actions/EditorActions.js:257:9)
at error (webpack:///node_modules/diagram-js/lib/features/editor-actions/EditorActions.js:167:10)
at trigger (webpack:///src/app/tabs/bpmn/BpmnEditor.js:630:40)
at triggerAction (webpack:///src/app/tabs/MultiSheetTab.js:270:18)
at triggerAction (webpack:///src/app/tabs/EditorTab.js:36:33)
at triggerAction (webpack:///src/app/App.js:1718:15)
at fn (webpack:///src/app/App.js:2186:19)
at file:///C:/Users/alneuman/workspace/camunda-modeler-4.9.0-win-x64/resources/app.asar/public/bundle.js:65:144104
at exec (webpack:///src/app/AppParent.js:76:11) [ error ]
Is electronApp.emit
the right method for my use case? I tried to listen to bpmn.modeler.configure
in ClientPlugin.js
with eventBus.on
to maybe get the editorActions
as suggested by the post above but I guess this event has already been processed or is currently processed when the plugin is loaded since the callback is never called.