Explorar o código

fix(demo): freelayout shortcuts copy (#140)

xiamidaxia hai 9 meses
pai
achega
e75c2f8607

+ 2 - 2
apps/demo-free-layout/src/form-components/form-header/index.tsx

@@ -43,7 +43,7 @@ function DropdownContent() {
 
   const handleCopy = useCallback(
     (e: React.MouseEvent) => {
-      clientContext.playground.commandService.executeCommand(FlowCommandId.COPY, node);
+      clientContext.playground.commandService.executeCommand(FlowCommandId.PASTE, [node]);
       e.stopPropagation(); // Disable clicking prevents the sidebar from opening
     },
     [clientContext, node]
@@ -66,7 +66,7 @@ function DropdownContent() {
         <Dropdown.Menu key={key}>
           {canMoveOut && <Dropdown.Item onClick={handleMoveOut}>Move out</Dropdown.Item>}
           <Dropdown.Item onClick={handleCopy} disabled={registry.meta!.copyDisable === true}>
-            Copy
+            Create Copy
           </Dropdown.Item>
           <Dropdown.Item
             onClick={handleDelete}

+ 3 - 2
apps/demo-free-layout/src/shortcuts/shortcuts.ts

@@ -8,6 +8,7 @@ import {
   WorkflowNodeEntity,
   WorkflowNodeJSON,
   WorkflowSelectService,
+  getAntiOverlapPosition,
 } from '@flowgram.ai/free-layout-editor';
 import { Toast } from '@douyinfe/semi-ui';
 
@@ -92,7 +93,7 @@ export function shortcuts(shortcutsRegistry: ShortcutsRegistry, ctx: FreeLayoutP
               nodeJSON.type as string,
               nodeJSON,
               '',
-              nodeJSON.meta?.position,
+              getAntiOverlapPosition(document, nodeJSON.meta!.position!),
               node.parent?.id
             );
           })
@@ -144,7 +145,7 @@ export function shortcuts(shortcutsRegistry: ShortcutsRegistry, ctx: FreeLayoutP
             nodeJSON.type as string,
             nodeJSON,
             '',
-            position,
+            getAntiOverlapPosition(document, position!),
             containerNode?.id
           );
         })