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 @@ -1358,38 +1358,6 @@ export class Navigation {
13581358 return true ;
13591359 }
13601360
1361- /**
1362- * Pastes the copied block to the marked location if possible or
1363- * onto the workspace otherwise.
1364- *
1365- * @param copyData The data to paste into the workspace.
1366- * @param workspace The workspace to paste the data into.
1367- * @returns True if the paste was sucessful, false otherwise.
1368- */
1369- paste ( copyData : Blockly . ICopyData , workspace : Blockly . WorkspaceSvg ) : boolean {
1370- // Do this before clipoard.paste due to cursor/focus workaround in getCurNode.
1371- const targetNode = workspace . getCursor ( ) ?. getCurNode ( ) ;
1372-
1373- Blockly . Events . setGroup ( true ) ;
1374- const block = Blockly . clipboard . paste (
1375- copyData ,
1376- workspace ,
1377- ) as Blockly . BlockSvg ;
1378- if ( block ) {
1379- if ( targetNode ) {
1380- this . tryToConnectNodes (
1381- workspace ,
1382- targetNode ,
1383- Blockly . ASTNode . createBlockNode ( block ) ! ,
1384- ) ;
1385- }
1386- this . removeMark ( workspace ) ;
1387- return true ;
1388- }
1389- Blockly . Events . setGroup ( false ) ;
1390- return false ;
1391- }
1392-
13931361 /**
13941362 * Triggers a flyout button's callback.
13951363 *
You can’t perform that action at this time.
0 commit comments