Groups
Groups
Sign in
Groups
Groups
Blockly
Conversations
About
Send feedback
Help
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 AM
4/30/23
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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?
I know I need use <script src="
https://unpkg.com/@blockly/block-shareable-procedures/dist/index.js
"></script>
but how to change above code is hard for me.
any suggestion is prefred
Christopher Allen
unread,
May 3, 2023, 6:57:44 PM
5/3/23
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to blo...@googlegroups.com
Hi Frederik,
You can import Blockly and the shareable procedures from unpkg like this:
<script src="
https://unpkg.com/blo...@9.0.0/blockly.min.js
"></script>
<script src="
https://unpkg.com/@blockly/block-shareab...@1.2.7/dist/index.js
"></script>
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>
See also
this more complete example of how to load Blockly from unpkg.com
.
Best wishes,
Christopher
Reply all
Reply to author
Forward
0 new messages