fix: RTL copy-paste and duplicate (#5560)

This commit is contained in:
Beka Westberg
2021-09-30 17:55:18 -04:00
committed by GitHub
parent ad57942efa
commit f994a9ca58

View File

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