@@ -1356,45 +1356,27 @@ export class Navigation {
1356
1356
* @returns True if the paste was sucessful, false otherwise.
1357
1357
*/
1358
1358
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
+
1360
1362
Blockly . Events . setGroup ( true ) ;
1361
1363
const block = Blockly . clipboard . paste (
1362
1364
copyData ,
1363
1365
workspace ,
1364
1366
) as Blockly . BlockSvg ;
1365
1367
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
+ }
1367
1375
this . removeMark ( workspace ) ;
1376
+ return true ;
1368
1377
}
1369
1378
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 ;
1398
1380
}
1399
1381
1400
1382
/**
0 commit comments