contex improvements
This commit is contained in:
22
src/lib/flowUtils.ts
Normal file
22
src/lib/flowUtils.ts
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user