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);