This commit is contained in:
2026-03-07 10:43:26 +01:00
parent 7e42e74a1e
commit 59224880d2
7 changed files with 164 additions and 76 deletions

View File

@@ -39,18 +39,27 @@ const snapToGrid = (x: number, y: number): { x: number; y: number } => ({
y: Math.round(y / SNAP_GRID[1]) * SNAP_GRID[1],
})
const DEFAULT_NODE_STYLE: Record<string, { width: number; height: number }> = {
config: { width: 320, height: 320 },
render: { width: 384, height: 320 },
variable: { width: 224, height: 180 },
function: { width: 288, height: 260 },
}
const initialNodes: Node[] = [
{
id: 'config-1',
position: { x: 50, y: 50 },
data: { plantuml: '@startuml\nactor User\nparticipant "Render" as R\nUser -> R : config\n@enduml\n' },
type: 'config',
style: DEFAULT_NODE_STYLE.config,
},
{
id: 'render-1',
position: { x: 350, y: 80 },
data: {},
type: 'render',
style: DEFAULT_NODE_STYLE.render,
},
].map((n) => ({ ...n, id: n.id ?? genId() }))
@@ -133,11 +142,13 @@ export default function App() {
variable: { value: '', valueType: 'string' },
function: { body: '// args[0], args[1], ...\nreturn args[0];' },
}
const nodeType = typeMap[type] ?? 'config'
const newNode: Node = {
id,
type: typeMap[type] ?? 'config',
type: nodeType,
position: { x: position.x, y: position.y },
data: dataMap[type] ?? {},
style: DEFAULT_NODE_STYLE[nodeType] ?? DEFAULT_NODE_STYLE.config,
}
setNodes((nds) => nds.concat(newNode))
lastClickRef.current = null