From 6f433d75219b8c3e9ddb1cee81bfec26e6d16595 Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Wed, 1 May 2019 21:12:38 -0700 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20preserve=20IDs=20during=20cut/c?= =?UTF-8?q?opy/paste=20or=20flyout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, if the XML of a toolbox contained a block ID, the first creation of this block would inherit this ID. Thus two realtime collaborators could realistically end up with conflict. Likewise, cut and paste could generate similar conflict. --- core/blockly.js | 2 +- core/flyout_base.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/blockly.js b/core/blockly.js index ca1dcb83f..562af5f29 100644 --- a/core/blockly.js +++ b/core/blockly.js @@ -281,7 +281,7 @@ Blockly.copy_ = function(toCopy) { if (toCopy.isComment) { var xml = toCopy.toXmlWithXY(); } else { - var xml = Blockly.Xml.blockToDom(toCopy); + var xml = Blockly.Xml.blockToDom(toCopy, true); // Copy only the selected block and internal blocks. Blockly.Xml.deleteNext(xml); // Encode start position in XML. diff --git a/core/flyout_base.js b/core/flyout_base.js index ab77802f9..61ffed7cb 100644 --- a/core/flyout_base.js +++ b/core/flyout_base.js @@ -794,7 +794,7 @@ Blockly.Flyout.prototype.placeNewBlock_ = function(oldBlock) { } // Create the new block by cloning the block in the flyout (via XML). - var xml = Blockly.Xml.blockToDom(oldBlock); + var xml = Blockly.Xml.blockToDom(oldBlock, true); // The target workspace would normally resize during domToBlock, which will // lead to weird jumps. Save it for terminateDrag. targetWorkspace.setResizesEnabled(false);