How can i save diagram and svg in angular

How can i save diagram and svg bpmn in angular

What did you try? Where did you get stuck?

i got this error :“ERROR TypeError: this.saveSVG is not a function”

this codes:

import BpmnModeler from 'bpmn-js/lib/Modeler';
  ngOnInit(): void {

    this.modeler = new BpmnModeler({

      container: '#canvas-js',
      width: '100%',
      height: '600px',


    });

   saveSVG(done) {
     this.modeler.saveSVG(done);
   }

    this.saveSVG((err, svg)=> {
      setEncoded(downloadSvgLink, 'diagram.svg', err ? null : svg);
    });

The error is saying exactly what is happening. You’ll have to create the saveSVG function so it is accessible in your component. This

saveSVG(done) {
     this.modeler.saveSVG(done);
}

is not working. Rather store the function as local variable

const saveSVG = (done) => {
   this.modeler.saveSVG(done);
};

saveSVG((err, svg) => {
   setEncoded(downloadSvgLink, 'diagram.svg', err ? null : svg);
});

Or outside the ngOnInit method to bind it to this.

i put outside ngOnInit but got this error

ERROR TypeError: done is not a function
    at Modeler.push../node_modules/bpmn-js/lib/Viewer.js.Viewer.saveSVG

have you tried Anyone can help me?

i solved it

this.modeler.saveSVG((err: any, svg: any) => {
  const blob = new Blob([svg], {type: 'text/plain;charset=utf-8'});
  FileSaver.saveAs(blob, 'bpmnSample.bpmn');
});

can you please send me html code for that is there any button we need to call saveSVG

Please do not necrobump old topics. Instead link to this thread from new topic.

can you please help how to customize proeprties panel when i select element custom proeprites added in properties panel

As @Niklas_Kiefer said, no necrobumping.