Fixes copy paste to work with the marker (#2740)

* Fixes copy paste to work with the marker
This commit is contained in:
alschmiedt
2019-07-31 07:49:02 -07:00
committed by GitHub
parent 45e5fb4157
commit 62f4871e45
2 changed files with 11 additions and 0 deletions

View File

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

View File

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