mirror of
https://github.com/google/blockly.git
synced 2026-01-10 18:37:09 +01:00
Fixes copy paste to work with the marker (#2740)
* Fixes copy paste to work with the marker
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user