<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ghalia on Medium]]></title>
        <description><![CDATA[Stories by Ghalia on Medium]]></description>
        <link>https://medium.com/@galloooshareif?source=rss-1c16dd4fb959------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Shd7xdrNvwGw_i80</url>
            <title>Stories by Ghalia on Medium</title>
            <link>https://medium.com/@galloooshareif?source=rss-1c16dd4fb959------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 22:13:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@galloooshareif/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How To Add BPMN Editor in your Angular Project?]]></title>
            <link>https://medium.com/@galloooshareif/how-to-add-bpmn-editor-in-your-angular-project-f3338cdd8364?source=rss-1c16dd4fb959------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3338cdd8364</guid>
            <category><![CDATA[camunda]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[bpmn-diagram]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Ghalia]]></dc:creator>
            <pubDate>Wed, 15 Jan 2025 07:20:18 GMT</pubDate>
            <atom:updated>2025-01-16T06:45:20.066Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello everyone👋</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4WPbS4IvfvT4uZ3kXOB54Q.png" /></figure><p>Creating a BPMN could sound challenging, let alone implement it into an Angular project, so i decided to write this article to show its not as hard as it sounds, -like everything in the tech world😁-. So here’s your guide to create/edit BPMN diagrams in Angular projects.</p><h3>What is BPMN?</h3><p>BPMN is shortage for Business Process Management Notion and it used in Camunda workflows to automate tasks.</p><h3>Use case</h3><p>In your project perhaps you want to give the user the ability to create and deploy a workflow or just view a workflow.</p><h3>How?</h3><p>to do so, here in this implementation I’ve used <a href="https://www.npmjs.com/package/camunda-bpmn-js">camunda-bpmn-js</a> library since my requirements were Camunda’s specific, for general use you could go with <a href="https://www.npmjs.com/package/bpmn-js">bpmn-js</a>, since its more generic.</p><h4>When to use bpmn-js and when to use Camunda-bpmn-js?</h4><p>bpmn-js have a great capabilities, and huge modules library to integrate with. Camuda-bpmn-js is built on bpmn-js an it’s modules, such as: bpmn-js-properies-panel, camunda-bpmn-js-behaviors, and more. which encapsulates all Camunda’s specific characteristics so you don’t have to add all modules one by one, and of course for simplicity and abstraction you can always use the original bpmn-js. In this use case my workflow engine was Camunda so the best choice was to go with camunda-bpmn-js.</p><p>Without further ado, lets jump to implementation. First you should install the library using npm -or yarn- :</p><pre>npm i camunda-bpmn-js</pre><p>Then import it into your page</p><pre>import BpmnModeler from &#39;camunda-bpmn-js/lib/base/Modeler&#39;;<br>import &#39;camunda-bpmn-js/dist/assets/camunda-platform-modeler.css&#39;;</pre><p>Note that when dealing with any bpmn-js related libraries it’s important to <em>include the style sheets explicitly</em> in your project.</p><p>Then create an object of bpmn-modeler</p><pre>private modeler: BpmnModeler;</pre><p>Then initiate that object</p><pre>initBpmn(): void {<br>    this.modeler = new BpmnModeler({<br>      container: &#39;#canvas&#39;,<br>      propertiesPanel: {<br>        parent: &#39;#properties&#39;,<br>      },<br>    });<br>  }</pre><p>You can add whatever extra libraries and modules you want, but lets keep it simple for now.</p><p>Now we have finished the typescript implementation part, only HTML left to go, and of course if HTML known for something it would be it’s simplicity and straight-forwardness.</p><pre>&lt;div class=&quot;modeler&quot;&gt;<br>    &lt;div id=&quot;canvas&quot;&gt;&lt;/div&gt;<br>    &lt;div class=&quot;properties-panel&quot; id=&quot;properties&quot;&gt;&lt;/div&gt;<br>&lt;/div&gt;</pre><h3>Adding unique IDs</h3><p>Important thing to note is that, the modeler won’t let you create something from scratch, there must be an initial diagram to start with, so following the official demo of <a href="https://demo.bpmn.io/new">BPMN.io</a> I have created an initial diagram that consist of only a start event and I load it into the modeler. but then another problem accrues, since I have created the diagram, every initial diagram will have the same id, which is not correct, each diagram should have it’s own id, to solve this problem, I used “replace-ids” library. First install the library</p><pre>@bpmn-io/replace-ids</pre><p>then import it</p><pre>import replaceIds from &quot;@bpmn-io/replace-ids&quot;;<br>import Ids from &quot;ids&quot;;</pre><p>Initialize it</p><pre>private ids = new Ids([32, 36, 1]);<br><br> generateId() {<br>    return this.ids.next();<br>  }</pre><p>make your initial BPMN file takes the process ID as a variable:</p><pre> &lt;bpmn:process id=&quot;Process_{{ ID:process }}&quot; isExecutable=&quot;true&quot;&gt;</pre><p>Then use it in your create BPMN function, here is my implementation to that concept.</p><pre>createEmptyDiagram(): void {<br>    this.http.get(&quot;assets/test.bpmn&quot;, { responseType: &quot;text&quot; }).subscribe(<br>      (xml: string) =&gt; {<br><br>        // Extract IDs from XML<br>        const extractIds = (xml: string) =&gt; {<br>          const ids = [];<br>          const idRegex = /id=&quot;([^&quot;]+)&quot;/g;<br>          let match;<br>          while ((match = idRegex.exec(xml)) !== null) {<br>            ids.push(match[1]);<br>          }<br>          return ids;<br>        };<br><br>        // Original IDs<br>        const originalIds = extractIds(xml);<br><br>        try {<br>          // Pass both the XML and the ID generator function to replaceIds<br>          const updatedXml = replaceIds(xml, this.generateId.bind(this));<br>          // Updated IDs<br>          const updatedIds = extractIds(updatedXml);<br>          this.importDiagram(updatedXml).subscribe(<br>            (warnings) =&gt; {<br>              this.importDone.emit({<br>                type: &quot;success&quot;,<br>                warnings,<br>              });<br>            },<br>            (err) =&gt; {<br>              this.importDone.emit({<br>                type: &quot;error&quot;,<br>                error: err,<br>              });<br>            }<br>          );<br>        } catch (error) {<br>          console.error(&quot;Error replacing IDs:&quot;, error);<br>          this.importDone.emit({<br>            type: &quot;error&quot;,<br>            error,<br>          });<br>        }<br>      },<br>      (err) =&gt; {<br>        console.error(&quot;Error loading empty diagram XML&quot;, err);<br>      }<br>    );<br>  }<br><br> private importDiagram(xml: string): Observable&lt;{ warnings: Array&lt;any&gt; }&gt; {<br>    return from(<br>      this.modeler.importXML(xml) as Promise&lt;{ warnings: Array&lt;any&gt; }&gt;<br>    );<br>  }</pre><p>After implementing all that code, your Angular page should look like something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RiEKRINBh_FRQbU-JdeaGA.png" /></figure><p>You could use this as a start and enhance it and expand it to match your use case.</p><p>Here are my two cents on integrating Camunda BPMN into an Angular project. Feel free to reach out if you have any questions 🤗 .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3338cdd8364" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>