Add new things.

This commit is contained in:
ZXMushroom63
2024-12-09 20:11:19 +08:00
parent 7b384878c2
commit 3bea644b80
8 changed files with 239 additions and 30 deletions

15
block_libmap.js Normal file
View File

@@ -0,0 +1,15 @@
const BLOCK_LIBMAP = {};
var oldDefineBlocks = Blockly.common.defineBlocks;
Blockly.common.defineBlocks = function (blockMap) {
var types = Object.keys(blockMap);
types.forEach(type => {
BLOCK_LIBMAP[type] = (blockMap[type].libs || []);
});
return oldDefineBlocks.apply(this, [blockMap]);
}
function getBlockLibs(block) {
return BLOCK_LIBMAP[block.type] || [];
}
function getBlockLibsByType(blockType) {
return BLOCK_LIBMAP[blockType] || [];
}