diff --git a/core/workspace_svg.js b/core/workspace_svg.js index aa147b2bd..06a6c292d 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -1548,23 +1548,24 @@ WorkspaceSvg.prototype.pasteBlock_ = function(xmlBlock, jsonBlock) { eventUtils.disable(); let block; try { - let blockX; - let blockY; + let blockX = 0; + let blockY = 0; if (xmlBlock) { block = Xml.domToBlock(xmlBlock, this); blockX = parseInt(xmlBlock.getAttribute('x'), 10); + if (this.RTL) { + blockX = -blockX; + } blockY = parseInt(xmlBlock.getAttribute('y'), 10); } else if (jsonBlock) { block = blocks.append(jsonBlock, this); blockX = jsonBlock['x'] || 10; + blockX = this.getWidth() - blockX; blockY = jsonBlock['y'] || 10; } // Move the duplicate to original position. if (!isNaN(blockX) && !isNaN(blockY)) { - if (this.RTL) { - blockX = -blockX; - } // Offset block until not clobbering another block and not in connection // distance with neighbouring blocks. let collide;