@@ -12,6 +12,7 @@ import { StageHistoryManager } from "../StageHistoryManager";
1212import { StageManager } from "../StageManager" ;
1313import { StageManagerUtils } from "./StageManagerUtils" ;
1414import { StageSectionInOutManager } from "./StageSectionInOutManager" ;
15+ import { Edge } from "../../stageObject/association/Edge" ;
1516
1617/**
1718 * 管理所有东西进出StageSection的逻辑
@@ -135,28 +136,27 @@ export namespace StageSectionPackManager {
135136 details : textNode . details ,
136137 } ) ;
137138 newSection . adjustLocationAndSize ( ) ;
138- // 获取所有连向它的和它连向的东西
139- const fatherConnections = GraphMethods . nodeParentArray ( textNode ) ;
140- const childConnections = GraphMethods . nodeChildrenArray ( textNode ) ;
141139
142- // 删除原来的textNode
143- StageManager . deleteEntities ( [ textNode ] ) ;
144140 // 将新的Section加入舞台
145141 StageManager . addSection ( newSection ) ;
146142 for ( const fatherSection of fatherSections ) {
147143 StageSectionInOutManager . goInSection ( [ newSection ] , fatherSection ) ;
148144 }
149145
150146 if ( ! ignoreEdges ) {
151- // 将所有连向它的东西连到新的Section
152- for ( const fatherConnection of fatherConnections ) {
153- StageManager . connectEntity ( fatherConnection , newSection ) ;
154- }
155- // 将所有连向新的Section的东西连到它
156- for ( const childConnection of childConnections ) {
157- StageManager . connectEntity ( newSection , childConnection ) ;
147+ for ( const edge of StageManager . getAssociations ( ) ) {
148+ if ( edge instanceof Edge ) {
149+ if ( edge . target . uuid === textNode . uuid ) {
150+ edge . target = newSection ;
151+ }
152+ if ( edge . source . uuid === textNode . uuid ) {
153+ edge . source = newSection ;
154+ }
155+ }
158156 }
159157 }
158+ // 删除原来的textNode
159+ StageManager . deleteEntities ( [ textNode ] ) ;
160160 // 更新section的碰撞箱
161161 newSection . adjustLocationAndSize ( ) ;
162162 return newSection ;
0 commit comments