Added Default Value Population to Node Configuration Sidebar
This commit is contained in:
parent
b6500b84da
commit
dff4938f51
@ -199,17 +199,26 @@ export default function FlowEditor({
|
|||||||
});
|
});
|
||||||
const id = "node-" + Date.now();
|
const id = "node-" + Date.now();
|
||||||
const nodeMeta = Object.values(categorizedNodes).flat().find((n) => n.type === type);
|
const nodeMeta = Object.values(categorizedNodes).flat().find((n) => n.type === type);
|
||||||
|
// Seed config defaults:
|
||||||
|
const configDefaults = {};
|
||||||
|
(nodeMeta?.config || []).forEach(cfg => {
|
||||||
|
if (cfg.defaultValue !== undefined) {
|
||||||
|
configDefaults[cfg.key] = cfg.defaultValue;
|
||||||
|
}
|
||||||
|
});
|
||||||
const newNode = {
|
const newNode = {
|
||||||
id,
|
id,
|
||||||
type,
|
type,
|
||||||
position,
|
position,
|
||||||
data: {
|
data: {
|
||||||
label: nodeMeta?.label || type,
|
label: nodeMeta?.label || type,
|
||||||
content: nodeMeta?.content
|
content: nodeMeta?.content,
|
||||||
|
...configDefaults
|
||||||
},
|
},
|
||||||
dragHandle: ".borealis-node-header"
|
dragHandle: ".borealis-node-header"
|
||||||
};
|
};
|
||||||
setNodes((nds) => [...nds, newNode]);
|
setNodes((nds) => [...nds, newNode]);
|
||||||
|
|
||||||
}, [project, setNodes, categorizedNodes]);
|
}, [project, setNodes, categorizedNodes]);
|
||||||
|
|
||||||
const onDragOver = useCallback((event) => {
|
const onDragOver = useCallback((event) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user