mo4islona / node-blockly

Blockly for Node.js and Browser via CommonJS module
133 stars 81 forks source link

Can't load javascript blocks #25

Closed rjpicucci closed 6 years ago

rjpicucci commented 6 years ago

The api I'm using passes me a javascript defined set of blocks. (React application) So I have to load the javascript via script tag.

The issue is that node-blockly doesn't seem to expose the Blockly.Blocks so when I load the script, I get a undefined "Blockly.Blocks". How can I load it without having to convert the javascript to xml?

Example: Blockly.Blocks['or'] = { init: function() { this.jsonInit({ "args0": [ { "check": "Boolean", "name": "op1", "type": "input_value" }, { "check": "Boolean", "name": "op2", "type": "input_value" } ], "colour": 165, "helpUrl": "", "message0": "%1 or %2", "output": "Boolean", "tooltip": "", "type": "or" }); } };

rjpicucci commented 6 years ago

Would exporting the "Blockly.Blocks" from the browser.js file do the trick here? (using the browser version).

rjpicucci commented 6 years ago

closing issue for now... using "require" instead of "import" fixed the issue I think