Save xml not working in custom element version

I followed your guide on github to customize the tool adding elements and parameters.
Everything works fine, I run it with npm as explained and it looks good.
The problem is when I want to export the XML: I added this in the app.js file:

async function exportDiagram() {
  try {
    var result = await bpmnModeler.saveXML({ format: true });
    alert('Diagram exported. Check the developer tools!');
    console.log('DIAGRAM', result.xml);
  } catch (err) {
    console.error('could not save BPMN 2.0 diagram', err);

exportButton.addEventListener('click', (event) => {

but when I click on the exportButton I get this error:

app.js:50 could not save BPMN 2.0 diagram TypeError: done is not a function
    at Viewer.js:370

What am I missing? Thank you very much if you can help!

What version of bpmn-js are you using? I was not able to reproduce the issue on my codesandbox.

Sorry, I was not really specific.
I downloaded, modified and ran this example, and I was trying to add an export function in the app.js of this version.

Oh, the version of bpmn-js is super old in that example. Please run npm install bpmn-js@latest in your project so that the Promise-based APIs are available.

1 Like