When user click the “save file” menu item, I would like to do some update on bpmn diagram and save it. The code looks like below.
function LoggingPlugin(canvas, eventBus, bpmnFactory, bpmnjs) {
var self = this;
this._canvas = canvas;
this._bpmnFactory = bpmnFactory;
this._bpmnjs = bpmnjs;
this.electron = window.require(‘electron’);
this.electron.remote.app.on(‘menu:action’, function (action, options) {
if (action === ‘save’) {
var definitions = this._canvas.getRootElement().businessObject.$parent;
var rootElements = definitions.rootElements;
// Add message
var msg = this._bpmnFactory.create("bpmn:Message");
msg.name = 'testMessage';
rootElements["0"].flowElements.push(msg);
// How save this update bpmn?
}
}.bind(this));
}
My question is how I can save this updated bpmn diagram? Second question is how catch the this “save file” event if user click on the toolbar item?
Thanks
Steven