mirror of
https://gitee.com/ByteDance/flowgram.ai.git
synced 2025-07-07 17:43:29 +08:00
feat(fixed-layout): add ConstantKeys.BRANCH_SPACING (#413)
This commit is contained in:
parent
099fd445f2
commit
629a9e564f
@ -91,6 +91,7 @@ export function useEditorProps(
|
|||||||
*/
|
*/
|
||||||
constants: {
|
constants: {
|
||||||
// [ConstantKeys.NODE_SPACING]: 24,
|
// [ConstantKeys.NODE_SPACING]: 24,
|
||||||
|
// [ConstantKeys.BRANCH_SPACING]: 20,
|
||||||
// [ConstantKeys.INLINE_SPACING_BOTTOM]: 24,
|
// [ConstantKeys.INLINE_SPACING_BOTTOM]: 24,
|
||||||
// [ConstantKeys.INLINE_BLOCKS_INLINE_SPACING_BOTTOM]: 13,
|
// [ConstantKeys.INLINE_BLOCKS_INLINE_SPACING_BOTTOM]: 13,
|
||||||
// [ConstantKeys.ROUNDED_LINE_X_RADIUS]: 8,
|
// [ConstantKeys.ROUNDED_LINE_X_RADIUS]: 8,
|
||||||
|
|||||||
@ -56,6 +56,10 @@ export const DefaultSpacingKey = {
|
|||||||
* 普通节点间距。垂直 / 水平
|
* 普通节点间距。垂直 / 水平
|
||||||
*/
|
*/
|
||||||
NODE_SPACING: 'SPACING',
|
NODE_SPACING: 'SPACING',
|
||||||
|
/**
|
||||||
|
* 分支节点间距
|
||||||
|
*/
|
||||||
|
BRANCH_SPACING: 'BRANCH_SPACING',
|
||||||
/**
|
/**
|
||||||
* 圆弧线条 x radius
|
* 圆弧线条 x radius
|
||||||
*/
|
*/
|
||||||
@ -85,7 +89,11 @@ export const DefaultSpacingKey = {
|
|||||||
export const DEFAULT_SPACING = {
|
export const DEFAULT_SPACING = {
|
||||||
NULL: 0,
|
NULL: 0,
|
||||||
[DefaultSpacingKey.NODE_SPACING]: 32, // 普通节点间距。垂直 / 水平
|
[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_BLOCK_PADDING_BOTTOM: 16, // block 底部留白
|
||||||
INLINE_BLOCKS_PADDING_TOP: 30, // block list 上部留白间距
|
INLINE_BLOCKS_PADDING_TOP: 30, // block list 上部留白间距
|
||||||
[DefaultSpacingKey.INLINE_BLOCKS_PADDING_BOTTOM]: 40, // block lit 下部留白间距,因为有两个拐弯,所以翻一倍
|
[DefaultSpacingKey.INLINE_BLOCKS_PADDING_BOTTOM]: 40, // block lit 下部留白间距,因为有两个拐弯,所以翻一倍
|
||||||
|
|||||||
@ -43,7 +43,7 @@ export const InlineBlocksRegistry: FlowNodeRegistry = {
|
|||||||
// 如果小于最小宽度,偏移最小宽度的距离
|
// 如果小于最小宽度,偏移最小宽度的距离
|
||||||
const delta = Math.max(
|
const delta = Math.max(
|
||||||
child.parent!.minInlineBlockSpacing - leftSpacing,
|
child.parent!.minInlineBlockSpacing - leftSpacing,
|
||||||
DEFAULT_SPACING.MARGIN_RIGHT - child.originDeltaX
|
getDefaultSpacing(child.entity, ConstantKeys.BRANCH_SPACING) - child.originDeltaX
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -57,7 +57,7 @@ export const InlineBlocksRegistry: FlowNodeRegistry = {
|
|||||||
// 如果小于最小高度,偏移最小高度的距离
|
// 如果小于最小高度,偏移最小高度的距离
|
||||||
const delta = Math.max(
|
const delta = Math.max(
|
||||||
child.parent!.minInlineBlockSpacing - bottomSpacing,
|
child.parent!.minInlineBlockSpacing - bottomSpacing,
|
||||||
DEFAULT_SPACING.MARGIN_RIGHT - child.originDeltaY
|
getDefaultSpacing(child.entity, ConstantKeys.BRANCH_SPACING) - child.originDeltaY
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
import { FlowRendererKey, FlowTextKey } from '@flowgram.ai/renderer';
|
import { FlowRendererKey, FlowTextKey } from '@flowgram.ai/renderer';
|
||||||
import {
|
import {
|
||||||
DEFAULT_SPACING,
|
|
||||||
FlowNodeBaseType,
|
FlowNodeBaseType,
|
||||||
type FlowNodeRegistry,
|
type FlowNodeRegistry,
|
||||||
FlowNodeTransformData,
|
FlowNodeTransformData,
|
||||||
FlowTransitionLabelEnum,
|
FlowTransitionLabelEnum,
|
||||||
FlowTransitionLineEnum,
|
FlowTransitionLineEnum,
|
||||||
FlowLayoutDefault,
|
FlowLayoutDefault,
|
||||||
|
getDefaultSpacing,
|
||||||
|
ConstantKeys,
|
||||||
} from '@flowgram.ai/document';
|
} from '@flowgram.ai/document';
|
||||||
|
|
||||||
import { TryCatchSpacings, TryCatchTypeEnum } from './constants';
|
import { TryCatchSpacings, TryCatchTypeEnum } from './constants';
|
||||||
@ -118,12 +119,12 @@ export const MainInlineBlocksRegistry: FlowNodeRegistry = {
|
|||||||
if (isVertical) {
|
if (isVertical) {
|
||||||
delta = Math.max(
|
delta = Math.max(
|
||||||
child.parent!.minInlineBlockSpacing,
|
child.parent!.minInlineBlockSpacing,
|
||||||
-child.originDeltaX + DEFAULT_SPACING.MARGIN_RIGHT
|
-child.originDeltaX + getDefaultSpacing(child.entity, ConstantKeys.BRANCH_SPACING)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
delta = Math.max(
|
delta = Math.max(
|
||||||
child.parent!.minInlineBlockSpacing,
|
child.parent!.minInlineBlockSpacing,
|
||||||
-child.originDeltaY + DEFAULT_SPACING.MARGIN_RIGHT
|
-child.originDeltaY + getDefaultSpacing(child.entity, ConstantKeys.BRANCH_SPACING)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -68,4 +68,4 @@ export function ConditionRow({ style, value, onChange, readonly }: PropTypes) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export { ConditionRowValueType };
|
export { type ConditionRowValueType };
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user