mirror of
https://github.com/The-Low-Code-Foundation/OpenNoodl.git
synced 2026-03-07 17:43:28 +01:00
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).
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { each, filter, find, isEqual, some } from 'underscore';
|
import { each, filter, find, isEqual, some } from 'underscore';
|
||||||
|
|
||||||
import { ComponentModel } from '@noodl-models/componentmodel';
|
import { ComponentModel } from '@noodl-models/componentmodel';
|
||||||
|
import { ElementConfigRegistry } from '@noodl-models/ElementConfigs';
|
||||||
import { NodeGraphModel } from '@noodl-models/nodegraphmodel/NodeGraphModel';
|
import { NodeGraphModel } from '@noodl-models/nodegraphmodel/NodeGraphModel';
|
||||||
import { NodeGrapPort } from '@noodl-models/NodeGraphPort';
|
import { NodeGrapPort } from '@noodl-models/NodeGraphPort';
|
||||||
import { NodeLibrary } from '@noodl-models/nodelibrary';
|
import { NodeLibrary } from '@noodl-models/nodelibrary';
|
||||||
@@ -131,6 +132,12 @@ export class NodeGraphNode extends Model {
|
|||||||
if (!this.children) this.children = [];
|
if (!this.children) this.children = [];
|
||||||
if (!this.ports) this.ports = [];
|
if (!this.ports) this.ports = [];
|
||||||
if (!this.dynamicports) this.dynamicports = [];
|
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 {
|
static fromJSON(json: NodeGraphNodeJSON): NodeGraphNode {
|
||||||
|
|||||||
Reference in New Issue
Block a user