Browse Source

fix(slot): slot dash array line style (#714)

* fix: code-editor indent

* fix(slot): slot line dash array
Yiwei Mao 4 months ago
parent
commit
ebeddef1ad

+ 9 - 9
apps/demo-free-layout/src/nodes/code/index.tsx

@@ -20,16 +20,16 @@ const defaultCode = `// Here, you can retrieve input variables from the node usi
 // const ret = { "name": 'Xiaoming', "hobbies": ["Reading", "Traveling"] };
 
 async function main({ params }) {
-    // Build the output object
-    const ret = {
-        "key0": params.input + params.input, // Concatenate the input parameter 'input' twice
-        "key1": ["hello", "world"], // Output an array
-        "key2": { // Output an Object
-            "key21": "hi"
-        },
-    };
+  // Build the output object
+  const ret = {
+    "key0": params.input + params.input, // Concatenate the input parameter 'input' twice
+    "key1": ["hello", "world"], // Output an array
+    "key2": { // Output an Object
+      "key21": "hi"
+    },
+  };
 
-    return ret;
+  return ret;
 }`;
 
 export const CodeNodeRegistry: FlowNodeRegistry = {

+ 23 - 0
packages/canvas-engine/fixed-layout-core/src/activities/slot/extends/slot-block.ts

@@ -58,6 +58,10 @@ export const SlotBlockRegistry: FlowNodeRegistry = {
 
     let startPortVertices: Vertex[] = [{ x: start.x, y: portPoint.y }];
 
+    /**
+     * When Radius is not enough, we should use truncate strategy
+     * 弧度不够时,采取截断策略
+     */
     if (transition.entity.isVertical) {
       const deltaY = Math.abs(portPoint.y - start.y);
       let deltaX = radius;
@@ -87,6 +91,25 @@ export const SlotBlockRegistry: FlowNodeRegistry = {
       ];
     }
 
+    /**
+     * When One Children, we should keep dash array align, so we draw one line directly to child nodes
+     * 只有一个子节点时,我们通常需要保证两条虚线是连贯的,因此我们直接合并,绘制一条线连到子节点
+     */
+    if (transition.transform.children.length === 1) {
+      return [
+        {
+          type: FlowTransitionLineEnum.ROUNDED_LINE,
+          from: start,
+          to: getPortChildInput(transition.transform.children[0]),
+          vertices: startPortVertices,
+          style: {
+            strokeDasharray: '5 5',
+          },
+          radius,
+        },
+      ];
+    }
+
     return [
       {
         type: FlowTransitionLineEnum.ROUNDED_LINE,

+ 5 - 0
packages/canvas-engine/fixed-layout-core/src/index.ts

@@ -4,6 +4,7 @@
  */
 
 export * from './fixed-layout-container-module';
+import { SlotIconRegistry, SlotInlineBlocksRegistry } from './activities/slot/extends';
 import {
   BlockIconRegistry,
   BlockOrderIconRegistry,
@@ -18,6 +19,7 @@ import {
   InlineBlocksRegistry,
   EndRegistry,
   SlotRegistry,
+  SlotBlockRegistry,
 } from './activities';
 
 export const FixedLayoutRegistries = {
@@ -34,6 +36,9 @@ export const FixedLayoutRegistries = {
   InlineBlocksRegistry,
   EndRegistry,
   SlotRegistry,
+  SlotBlockRegistry,
+  SlotIconRegistry,
+  SlotInlineBlocksRegistry,
 };
 
 // Export constant