Skip to content
Snippets Groups Projects
Commit a30cd331 authored by Maximilian Giller's avatar Maximilian Giller :squid:
Browse files

Delete link on link click

parent fd98b3c4
No related branches found
No related tags found
1 merge request!2Implemented editor in the react framework
Pipeline #56710 passed
......@@ -9,6 +9,7 @@ import ReactForceGraph2d from "react-force-graph-2d";
import { Node } from "../structures/graph/node";
import { HistoryNavigator } from "./historynavigator";
import { GraphElement } from "../structures/graph/graphelement";
import { Link } from "../structures/graph/link";
type propTypes = any;
type stateTypes = {
......@@ -50,6 +51,7 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
this.handleBackgroundClick = this.handleBackgroundClick.bind(this);
this.handleNodeDrag = this.handleNodeDrag.bind(this);
this.handleNodeDragEnd = this.handleNodeDragEnd.bind(this);
this.handleLinkClick = this.handleLinkClick.bind(this);
this.renderer = React.createRef();
......@@ -342,6 +344,11 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
return;
}
private handleLinkClick(link: Link) {
link.delete();
this.forceUpdate();
}
private handleEngineStop() {
// Only do something on first stop for each graph
if (this.warmupTicks <= 0) {
......@@ -391,6 +398,7 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
linkCanvasObjectMode={"replace"}
onNodeDrag={this.handleNodeDrag}
onNodeDragEnd={this.handleNodeDragEnd}
onLinkClick={this.handleLinkClick}
onBackgroundClick={(event) =>
this.handleBackgroundClick(
event,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment