mirror of
https://github.com/langgenius/dify.git
synced 2026-04-26 10:16:40 +08:00
initial node position
This commit is contained in:
parent
ba7b9a595b
commit
b31da3b195
@ -9,9 +9,23 @@ import type {
|
|||||||
Node,
|
Node,
|
||||||
} from './types'
|
} from './types'
|
||||||
import { BlockEnum } from './types'
|
import { BlockEnum } from './types'
|
||||||
|
import {
|
||||||
|
NODE_WIDTH_X_OFFSET,
|
||||||
|
START_INITIAL_POSITION,
|
||||||
|
} from './constants'
|
||||||
import type { QuestionClassifierNodeType } from './nodes/question-classifier/types'
|
import type { QuestionClassifierNodeType } from './nodes/question-classifier/types'
|
||||||
|
|
||||||
export const initialNodes = (nodes: Node[], edges: Edge[]) => {
|
export const initialNodes = (nodes: Node[], edges: Edge[]) => {
|
||||||
|
const firstNode = nodes[0]
|
||||||
|
|
||||||
|
if (!firstNode?.position) {
|
||||||
|
nodes.forEach((node, index) => {
|
||||||
|
node.position = {
|
||||||
|
x: START_INITIAL_POSITION.x + index * NODE_WIDTH_X_OFFSET,
|
||||||
|
y: START_INITIAL_POSITION.y,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
return nodes.map((node) => {
|
return nodes.map((node) => {
|
||||||
node.type = 'custom'
|
node.type = 'custom'
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user