Install canvas renderers through validated host extensions

This commit is contained in:
2026-11-08 19:08:58 +08:00
parent 361e636ce7
commit 627a043d92
12 changed files with 157 additions and 39 deletions
+5 -1
View File
@@ -25,6 +25,10 @@ function connector(node: InternalNode<CanvasNode>, handle: string | null | undef
}
return result;
}
function nativeConnector(x:number,y:number,side:ConnectorSide):Connector{
const normals={top:{x:0,y:-1},right:{x:1,y:0},bottom:{x:0,y:1},left:{x:-1,y:0}};
return {point:{x,y},normal:normals[side]};
}
function Marker({ id, value, color }: { id: string; value?: EdgeMarker; color: string }) {
const type = value?.type || "none";
if (type === "none") return null;
@@ -47,7 +51,7 @@ export function CanvasEdge(props: EdgeProps<CanvasEdgeModel>) {
if (current?.capture.hasPointerCapture(current.pointerId)) current.capture.releasePointerCapture(current.pointerId);
}, []);
if (!source || !target) return null;
const from = connector(source, props.sourceHandleId, "right"), to = connector(target, props.targetHandleId, "left");
const from = (source.data as ProjectionNode['data']).__headlessRecord ? nativeConnector(props.sourceX,props.sourceY,props.sourcePosition) : connector(source, props.sourceHandleId, "right"), to = (target.data as ProjectionNode['data']).__headlessRecord ? nativeConnector(props.targetX,props.targetY,props.targetPosition) : connector(target, props.targetHandleId, "left");
const data = props.data || {}, appearance = data.appearance || {}, animation = data.animation || {};
const segments = curveSegments(from, to, data.path), path = curvePath(segments);
const midpoint = cubicPoint(segments[Math.floor(segments.length / 2)], .5);