fix: copy paste with json system (#5423)

* fix: copy paste w/ json system

* fix: pr comments
This commit is contained in:
Beka Westberg
2021-09-03 22:19:52 +00:00
committed by alschmiedt
parent 96935c2502
commit e7541cb315
7 changed files with 72 additions and 64 deletions

View File

@@ -57,8 +57,8 @@ const Tooltip = goog.require('Blockly.Tooltip');
const Warning = goog.requireType('Blockly.Warning');
/* eslint-disable-next-line no-unused-vars */
const WorkspaceSvg = goog.requireType('Blockly.WorkspaceSvg');
const Xml = goog.require('Blockly.Xml');
const blockAnimations = goog.require('Blockly.blockAnimations');
const blocks = goog.require('Blockly.serialization.blocks');
const browserEvents = goog.require('Blockly.browserEvents');
const common = goog.require('Blockly.common');
const connectionTypes = goog.require('Blockly.connectionTypes');
@@ -996,15 +996,9 @@ BlockSvg.prototype.toCopyData = function() {
if (this.isInsertionMarker_) {
return null;
}
const xml = /** @type {!Element} */ (Xml.blockToDom(this, true));
// Copy only the selected block and internal blocks.
Xml.deleteNext(xml);
// Encode start position in XML.
const xy = this.getRelativeToSurfaceXY();
xml.setAttribute('x', this.RTL ? -xy.x : xy.x);
xml.setAttribute('y', xy.y);
return {
xml: xml,
saveInfo: /** @type {!blocks.State} */(blocks.save(
this, {addCoordinates: true, addNextBlocks: false})),
source: this.workspace,
typeCounts: utils.getBlockTypeCounts(this, true)
};