0

我在我的网站上使用 bpmn-js 查看器(使用角度开发)并将 xml 解析到数据库中。查看时如何为一个元素着色

import * as BpmnJS from 'bpmn-js/dist/bpmn-navigated-viewer.production.min.js';
.
.
.
 private bpmnJS: BpmnJS;
.
.
.
 constructor(private http: HttpClient, private route: ActivatedRoute,) {
    this.url = "assets/bpmn/" + this.route.snapshot.queryParamMap.get('furl');
    this.bpmnJS = new BpmnJS();
    this.loadUrl(this.url);
    
    this.bpmnJS.on('import.done', (error: any) => {
      if (!error) {
        this.bpmnJS.get('canvas').zoom('fit-viewport');

      }
    });
  }

  loadUrl(url: string): Subscription {

    return (
      this.http.get(url, { responseType: 'text' }).pipe(
        switchMap((xml: string) => this.importDiagram(xml)),
        map(result => result.warnings),
      ).subscribe(
        (warnings) => {
          this.importDone.emit({
            type: 'success',
            warnings
          });
        },
        (err) => {
          this.importDone.emit({
            type: 'error',
            error: err
          });
        }
      )
    );
  }

 private importDiagram(xml: string): Observable<{ warnings: Array<any> }> {
    return from(this.bpmnJS.importXML(xml) as Promise<{ warnings: Array<any> }>);
  }

如何通过 id 为一个元素着色(或指定),例如从数据库中检索的“Activity_1je8h8x”并在查看器中为其添加标题(标题也从数据库中检索)

4

0 回答 0