This is my node + selection Adornment :
return g(go.Node, 'Auto', {
alignmentFocus: go.Spot.Center,
selectionAdornmentTemplate: g(go.Adornment, 'Spot',
createEventOptions(),
g(go.Shape, 'RoundedRectangle',
{
width: shapeWidth || 110,
height: shapeHeight || 90,
stroke: '#16c4d9',
strokeWidth: 4,
margin: new go.Margin(13,0,0,0),
fill: 'transparent'
}))
},
createEventOptions(),
g(go.Shape, 'RoundedRectangle', {
name: 'MainShape',
width: shapeWidth || 110,
height: shapeHeight || 90,
fill: fill || '#f2f2f2',
margin: new go.Margin(15, 25, 0, 0),
spot1: go.Spot.TopLeft,
spot2: go.Spot.BottomRight,
stroke: '#cdcdcd',
strokeWidth:2
}
// ,
// new go.Binding('stroke', 'isSelected', (b) => b ? '#16c4d9' : '#cdcdcd').ofObject()
),
createBindedTextBlock(shapeWidth),
g(go.Picture, {
maxSize: new go.Size(NaN, imageHeight),
desiredSize: new go.Size(imageWidth, NaN),
alignment: new go.Spot(0.5, 0.3),
imageStretch: go.GraphObject.Uniform,
sourceCrossOrigin: () => 'anonymous'
},
new go.Binding('source', '', function (data) {
return data.ImageUrl ? data.ImageUrl : data.NodeImageUrl;
}),
new go.Binding('visible', 'showMockup', (v) => !v)),
g(go.Picture, {
width: shapeWidth - 6 || 104,
height: shapeHeight - 8 || 82,
alignment: new go.Spot(0.5, 0),
alignmentFocus: go.Spot.TopCenter,
margin:new go.Margin(5,0,0,0),
imageStretch: go.GraphObject.Horizontal,
cursor: diagramMode.isPreview ? 'pointer' : '',
sourceCrossOrigin: () => 'anonymous',
click: (e, obj) => {
if (diagramMode.isPreview) {
if (obj.part.data.showMockup) {
$window.open(obj.part.data.fullSizeMockUrl, "_blank", "width=800, height=600")
}
}
}
},
new go.Binding('source', 'mockupUrl'),
new go.Binding('visible', 'showMockup')),
createLocationBinding(),
createNodePorts(0.015, 0.015, 0.015, 0.015)
);
}
This is the function that creates the ports :
return [({
alignment: new go.Spot(0.5, 0 + top),
portId: '1',
fromSpot: go.Spot.Top,
toSpot: go.Spot.Top,
name: 'PortT',
toLinkable: arePortsEditable(),
fromLinkable: arePortsEditable()
}),
({
alignment: new go.Spot(0 + left, 0.5),
portId: '2',
fromSpot: go.Spot.Left,
toSpot: go.Spot.Left,
name: 'PortR',
toLinkable: arePortsEditable(),
fromLinkable: arePortsEditable()
}),
({
alignment: new go.Spot(0.5, 1 - bottom),
portId: '0',
fromSpot: go.Spot.Bottom,
toSpot: go.Spot.Bottom,
name: 'PortB',
toLinkable: arePortsEditable(),
fromLinkable: arePortsEditable()
}),
({
alignment: new go.Spot(1 - right, 0.5),
portId: '3',
fromSpot: go.Spot.Right,
toSpot: go.Spot.Right,
name: 'PortL',
toLinkable: arePortsEditable(),
fromLinkable: arePortsEditable()
})
];
}