@@ -1356,45 +1356,27 @@ export class Navigation {
13561356 * @returns True if the paste was sucessful, false otherwise.
13571357 */
13581358 paste ( copyData : Blockly . ICopyData , workspace : Blockly . WorkspaceSvg ) : boolean {
1359- let isHandled = false ;
1359+ // Do this before clipoard.paste due to cursor/focus workaround in getCurNode.
1360+ const targetNode = workspace . getCursor ( ) ?. getCurNode ( ) ;
1361+
13601362 Blockly . Events . setGroup ( true ) ;
13611363 const block = Blockly . clipboard . paste (
13621364 copyData ,
13631365 workspace ,
13641366 ) as Blockly . BlockSvg ;
13651367 if ( block ) {
1366- isHandled = this . insertPastedBlock ( workspace , block ) ;
1368+ if ( targetNode ) {
1369+ this . tryToConnectNodes (
1370+ workspace ,
1371+ targetNode ,
1372+ Blockly . ASTNode . createBlockNode ( block ) ! ,
1373+ ) ;
1374+ }
13671375 this . removeMark ( workspace ) ;
1376+ return true ;
13681377 }
13691378 Blockly . Events . setGroup ( false ) ;
1370- return isHandled ;
1371- }
1372-
1373- /**
1374- * Inserts the pasted block at the marked location if a compatible
1375- * connection exists. If no connection has been marked, or there is
1376- * not a compatible connection then the block is placed on the
1377- * workspace.
1378- *
1379- * @param workspace The workspace to paste the block on.
1380- * @param block The block to paste.
1381- * @returns True if the block was pasted to the workspace, false
1382- * otherwise.
1383- */
1384- insertPastedBlock (
1385- workspace : Blockly . WorkspaceSvg ,
1386- block : Blockly . BlockSvg ,
1387- ) : boolean {
1388- let isHandled = false ;
1389- const targetNode = workspace . getCursor ( ) ?. getCurNode ( ) ;
1390- if ( targetNode ) {
1391- isHandled = this . tryToConnectNodes (
1392- workspace ,
1393- targetNode ,
1394- Blockly . ASTNode . createBlockNode ( block ) ! ,
1395- ) ;
1396- }
1397- return isHandled ;
1379+ return false ;
13981380 }
13991381
14001382 /**
0 commit comments