I’m ultimately trying to get access to the model XML from within a Modeler plugin, but every time I inject a ‘bpmnjs’ object (with the vain hope of finding a saveXML function) the modeler crashes when I create a new BPMN model.
If I take out the injection of this service it starts up OK.
What am I doing wrong, and more importantly where can I find some definitive documentation on what is valid to be injected?
Thanks
Example code is as follows:
'use strict';
var http = require('http');
function InsurtechUploadPlugin(bpmnjs, eventBus, elementRegistry, editorActions, canvas, modeling) {
this._elementRegistry = elementRegistry;
this._modeling = modeling;
this._canvas = canvas;
this._eventBus = eventBus;
this._bpmnjs = bpmnjs;
var self = this;
eventBus.on('shape.added', function(event) {
console.log('A shape was added to the diagram!');
});
editorActions.register({
uploadModel: function() {
self.doTheWork();
}
});
}
InsurtechUploadPlugin.prototype.doTheWork = function() {
console.log("Do the work ... ", this._bpmnjs);
http.get({
host: 'www.google.co.uk',
path: '/'
}, function(response) {
var body = '';
response.on('data', function(d) {
body += d;
});
response.on('end', function() {
// console.log("->", body);
});
});
};
InsurtechUploadPlugin.$inject = [ 'eventBus', 'elementRegistry', 'editorActions', 'canvas', 'modeling', 'bpmnjs' ];
module.exports = {
__init__: ['insurtechUploadPlugin'],
insurtechUploadPlugin: ['type', InsurtechUploadPlugin]
};