-
Notifications
You must be signed in to change notification settings - Fork 17
Update to Blockly 12 #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
I tested this with the Blockly demo project and it worked fine with the JavaScript variant. When using the TypeScript example, I encountered an import error similar to issue #38, but that’s not really relevant to this PR. |
TannerGabriel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After using the PR for additional testing with the TypeScript version, I encountered an issue when opening the toolbar after creating a function with parameters. This also occurs in the JavaScript version.
Steps to Reproduce
- Create a Blockly demo application (
npx @blockly/create-package app hello-world) - Add the plugin
- Create a function and add parameters
- Reopen the toolbar
After some debugging, I found the issue originates from the procedures_callreturn block definition. I resolved it by implementing the saveExtraState and loadExtraState methods (newer JSON-based methods replacing XML) with the same logic as mutationToDom and domToMutation.
Fix
saveExtraState() {
const params = [];
for (let i = 0; this.getInput('ARG' + i); i++) {
const input = this.getInput('ARG' + i);
const field = input.fieldRow[0];
params.push(field.getText());
}
return {
name: this.getFieldValue('PROCNAME'),
params,
};
},
loadExtraState: function(state) {
const name = state['name']
this.setFieldValue(name, 'PROCNAME');
this.arguments_ = []
state.params.forEach(argument => {
this.arguments_.push(argument)
});
this.setProcedureParameters(this.arguments_, null, true);
},Screencast.from.2025-08-09.17-57-23.webm
|
It might generally be beneficial to add the JSON functions to all blocks. Let me know your opinion here @mjgallag |
|
@mjgallag I'm very new to Blockly at the moment so still trying to wrap my head around what makes sense in a plugin and what doesn't. @mark-friedman might have a better sense. |
|
I might be worth trying to figure out what, exactly, is going wrong with the XML-based mutation functions. AFAIK, that hasn't been a problem before, so maybe there is something going on with Blockly 12 (or 11) that is causing this and it would be worth our knowing what that is. Part of the context here, @TannerGabriel, is that we are also in the process of updating MIT App Inventor to Blockly 11 (and later, 12) and if we need to alter all of its blocks' mutation functions from the XML-based ones to JSON-based ones, it would be really nice to know asap. |
|
Fully agree here. The problem doesn't seem to happen in Blockly V11 and according to the documentation a missing While testing, I also found another issue that occurs in both Blockly V11 and V12. It throws an error when trying to add a second variable to the Steps:
After some debugging, I was able to fix the issue by using the input getters and setters instead of directly manipulating |
|
We should probably also add additional unit tests that interact with the mutations and test these scenarios for future version updates. |
|
Any news on how to continue with the update? |
For one I would suggest adding the additional unit tests that interact with the mutations that you suggested. @mjgallag Are you seeing the problem that @TannerGabriel pointed out above where the plugin throws an error when trying to add a second variable to the local_declaration_statement block? |
|
The test cases I mentioned involve UI interactions, like using the toolbox and applying mutations. Do you plan to cover these with browser tests (e.g. Playwright), or simulate them with the current test setup? |
|
@mark-friedman if I run |
Ah, so they actually require UI interactions? I should have inferred that from your previous comments. This is quite odd and suggests some kind of timing issue that I would suggest that for now, let's not bother with browser tests for this. |
|
@mark-friedman ah, sorry wrong bug. @TannerGabriel thanks for testing, I can reproduce adding 2nd variable to |
#68 (comment) RaspberryPiFoundation/blockly#7777 RaspberryPiFoundation/blockly#6786 https://developers.google.com/blockly/guides/contribute/core-architecture/render-management Co-Authored-By: TannerGabriel <40315960+TannerGabriel@users.noreply.github.com>
* Update to Blockly 11.2.2 * Fix deprecated Blockly.inputTypes RaspberryPiFoundation/blockly@75007a0#diff-b0eef723c99dc1228104b3187ab5ff8c524198db8a12994fcbe099f9bef4b010L654-L655 * Fix headless horizontal/vertical param toggle RaspberryPiFoundation/blockly@5db9b5b#diff-d2452865ee29274f173594ba31093a2b8845c47113f7223ca0df1933e4b3de85L273-L274 RaspberryPiFoundation/blockly@5db9b5b#diff-d2452865ee29274f173594ba31093a2b8845c47113f7223ca0df1933e4b3de85R288-R291 * Fix Blockly.Drawer not found in blocky/core ewpatton/appinventor-sources@6c74e5b#diff-179ada7bc9ef841c7b52e24fe50097e0ee0aad37f7f1e4d19fec4f5323ef9785L24 * Fix init/render timing issues #68 (comment) RaspberryPiFoundation/blockly#7777 RaspberryPiFoundation/blockly#6786 https://developers.google.com/blockly/guides/contribute/core-architecture/render-management Co-Authored-By: TannerGabriel <40315960+TannerGabriel@users.noreply.github.com> * Fix block warning icon RaspberryPiFoundation/blockly@75007a0#diff-bb0de0069443e7577f62ffa96e6b51c5fafd06703f50c3eed6eb616ac87467bfL118-L124 https://developers.google.com/blockly/reference/js/blockly.blocksvg_class.setwarningtext_1_method.md * Fix renamed editable_ RaspberryPiFoundation/blockly@61bbd7d#diff-3b78eb431743f14de69af3dbc7fa1d3d158299c58ee01e47c05c33dd205165fbL191-R191 https://github.com/google/blockly/blob/blockly-v11.2.2/core/block.ts#L921-L928 * Fix block warning icon (revert comment) setWarningText checks for warning icon https://github.com/google/blockly/blob/blockly-v11.2.2/core/block_svg.ts#L972 * Fix render & code generation on dropdown change Blocky 10 caused `this.setValue(text)` to stack overflow so it was replaced with `this.doValueUpdate_(text)` which stops render & code generation. It can be removed as it's inside the field validator so the value will be set after successful validation. ewpatton/appinventor-sources@bd2cec9 ewpatton/appinventor-sources@6c74e5b#diff-179ada7bc9ef841c7b52e24fe50097e0ee0aad37f7f1e4d19fec4f5323ef9785R41 https://developers.google.com/blockly/guides/create-custom-blocks/fields/validators --------- Co-authored-by: TannerGabriel <40315960+TannerGabriel@users.noreply.github.com> Co-authored-by: TannerGabriel <gabrieltanner.code@gmail.com>
c70bd69 to
5274868
Compare
5274868 to
760c64a
Compare
|
@mjgallag is this still just a draft or is it ready for review? |
|
@mark-friedman draft, I have not worked on #68 (comment) yet. |
No description provided.