From 5049826ca34f4d08716afb9f4a1796549cc056fe Mon Sep 17 00:00:00 2001 From: Tara West Date: Thu, 15 Jan 2026 10:51:01 +0100 Subject: [PATCH] feat(element-configs): Auto-apply defaults on node creation - Added ElementConfigRegistry import to NodeGraphNode - Modified constructor to call applyDefaults() for new nodes - Only applies when node has typename and no existing parameters - Completes MVP 2: Node Integration + Auto-defaults New nodes (Button, Text, etc.) now automatically get: - Sensible default values from their config - Token-based styling (e.g., var(--theme-color-primary)) - Proper sizing (Text gets display: flex, width: auto) Part of STYLE-002 MVP implementation. Next: Test in app, then MVP 3 (Variants + UI). --- .../src/editor/src/models/nodegraphmodel/NodeGraphNode.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/noodl-editor/src/editor/src/models/nodegraphmodel/NodeGraphNode.ts b/packages/noodl-editor/src/editor/src/models/nodegraphmodel/NodeGraphNode.ts index f18bef1..76583c9 100644 --- a/packages/noodl-editor/src/editor/src/models/nodegraphmodel/NodeGraphNode.ts +++ b/packages/noodl-editor/src/editor/src/models/nodegraphmodel/NodeGraphNode.ts @@ -1,6 +1,7 @@ import { each, filter, find, isEqual, some } from 'underscore'; import { ComponentModel } from '@noodl-models/componentmodel'; +import { ElementConfigRegistry } from '@noodl-models/ElementConfigs'; import { NodeGraphModel } from '@noodl-models/nodegraphmodel/NodeGraphModel'; import { NodeGrapPort } from '@noodl-models/NodeGraphPort'; import { NodeLibrary } from '@noodl-models/nodelibrary'; @@ -131,6 +132,12 @@ export class NodeGraphNode extends Model { if (!this.children) this.children = []; if (!this.ports) this.ports = []; if (!this.dynamicports) this.dynamicports = []; + + // Apply element config defaults if available + // This auto-populates new nodes with sensible defaults from their config + if (this.typename && Object.keys(this.parameters).length === 0) { + ElementConfigRegistry.instance.applyDefaults(this as any); + } } static fromJSON(json: NodeGraphNodeJSON): NodeGraphNode {