feat: implement Convex-synced canvas foundation

This commit is contained in:
Matthias
2026-03-25 14:21:19 +01:00
parent 66c4455033
commit 4d17936570
21 changed files with 2347 additions and 35 deletions

35
lib/canvas-utils.ts Normal file
View File

@@ -0,0 +1,35 @@
import type { Edge as RFEdge, Node as RFNode } from "@xyflow/react";
import type { Doc } from "@/convex/_generated/dataModel";
export function convexNodeToRF(node: Doc<"nodes">): RFNode {
return {
id: node._id,
type: node.type,
position: {
x: node.positionX,
y: node.positionY,
},
data: {
...(typeof node.data === "object" && node.data !== null ? node.data : {}),
status: node.status,
statusMessage: node.statusMessage,
},
style: {
width: node.width,
height: node.height,
},
zIndex: node.zIndex,
parentId: node.parentId,
};
}
export function convexEdgeToRF(edge: Doc<"edges">): RFEdge {
return {
id: edge._id,
source: edge.sourceNodeId,
target: edge.targetNodeId,
sourceHandle: edge.sourceHandle,
targetHandle: edge.targetHandle,
};
}