/** * @author Martin Karkowski * @email m.karkowski@zema.de * @create date 2021-06-24 17:52:26 * @modify date 2021-06-24 17:52:26 * @desc [description] */ import * as go from "gojs"; import { addNodeNextTo } from "../helpers/add-node-next-to"; const make = go.GraphObject.make; /** * Add the Possibility to add comments to the diagram. * @param diagram Go.Diagramm */ export function addCommentsNodes(diagram: go.Diagram): void { diagram.nodeTemplateMap.add("comment", make(go.Node, // this needs to act as a rectangular shape for BalloonLink, { background: "transparent" }, // which can be accomplished by setting the background. make(go.TextBlock, { stroke: "brown", margin: 3 }, new go.Binding("text", "text")) )); diagram.linkTemplateMap.add("comment", // if the BalloonLink class has been loaded from the Extensions directory, use it make(go.Link, make(go.Shape, // the Shape.geometry will be computed to surround the comment node and // point all the way to the commented node { stroke: "brown", strokeWidth: 1, fill: "lightyellow" }) )); } export function addCommentToNode(node: go.Node, text: string): void { addNodeNextTo(node, { text }, { category: "comment" }); }