I have a problem with the translation of custom blocks in javascript.
When I build the blocks one below the other I get the code of all blocks displayed correctly. But as soon as I nest one of my blocks inside another one I only get the code for the outer block.
Does anyone have an idea how I could solve this problem?
Function of the outer custom block:
(Blockly as any).JavaScript['chapter'] = function (block) {
let value = '\'' + block.getFieldValue('VAR_FILTER') + '\'';
return 'chapter ';
};
Function of inner custom block:
(Blockly as any).JavaScript['text_input'] = function (block) {
let question_text = '\'' + block.getFieldValue('VAR_QUESTION_TEXT') + '\'';
return question_text;
}
Function that outputs the code:
blocklyToCode() {
(Blockly as any).JavaScript.INFINITE_LOOP_TRAP = null;
let code = (Blockly as any).JavaScript.workspaceToCode(Blockly.mainWorkspace, (Blockly as any).JavaScript.ORDER_ATOMIC);
console.log(code);
}