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

Implemented basic delete on node click

parent 57b6e001
No related branches found
No related tags found
1 merge request!2Implemented editor in the react framework
Pipeline #56565 passed
......@@ -8,6 +8,7 @@ import { ToolDetails } from "./tooldetails";
import { SpaceSelect } from "./spaceselect";
import "./editor.css";
import ReactForceGraph2d from "react-force-graph-2d";
import { Node } from "../structures/graph/node";
type propTypes = any;
type stateTypes = {
......@@ -26,6 +27,7 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
super(props);
this.loadGraph = this.loadGraph.bind(this);
this.loadSpace = this.loadSpace.bind(this);
this.handleNodeClick = this.handleNodeClick.bind(this);
// Set as new state
this.state = {
......@@ -156,6 +158,10 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
};
}
private handleNodeClick(node: Node) {
node.delete();
}
render(): React.ReactNode {
// The id "ks-editor" indicates, that the javascript associated with this should automatically be executed
return (
......@@ -170,7 +176,11 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
<ToolDetails />
</div>
{this.state.graph ? (
<ReactForceGraph2d graphData={this.state.graph.data} />
<ReactForceGraph2d
graphData={this.state.graph.data}
onNodeClick={this.handleNodeClick}
autoPauseRedraw={false}
/>
) : undefined}
</div>
</div>
......
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