Hi,
In our application we generate a serialised Blockly workspace that we subsequently load using the Blockly deserialization functions. I am a bit confused about the requirement for an XML 'extraState' in the JSON serialisation of the 'lists_getIndex' block, i.e.:
{
"type": "lists_getIndex",
"id": "PgTtxza3@08!tgP(kAEJ",
"x": -12,
"y": 13,
"extraState": "<mutation statement=\"true\" at=\"false\"></mutation>",
"fields": {
"MODE": "REMOVE",
"WHERE": "FIRST"
}
}
Line 449 of
https://github.com/google/blockly/blob/master/blocks/lists.js says that this is for backwards compatibility, which might suggest that it isn't necessary for restoring blocks using the new JSON serialization system, however this does not appear to be true for all cases.
If I do the following:
1. Open the Blockly Playground
2. Drag a 'lists_getIndex' block from the 'Lists' section into the workspace
3. Click the 'get' dropdown and change to 'remove'
4. Drag a 'controls_forEach' block from the 'Loops' section into the workspace
5. Attach the 'lists_getIndex' block into the body of the loop
6. Click 'Save JSON'
7. Remove the 'extraState' property from the generated JSON
8. Click 'Load'
I get the exception 'Error: The block "lists_getIndex" block (id="PgTtxza3@08!tgP(kAEJ") is missing a(n) previous connection' from line 485 of
https://github.com/google/blockly/blob/master/core/serialization/blocks.jsI do not get the error after removing the 'extraState' if the 'lists_getIndex' block is at its default values or is not contained within another block.
I can easily just create the required XML fragments in my generated blocks, however I am curious as to why this 'extraState' is stored as XML instead of JSON, as it does seem necessary for successful JSON deserialization in some cases. Am I missing something? I did look through the documentation, but have not yet been able find anything.
Thanks,
Chris