Selaa lähdekoodia

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

xiamidaxia 6 kuukautta sitten
vanhempi
commit
629a9e564f

+ 1 - 0
apps/demo-fixed-layout/src/hooks/use-editor-props.ts

@@ -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,

+ 9 - 1
packages/canvas-engine/document/src/typings/flow-node-register.ts

@@ -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 下部留白间距,因为有两个拐弯,所以翻一倍

+ 2 - 2
packages/canvas-engine/fixed-layout-core/src/activities/inline-blocks.ts

@@ -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 {

+ 4 - 3
packages/canvas-engine/fixed-layout-core/src/activities/try-catch-extends/main-inline-blocks.ts

@@ -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)
         );
       }
 

+ 1 - 1
packages/materials/form-materials/src/components/condition-row/index.tsx

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