Skip to content

Commit 718315a

Browse files
Migrating old blocks to new format (#1902)
1 parent 865e684 commit 718315a

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ Executes Javascript, Typescript Scripts.
2626
<!--
2727
### **WORK IN PROGRESS**
2828
-->
29-
### 9.0.5 (2025-06-17)
29+
### **WORK IN PROGRESS**
3030
* (@GermanBluefox) Speed-up loading of GUI
31+
* (@GermanBluefox) Migrating old blocks to new format
3132

3233
### 9.0.4 (2025-06-16)
3334
* (@GermanBluefox) Corrected script editor for Polish language

src-editor/src/Components/blockly-plugins/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,4 +257,18 @@ export function initBlockly(): void {
257257
]),
258258
);
259259
}
260+
261+
// migrate old registry Blockly.JavaScript.my_block to new registry Blockly.JavaScript.forBlock.my_block
262+
const blocklyObject: Record<string, any> = window.Blockly.JavaScript;
263+
if (blocklyObject.forBlock) {
264+
Object.keys(blocklyObject).forEach(key => {
265+
if (typeof blocklyObject[key] === 'function') {
266+
if (!blocklyObject.forBlock[key]) {
267+
console.log(`Migrating Blockly.JavaScript.${key} to Blockly.JavaScript.forBlock.${key}`);
268+
blocklyObject.forBlock[key] = blocklyObject[key];
269+
delete blocklyObject[key];
270+
}
271+
}
272+
});
273+
}
260274
}

0 commit comments

Comments
 (0)