The a Camunda Modeler Plugin, how I can read the bpmn xml string, update it, and show the update in the Camunda Modeler immediately? Where I can find the more detail reference about plugin implementation?
Thanks
Steven
The a Camunda Modeler Plugin, how I can read the bpmn xml string, update it, and show the update in the Camunda Modeler immediately? Where I can find the more detail reference about plugin implementation?
Thanks
Steven
Hi @steventao,
you can inject the bpmn-js instance into the plugin to get the XML.
here are some links where you can find some modeler plugins [1], examples [2] and documentation [3].
[1] https://github.com/camunda/camunda-modeler-plugins
[2] https://github.com/camunda/camunda-modeler-plugin-example
[3] https://github.com/camunda/camunda-modeler/tree/master/docs/plugins
Cheers
kristin
Kristin
Thank you very much for your reply.
How I can inject the bpmn-js instance into the plugin to get the XML? Do you have a simple code?
Thank you again.
Steven
Hi @steventao,
when you take the LoggingPlugin from the documentation, you can use the following line.
LoggingPlugin.$inject = [ 'eventBus', 'bpmnjs' ];
The whole extended LoggingPlugin:
function LoggingPlugin(eventBus, bpmnjs) {
eventBus.on('shape.added', function() {
console.log('A shape was added to the diagram!');
});
eventBus.on('import.done', function() {
bpmnjs.saveXML(function(err, xml) {
if (!err) {
console.log(xml);
}
});
});
}
LoggingPlugin.$inject = [ 'eventBus', 'bpmnjs' ];
module.exports = {
__init__: [ 'loggingPlugin' ],
loggingPlugin: [ 'type', LoggingPlugin ]
};
Cheers
kristin
Kristin
Thank you very much. It works.
Another question, where I can find the information regarding what kind of service can be injected into plugin?
Thanks
Steven
Bump - I’d quite like some info on what can be injected too …
You can find out here which modules are included into the Modeler (and then look into the separate module which modules they are injecting separately).
The BpmnEditor of the Camunda Modeler additionally includes some modules itself. All modules which are included into the Modeler can be injected inside a plugin.