mirror of
https://github.com/google/blockly.git
synced 2026-01-20 15:27:09 +01:00
fix: RTL copy-paste and duplicate (#5560)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user