@@ -13,7 +13,7 @@ import { ReactNextElement } from "@next-core/react-element";
1313import type { UseSingleBrickConf } from "@next-core/react-runtime" ;
1414import { unwrapProvider } from "@next-core/utils/general" ;
1515import "@next-core/theme" ;
16- import { uniqueId } from "lodash" ;
16+ import { get , uniqueId } from "lodash" ;
1717import classNames from "classnames" ;
1818import { select } from "d3-selection" ;
1919import type { lockBodyScroll as _lockBodyScroll } from "@next-bricks/basic/data-providers/lock-body-scroll/lock-body-scroll" ;
@@ -520,7 +520,7 @@ class EoDrawCanvas extends ReactNextElement implements EoDrawCanvasProps {
520520 source,
521521 target,
522522 data,
523- view : this . lineSettings ,
523+ view : this . lineSettings ! ,
524524 } ;
525525 this . #canvasRef. current ?. addEdge ( newEdge ) ;
526526 return newEdge ;
@@ -1041,25 +1041,24 @@ function LegacyEoDrawCanvasComponent(
10411041 } ,
10421042 [ zoomer ]
10431043 ) ;
1044-
10451044 const { lineConfMap, lineConnectorConf, markers } = useLineMarkers ( {
10461045 cells,
10471046 defaultEdgeLines,
10481047 lineConnector,
10491048 markerPrefix,
10501049 } ) ;
1050+
10511051 const editableLineMap = useEditableLineMap ( { cells, lineConfMap } ) ;
1052- const activeEditableEdge = useMemo ( ( ) => {
1053- let edge : EdgeCell | undefined ;
1054- if ( activeTarget ?. type === "edge" ) {
1055- edge = cells . find ( ( cell ) =>
1056- targetIsActive ( cell , activeTarget )
1057- ) as EdgeCell ;
1058- }
1059- if ( edge && editableLineMap . has ( edge ) ) {
1060- return edge ;
1061- }
1062- return null ;
1052+
1053+ const activeEditableEdges = useMemo ( ( ) => {
1054+ let edges : EdgeCell [ ] = [ ] ;
1055+ edges = cells . filter (
1056+ ( cell ) =>
1057+ targetIsActive ( cell , activeTarget ) &&
1058+ cell . type === "edge" &&
1059+ editableLineMap . has ( cell )
1060+ ) as EdgeCell [ ] ;
1061+ return edges ;
10631062 } , [ activeTarget , cells , editableLineMap ] ) ;
10641063
10651064 const ready = useReady ( { cells, layout, centered } ) ;
@@ -1181,7 +1180,7 @@ function LegacyEoDrawCanvasComponent(
11811180 smartConnectLineState,
11821181 unsetHoverStateTimeoutRef,
11831182 hoverState,
1184- activeEditableEdge ,
1183+ activeEditableEdges ,
11851184 lineEditorState,
11861185 setLineEditorState,
11871186 setHoverState,
@@ -1190,7 +1189,7 @@ function LegacyEoDrawCanvasComponent(
11901189 onChangeEdgeView : handleEdgeChangeView ,
11911190 } ) ,
11921191 [
1193- activeEditableEdge ,
1192+ activeEditableEdges ,
11941193 handleEdgeChangeView ,
11951194 handleSmartConnect ,
11961195 hoverState ,
@@ -1214,20 +1213,23 @@ function LegacyEoDrawCanvasComponent(
12141213 } ,
12151214 onLassoed ( rect ) {
12161215 setLassoRect ( null ) ;
1217- const lassoedCells : ( NodeCell | DecoratorCell ) [ ] = [ ] ;
1216+ const lassoedCells : ( NodeCell | DecoratorCell | EdgeCell ) [ ] = [ ] ;
12181217 for ( const cell of cells ) {
12191218 if (
12201219 isContainerDecoratorCell ( cell ) ||
12211220 isNodeOrAreaDecoratorCell ( cell ) ||
1222- isTextDecoratorCell ( cell )
1221+ isTextDecoratorCell ( cell ) ||
1222+ isEdgeCell ( cell )
12231223 ) {
1224- const x = cell . view . x ;
1225- const y = cell . view . y ;
1224+ const x = get ( cell , "view.x" , 0 ) ;
1225+ const y = get ( cell , "view.y" , 0 ) ;
1226+ const width = get ( cell , "view.width" , 0 ) ;
1227+ const height = get ( cell , "view.height" , 0 ) ;
12261228 if (
12271229 x >= rect . x &&
1228- x + cell . view . width <= rect . x + rect . width &&
1230+ x + width <= rect . x + rect . width &&
12291231 y >= rect . y &&
1230- y + cell . view . height <= rect . y + rect . height
1232+ y + height <= rect . y + rect . height
12311233 ) {
12321234 lassoedCells . push ( cell ) ;
12331235 }
@@ -1352,12 +1354,15 @@ function LegacyEoDrawCanvasComponent(
13521354 ) ) }
13531355 </ g >
13541356 < g >
1355- { lineConnectorConf && (
1356- < LineEditorComponent
1357- editableLineMap = { editableLineMap }
1358- scale = { transform . k }
1359- />
1360- ) }
1357+ { lineConnectorConf &&
1358+ activeEditableEdges ?. map ( ( activeEdge ) => (
1359+ < LineEditorComponent
1360+ editableLineMap = { editableLineMap }
1361+ scale = { transform . k }
1362+ activeEditableEdge = { activeEdge }
1363+ key = { `${ activeEdge . source } -${ activeEdge . target } ` }
1364+ />
1365+ ) ) }
13611366 </ g >
13621367 { lineConnectorConf && (
13631368 < LineConnectorComponent
0 commit comments