@@ -13,6 +13,7 @@ import type {
1313 NodeBrickConf ,
1414 NodeCell ,
1515 EditableLine ,
16+ BaseEdgeCell ,
1617} from "./interfaces" ;
1718import {
1819 isContainerDecoratorCell ,
@@ -51,6 +52,9 @@ export interface CellComponentProps {
5152 unrelatedCells : Cell [ ] ;
5253 dragNodeToContainerActive ?: boolean ;
5354 allowEdgeToArea ?: boolean ;
55+ updateCurActiveEditableEdge ?: (
56+ activeEditableEdge : BaseEdgeCell | null
57+ ) => void ;
5458 onCellsMoving ?( info : MoveCellPayload [ ] ) : void ;
5559 onCellsMoved ?( info : MoveCellPayload [ ] ) : void ;
5660 onCellResizing ?( info : ResizeCellPayload ) : void ;
@@ -82,6 +86,7 @@ export function CellComponent({
8286 hoverCell,
8387 unrelatedCells,
8488 allowEdgeToArea,
89+ updateCurActiveEditableEdge,
8590 onCellsMoving,
8691 onCellsMoved,
8792 onCellResizing,
@@ -96,7 +101,7 @@ export function CellComponent({
96101 onCellMouseLeave,
97102} : CellComponentProps ) : JSX . Element | null {
98103 const {
99- activeEditableEdge ,
104+ activeEditableEdges ,
100105 lineEditorState,
101106 smartConnectLineState,
102107 setSmartConnectLineState,
@@ -109,6 +114,15 @@ export function CellComponent({
109114 ( ) => unrelatedCells . some ( ( item ) => sameTarget ( item , cell ) ) ,
110115 [ cell , unrelatedCells ]
111116 ) ;
117+ const activeEditableEdge = useMemo (
118+ ( ) =>
119+ cell . type === "edge"
120+ ? activeEditableEdges . find (
121+ ( edge ) => edge . source === cell . source && edge . target === cell . target
122+ )
123+ : null ,
124+ [ cell , activeEditableEdges ]
125+ ) ;
112126 // `containerRect` is undefined when it's an edge cell.
113127 const containerRect = useMemo ( ( ) : DecoratorView | undefined => {
114128 if ( isContainerDecoratorCell ( cell ) && isNoManualLayout ( layout ) ) {
@@ -196,7 +210,9 @@ export function CellComponent({
196210 ) ;
197211 }
198212 setSmartConnectLineState ( null ) ;
199- } else if ( activeEditableEdge && lineEditorState ) {
213+ } else if ( ! activeEditableEdge ) {
214+ updateCurActiveEditableEdge ?.( null ) ;
215+ } else if ( lineEditorState ) {
200216 const { type } = lineEditorState ;
201217 const { source, target } = editableLineMap . get ( activeEditableEdge ) ! ;
202218 const { view } = activeEditableEdge ;
@@ -276,7 +292,6 @@ export function CellComponent({
276292 } , [ cell , onCellMouseLeave ] ) ;
277293
278294 const active = targetIsActive ( cell , activeTarget ) ;
279-
280295 return (
281296 < g
282297 className = { classNames ( "cell" , {
0 commit comments