 make sure new data keys are unique positive integers
    let lastkey = 1;
    myDiagram.model.makeUniqueKeyFunction = (model, data) => {
      let k = data.key || lastkey;
      while (model.findNodeDataForKey(k)) k++;
      data.key = lastkey = k;
      return k;
    };
  }

  window.addEventListener('DOMContentLoaded', init);
</script>

<div id="sample">
  <div id="myDiagramDiv" style="background-color: #f3f4f6; border: solid 1px black; height: 500px"></div>
  <div>
    Edit details:<br />
    <div id="m