1. Anchor routing added with mutiport

This commit is contained in:
2026-05-30 12:04:02 +08:00
parent 2d9b2b0983
commit 5a3a80700f
23 changed files with 1226 additions and 234 deletions
+45 -2
View File
@@ -196,8 +196,51 @@ assert(
'holding a component and pressing Space should rotate it by 90 degrees'
);
assert(
canvasHtml.includes('getSpaceRotationTarget') && canvasHtml.includes('selectedSpaceNode'),
'Space rotation should also use the currently selected component when no mouse-hold target is active'
canvasHtml.includes('getSpaceRotationTarget') &&
canvasHtml.includes('selectedSpaceNode') &&
canvasHtml.includes('node.type !== \'rotatableNode\' && node.type !== \'portNode\' && node.type !== \'anchorNode\'') &&
canvasHtml.includes('node.type === \'portNode\' || node.data?.elementType === \'port\'') &&
canvasHtml.includes('angle: normalizeAngle(Number(node.data?.angle || 0) + 90)'),
'Space rotation should also rotate selected Port and Anchor elements'
);
assert(
canvasHtml.includes('const anchorRotation = data.rotation || 0') &&
canvasHtml.includes('const anchorVisualRotation = -Number(anchorRotation || 0)') &&
canvasHtml.includes('transform: `rotate(${anchorVisualRotation}deg)`') &&
canvasHtml.includes('buildPortHandles(localAnchorHandlePorts, { rotation: 0') &&
canvasHtml.includes('anchorDirectionHandles') &&
canvasHtml.includes('rotation: Number(anchorRotation || 0)') &&
canvasHtml.includes('anchorHandleVisualStyle(portHandle') &&
canvasHtml.includes('anchorPortVisualSide') &&
canvasHtml.includes('portHandle.name') &&
canvasHtml.includes('visualSide === \'left\' ? 0 : elementSize.width') &&
canvasHtml.includes('anchorPortVisualTop') &&
canvasHtml.includes('(index - 1) / (portCount - 1)') &&
canvasHtml.includes('elementSize.height - baseHandleStyle.height') &&
canvasHtml.includes('localLeft') &&
canvasHtml.includes('localTop') &&
canvasHtml.includes('handlePositionMap[anchorDirectionHandles.get(portHandle.name) || portHandle.position]') &&
canvasHtml.includes('getAnchorHandleRouteDirection') &&
canvasHtml.includes('rotation: Number(node.data?.rotation || 0)') &&
canvasHtml.includes('directionToReactFlowPosition') &&
canvasHtml.includes('sourcePosition: directionToReactFlowPosition(sourceDirection)') &&
canvasHtml.includes('targetPosition: directionToReactFlowPosition(targetDirection)') &&
!canvasHtml.includes('type: \'parallelRoute\',\n data: {\n ...(edge.data || {}),\n parallelOffset: offset,\n sourceDirection,\n targetDirection') &&
!canvasHtml.includes('rotatedAnchorHandlePositions'),
'Anchor port circles should split into side columns and spread across the full anchor body while built-in rectangular links use rotated directions'
);
assert(
canvasHtml.includes('Port Number') &&
canvasHtml.includes('Pitch') &&
canvasHtml.includes('portNumber') &&
canvasHtml.includes('pitch') &&
canvasHtml.includes('DEFAULT_ELEMENT_PITCH') &&
canvasHtml.includes('buildElementBoxSize') &&
canvasHtml.includes('height: elementSize.height') &&
canvasHtml.includes('elementType: \'anchor\'') &&
canvasHtml.includes('pitch: DEFAULT_ELEMENT_PITCH') &&
canvasHtml.includes('ports: buildElementPorts'),
'Port and Anchor inspectors should expose port number and pitch, default to 10 um pitch, and grow in height'
);
assert(
canvasHtml.includes('const componentIndexesByPrefixRef = useRef({});') &&