<?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[Diagramming for Developers - Medium]]></title>
        <description><![CDATA[Building diagramming apps on the web, by devs for devs. Published by the JointJS team. - Medium]]></description>
        <link>https://medium.com/diagramming-for-developers?source=rss----e235bddacae4---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Diagramming for Developers - Medium</title>
            <link>https://medium.com/diagramming-for-developers?source=rss----e235bddacae4---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 05 Nov 2026 12:54:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/diagramming-for-developers" 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 embed a visual Mermaid editor in your React app]]></title>
            <link>https://medium.com/diagramming-for-developers/how-to-embed-a-visual-mermaid-editor-in-your-react-app-cc898c0e499e?source=rss----e235bddacae4---4</link>
            <guid isPermaLink="false">https://medium.com/p/cc898c0e499e</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[diagramming-tools]]></category>
            <category><![CDATA[mermaid]]></category>
            <category><![CDATA[diagramming]]></category>
            <dc:creator><![CDATA[JointJS]]></dc:creator>
            <pubDate>Wed, 04 Nov 2026 13:04:01 GMT</pubDate>
            <atom:updated>2026-11-04T13:04:01.617Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="An example diagram with title Mermaid Editor, and the Mermaid logo." src="https://cdn-images-1.medium.com/max/1000/1*T8_xPUcpVQMnuTkYk8tDXQ.png" /></figure><p>Mermaid has effectively become the standard for diagrams as code. You write a flowchart like A --&gt; B in Markdown, GitHub renders it, and it lives in version control next to your code. Mermaid diagrams are in READMEs, docs sites, and wikis, and increasingly the output across almost all major AI platforms for generating text-based diagrams. All of this makes Mermaid the obvious format for any product that displays diagrams, and the next step for those products is a visual Mermaid editor that lets users change a diagram by clicking on it instead of learning the syntax.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FNyQq2KX3O6U%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DNyQq2KX3O6U&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FNyQq2KX3O6U%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8504cd88f6470ffd8afa364d8215076/href">https://medium.com/media/d8504cd88f6470ffd8afa364d8215076/href</a></iframe><p>But Mermaid diagrams integrated into products can quickly show their limits. The output is a static SVG; users can’t click a node to rename it or restyle an arrow without learning the syntax. Just as well, a typical visual editor built on top keeps its own copy of the diagram, separate from the Mermaid text. When you edit the diagram, the text becomes out of date. If you edit the text, the diagram is no longer accurate. Teams building docs platforms, wikis, low-code tools, and AI assistants often realize that Mermaid is great, but the editing experience isn’t.</p><p>To close that gap, we built the Mermaid Editor app template with JointJS, a diagramming library for building visual editors in JavaScript and React. It reads Mermaid with Mermaid’s own parser, renders it as a live, editable diagram, and writes every canvas change back into the text.</p><p>In this article, you’ll see what the JointJS Mermaid Editor does, the patterns behind it, and how to embed it in your own React app.</p><h3>About the JointJS Mermaid Editor demo</h3><p><a href="https://jointjs.com/demos/mermaid-editor">The Mermaid Editor</a> is a split-screen editor for Mermaid flowcharts. You write Mermaid on the left, and on the right you get a real, interactive diagram rendered by JointJS+ for React. As you type, the source is reparsed, and the diagram is laid out as you go. When you edit the diagram, the text changes.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F1242448332%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fvimeo.com%2F1242448332&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F2220699037-7335d79504f15c7834a31dd95ad10a04bb5f16dbfc8f45f2990b6b4c4a24c285-d_1280%3Fregion%3Dus&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1422" frameborder="0" scrolling="no"><a href="https://medium.com/media/058d46ca981ef675307a4c9958694c36/href">https://medium.com/media/058d46ca981ef675307a4c9958694c36/href</a></iframe><p>Here’s what that looks like in practice:</p><ul><li><strong>It works with standard Mermaid syntax.</strong> All classic delimiter shapes ([ ], ( ), { }, [( )], and the rest), the extended v11 @{ shape: ... } catalog, @{ img: ... } image nodes, nested subgraph blocks, style, classDef, click links, linkStyle, edge labels, curves, and even @{ animate: true } dash animated links.</li><li><strong>Every node is a real SVG shape that sizes itself to its label.</strong> No fixed-width boxes with overflowing text.</li><li><strong>The source and the canvas point at each other.</strong> Click a node, and every mention of it lights up in the source. Move the caret in the editor, and the diagram selects and scrolls to the node you’re on.</li><li><strong>The canvas is an editor, not a viewer.</strong> Double-click to rename a node in place. Select a node to see a toolbar with shape, fill, text color, bold and italic, border, hyperlink, image, and an “add a step” action. Select a link to change its line pattern, arrowheads, color, curve, and animation. Shift-click to select two nodes, and the editor offers to connect them.</li><li><strong>Every edit is written into the Mermaid text.</strong> The source stays the single source of truth, so what you export is still a plain .mmd file that works in GitHub, GitLab, Notion, or anywhere else Mermaid does.</li><li><strong>It’s a proper canvas.</strong> Pan and zoom on an infinite PaperScroller, switch layout direction and link routing (curved or orthogonal), toggle light and dark themes, and export the diagram to SVG.</li></ul><p>The source editor is Monaco, the same editor that powers VS Code, with Mermaid syntax highlighting, autocompletion, find and replace, multiple cursors, and full undo history.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Pl0BMUpQyuMJq9X1.png" /><figcaption>A detail from the Mermaid Editor, a node toolbar.</figcaption></figure><p>You can find the full source code on GitHub:<a href="https://github.com/clientIO/joint-demos/tree/main/mermaid-editor"> clientIO/joint-demos/mermaid-editor</a>.</p><h3>How the editor keeps the Mermaid text and the diagram in sync</h3><p>The key aspect of the Mermaid Editor, precisely as in our<a href="https://www.jointjs.com/demos/data-modeling"> Data Modeling App Template</a>, is that there is a single source of truth, the Mermaid text.</p><p>The visual diagram is never edited directly, but rather always a rendering of the current source. When you type, the source changes and the diagram is rendered from it. When you change something on the canvas, the app doesn’t touch the diagram, but computes the new Mermaid text and derives the visual from that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_FgWEBLKlNM1g0F_.png" /><figcaption><em>Every first edit updates the Mermaid text, and then renders the diagram from it.</em></figcaption></figure><p>Everything flows clockwise. The text will be parsed by Mermaid, mapped to JointJS cells, and rendered. Canvas actions become text edits, which start the loop again. There’s no second model to keep in sync, so the diagram and the text can’t fall out of sync.</p><p>An automatic layout engine calculates node positions on every render, just as Mermaid does. The editor supports the two layout engines Mermaid offers for flowcharts. Dagre, a layered layout with smooth, curved links, which is the default, and ELK, which routes links at right angles and is used when the source sets layout: elk. You can easily switch between them by editing Mermaid text.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wAeQbTVj6MRs5K5f.png" /><figcaption><em>A look at the layout: elk option in Mermaid config.</em></figcaption></figure><h3>From Mermaid to JointJS cells</h3><p>Mermaid’s syntax is large, evolving, and full of edge cases, so the demo uses Mermaid’s own parser and reads the result from its diagram database:</p><pre>// src/mermaid/parse.ts<br><br>const mermaid = await loadMermaid();<br><br>let diagram;<br>try {<br>  diagram = await mermaid.mermaidAPI.getDiagramFromText(text);<br>} catch (error) {<br>  throw new MermaidParseError(toMessage(error));<br>}<br><br>// … (rejects diagram types other than flowchart)<br><br>const db = diagram.db as unknown as FlowDbLike;<br>const { nodes, edges } = db.getData();</pre><p>When Mermaid is parsed, it figures out what each shape should be, breaks two-way arrows into separate one-way arrows, and keeps track of which nodes are inside each subgraph.</p><p>The parsed graph is then mapped onto declarative JointJS cell records with a single pure function:</p><pre>// src/mermaid/to-cells.ts<br><br>export function toCells(flow: FlowGraph): MermaidCell[]</pre><p>That’s the same pattern the<a href="https://www.jointjs.com/blog/how-to-build-production-grade-data-modeling-apps-in-react-a-jointjs-architecture-walkthrough"> Data Modeling app</a> uses with schemaToCells.</p><h4>Nodes grow to fit their labels</h4><p>Each node on the diagram is a React component that renders its Mermaid shape as SVG, and useMeasureElement measures the label and provides its exact sizing:</p><pre>// src/components/render-node.tsx<br><br>const { width, height } = useMeasureElement(textRef, options);</pre><p>That’s why a diamond with a long label grows bigger instead of clipping its text, and why a label can span as many lines as it needs to. Shapes are defined once in shapes.ts, and the same geometry draws both the node on the canvas and its icon in the toolbar&#39;s shape picker, so the two can never drift apart.</p><h4>Subgraphs become real containers</h4><p>A Mermaid subgraph turns into a JointJS container element. Its nodes are embedded inside it, and after layout, the container is resized to fit perfectly. Because the nodes really belong to the container, rather than sitting on a box drawn behind them, subgraphs can be nested too.</p><h4>Links keep their Mermaid styling</h4><p>Each Mermaid link (the parser returns them as edges) becomes a JointJS link that carries everything Mermaid knows about it, from solid, dotted, or thick lines, to point, circle, or cross arrowheads at either end, labels, linkStyle colors and widths, curved routing for Mermaid&#39;s curve families, and a CSS marching-dash animation for animate: true links.</p><h4>Layout runs when every node is measured</h4><p>Once every node is measured, DirectedGraph.layout from <a href="https://docs.jointjs.com/learn/features/automatic-layouts/directed-graph/">@joint/layout-directed-graph</a> arranges the graph in whatever direction the source declares ( TB, BT, LR, or RL). The DirectedGraph.layout is the default, the same dagre-style layout Mermaid uses, with curved links. When you set layout: elk option, the editor switches to <a href="https://docs.jointjs.com/learn/features/automatic-layouts/elk">@joint/layout-elk</a> with orthogonal links.</p><pre>useOnElementsMeasured(({ graph: measuredGraph }) =&gt; {<br>    settle(measuredGraph, onLayoutSettled);<br>});</pre><p>The useOnElementsMeasured hook repaints the paper right after the callback, so there&#39;s never a frame where diagram nodes are visible at their pre-layout position.</p><h3>From the diagram canvas back to Mermaid</h3><p>Rendering Mermaid is the easier half. The hard part, and the reason so many Mermaid tools stop at a preview, is writing visual edits back into Mermaid format without breaking it.</p><p>The obvious approach is to regenerate the whole source from the parsed graph after every edit. It’s also the wrong one. Mermaid’s parsed output is a normalization, not a faithful syntax tree, so it has no comments, no formatting, no classDef names, and shapes come back as IDs rather than the delimiters the author typed. With this approach, every click on the canvas would reformat the author&#39;s entire document, delete their comments, and produce a massive diff.</p><p>In this app, the source is never fully recreated. Every canvas action is a targeted edit that finds the exact span of text responsible for the change made and splices in the new value.</p><p>For example, here’s how renaming a node works:</p><pre>// src/mermaid/edit-source.ts<br><br>export function setNodeLabel(source: string, id: CellId, label: string): string | null {<br>   // … (a v11 `id@{ label: … }` block is edited in place first)<br><br>   const parsed = parse(source);<br>   const declaration = findDeclaration(parsed, id);<br>   if (!declaration) return null;<br>   const text = quoteLabel(encodeBreaks(label.trim()));<br><br>   if (declaration.labelFrom !== undefined &amp;&amp; declaration.labelTo !== undefined) {<br>       return splice(source, declaration.labelFrom, declaration.labelTo, text);<br>   }<br>   // A bare `a --&gt; b` has no shape to hold a label; give it the default one.<br>   if (declaration.shapeFrom !== undefined &amp;&amp; declaration.shapeTo !== undefined) {<br>       return splice(source, declaration.shapeFrom, declaration.shapeTo, `[${text}]`);<br>   }<br>   return splice(source, declaration.idTo, declaration.idTo, `[${text}]`);<br>}</pre><p>Ideally, Mermaid’s own parser would say where each piece of the diagram sits in the text. Mermaid’s newer diagram types are parsed with Langium, which returns a typed syntax tree whose nodes record their exact offset and length in the source. Flowcharts, though, haven’t been migrated yet. They still use Mermaid’s older Jison grammar, which Mermaid now marks as deprecated, and Jison hands back the finished diagram data with no record of where anything came from in the text. To edit the source precisely, you need a second parser that keeps positions.</p><p>So each edit parses the current source using a separate Lezer grammar for Mermaid from the <a href="https://github.com/inspirnathan/codemirror-lang-mermaid">codemirror-lang-mermaid</a> package, but it doesn’t interpret the diagram. It only records where each node ID, shape bracket, and label sits in the text. The edit then replaces just that piece, so the rest of the source, including comments and formatting, stays exactly as the author wrote it.</p><p>There’s one of these functions per action, and each one deals with corner cases of Mermaid syntax so the UI doesn’t have to.</p><p>The React side is equally small. Every handler on the node toolbar runs one of these functions on the current source and hands the result back to the same state the editor writes to:</p><pre>// src/app.tsx<br><br>onLabelChange: (id, label) =&gt; apply(setNodeLabel(sourceRef.current, id, label)),<br>onShapeChange: (id, shape) =&gt; apply(setNodeShape(sourceRef.current, id, shape)),<br>onFillChange: (id, fill) =&gt; apply(setNodeFill(sourceRef.current, id, fill)),</pre><p>Any change, whether typed or made on the canvas, is handled in the same way. There are no separate processes for canvas and editor edits, so they always stay in sync. Since every edit only updates the text, it’s easy to test these changes, and the repo includes unit tests for edits like removing elements or updating labels and links.</p><h3>Details that make it feel like an editor</h3><p>A two-way binding is easy to describe and surprisingly easy to get subtly wrong. Most of the remaining code in the demo is about making it feel instant and predictable.</p><h4>Selection without feedback loops</h4><p>The text and diagram don’t directly control each other. Instead, the app manages selection in one central place. Whenever you interact with either side, that action is reported up, so the app then knows what to display in both the text and the diagram.</p><pre>// src/app.tsx<br><br>interface Selection {<br>   readonly ids: readonly CellId[];<br>   readonly origin: &#39;canvas&#39; | &#39;editor&#39;;<br>}</pre><p>For example:</p><ul><li>Clicking a node in the diagram highlights all its matches in the text and scrolls the first one into view, which is helpful when you want to find the code for a shape you see.</li><li>Moving the caret in the text editor selects and centers the matching node in the diagram.</li></ul><p>By letting the app handle selection, changes don’t bounce back and forth between the text and the diagram. This keeps everything in sync without causing endless update loops.</p><h4>Optimized for production-grade use cases</h4><p>The demo, as it’s always the case with JointJS application templates, is optimized for performance, from the big picture to the smallest details.</p><p>Typing is debounced by 300 ms, so the editor is not parsing text on every keystroke. But actions like picking a shape, loading an example, or hitting undo happen right away without any delay. This avoids lag and keeps the app feeling quick and responsive.</p><p>Two heavy dependencies, Mermaid and Monaco, are loaded with dynamic imports, so each comes in its own chunk instead of the app’s main bundle. And since JointJS for React works with declarative cell records, an edit that only changes a label or a color updates the existing graph instead of rebuilding it.</p><h4>Accessible by default</h4><p>As with any JointJS app template, we paid special consideration to accessibility.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F1242772585%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fvimeo.com%2F1242772585&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F2221110359-32810a9c7117d64b432437b2eda5de93efa6987d2368b91d71d7614ec50780d7-d_1280%3Fregion%3Dus&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1097" frameborder="0" scrolling="no"><a href="https://medium.com/media/c63046e767eb0f1b3e779d1b3f1c18a7/href">https://medium.com/media/c63046e767eb0f1b3e779d1b3f1c18a7/href</a></iframe><p>The app works with screen readers, everything is accessible with keyboard, text not only has sufficient contrast but also looks great in both themes, and reduced-motion preferences are respected, enabling users to disable unnecessary animations (@media (prefers-reduced-motion: reduce) {}).</p><h3>Embedding the Mermaid editor in your React app</h3><p>The demo is a complete app, built from two pieces you can embed into your own product. The Mermaid logic is in src/mermaid/ and the React components in src/components/. The app shell in app.tsx holds the raw text as state and connects the two:</p><pre>// src/app.tsx (simplified)<br><br>&lt;EditorPanel<br>   source={source}<br>   onSourceChange={handleSourceChange}<br>   onCursorNodeChange={selectFromEditor}<br>   highlightedIds={selection.origin === &#39;canvas&#39; ? selection.ids : NO_IDS}<br>/&gt;<br><br>&lt;MermaidDiagram<br>   direction={rendered.direction}<br>   layout={rendered.layout}<br>   cells={rendered.cells}<br>   selectedIds={selection.ids}<br>   onSelect={selectFromCanvas}<br>   edit={edit}<br>   linkEdit={linkEdit}<br>/&gt;</pre><p>Notice that the diagram component, MermaidDiagram, never sees the Mermaid text. It receives a list of shapes and links to draw, and when the user changes something, it reports the change. The app shell turns that info into updated Mermaid text and passes the new shapes back down. Because the component only draws and reports, you can plug it into any app that stores Mermaid text:</p><ul><li><strong>The source can live anywhere.</strong> Load your own Mermaid text from anywhere, such as a Markdown file, a database field, or an LLM response, and let your users edit it visually, then save the Mermaid text back. There’s no extra diagram format to store.</li><li><strong>The code editor is optional.</strong> EditorPanel and MermaidDiagram are completely separate components. Developers probably want both side by side, but for non-technical users, you can show only the canvas and its toolbars, and keep Mermaid behind the scenes.</li><li><strong>The Mermaid logic is plain TypeScript.</strong> Parsing Mermaid flowchart source is done in parse.ts, which contains no React or canvas code, so you can easily extend it for the parts of Mermaid your users rely on.</li><li><strong>Theming is done with CSS Custom Properties.</strong> Color themes (both light and dark) are set entirely in CSS variables (index.css), so you can easily tweak them to match your own brand and product style.</li></ul><h3>Use the Mermaid Editor in your projects, from docs platforms to AI assistants</h3><p>If you read our<a href="https://www.jointjs.com/blog/how-to-build-production-grade-data-modeling-apps-in-react-a-jointjs-architecture-walkthrough"> Data Modeling App Template walkthrough</a>, the shape of this app will look familiar. In Data Modeling Demo, SQL DDL serves as the text format, and the graph carries the schema. In Mermaid Editor Demo, Mermaid functions as the text format, and the source carries the diagram. In both cases:</p><ul><li>One thing is the source of truth, and everything else is derived from it.</li><li>The domain logic (SQL generation and parsing in Data Modeling, and Mermaid parsing and source edits here) doesn’t depend on the canvas, so it’s testable on its own.</li><li>A single function maps the domain model to cells, and JointJS for React renders those cells declaratively.</li><li>Nodes are React components, and the interaction layer (selection, scrolling, zooming, layout, export) comes from the library instead of being rebuilt by hand.</li></ul><p>That makes the demo a useful starting point well beyond flowcharts. A few places it fits naturally:</p><ul><li><strong>Docs and knowledge-base platforms</strong> that already store Mermaid in Markdown, so you can easily give non-technical users a visual way to edit it, without changing the storage format.</li><li><strong>AI assistants and agents</strong> that generate flowcharts as Mermaid. LLMs are good at writing Mermaid and not great at getting a diagram exactly right on the first try. A visual editor on top lets users fix the last 10% by clicking instead of re-prompting.</li><li><strong>Internal tools and wikis</strong> where diagrams live in Git and need to stay reviewable as text diffs.</li><li><strong>Other text-based diagram formats.</strong> Swap parse.ts and edit-source.ts for another grammar (another Mermaid diagram type, PlantUML, D2, Graphviz DOT, or your own DSL), and most of the rendering and interaction layer stays as it is.</li></ul><p>The current demo covers Mermaid flowcharts. Other Mermaid types like sequence or state diagrams would need their own mapping in toCells and their own source edits, but the architecture doesn&#39;t change.</p><h3>Getting started</h3><p>The quickest way to see what this does is to<a href="https://jointjs.com/demos/mermaid-editor"> open the live Mermaid Editor demo</a> and paste in a flowchart of your own. Pick something from a real README, or ask your favorite LLM to generate one. Then click around, rename a node, change an arrow, switch the layout direction, and watch the source follow along.</p><p>When you’re ready to embed it in your own app, download the app template locally:</p><pre>npx @joint/cli download mermaid-editor/react</pre><p>You’ll need access to the JointJS+ for React package, through a license or a<a href="https://www.jointjs.com/free-trial"> free trial</a>. The full source is on GitHub:<a href="https://github.com/clientIO/joint-demos/tree/main/mermaid-editor"> clientIO/joint-demos/mermaid-editor</a>.</p><p>Like our other demos, the codebase is heavily commented with the reasoning behind each decision, which makes it a good fit for an AI coding agent. Point your agent at it, describe your use case, and let it adapt the demo. For best results, set up the<a href="https://docs.jointjs.com/learn/help-center/mcp-server/"> JointJS MCP Server</a>, which gives your agent direct access to up-to-date JointJS docs and demo code.</p><p>Happy diagramming!</p><ul><li><a href="https://jointjs.com/demos/mermaid-editor">Try the Mermaid Editor demo</a></li><li><a href="https://github.com/clientIO/joint-demos/tree/main/mermaid-editor">Browse the source on GitHub</a></li><li><a href="https://docs.jointjs.com/react/">Read the JointJS for React docs</a></li><li><a href="https://www.jointjs.com/free-trial">Start your free JointJS+ trial</a>‍</li></ul><p>—</p><h3>FAQ</h3><h4><strong>What is the JointJS Mermaid Editor?</strong></h4><p>It’s an app template built with JointJS+ for React that turns Mermaid flowchart source into an interactive, editable diagram. Changes made on the canvas are written back into the Mermaid text, so the source always stays the single source of truth.</p><h4><strong>How is this different from the Mermaid Live Editor?</strong></h4><p>The Mermaid Live Editor renders a static preview of your text. The JointJS Mermaid Editor renders a live JointJS graph you can edit directly, from renaming nodes and changing shapes and styles to adding and connecting steps, restyling links, and switching the layout direction, with every change synced back to the source.</p><h4><strong>How is this different from Mermaid’s Advanced Editor?</strong></h4><p>The Advanced Editor is the editor in mermaid.ai, Mermaid’s subscription-based platform. It bundles AI generation, saved diagrams, and collaboration with a Visual Editor for canvas editing. The JointJS editor offers the same kind of two-way editing for flowcharts, but as a template you embed in your own React app.</p><h4><strong>Can I easily embed the Mermaid Editor in an existing React app?</strong></h4><p>Yes. The editor uses React components to handle diagram updates, while your app manages the Mermaid text. You can keep the source anywhere you like, from a Markdown file, to a database, or from an LLM response, and add the code editor panel only if your users want to see or edit the text.</p><h4><strong>Does it use a custom Mermaid parser?</strong></h4><p>No. It uses Mermaid’s own parser to read the diagram, so syntax support follows Mermaid itself. A separate Lezer grammar locates exact text spans so canvas edits can be applied without reformatting the rest of the source.</p><h4><strong>Which Mermaid features are supported?</strong></h4><p>Flowcharts, including all classic node shapes, the extended v11 @{ shape: … } catalog, image nodes, nested subgraphs, style, classDef, click, linkStyle, link labels, arrow types, curves, animated links, and Mermaid&#39;s layout: elk option.</p><h4><strong>Can I export the result?</strong></h4><p>Yes. You can export the diagram as SVG or download the Mermaid source as a .mmd file that works anywhere Mermaid is supported.</p><h4><strong>Can I adapt it for other diagram formats?</strong></h4><p>Yes. Parsing and source editing are separated from rendering, so you can use different formats, such as another Mermaid diagram type or your own DSL, and keep most of the canvas and interaction code.</p><p><em>Originally published at </em><a href="https://www.jointjs.com/blog/how-to-embed-a-visual-mermaid-editor-in-your-react-app"><em>https://www.jointjs.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc898c0e499e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/diagramming-for-developers/how-to-embed-a-visual-mermaid-editor-in-your-react-app-cc898c0e499e">How to embed a visual Mermaid editor in your React app</a> was originally published in <a href="https://medium.com/diagramming-for-developers">Diagramming for Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to get started with JointJS for React]]></title>
            <link>https://medium.com/diagramming-for-developers/how-to-get-started-with-jointjs-for-react-a50f55385f24?source=rss----e235bddacae4---4</link>
            <guid isPermaLink="false">https://medium.com/p/a50f55385f24</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[diagramming]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[jointjs]]></category>
            <dc:creator><![CDATA[JointJS]]></dc:creator>
            <pubDate>Thu, 22 Oct 2026 14:43:09 GMT</pubDate>
            <atom:updated>2026-10-22T14:45:57.963Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RjYN0Obhx7zmXhBZYS4szg.jpeg" /></figure><p>Whether you’re experimenting, building a proof of concept, or ready for a production-grade app, this roadmap will help you find the right starting point.</p><p>We just released<a href="https://docs.jointjs.com/react"> JointJS for React</a> and<a href="https://www.jointjs.com/blog/introducing-jointjs-for-react"> shared a bit about who it is for, why it matters, and why you should start using it</a>.</p><p>In this article, you’ll get a practical, hands-on guide on getting started with JointJS for React. We won’t go into nitty-gritty details here, but instead we’ll give you a clear outline of the best ways you can jump into it without much effort.</p><p>We’ll briefly cover:</p><ul><li>How to start from a ready-made demo (<a href="https://www.jointjs.com/demos/ai-workflow-builder">AI Workflow Builder</a>) and customize it for your project</li><li>Guidance on building your first app step-by-step using the documentation and quickstart guide</li><li>How to use AI Coding Agents to accelerate development, along with quick installation instructions to get you up and running</li><li>A conclusion with tips, next steps, and further resources</li></ul><h3>Start with the AI Workflow Builder demo</h3><p>Instead of building your app from scratch, the best way to start is to use one of the existing JointJS for React demos that’s close to your actual needs, such as AI Workflow Builder, to build your own proof of concept JointJS for React app.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F1208077455%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fvimeo.com%2F1208077455&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F2177306193-51ab2508d48e546029ee25c3a950cd0bf239e6a93459e80d6ada5dc5b6c0a0a6-d_1280%3Fregion%3Dus&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/25e0efb165febc0d7569fc7b917ccfb5/href">https://medium.com/media/25e0efb165febc0d7569fc7b917ccfb5/href</a></iframe><p>First, we’ll set up an AI Workflow Builder demo project in a new folder. You can download it using the JointJS CLI tool:</p><pre>npx @joint/cli download ai-workflow-editor/react‍</pre><p>Alternatively, you can simply clone the<a href="https://github.com/clientIO/joint-demos/archive/refs/heads/main.zip"> AI Workflow Builder demo GitHub repository</a>.</p><p>Once the demo is downloaded, run npm install to set up all project dependencies. Note that this demo is built in JointJS+ for React, the commercial extension of the open-source, community-driven library, which installs from the private JointJS npm registry, so you’ll need an access token in the .npmrc file to install it.</p><p>You can get the access token in our<a href="https://my.jointjs.com/login"> customer portal</a> or by starting your <a href="https://www.jointjs.com/free-trial">free trial of JointJS+</a>. You can find<a href="https://docs.jointjs.com/learn/help-center/npm-registry/"> more info on setting up the access token in the docs</a>.</p><p>Once you’ve successfully installed the dependencies, run the npm run start command to start the development server. By default, it will start on localhost, port 5173 (http://localhost:5173/).</p><p>Once you have the demo set up, you can either explore the codebase yourself or ask your AI Coding Agent to give you a detailed overview of the project:</p><pre>Give me an overview of this JointJS+ for React codebase, focusing <br>on JointJS and the key things I need to know about the app.‍</pre><p>As expected, Claude Code, the AI Agent I’m using for this demo, examined the codebase in detail and provided a clear overview of key concepts and everything you need to dig into it yourself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IiuTZZAS3poePuuJ.png" /><figcaption>An example output of a prompt requesting an overview of JointJS for React codebase.</figcaption></figure><p>You can now start tweaking the demo yourself, or better yet, follow up with your AI Coding agent to precisely tweak it to suit your needs.</p><p>I recommend you use the<a href="https://docs.jointjs.com/learn/help-center/mcp-server/"> JointJS MCP Server</a> to get direct access to the latest, up-to-date JointJS docs. Even without the MCP server, your AI coding agent will be able to figure out precisely what it needs to do by analyzing JointJS code, but using the MCP server is more efficient and will get you better results in the end.</p><p>Also, if you’re using JointJS MCP Server, you don’t have to manually clone the demo; you can just ask AI to tweak the JointJS for React AI Workflow Builder demo, and AI will set up everything for you.</p><h3>Build your first app step by step by following our quickstart guide</h3><p>Using AI Coding agents to tweak one of our prebuilt demos is the simplest and most efficient way of starting if you’re building a proof of concept and plan to build a serious, production-grade app.</p><p>But if you want to learn more about JointJS for React, if you want to understand key concepts to be able to review AI agent’s changes and to be able to direct your AI coding agent better, it’s best to get your hands dirty by following our<a href="https://docs.jointjs.com/react/getting-started/"> JointJS for React Quickstart Guide</a> in the docs.</p><p>The guide is structured into multiple chapters, and each chapter focuses on one key concept, so it’s easy and straightforward to follow:</p><ol><li>Install @joint/react: add the package, import the styles, and size the canvas.</li><li>Build your first diagram: render elements from plain data.</li><li>Add and update elements: read the graph and change it while the app runs.</li><li>Create custom elements: rich, data-driven nodes with ports, styled your way.</li><li>Connect elements with links: arrowheads, labels, and routing.</li><li>Make the canvas interactive: dragging, clicks, and selection.</li><li>Zoom and pan the canvas: an infinite, scrollable, zoomable viewport with JointJS+.</li><li>Add an element palette: drag from a palette onto the canvas.</li><li>Add a property editor: edit the selected node from a live inspector.</li><li>Add an element overlay: React UI anchored to an element, such as a badge, toolbar, or popover.</li><li>Add a minimap: a bird’s-eye view that tracks the canvas.</li></ol><p>The quickstart guide is designed to be straightforward and approachable for everyone, clearly outlining all key concepts of the library as you encounter them.</p><p>By the end of the guide, you’ll build a complete workflow editor that includes all the key features you’ll find in flowcharts and diagrams, from palette, canvas, minimap, to a live properties panel, giving you insight into JointJS open-source and JointJS+ commercial features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xbtZv1K6Y5CzV7AL.png" /><figcaption>A final state of a diagramming app built by following JointJS for React quickstart guide.</figcaption></figure><h3>Use AI Coding agents to set up your JointJS for React project from scratch</h3><p>If you want to start completely from scratch, or add JointJS for React to your existing project, install the library directly from NPM. The open-source version of the library is available at @joint/react, and the commercial extension, JointJS+ for React, is available on NPM at @joint/react-plus.</p><h4>Install JointJS for React through NPM</h4><p>For this demo, we’ll start from scratch and use the Vite build tool to set up a simple React project:</p><pre>npm create vite@latest jointjs-for-react-demo -- --template react-ts‍</pre><p>Next, we need to install JointJS for React, the open-source version of the library. The package is available at<a href="https://www.npmjs.com/package/@joint/react?activeTab=readme"> @joint/react</a>:</p><pre>npm install @joint/react‍</pre><p>This will work with any modern React setup, so you can easily drop it into Vite, Next.js, Remix, and so on. Just as well, you can use JointJS+ for React instead of the open-source version.</p><pre>npm install @joint/react-plus</pre><p>For this guide, we’ll use the open-source version of the library, but JointJS+ for React includes everything from JointJS for React and works exactly the same (the only difference being that &lt;GraphProvider /&gt; in JointJS+ becomes &lt;Diagram /&gt;. And of course, it also gives you access to selection, history, clipboard, spatial index, and more.), just with an expanded set of features.</p><p>Once our React project is up and running and the JointJS for React package is installed, we’ll set up a simple JointJS canvas. The easiest way to start is to use an AI Coding agent to set up the boilerplate project.</p><h4>Set up a basic JointJS canvas with your AI Coding agent</h4><p>Most developers these days use AI Coding Agents extensively in development, just as they should. And this is precisely where JointJS for React shines. JointJS for React is strongly typed, so your AI Coding agents can easily parse the library and understand exactly how it works and how it can give you the result you want.</p><p>You can feel confident using JointJS for React even if you don’t want to wait for the AI training sets to update and kick in with new<a href="https://docs.jointjs.com/react/"> JointJS for React docs</a>. Better yet, you can install<a href="https://docs.jointjs.com/learn/help-center/mcp-server/"> JointJS MCP Server</a>, which provides direct access to up-to-date JointJS docs, including React, to achieve higher-quality code overall.</p><pre>Replace the React demo and build a @joint/react app with a canvas graph, <br>paper, and two rectangles I can drag. Add one input port on the left <br>and one output port on the right to the rectangles, and draw a link <br>from the output port of the first rectangle to the input port of the <br>second rectangle.<br><br>Make the styling slick, modern, and clean with plenty of padding.</pre><p>Note that I’m explicitly mentioning the <em>@joint/react</em> package so the AI Coding Agent knows exactly what to use. I’m using Claude Code in this article, but this will work with any other setup as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bqcS-c8BNlrE53RZ.png" /><figcaption>An example of a JointJS for React app built with an AI Coding Agent through a single prompt.</figcaption></figure><p>AI Agent set up a simple JointJS for React canvas and configured the app precisely as it needs to:</p><pre>import { GraphProvider, Paper, HTMLHost, linkRoutingSmooth, type ElementPort, type CellRecord } from &#39;@joint/react&#39;;<br>import &#39;@joint/react/styles.css&#39;;<br>import &#39;./App.css&#39;;<br><br>function App() {<br>  return (<br>    &lt;div className=&quot;canvas-page&quot;&gt;<br>      &lt;header className=&quot;canvas-header&quot;&gt;<br>        &lt;h1&gt;JointJS + React&lt;/h1&gt;<br>        &lt;p&gt;Drag the rectangles around the canvas&lt;/p&gt;<br>      &lt;/header&gt;<br>      &lt;div className=&quot;canvas-frame&quot;&gt;<br>        &lt;GraphProvider initialCells={initialCells}&gt;<br>          &lt;Paper<br>            renderElement={RectangleNode}<br>            linkRouting={linkRoutingSmooth()}<br>            defaultLink={{ style: { color: &#39;#7c3aed&#39;, width: 2.5, targetMarker: &#39;arrow&#39; } }}<br>            gridSize={20}<br>            drawGrid={{ name: &#39;dot&#39;, args: { color: &#39;#d8d3e6&#39;, thickness: 1.5 } }}<br>            background={{ color: &#39;#faf9fc&#39; }}<br>            className=&quot;canvas&quot;<br>          /&gt;<br>        &lt;/GraphProvider&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default App;</pre><p>The RectangleNode function is responsible for turning the element&#39;s data into React UI. It uses HTMLHost so the element can be plain HTML:‍</p><pre>function RectangleNode({ label, hint }: NodeData) {<br>  return (<br>    &lt;HTMLHost useModelGeometry className=&quot;node&quot;&gt;<br>      &lt;span className=&quot;node__hint&quot;&gt;{hint}&lt;/span&gt;<br>      &lt;span className=&quot;node__label&quot;&gt;{label}&lt;/span&gt;<br>    &lt;/HTMLHost&gt;<br>  )<br>}</pre><p>And the initial elements, ports, and links are configured in their own constants:</p><pre>type NodeData = {<br>  label: string<br>  hint: string<br>}<br><br>const ports: Record&lt;string, ElementPort&gt; = {<br>  in: {<br>    cx: 0,<br>    cy: &#39;50%&#39;,<br>    width: 16,<br>    height: 16,<br>    color: &#39;#ffffff&#39;,<br>    outline: &#39;#c4b5fd&#39;,<br>    outlineWidth: 2,<br>    passive: true,<br>},<br>  out: {<br>    cx: &#39;100%&#39;,<br>    cy: &#39;50%&#39;,<br>    width: 16,<br>    height: 16,<br>    color: &#39;#7c3aed&#39;,<br>    outline: &#39;#ffffff&#39;,<br>    outlineWidth: 2,<br>  },<br>}<br><br>const initialCells: CellRecord&lt;NodeData&gt;[] = [<br>  {<br>    id: &#39;rect-a&#39;,<br>    type: &#39;element&#39;,<br>    position: { x: 120, y: 160 },<br>    size: { width: 220, height: 120 },<br>    portMap: ports,<br>    data: { label: &#39;Rectangle A&#39;, hint: &#39;Output&#39; },<br>  },<br>  {<br>    id: &#39;rect-b&#39;,<br>    type: &#39;element&#39;,<br>    position: { x: 560, y: 160 },<br>    size: { width: 220, height: 120 },<br>    portMap: ports,<br>    data: { label: &#39;Rectangle B&#39;, hint: &#39;Input&#39; },<br>  },<br>  {<br>    id: &#39;rect-a-rect-b&#39;,<br>    type: &#39;link&#39;,<br>    source: { id: &#39;rect-a&#39;, port: &#39;out&#39; },<br>    target: { id: &#39;rect-b&#39;, port: &#39;in&#39; },<br>    style: {<br>      color: &#39;#7c3aed&#39;,<br>      width: 2.5,<br>      targetMarker: &#39;arrow&#39;,<br>    },<br>  },<br>]</pre><p>From here, you can use your AI Coding Agent to tweak and extend it according to your precise project needs. Follow up in your initial prompt to get the result you’re looking for.</p><h3>Conclusion</h3><p>If you want to quickly build a proof of concept for your own use case with JointJS for React, start with the AI Workflow Builder demo and use AI coding agents to tweak it to suit your needs.</p><p>If you want to understand a bit more about how JointJS for React works, follow our<a href="https://docs.jointjs.com/react/getting-started/"> Getting Started Guide</a> in the docs, and in the few short lessons, you’ll learn everything you need to get confident in building production-grade diagramming and flowchart apps.</p><h4>Ready to get started?</h4><ul><li><a href="https://docs.jointjs.com/react">Explore the official JointJS for React documentation for detailed guides and API references</a></li><li><a href="https://www.jointjs.com/demos/ai-workflow-builder">Try the AI Workflow Builder demo</a></li><li><a href="https://www.jointjs.com/free-trial">Learn more about JointJS+ and start a free trial</a></li></ul><p>These resources will help you take your next steps and get the most out of JointJS for React and JointJS+ for React.</p><p>Happy diagramming!<br><a href="https://zoranjambor.com">Z‍oran Jambor</a></p><h3>FAQ</h3><h4><strong>What is the recommended way to start building with JointJS for React?</strong></h4><p>The fastest way is to use the <a href="https://www.jointjs.com/demos/ai-workflow-builder">AI Workflow Builder demo</a> as a starting point. Download or clone the demo, install dependencies (you’ll need a JointJS+ access token for the commercial version), and run it locally. This gives you a working proof of concept that you can customize to your needs.</p><h4><strong>How do I install JointJS for React in a new or existing project?</strong></h4><p>For open-source, run npm install @joint/react. For the commercial extension, run npm install @joint/react-plus (requires private npm access). Both can be integrated into any modern React setup like Vite, Next.js, or Remix.</p><h4><strong>What’s the difference between JointJS for React and JointJS+ for React?</strong></h4><p>JointJS for React is open-source and provides core diagramming tools. JointJS+ for React is a commercial extension with advanced features (selection, history, clipboard, minimap, spatial index, and more), and uses &lt;Diagram /&gt; instead of &lt;GraphProvider /&gt;.</p><h4><strong>Can I use AI Coding Agents with JointJS for React?</strong></h4><p>Yes! JointJS for React is strongly typed and works well with AI Coding Agents (like Claude Code or GitHub Copilot). Agents can help you set up projects, tweak demos, and generate code. Using the <a href="https://docs.jointjs.com/learn/help-center/mcp-server/">JointJS MCP Server</a> gives them direct access to the latest docs for even better results.</p><h4><strong>How can I learn the basics and key concepts of JointJS for React?</strong></h4><p>Follow the <a href="https://docs.jointjs.com/react/getting-started/">Quickstart Guide</a> in the official docs. It covers installation, rendering diagrams, custom elements, interactivity, palettes, property editors, overlays, and minimaps — everything needed to build a production-grade workflow editor.</p><h4><strong>Do I need a commercial license to try JointJS for React?</strong></h4><p>No, the open-source version is free to use. To try advanced features in JointJS+, <a href="https://www.jointjs.com/free-trial">start a free trial for access to the commercial package and features</a>.</p><h4><strong>Where can I find more resources?</strong></h4><p>Best ways to continue your journey with JointJS for React are:</p><ul><li><a href="https://docs.jointjs.com/react">JointJS for React documentation</a></li><li><a href="https://www.jointjs.com/demos/ai-workflow-builder">AI Workflow Builder demo</a></li><li><a href="https://www.jointjs.com/free-trial">JointJS+ for React free trial</a></li></ul><p><em>Originally published at </em><a href="https://www.jointjs.com/blog/how-to-get-started-with-jointjs-for-react"><em>https://www.jointjs.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a50f55385f24" width="1" height="1" alt=""><hr><p><a href="https://medium.com/diagramming-for-developers/how-to-get-started-with-jointjs-for-react-a50f55385f24">How to get started with JointJS for React</a> was originally published in <a href="https://medium.com/diagramming-for-developers">Diagramming for Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>