Skip to content

use all four handles; add marker arrow #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 57 additions & 4 deletions ui/src/components/Canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import ReactFlow, {
Handle,
useReactFlow,
Position,
ConnectionMode,
MarkerType,
Node,
} from "react-flow-renderer";
import Box from "@mui/material/Box";
Expand Down Expand Up @@ -94,8 +96,9 @@ const ScopeNode = memo<Props>(({ data, id, isConnectable }) => {
className="custom-drag-handle"
>
<Handle
type="target"
type="source"
position={Position.Top}
id="top"
isConnectable={isConnectable}
/>
{/* The header of scope nodes. */}
Expand Down Expand Up @@ -127,6 +130,19 @@ const ScopeNode = memo<Props>(({ data, id, isConnectable }) => {
<Handle
type="source"
position={Position.Bottom}
id="bottom"
isConnectable={isConnectable}
/>
<Handle
type="source"
position={Position.Left}
id="left"
isConnectable={isConnectable}
/>
<Handle
type="source"
position={Position.Right}
id="right"
isConnectable={isConnectable}
/>
{selected === id && (
Expand Down Expand Up @@ -285,8 +301,27 @@ const CodeNode = memo<Props>(({ data, id, isConnectable }) => {
ref={ref}
>
<Handle
type="target"
type="source"
position={Position.Top}
id="top"
isConnectable={isConnectable}
/>
<Handle
type="source"
position={Position.Bottom}
id="bottom"
isConnectable={isConnectable}
/>
<Handle
type="source"
position={Position.Left}
id="left"
isConnectable={isConnectable}
/>
<Handle
type="source"
position={Position.Right}
id="right"
isConnectable={isConnectable}
/>
{/* The header of code pods. */}
Expand Down Expand Up @@ -385,12 +420,13 @@ const CodeNode = memo<Props>(({ data, id, isConnectable }) => {
</Box>
)}
</Box>

<Handle
type="source"
position={Position.Bottom}
isConnectable={isConnectable}
/>

{false && (
<Moveable
target={target}
Expand Down Expand Up @@ -515,7 +551,23 @@ export function Canvas() {
[setEdges]
);
const onConnect = useCallback(
(connection) => setEdges((eds) => addEdge(connection, eds)),
(connection) =>
setEdges((eds) =>
addEdge(
{
...connection,
markerEnd: {
type: MarkerType.ArrowClosed,
color: "black",
},
style: {
stroke: "black",
strokeWidth: 3,
},
},
eds
)
),
[setEdges]
);

Expand Down Expand Up @@ -856,6 +908,7 @@ export function Canvas() {
nodeTypes={nodeTypes}
zoomOnScroll={false}
panOnScroll={true}
connectionMode={ConnectionMode.Loose}
>
<Box>
<MiniMap
Expand Down