in src/visual/Paper.js [14:69]
constructor(opts) {
super(_.defaults(opts, {
gridSize: 1,
linkPinning: false,
perpendicularLinks: false,
multiLinks: false,
highlighting: {
default: {
name: 'stroke',
options: {
padding: 6,
},
},
embedding: {
name: 'addClass',
options: {
className: 'highlighted-parent',
},
},
},
validateEmbedding: (child, parent) => {
const parentStep = parent.model.step;
const childStepParent = child.step;
return parent.model instanceof VisualGroup && childStepParent.name === parentStep.name;
},
validateConnection: (cellViewS, magnetS, cellViewT, magnetT, end, linkView) => {
if (!cellViewT || !cellViewS || cellViewT.id === cellViewS.id) {
return false;
}
const hasPortClass = (magnet) => {
const classStr = magnet.getAttribute('class');
return classStr && classStr.indexOf('port-body') !== -1;
};
// source
if (!magnetS || !hasPortClass(magnetS)) {
return false;
}
// target
if (!magnetT || !hasPortClass(magnetT)) {
return false;
}
const portUsed = _.find(this.model.getLinks(), link => (
(link.id !== linkView.model.id &&
link.get('target').id === cellViewT.model.id &&
link.get('target').port === magnetT.getAttribute('port'))
));
return !portUsed;
},
markAvailable: true,
}));
}