@@ -149,7 +149,6 @@ export function registerCopy() {
149149 name : names . COPY ,
150150 preconditionFn ( workspace , scope ) {
151151 const focused = scope . focusedNode ;
152- if ( ! ( focused instanceof BlockSvg ) ) return false ;
153152
154153 const targetWorkspace = workspace . isFlyout
155154 ? workspace . targetWorkspace
@@ -171,25 +170,12 @@ export function registerCopy() {
171170 const focused = scope . focusedNode ;
172171 if ( ! focused || ! isICopyable ( focused ) || ! isCopyable ( focused ) )
173172 return false ;
174- let targetWorkspace : WorkspaceSvg | null ;
175- let hideChaff = false ;
176- if ( focused instanceof BlockSvg ) {
177- hideChaff = ! focused . workspace . isFlyout ;
178- targetWorkspace =
179- focused . workspace instanceof WorkspaceSvg
180- ? focused . workspace
181- : workspace ;
182- targetWorkspace = targetWorkspace . isFlyout
183- ? targetWorkspace . targetWorkspace
184- : targetWorkspace ;
185- } else {
186- targetWorkspace = workspace . isFlyout
187- ? workspace . targetWorkspace
188- : workspace ;
189- }
173+ const targetWorkspace = workspace . isFlyout
174+ ? workspace . targetWorkspace
175+ : workspace ;
190176 if ( ! targetWorkspace ) return false ;
191177
192- if ( hideChaff ) {
178+ if ( focused . workspace . isFlyout ) {
193179 targetWorkspace . hideChaff ( ) ;
194180 }
195181 copyData = focused . toCopyData ( ) ;
@@ -230,27 +216,21 @@ export function registerCut() {
230216 } ,
231217 callback ( workspace , e , shortcut , scope ) {
232218 const focused = scope . focusedNode ;
219+ if ( ! focused || ! isCuttable ( focused ) || ! isICopyable ( focused ) ) {
220+ return false ;
221+ }
222+ copyData = focused . toCopyData ( ) ;
223+ copyWorkspace = workspace ;
224+ copyCoords = isDraggable ( focused )
225+ ? focused . getRelativeToSurfaceXY ( )
226+ : null ;
233227
234228 if ( focused instanceof BlockSvg ) {
235- copyData = focused . toCopyData ( ) ;
236- copyWorkspace = workspace ;
237- copyCoords = focused . getRelativeToSurfaceXY ( ) ;
238229 focused . checkAndDelete ( ) ;
239- return true ;
240- } else if (
241- isIDeletable ( focused ) &&
242- focused . isDeletable ( ) &&
243- isICopyable ( focused )
244- ) {
245- copyData = focused . toCopyData ( ) ;
246- copyWorkspace = workspace ;
247- copyCoords = isDraggable ( focused )
248- ? focused . getRelativeToSurfaceXY ( )
249- : null ;
230+ } else if ( isIDeletable ( focused ) ) {
250231 focused . dispose ( ) ;
251- return true ;
252232 }
253- return false ;
233+ return ! ! copyData ;
254234 } ,
255235 keyCodes : [ ctrlX , metaX ] ,
256236 } ;
0 commit comments