From f5206d4565b7e68133387287e543b317343239dc Mon Sep 17 00:00:00 2001 From: Tobias Weinert Date: Thu, 21 Apr 2022 23:01:11 +0200 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20dragging=20fails=20for=20collapsed?= =?UTF-8?q?=20blocks=20with=20Icons,=20which=20have=20been=20=E2=80=A6=20(?= =?UTF-8?q?#6081)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 6076 "dragging fails" improved * fix: "dragging fails (bug #6076)" tested version * fix: "dragging fails (bug google#6076)" moved fix-code after L625 --- core/serialization/blocks.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/serialization/blocks.js b/core/serialization/blocks.js index 6aabb08eebd..f093541a3ee 100644 --- a/core/serialization/blocks.js +++ b/core/serialization/blocks.js @@ -623,6 +623,12 @@ const initBlock = function(block, rendered) { blockSvg.initSvg(); blockSvg.render(false); + // fixes #6076 JSO deserialization doesn't + // set .iconXY_ property so here it will be set + const icons = block.getIcons(); + for (let i = 0; i < icons.length; i++) { + icons[i].computeIconLocation(); + } } else { block.initModel(); } From 75a071e5a9d5aa12983c2fe0a05c38f1178dae22 Mon Sep 17 00:00:00 2001 From: Tobias Weinert Date: Wed, 27 Apr 2022 17:00:47 +0200 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20JSON=20deserialization=20fails=20(bu?= =?UTF-8?q?g=20#6091)=20(collapsed=20procedure=20call=E2=80=A6=20(#6103)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: JSON deserialization fails (bug #6091) (collapsed procedure call blocks) * fix: JSON deserialization fails (bug #6091) changed fix, added tests (collapsed procedure call blocks) --- blocks/procedures.js | 9 ++++---- tests/mocha/serializer_test.js | 40 ++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/blocks/procedures.js b/blocks/procedures.js index 8e652ed3906..21afdb7fa38 100644 --- a/blocks/procedures.js +++ b/blocks/procedures.js @@ -721,10 +721,10 @@ const PROCEDURE_CALL_COMMON = { if (!mutatorOpen) { this.quarkConnections_ = {}; this.quarkIds_ = null; - } - if (!paramIds) { - // Reset the quarks (a mutator is about to open). - return; + } else { + // fix #6091 - this call could cause an error when outside if-else + // expanding block while mutating prevents another error (ancient fix) + this.setCollapsed(false); } // Test arguments (arrays of strings) for changes. '\n' is not a valid // argument name character, so it is a valid delimiter here. @@ -736,7 +736,6 @@ const PROCEDURE_CALL_COMMON = { if (paramIds.length !== paramNames.length) { throw RangeError('paramNames and paramIds must be the same length.'); } - this.setCollapsed(false); if (!this.quarkIds_) { // Initialize tracking for this block. this.quarkConnections_ = {}; diff --git a/tests/mocha/serializer_test.js b/tests/mocha/serializer_test.js index 85247cc98d9..9ddb4a90e32 100644 --- a/tests/mocha/serializer_test.js +++ b/tests/mocha/serializer_test.js @@ -1674,12 +1674,52 @@ Serializer.Mutations.Procedure.Caller = new SerializerTestCase( '' + '' + ''); +Serializer.Mutations.Procedure.CollapsedProceduresCallreturn = new SerializerTestCase( + 'CollapsedProceduresCallreturn', + '' + + '' + + 'x' + + '' + + '' + + '' + + '' + + '' + + 'do something' + + 'Describe this function...' + + '' + + '' + + '' + + '' + + '' + + '' + + ''); +Serializer.Mutations.Procedure.CollapsedProceduresCallnoreturn = new SerializerTestCase( + 'CollapsedProceduresCallnoreturn', + '' + + '' + + 'x' + + '' + + '' + + '' + + '' + + '' + + 'do something' + + 'Describe this function...' + + '' + + '' + + '' + + '' + + '' + + '' + + ''); Serializer.Mutations.Procedure.testCases = [ Serializer.Mutations.Procedure.NoMutation, Serializer.Mutations.Procedure.Variables, Serializer.Mutations.Procedure.NoStatements, Serializer.Mutations.Procedure.IfReturn, Serializer.Mutations.Procedure.Caller, + Serializer.Mutations.Procedure.CollapsedProceduresCallreturn, + Serializer.Mutations.Procedure.CollapsedProceduresCallnoreturn, ]; Serializer.Mutations.Procedure.Names = new SerializerTestSuite('Names'); From b5c4494e6ad7a3a35ba5147cb69954f6580a678c Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Thu, 28 Apr 2022 14:20:03 +0000 Subject: [PATCH 3/4] fix: update package files --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0715c735ea7..054aa5451e6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "blockly", - "version": "8.0.0", + "version": "8.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "blockly", - "version": "8.0.0", + "version": "8.0.1", "license": "Apache-2.0", "dependencies": { "jsdom": "15.2.1" diff --git a/package.json b/package.json index e911495246f..c35184c7ec0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blockly", - "version": "8.0.0", + "version": "8.0.1", "description": "Blockly is a library for building visual programming editors.", "keywords": [ "blockly" From f21b9dbbf9edf07dad3f7a8c3a4e07b8d6a27985 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Thu, 28 Apr 2022 14:22:56 +0000 Subject: [PATCH 4/4] fix: checkin built files --- blockly_compressed.js | 7 ++++--- blockly_compressed.js.map | 2 +- blocks_compressed.js | 2 +- blocks_compressed.js.map | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/blockly_compressed.js b/blockly_compressed.js index 6b95d5457eb..ca057d18c07 100644 --- a/blockly_compressed.js +++ b/blockly_compressed.js @@ -360,8 +360,9 @@ module$contents$Blockly$serialization$blocks_tryToConnectParent=function(a,b,c){ b,c);if(!a.connect(d)){var e=b.workspace.connectionChecker;throw new module$exports$Blockly$serialization$exceptions.BadConnectionCheck(e.getErrorMessage(e.canConnectWithReason(d,a,!1),d,a),a.type===$.module$exports$Blockly$inputTypes.inputTypes.VALUE?"output connection":"previous connection",b,c);}}},module$contents$Blockly$serialization$blocks_loadIcons=function(a,b){b.icons&&(b=b.icons.comment)&&(a.setCommentText(b.text),"pinned"in b&&(a.commentModel.pinned=b.pinned),"width"in b&&"height"in b&& (a.commentModel.size=new module$exports$Blockly$utils$Size.Size(b.width,b.height)),b.pinned&&a.rendered&&!a.isInFlyout&&setTimeout(function(){return a.getCommentIcon().setVisible(!0)},1))},module$contents$Blockly$serialization$blocks_loadFields=function(a,b){if(b.fields)for(var c=Object.keys(b.fields),d=0;d