jgraph / mxgraph

mxGraph is a fully client side JavaScript diagramming library
Other
6.79k stars 2.06k forks source link

Support request - editing existing edges #471

Closed flobiber closed 3 years ago

flobiber commented 4 years ago

i am trying to realize: that i can edit (reconnect to another vertex) an existing edge without selecting it before.

I dont find any solutions for that. My idea, i have to find a way to recognize clicks on start or end of a edge and then delete the old connection manually and start a new connection manually.

But i dont find a way to recognize such click event.

Can u help me? Maybe u can tell me how to recognize such event or you can tell that this function is allready implemented and i just have to activate it with the setting xxxx ;)

PrudhviMadasu commented 3 years ago

Firstly make edge editable using

graph.isCellEditable = function (cell) { return true;
}

then below, it helps you delete one at a time or set of selected edges at a time

graph.addListener(mxEvent.REMOVE_CELLS, function (sender, evt) { var cells = evt.getProperty('cells');

        for (var i = 0; i < cells.length; i++) {
            var cell = cells[i];

            if (this.model.isEdge(cell)) {
                var terminal = this.model.getTerminal(cell, true);
                var parent = this.model.getParent(terminal);
                this.model.remove(cell);
            }
        }
    });