File tree Expand file tree Collapse file tree 2 files changed +23
-33
lines changed Expand file tree Collapse file tree 2 files changed +23
-33
lines changed Original file line number Diff line number Diff line change 55 */
66
77import {
8+ ASTNode ,
89 ContextMenuRegistry ,
910 Gesture ,
1011 ShortcutRegistry ,
12+ Events ,
1113 utils as blocklyUtils ,
14+ clipboard ,
1215 ICopyData ,
1316} from 'blockly' ;
1417import * as Constants from '../constants' ;
@@ -356,7 +359,26 @@ export class Clipboard {
356359 const pasteWorkspace = this . copyWorkspace . isFlyout
357360 ? workspace
358361 : this . copyWorkspace ;
359- return this . navigation . paste ( this . copyData , pasteWorkspace ) ;
362+
363+ // Do this before clipoard.paste due to cursor/focus workaround in getCurNode.
364+ const targetNode = pasteWorkspace . getCursor ( ) ?. getCurNode ( ) ;
365+
366+ Events . setGroup ( true ) ;
367+ const block = clipboard . paste ( this . copyData , pasteWorkspace ) as BlockSvg ;
368+ if ( block ) {
369+ if ( targetNode ) {
370+ this . navigation . tryToConnectNodes (
371+ pasteWorkspace ,
372+ targetNode ,
373+ ASTNode . createBlockNode ( block ) ! ,
374+ ) ;
375+ }
376+ this . navigation . removeMark ( pasteWorkspace ) ;
377+ Events . setGroup ( false ) ;
378+ return true ;
379+ }
380+ Events . setGroup ( false ) ;
381+ return false ;
360382 }
361383
362384 /**
Original file line number Diff line number Diff line change @@ -1356,38 +1356,6 @@ export class Navigation {
13561356 return true ;
13571357 }
13581358
1359- /**
1360- * Pastes the copied block to the marked location if possible or
1361- * onto the workspace otherwise.
1362- *
1363- * @param copyData The data to paste into the workspace.
1364- * @param workspace The workspace to paste the data into.
1365- * @returns True if the paste was sucessful, false otherwise.
1366- */
1367- paste ( copyData : Blockly . ICopyData , workspace : Blockly . WorkspaceSvg ) : boolean {
1368- // Do this before clipoard.paste due to cursor/focus workaround in getCurNode.
1369- const targetNode = workspace . getCursor ( ) ?. getCurNode ( ) ;
1370-
1371- Blockly . Events . setGroup ( true ) ;
1372- const block = Blockly . clipboard . paste (
1373- copyData ,
1374- workspace ,
1375- ) as Blockly . BlockSvg ;
1376- if ( block ) {
1377- if ( targetNode ) {
1378- this . tryToConnectNodes (
1379- workspace ,
1380- targetNode ,
1381- Blockly . ASTNode . createBlockNode ( block ) ! ,
1382- ) ;
1383- }
1384- this . removeMark ( workspace ) ;
1385- return true ;
1386- }
1387- Blockly . Events . setGroup ( false ) ;
1388- return false ;
1389- }
1390-
13911359 /**
13921360 * Triggers a flyout button's callback.
13931361 *
You can’t perform that action at this time.
0 commit comments