(Blockly as any).Blocks.my_custom_block = {
init() {
this.jsonInit({
message0: ' %1 %2 %3 ',
args0: [
{
type: 'input_value',
name: 'A',
check: 'Number'
},
{
type: 'field_dropdown',
name: 'OP',
options: [
['%{BKY_MATH_ADDITION_SYMBOL}', 'ADD'],
['%{BKY_MATH_SUBTRACTION_SYMBOL}', 'MINUS'],
['%{BKY_MATH_MULTIPLICATION_SYMBOL}', 'MULTIPLY'],
['%{BKY_MATH_DIVISION_SYMBOL}', 'DIVIDE'],
['%{BKY_MATH_POWER_SYMBOL}', 'POWER']
]
},
{
type: 'input_value',
name: 'B',
check: 'Number'
}
],
inputsInline: true,
output: 'Number',
style: 'text_blocks',
helpUrl: '%{BKY_MATH_ARITHMETIC_HELPURL}',
extensions: ['math_op_tooltip']
});
}
};
Replace "my_custom_block" with your custom block name and the body of the object with the code to build it.
I used the same as the built in arithmetic block as an example.
I hope this can help you.
David.