@@ -81,7 +81,7 @@ export class SectionPackManager {
8181 if ( ! textNode . isSelected ) {
8282 continue ;
8383 }
84- this . targetTextNodeToSection ( textNode ) ;
84+ this . targetTextNodeToSection ( textNode , false , true ) ;
8585 }
8686 this . project . historyManager . recordStep ( ) ;
8787 }
@@ -152,8 +152,13 @@ export class SectionPackManager {
152152 * 将指定的文本节点转换成Section,自动删除原来的TextNode
153153 * @param textNode 要转换的节点
154154 * @param ignoreEdges 是否忽略边的影响
155+ * @param addConnectPoints 是否添加质点
155156 */
156- targetTextNodeToSection ( textNode : TextNode , ignoreEdges : boolean = false ) : Section {
157+ targetTextNodeToSection (
158+ textNode : TextNode ,
159+ ignoreEdges : boolean = false ,
160+ addConnectPoints : boolean = false ,
161+ ) : Section {
157162 // 获取这个节点的父级Section
158163 const fatherSections = this . project . sectionMethods . getFatherSections ( textNode ) ;
159164 const newSection = new Section ( this . project , {
@@ -165,40 +170,40 @@ export class SectionPackManager {
165170 newSection . adjustLocationAndSize ( ) ;
166171
167172 // 创建左上角和右下角的质点
168- const radius = ConnectPoint . CONNECT_POINT_SHRINK_RADIUS ;
169- const sectionRectangle = newSection . collisionBox . getRectangle ( ) ;
173+ if ( addConnectPoints ) {
174+ const radius = ConnectPoint . CONNECT_POINT_SHRINK_RADIUS ;
175+ const sectionRectangle = newSection . collisionBox . getRectangle ( ) ;
176+
177+ // 左上角质点
178+ const topLeftLocation = sectionRectangle . location . clone ( ) ;
179+ const topLeftCollisionBox = new CollisionBox ( [ new Rectangle ( topLeftLocation , Vector . same ( radius * 2 ) ) ] ) ;
180+ const topLeftPoint = new ConnectPoint ( this . project , {
181+ collisionBox : topLeftCollisionBox ,
182+ } ) ;
170183
171- // 左上角质点
172- const topLeftLocation = sectionRectangle . location . clone ( ) ;
173- const topLeftCollisionBox = new CollisionBox ( [ new Rectangle ( topLeftLocation , Vector . same ( radius * 2 ) ) ] ) ;
174- const topLeftPoint = new ConnectPoint ( this . project , {
175- collisionBox : topLeftCollisionBox ,
176- } ) ;
184+ // 右下角质点
185+ const bottomRightLocation = sectionRectangle . location
186+ . clone ( )
187+ . add ( new Vector ( sectionRectangle . size . x - radius * 2 , sectionRectangle . size . y - radius * 2 ) ) ;
188+ const bottomRightCollisionBox = new CollisionBox ( [ new Rectangle ( bottomRightLocation , Vector . same ( radius * 2 ) ) ] ) ;
189+ const bottomRightPoint = new ConnectPoint ( this . project , {
190+ collisionBox : bottomRightCollisionBox ,
191+ } ) ;
177192
178- // 右下角质点
179- const bottomRightLocation = sectionRectangle . location
180- . clone ( )
181- . add ( new Vector ( sectionRectangle . size . x - radius * 2 , sectionRectangle . size . y - radius * 2 ) ) ;
182- const bottomRightCollisionBox = new CollisionBox ( [ new Rectangle ( bottomRightLocation , Vector . same ( radius * 2 ) ) ] ) ;
183- const bottomRightPoint = new ConnectPoint ( this . project , {
184- collisionBox : bottomRightCollisionBox ,
185- } ) ;
193+ // 将质点添加到舞台
194+ this . project . stageManager . add ( topLeftPoint ) ;
195+ this . project . stageManager . add ( bottomRightPoint ) ;
186196
187- // 将质点添加到舞台
188- this . project . stageManager . add ( topLeftPoint ) ;
189- this . project . stageManager . add ( bottomRightPoint ) ;
197+ // 将质点放入Section
198+ this . project . sectionInOutManager . goInSection ( [ topLeftPoint , bottomRightPoint ] , newSection ) ;
199+ }
190200
191201 // 将新的Section加入舞台
192202 this . project . stageManager . add ( newSection ) ;
193203 for ( const fatherSection of fatherSections ) {
194204 this . project . sectionInOutManager . goInSection ( [ newSection ] , fatherSection ) ;
195- // 将质点放入Section
196- // this.project.sectionInOutManager.goInSection([topLeftPoint, bottomRightPoint], fatherSection);
197205 }
198206
199- // 将质点放入Section
200- this . project . sectionInOutManager . goInSection ( [ topLeftPoint , bottomRightPoint ] , newSection ) ;
201-
202207 if ( ! ignoreEdges ) {
203208 for ( const edge of this . project . stageManager . getAssociations ( ) ) {
204209 if ( edge instanceof Edge ) {
0 commit comments