JSFiddle - React, Tailwind, and code Playground

by Roman Bruckner

HTML

<html>
<head>
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/jointjs/3.6.5/joint.css" />
</head>
<body>
      <!-- content -->
      <div id="paper"></div>

      <!-- dependencies -->
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.20/lodash.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.4.0/backbone.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jointjs/3.6.5/joint.js"></script>
    
    </body>
</html>

JavaScript

var graph = new joint.dia.Graph({}, {
    cellNamespace: joint.shapes
});

const paper = new joint.dia.Paper({
    el: document.getElementById('paper'),
    width: 1000,
    height: 1000,
    model: graph,
    gridSize: 5,
    drawGrid: true,
    restrictTranslate: true,
    cellViewNamespace: joint.shapes,
    autoResizePaper: false,
    defaultConnectionPoint: { name: 'boundary' },
    defaultLink: new joint.shapes.standard.Link({
        attrs: {
            line: {
                stroke: 'grey',
                targetMarker: {
                    type: 'path',
                    d: 'M 0 0 0 0',
                },
            },
        },
    }),
    interactive: { linkMove: true },
    async: true,
    snapLabels: true,
    sorting: joint.dia.Paper.sorting.APPROX,
    defaultLinkAnchor: { name: 'connectionPerpendicular' },
    validateConnection:()=>{return true;}


});

let json=JSON.parse('{"cells":[{"type":"standard.Link","source":{"x":330,"y":391.1064147949219},"target":{"x":610,"y":391.1064147949219},"router":{"name":"normal"},"id":"176ec716-0a1d-47ac-8446-0a92afbeee83","z":1,"hoverPostion":{"x":103,"y":279},"vertices":[],"attrs":{"line":{"stroke":"#808080","targetMarker":{"d":"M 0 0 0 0","stroke":"none"},"sourceMarker":{"stroke":"none"}}}},{"type":"standard.Link","source":{"x":665,"y":205},"target":{"x":665,"y":565},"router":{"name":"normal"},"id":"84f20eb9-b075-4b6c-b827-7f3c633dca16","z":2,"hoverPostion":{"x":588,"y":288},"attrs":{"line":{"stroke":"#808080","targetMarker":{"d":"M 0 0 0 0","stroke":"none"},"sourceMarker":{"stroke":"none"}}}},{"type":"standard.Link","source":{"x":270,"y":215},"target":{"x":270,"y":575},"router":{"name":"normal"},"id":"60ff0366-c276-4667-a5be-e00688d4c5f5","z":3,"hoverPostion":{"x":173,"y":195},"attrs":{"line":{"stroke":"#808080","targetMarker":{"d":"M 0 0 0 0","stroke":"none"},"sourceMarker":{"stroke":"none"}}}}]}');

// Example



graph.fromJSON(json);
// Example

paper.on('link:connect', function(linkView, evt,...