Skip to content

Commit aef375e

Browse files
committed
programatic control for removing of nodes
1 parent 24109c1 commit aef375e

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/graph.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,10 @@ export class NodeFlowGraph {
396396
this.#mainNodeSubsystem.addNode(node);
397397
}
398398

399+
removeNode(node: FlowNode): void {
400+
this.#mainNodeSubsystem.removeNode(node);
401+
}
402+
399403
addNote(note: FlowNote): void {
400404
this.#mainNoteSubsystem.addNote(note);
401405
}

src/nodes/subsystem.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export class NodeSubsystem {
139139
public addOnNodeCreatedListener(callback: NodeCreatedCallback): void {
140140
this.#nodeFactory.addOnNodeCreatedListener(callback);
141141
}
142-
142+
143143
public nodeFactory(): NodeFactory {
144144
return this.#nodeFactory;
145145
}
@@ -477,6 +477,14 @@ export class NodeSubsystem {
477477
return this.#widgetCurrentlyClicking !== null;
478478
}
479479

480+
removeNode(node: FlowNode): void {
481+
for (let i = 0; i < this.#nodes.length; i++) {
482+
if (this.#nodes[i] === node) {
483+
this.#removeNodeByIndex(i);
484+
}
485+
}
486+
}
487+
480488
#removeNodeByIndex(nodeIndex: number): void {
481489
this.#removeNodeConnections(nodeIndex);
482490
const node = this.#nodes[nodeIndex];

0 commit comments

Comments
 (0)