From 62f4871e45e65f71155738bee2f5d15a5745fb34 Mon Sep 17 00:00:00 2001 From: alschmiedt Date: Wed, 31 Jul 2019 07:49:02 -0700 Subject: [PATCH] Fixes copy paste to work with the marker (#2740) * Fixes copy paste to work with the marker --- core/keyboard_nav/navigation.js | 3 +++ core/workspace_svg.js | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/core/keyboard_nav/navigation.js b/core/keyboard_nav/navigation.js index a37fb004d..6f9d0a5f9 100644 --- a/core/keyboard_nav/navigation.js +++ b/core/keyboard_nav/navigation.js @@ -543,6 +543,9 @@ Blockly.Navigation.insertBlock = function(block, targetConnection) { if (bestConnection && bestConnection.isConnected() && !bestConnection.targetBlock().isShadow()) { bestConnection.disconnect(); + } else if (!bestConnection) { + Blockly.Navigation.warn( + 'This block can not be inserted at the marked location.'); } return Blockly.Navigation.connect(bestConnection, targetConnection); }; diff --git a/core/workspace_svg.js b/core/workspace_svg.js index e3653b5fc..c6d9d3448 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -1081,6 +1081,14 @@ Blockly.WorkspaceSvg.prototype.pasteBlock_ = function(xmlBlock) { Blockly.Events.disable(); try { var block = Blockly.Xml.domToBlock(xmlBlock, this); + + // Handle paste for keyboard navigation + var markedNode = Blockly.Navigation.marker_.getCurNode(); + if (Blockly.keyboardAccessibilityMode && markedNode) { + Blockly.Navigation.insertBlock(block, markedNode.getLocation()); + return; + } + // Move the duplicate to original position. var blockX = parseInt(xmlBlock.getAttribute('x'), 10); var blockY = parseInt(xmlBlock.getAttribute('y'), 10);