-
Notifications
You must be signed in to change notification settings - Fork 3k
Workflow block spacing adjustment #2545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,17 @@ export { BLOCK_DIMENSIONS, CONTAINER_DIMENSIONS } from '@/lib/workflows/blocks/b | |
| /** | ||
| * Horizontal spacing between layers (columns) | ||
| */ | ||
| export const DEFAULT_HORIZONTAL_SPACING = 250 | ||
| export const DEFAULT_HORIZONTAL_SPACING = 200 | ||
|
|
||
| /** | ||
| * Offset for newly added/duplicated blocks | ||
| */ | ||
| export const NEW_BLOCK_OFFSET = { | ||
| /** Horizontal offset from source block */ | ||
| X: 200, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hằng xuất khẩu NEW_BLOCK_OFFSET: |
||
| /** Vertical offset from source block */ | ||
| Y: 20, | ||
| } as const | ||
|
|
||
| /** | ||
| * Vertical spacing between blocks in the same layer | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ import type { Edge } from 'reactflow' | |
| import { create } from 'zustand' | ||
| import { devtools } from 'zustand/middleware' | ||
| import { createLogger } from '@/lib/logs/console/logger' | ||
| import { NEW_BLOCK_OFFSET } from '@/lib/workflows/autolayout/constants' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thay vì dùng 250 và 20 cố định, code giờ dùng giá trị từ một hằng số tập trung (NEW_BLOCK_OFFSET). Điều này làm cho offset khi tạo block mới có thể điều chỉnh/đồng bộ từ một nơi duy nhất (dễ bảo trì, dễ thay đổi giao diện/autolayout) |
||
| import { getBlockOutputs } from '@/lib/workflows/blocks/block-outputs' | ||
| import { TriggerUtils } from '@/lib/workflows/triggers/triggers' | ||
| import { getBlock } from '@/blocks' | ||
|
|
@@ -591,8 +592,8 @@ export const useWorkflowStore = create<WorkflowStore>()( | |
|
|
||
| const newId = crypto.randomUUID() | ||
| const offsetPosition = { | ||
| x: block.position.x + 250, | ||
| y: block.position.y + 20, | ||
| x: block.position.x + NEW_BLOCK_OFFSET.X, | ||
| y: block.position.y + NEW_BLOCK_OFFSET.Y, | ||
| } | ||
|
|
||
| const newName = getUniqueBlockName(block.name, get().blocks) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trước: vị trí mới được tính bằng các "magic numbers" cố định x: sourceBlock.position.x + 250 và y: sourceBlock.position.y + 20
Sau: các giá trị 250 và 20 được thay bằng NEW_BLOCK_OFFSET.X và NEW_BLOCK_OFFSET.Y (và bạn thấy dòng import mới: import { NEW_BLOCK_OFFSET } from '@/lib/workflows/autolayout/constants')