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