diff --git a/src/editor/js/components/editor.tsx b/src/editor/js/components/editor.tsx index cf7c59b60b2a5d011bafc1ca9901c4675224548a..c1ebd2b3c02228cd4af7f3684decc7444cfd0b86 100644 --- a/src/editor/js/components/editor.tsx +++ b/src/editor/js/components/editor.tsx @@ -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,