contex improvements

This commit is contained in:
2026-03-07 22:10:16 +01:00
parent 39719b1823
commit 848305fd87
9 changed files with 246 additions and 83 deletions

22
src/lib/flowUtils.ts Normal file
View File

@@ -0,0 +1,22 @@
/** Generate short unique node id */
export const genId = () => `node_${Math.random().toString(36).slice(2, 9)}`
export 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 DEFAULT_DATA: Record<string, any> = {
config: { plantuml: '@startuml\n\n@enduml\n', title: '' },
render: {},
variable: { value: '', valueType: 'string' },
function: { body: '// args[0], args[1], ...\nreturn args[0];' },
}
export function getDefaultDataForType(type: string, newId?: string): any {
const base = { ...DEFAULT_DATA[type] }
if (type === 'config' && newId) base.title = `config-${newId}`
return base
}