Я пытаюсь избежать ссылок, заканчивающихся в космосе, и я хочу разрешить только ссылки, соединяющие один элемент с другим. Мой текущий код:
new joint.shapes.basic.Rect({
id: id,
size: {
width: width,
height: height
},
attrs: {
text: {
text: label,
'font-size': letterSize
},
rect: {
width: width,
height: height,
rx: 5,
ry: 5,
stroke: '#555',
'magnet': true
}
}
});
И для бумаги:
var paper = new joint.dia.Paper({
el: $('#paper-basic'),
width: 1250,
height: 1000,
model: graph,
gridSize: 1,
validateConnection: function(cellViewS, magnetS, cellViewT, magnetT, end, linkView) {
// Prevent linking from output ports to input ports within one element.
if (cellViewS === cellViewT) return false;
// Prevent linking to input ports.
return magnetT;
},
markAvailable: true
});
Как я могу потребовать, чтобы каждая ссылка имела источник и цель? Может быть, расширив validateConnection
?