Shadow Blocks in JSON

163 views
Skip to first unread message

18 Soham Kulkarni

unread,
Jun 30, 2023, 9:46:17 AM6/30/23
to Blockly
I am trying to modernize a Blockly app from XML to JSON but shadow blocks are being a painpoint is there any solution here if yes can someone point me to the documentation or code in the comment 
In the old version I cannot find Blockly.VERSION but in my modern version im using the 10.0.0

Beka Westberg

unread,
Jun 30, 2023, 10:48:55 AM6/30/23
to blo...@googlegroups.com
Hello,

Can you explain a bit about what the pain point is? If you haven't run across it, the migration guide might be helpful!

Hopefully with a bit more info we can find a solution for you =)

Best wishes,
--Beka

On Fri, Jun 30, 2023 at 6:46 AM 18 Soham Kulkarni <sohamku...@gmail.com> wrote:
I am trying to modernize a Blockly app from XML to JSON but shadow blocks are being a painpoint is there any solution here if yes can someone point me to the documentation or code in the comment 
In the old version I cannot find Blockly.VERSION but in my modern version im using the 10.0.0

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/305d75d6-a345-4eaa-8680-53be35985476n%40googlegroups.com.

18 Soham Kulkarni

unread,
Jun 30, 2023, 1:21:19 PM6/30/23
to Blockly
Let me look into that migration guide but the pain point was this is my xml toolbox definition and I wanted a clean JSON definition for the same and the documentation wasn't showing anything for the shadow blocks (the placeholder blocks)
    <category name="PWM" colour="120">
      <block type = "set_servo">
        <value name="pwm">
          <shadow type="servo_pwm">
            <field name="pwm">1000</field>
          </shadow>
        </value>
      </block>
    </category>

Beka Westberg

unread,
Jun 30, 2023, 2:54:01 PM6/30/23
to blo...@googlegroups.com
Ah yeah, the toolbox docs should be updated to include info about shadow blocks (in XML and in JSON) :/ I'll put that on the list of things to fix!

You can specify shadow blocks by taking adding a `shadow` property to the input struct:

```json
      {
        "type": "text_print",
        "inputs": {
          "TEXT": {
            "shadow": {  // This is the important bit!
              "type": "text",  // The rest is just a normal block definition
              "fields": {
                "TEXT": "abc"
              }
            }
          }
        }
      }
```

I hope that helps! If you have any further questions please reply =)
--Beka

18 Soham Kulkarni

unread,
Jul 1, 2023, 2:30:35 AM7/1/23
to Blockly
The `TEXT` in the inputs can be any name i give that input?

18 Soham Kulkarni

unread,
Jul 1, 2023, 10:29:47 AM7/1/23
to Blockly
Hey I tried the convert toolbox to JSON script from the migration guide but i get this error
```Uncaught TypeError: toolbox.getToolboxItems is not a function
    at <anonymous>:19:30
```
What might be the issue?

Beka Westberg

unread,
Jul 5, 2023, 2:09:04 PM7/5/23
to blo...@googlegroups.com
Hello again =)

> The `TEXT` in the inputs can be any name I give that input?

Yes, so for your code, the input name would be "pwm" =)

> Hey I tried the convert toolbox to JSON script from the migration guide but I get this error [error message]. What might be the issue?

Are you using a rendered workspace or a headless workspace? The workspace needs to be rendered and the toolbox needs to be fully instantiated before this works! We recommend running the script from your browser console =)

I hope that helps! If you have any further questions please reply =)
--Beka

18 Soham Kulkarni

unread,
Jul 16, 2023, 10:07:07 AM7/16/23
to Blockly
I tried it in the browser console itself but it didnt work but overall the issue is solved :)
Reply all
Reply to author
Forward
0 new messages