(Hrm, I really need to review this example in more depth... we're using Blockly in a React environment, but we've been using a fork of https://github.com/patientslikeme/react-blockly-component and I have no idea how similar or different it is to this new example.)But I need to ask a few more in depth questions here... do you mean where would you run stuff like workspaceToCode, or where would you include the generator code specifically for Blockly[yourGenerator].test_react_field, or?
--
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/23d1667c-248b-4df0-95b1-9008f74e7e75%40googlegroups.com.
Blockly.JavaScript['test_react_field'] = function(block) {
...
};
ooh! I'll look into that repo - thanks!As for clarifications: both, please! I was hoping to be pointed to where to put Blockly.Javascript['test_react_field']. (In my vanilla JS webpage I just required a file with my generator scripts within the index.html) as well as the react/component version of Blockly.JavaScript.workspaceToCode(MyWorkspace). Maybe the repo you linked will have more insight.The example in my prior email just has a block workspace --- and I think it would be valuable to have a resource like https://blockly-demo.appspot.com/static/demos/generator/index.html which walks through adding generator code and how to eval the blocks.Thanks again!
On Mon, Oct 7, 2019 at 2:02 PM Amber B <ablaylock@citizendeveloper.com> wrote:
--(Hrm, I really need to review this example in more depth... we're using Blockly in a React environment, but we've been using a fork of https://github.com/patientslikeme/react-blockly-component and I have no idea how similar or different it is to this new example.)But I need to ask a few more in depth questions here... do you mean where would you run stuff like workspaceToCode, or where would you include the generator code specifically for Blockly[yourGenerator].test_react_field, or?
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+unsubscribe@googlegroups.com.
Hey Maya,Blockly isn't opinionated about where you define your blocks and their respective generator methods.As you've pointed out, the test block in the sample was defined in customblocks.js by using the JS definition of blocks in Blockly.In order to implement the generator for the custom block, set a block generator function to a property on the generator object with the same name as the block type like so:The above assumes you're using the JavaScript generator, you can substitute JavaScript with your generator of choice.
Blockly.JavaScript['test_react_field'] = function(block) {
...
};It can be added anywhere in your codebase as long as it's imported by your app, and loaded before you run workspaceToCode.Since you asked for somewhere specific to add it, try adding the above in customblocks.js.If you'd like to separate where your blocks are defined and where the generator code sits, you can create another file (say generator.js) and import it in App.js.Be sure to import the generator module (JavaScript / Python / Lua ...) in whichever file you add your generator code to.I've updated the react sample to show how to do this. see https://github.com/google/blockly-samples/pull/8Cheers,Sam
On Monday, October 7, 2019 at 12:11:53 PM UTC-7, Maya Jaffe wrote:
ooh! I'll look into that repo - thanks!As for clarifications: both, please! I was hoping to be pointed to where to put Blockly.Javascript['test_react_field']. (In my vanilla JS webpage I just required a file with my generator scripts within the index.html) as well as the react/component version of Blockly.JavaScript.workspaceToCode(MyWorkspace). Maybe the repo you linked will have more insight.The example in my prior email just has a block workspace --- and I think it would be valuable to have a resource like https://blockly-demo.appspot.com/static/demos/generator/index.html which walks through adding generator code and how to eval the blocks.Thanks again!
On Mon, Oct 7, 2019 at 2:02 PM Amber B <abla...@citizendeveloper.com> wrote:
--(Hrm, I really need to review this example in more depth... we're using Blockly in a React environment, but we've been using a fork of https://github.com/patientslikeme/react-blockly-component and I have no idea how similar or different it is to this new example.)But I need to ask a few more in depth questions here... do you mean where would you run stuff like workspaceToCode, or where would you include the generator code specifically for Blockly[yourGenerator].test_react_field, or?
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/23d1667c-248b-4df0-95b1-9008f74e7e75%40googlegroups.com.
--
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/f39989db-f7c0-43db-9aab-40cd2fd8aa85%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/CALhCQa0MoNhn%3Dj%2B%2BrzO2u3guPDWYNgx9p7puEaedNaTmYY9MXA%40mail.gmail.com.
Blockly.fieldRegistry.register(...)
Blockly.Field.register(...)
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/23d1667c-248b-4df0-95b1-9008f74e7e75%40googlegroups.com.
--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/f39989db-f7c0-43db-9aab-40cd2fd8aa85%40googlegroups.com.
--
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+unsubscribe@googlegroups.com.
Cheers,
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/23d1667c-248b-4df0-95b1-9008f74e7e75%40googlegroups.com.
--
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/f39989db-f7c0-43db-9aab-40cd2fd8aa85%40googlegroups.com.
--
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/CALhCQa0MoNhn%3Dj%2B%2BrzO2u3guPDWYNgx9p7puEaedNaTmYY9MXA%40mail.gmail.com.
--
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/74ca5a91-5deb-4c25-a250-6857455a5cf6%40googlegroups.com.