connectionHandler.factoryMethod in mxEditor did not set style for new edge
I tried to set sourcePortConstraint when create new edge through mxConnectionHandler, but the sourcePortConstraint of the new edge was not what I setted .
const es = graph.connectionHandler.edgeState;
const direction = 'east';
es.cell.style = mxUtils.setStyle(es.cell.style, 'sourcePortConstraint', direction);
es.style.sourcePortConstraint = direction;
then I found that the style of the new edge is not the same as the style passed to createEdge method. And finally I found out that the factoryMethod defined in mxEditor did not set edge style at all.
my version is 3.9.12, I found the code is the same as the latest version 4.0.3. And the same problem in mxClient.js.
my solution is to rewrite createEdge to set style manual, this works for me.
const connectionHandlerCreateEdge = mxConnectionHandler.prototype.createEdge;
mxConnectionHandler.prototype.createEdge = function (value, source, target, style) {
const edge = connectionHandlerCreateEdge.apply(this, arguments);
if (style) {
edge.setStyle(style);
}
return edge;
}
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.