@@ -116,31 +116,6 @@ export default class ElementEditor {
116
116
const svgGroup = corshape . parentNode ;
117
117
svgGroup . classList . add ( 'selected' ) ;
118
118
119
- // Ofcourse, we dont have to do it if there already are resize handlers
120
- if ( svgGroup . querySelector ( '.resize-handle, .line-modify-handle' ) ) {
121
- return ;
122
- }
123
-
124
- // Connector line special case
125
- if ( selElement . name == 'ConnectionLine' ) {
126
- const pathpoints = corshape . getPathData ( ) ;
127
-
128
- for ( let i = 0 ; i < pathpoints . length ; i ++ ) {
129
- const conhandle = Util . makeSVGElement ( 'circle' ) ;
130
- conhandle . dataset . pathIndex = i ;
131
- if ( i == pathpoints . length - 1 ) {
132
- conhandle . dataset . pathIsLast = true ;
133
- }
134
- conhandle . setAttribute ( 'class' , 'line-modify-handle' ) ;
135
- conhandle . setAttribute ( 'cx' , pathpoints [ i ] . values [ 0 ] ) ;
136
- conhandle . setAttribute ( 'cy' , pathpoints [ i ] . values [ 1 ] ) ;
137
- conhandle . setAttribute ( 'r' , 5 ) ;
138
- svgGroup . appendChild ( conhandle ) ;
139
- }
140
-
141
- return ;
142
- }
143
-
144
119
const boundingBox = corshape . getBBox ( ) ;
145
120
// Make selection borders and corners
146
121
const handles = [
@@ -178,6 +153,58 @@ export default class ElementEditor {
178
153
}
179
154
] ;
180
155
156
+ // Ofcourse, we dont have to do it if there already are resize handlers
157
+ if ( svgGroup . querySelector ( '.resize-handle, .line-modify-handle' ) ) {
158
+ // Update handles
159
+ const resizeHandleEdges = svgGroup . querySelectorAll ( '.resize-handle.edge' ) ;
160
+ const resizeHandleCorners = svgGroup . querySelectorAll ( '.resize-handle.corner' ) ;
161
+ const connectors = svgGroup . querySelectorAll ( '.connector' ) ;
162
+ const connectorSuggestions = svgGroup . querySelectorAll ( '.connection-suggestion' ) ;
163
+
164
+ for ( let i = 0 ; i < handles . length ; i ++ ) {
165
+ if ( ! resizeHandleEdges [ i ] ) {
166
+ continue ;
167
+ }
168
+ const x2 = handles [ ( i + 1 ) % handles . length ] . x ;
169
+ const y2 = handles [ ( i + 1 ) % handles . length ] . y ;
170
+ resizeHandleEdges [ i ] . setAttribute ( 'x1' , handles [ i ] . x ) ;
171
+ resizeHandleEdges [ i ] . setAttribute ( 'y1' , handles [ i ] . y ) ;
172
+ resizeHandleEdges [ i ] . setAttribute ( 'x2' , x2 ) ;
173
+ resizeHandleEdges [ i ] . setAttribute ( 'y2' , y2 ) ;
174
+
175
+ connectors [ i ] . setAttribute ( 'cx' , handles [ i ] . cx ) ;
176
+ connectors [ i ] . setAttribute ( 'cy' , handles [ i ] . cy ) ;
177
+
178
+ connectorSuggestions [ i ] . setAttribute ( 'cx' , handles [ i ] . closecx ) ;
179
+ connectorSuggestions [ i ] . setAttribute ( 'cy' , handles [ i ] . closecy ) ;
180
+
181
+ resizeHandleCorners [ i ] . setAttribute ( 'cx' , handles [ i ] . x ) ;
182
+ resizeHandleCorners [ i ] . setAttribute ( 'cy' , handles [ i ] . y ) ;
183
+ }
184
+
185
+ return ;
186
+ }
187
+
188
+ // Connector line special case
189
+ if ( selElement . name == 'ConnectionLine' ) {
190
+ const pathpoints = corshape . getPathData ( ) ;
191
+
192
+ for ( let i = 0 ; i < pathpoints . length ; i ++ ) {
193
+ const conhandle = Util . makeSVGElement ( 'circle' ) ;
194
+ conhandle . dataset . pathIndex = i ;
195
+ if ( i == pathpoints . length - 1 ) {
196
+ conhandle . dataset . pathIsLast = true ;
197
+ }
198
+ conhandle . setAttribute ( 'class' , 'line-modify-handle' ) ;
199
+ conhandle . setAttribute ( 'cx' , pathpoints [ i ] . values [ 0 ] ) ;
200
+ conhandle . setAttribute ( 'cy' , pathpoints [ i ] . values [ 1 ] ) ;
201
+ conhandle . setAttribute ( 'r' , 5 ) ;
202
+ svgGroup . appendChild ( conhandle ) ;
203
+ }
204
+
205
+ return ;
206
+ }
207
+
181
208
// Resize borders around object, also put connector handles in the middle
182
209
for ( let i = 0 ; i < handles . length ; i ++ ) {
183
210
const border = Util . makeSVGElement ( 'line' ) ;
@@ -654,7 +681,7 @@ export default class ElementEditor {
654
681
}
655
682
656
683
const previousSuggestion = this . editor . svgElement . querySelectorAll (
657
- '.connection-suggest:not(# ' + target . id + ')' ) ;
684
+ '.connection-suggest:not([id=" ' + target . id + '"] )' ) ;
658
685
for ( const suggestion of previousSuggestion ) {
659
686
suggestion . classList . remove ( 'connection-suggest' ) ;
660
687
}
0 commit comments