Block (factory) Library: base block gone after manually edit generated JSON

42 views
Skip to first unread message

Charles Lee

unread,
May 24, 2022, 8:15:19 PM5/24/22
to Blockly
Hi guys,

I found a bug in block factory library demo when trying to customise it to suit my project.

Reproduce step: (See screenshot for more details)
  1. Open the demo and change the block type in base block, e.g. I changed it to "test";
  2. Change the Block Definition format to "Manual JSON..." and make a change, e.g. I changed colour
  3. Switch the Block Definition format back to "JSON", the changes stays in preview workspace, but the base block in main workspace is gone.  

Please help. Any idea is appreciated. 

Charles.
step 1.pngstep 2.pngstep 3.png

Charles Lee

unread,
May 25, 2022, 2:54:42 AM5/25/22
to Blockly
Found the problem. The following function has not been defined. 

Blockly.hueToRgb(hue)

To fix it, replace line 718 - 720 with the following code.

var colourHex = Blockly.utils.colour.hsvToHex(hue, Blockly.HSV_SATURATION, 255 * Blockly.HSV_VALUE);
colourBlock.append(BlockDefinitionExtractor.newDomElement_('mutation', {
    colour: colourHex
}));

I will report this in GitHub later today.
Message has been deleted

Christopher Allen

unread,
May 30, 2022, 1:34:02 PM5/30/22
to Blockly
On Wednesday, 25 May 2022 at 07:54:42 UTC+1 tuba...@gmail.com wrote:
Found the problem. The following function has not been defined. 

Blockly.hueToRgb(hue)

To fix it, replace line 718 - 720 with the following code.

var colourHex = Blockly.utils.colour.hsvToHex(hue, Blockly.HSV_SATURATION, 255 * Blockly.HSV_VALUE);
colourBlock.append(BlockDefinitionExtractor.newDomElement_('mutation', {
    colour: colourHex
}));

I will report this in GitHub later today.

Great!  I see your report of issue #6175; thanks for that.


Christopher

Reply all
Reply to author
Forward
0 new messages