Skip to content

Commit 73e0866

Browse files
committed
bugfix
1 parent 09beb13 commit 73e0866

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/EditorNodes.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,19 @@ export function newNodeById( id:string ) {
164164
}
165165

166166
const args = referencedNode.constructorArgs;
167+
let node:Node;
167168

168169
if (args) {
169-
return new referencedNode.TypeClass(
170+
node = new referencedNode.TypeClass(
170171
...(Array.isArray(args)
171172
? args
172173
: [args]),
173174
);
174175
} else {
175-
return new referencedNode.TypeClass();
176+
node = new referencedNode.TypeClass();
176177
}
178+
179+
node.type = id;
180+
181+
return node;
177182
}

src/nodes/Node.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ export class Node<MyEvents extends NodeEvents = NodeEvents>
1919
{
2020
editor!: Editor;
2121

22+
private _type:string|undefined;
23+
set type( nodeTYpe:string ) {
24+
if(!this._type) this._type=nodeTYpe;
25+
else throw new Error(`Node ${this.nodeName} already has a type ${nodeTYpe}, you can't set the type again (to ${nodeTYpe})`);
26+
}
27+
get type() {
28+
return this._type ?? "";
29+
}
30+
2231
/**
2332
* ... by the user...
2433
*/
@@ -165,7 +174,7 @@ export class Node<MyEvents extends NodeEvents = NodeEvents>
165174
globalY: number,
166175
onOutletHit?: (outlet: IOutlet) => void,
167176
) {
168-
let hitAreaRatio = 10;
177+
const hitAreaRatio = 10;
169178

170179
//
171180
// for each outlet of this node....

src/ui/NodeSelectionModal.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ class NodeSelector {
8686
instance = new node.TypeClass();
8787
}
8888

89+
instance.type = node.id;
90+
8991
node.onCreated?.(instance);
9092
this.addNewNode(instance);
9193
});

0 commit comments

Comments
 (0)