how to use block-sharable-procedures plugin in script tag way?

61 views
Skip to first unread message

m lz

unread,
Apr 30, 2023, 11:14:56 AM4/30/23
to Blockly
hi buddy,in this article https://developers.google.com/blockly/guides/create-custom-blocks/procedures/using-procedures?hl=en#json
introduce the modules way code like bellows
import Blockly from 'blockly';
import {blocks, unregisterProcedureBlocks} '@blockly/block-sharable-procedures';

unregisterProcedureBlocks
();
Blockly.common.defineBlocks(blocks);


but how to transform this code to unpkg code?
but how to change above code is hard for me.

any suggestion is prefred

Christopher Allen

unread,
May 3, 2023, 6:57:44 PM5/3/23
to blo...@googlegroups.com
Hi Frederik,

You can import Blockly and the shareable procedures from unpkg like this:


then you will find that all of the needed exports are automatically defined in the global scope (i.e., as properties on window), so you can just:

<script>
unregisterProcedureBlocks();
Blockly.common.defineBlocks(blocks);
</script>



Best wishes,

Christopher
 
Reply all
Reply to author
Forward
0 new messages