feat(fixed-layout): add ConstantKeys.BRANCH_SPACING (#413)

This commit is contained in:
xiamidaxia 2025-06-26 17:02:37 +08:00 committed by GitHub
parent 099fd445f2
commit 629a9e564f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 17 additions and 7 deletions

View File

@ -91,6 +91,7 @@ export function useEditorProps(
*/
constants: {
// [ConstantKeys.NODE_SPACING]: 24,
// [ConstantKeys.BRANCH_SPACING]: 20,
// [ConstantKeys.INLINE_SPACING_BOTTOM]: 24,
// [ConstantKeys.INLINE_BLOCKS_INLINE_SPACING_BOTTOM]: 13,
// [ConstantKeys.ROUNDED_LINE_X_RADIUS]: 8,

View File

@ -56,6 +56,10 @@ export const DefaultSpacingKey = {
* /
*/
NODE_SPACING: 'SPACING',
/**
*
*/
BRANCH_SPACING: 'BRANCH_SPACING',
/**
* 线 x radius
*/
@ -85,7 +89,11 @@ export const DefaultSpacingKey = {
export const DEFAULT_SPACING = {
NULL: 0,
[DefaultSpacingKey.NODE_SPACING]: 32, // 普通节点间距。垂直 / 水平
MARGIN_RIGHT: 20, // 普通节点右边间距
[DefaultSpacingKey.BRANCH_SPACING]: 20, // 分支节点间距
/**
* @deprecated use 'BRANCH_SPACING' instead
*/
MARGIN_RIGHT: 20, // 分支节点右边间距
INLINE_BLOCK_PADDING_BOTTOM: 16, // block 底部留白
INLINE_BLOCKS_PADDING_TOP: 30, // block list 上部留白间距
[DefaultSpacingKey.INLINE_BLOCKS_PADDING_BOTTOM]: 40, // block lit 下部留白间距,因为有两个拐弯,所以翻一倍

View File

@ -43,7 +43,7 @@ export const InlineBlocksRegistry: FlowNodeRegistry = {
// 如果小于最小宽度,偏移最小宽度的距离
const delta = Math.max(
child.parent!.minInlineBlockSpacing - leftSpacing,
DEFAULT_SPACING.MARGIN_RIGHT - child.originDeltaX
getDefaultSpacing(child.entity, ConstantKeys.BRANCH_SPACING) - child.originDeltaX
);
return {
@ -57,7 +57,7 @@ export const InlineBlocksRegistry: FlowNodeRegistry = {
// 如果小于最小高度,偏移最小高度的距离
const delta = Math.max(
child.parent!.minInlineBlockSpacing - bottomSpacing,
DEFAULT_SPACING.MARGIN_RIGHT - child.originDeltaY
getDefaultSpacing(child.entity, ConstantKeys.BRANCH_SPACING) - child.originDeltaY
);
return {

View File

@ -1,12 +1,13 @@
import { FlowRendererKey, FlowTextKey } from '@flowgram.ai/renderer';
import {
DEFAULT_SPACING,
FlowNodeBaseType,
type FlowNodeRegistry,
FlowNodeTransformData,
FlowTransitionLabelEnum,
FlowTransitionLineEnum,
FlowLayoutDefault,
getDefaultSpacing,
ConstantKeys,
} from '@flowgram.ai/document';
import { TryCatchSpacings, TryCatchTypeEnum } from './constants';
@ -118,12 +119,12 @@ export const MainInlineBlocksRegistry: FlowNodeRegistry = {
if (isVertical) {
delta = Math.max(
child.parent!.minInlineBlockSpacing,
-child.originDeltaX + DEFAULT_SPACING.MARGIN_RIGHT
-child.originDeltaX + getDefaultSpacing(child.entity, ConstantKeys.BRANCH_SPACING)
);
} else {
delta = Math.max(
child.parent!.minInlineBlockSpacing,
-child.originDeltaY + DEFAULT_SPACING.MARGIN_RIGHT
-child.originDeltaY + getDefaultSpacing(child.entity, ConstantKeys.BRANCH_SPACING)
);
}

View File

@ -68,4 +68,4 @@ export function ConditionRow({ style, value, onChange, readonly }: PropTypes) {
);
}
export { ConditionRowValueType };
export { type ConditionRowValueType };