Explorar o código

fix: fixed-layout dragging adder materials check canDrop (#163)

xiamidaxia hai 8 meses
pai
achega
02a70f4b48

+ 0 - 6
apps/demo-free-layout/src/styles/index.css

@@ -41,12 +41,6 @@
     margin-right: 8px;
 }
 
-.port-if {
-    position: absolute;
-    right: 0px;
-    top: 36px;
-}
-
 .mouse-pad-option-icon {
     display: flex;
     justify-content: center;

+ 16 - 1
packages/materials/fixed-semi-materials/src/components/dragging-adder/index.tsx

@@ -1,7 +1,22 @@
 import React from 'react';
 
+import { FlowDragLayer, usePlayground } from '@flowgram.ai/fixed-layout-editor';
+
 import { UIDragNodeContainer } from './styles';
 
-export default function DraggingAdder(): JSX.Element {
+export default function DraggingAdder(props: any): JSX.Element {
+  const playground = usePlayground();
+  const layer = playground.getLayer(FlowDragLayer);
+  if (!layer) return <></>;
+  if (
+    layer.options.canDrop &&
+    !layer.options.canDrop({
+      dragNodes: layer.dragEntities || [],
+      dropNode: props.from,
+      isBranch: false,
+    })
+  ) {
+    return <></>;
+  }
   return <UIDragNodeContainer />;
 }