HMR for blockly blocks
This commit is contained in:
@@ -1,24 +1,22 @@
|
||||
import * as Blockly from "blockly";
|
||||
import { javascriptGenerator, Order } from "blockly/javascript";
|
||||
import { Order } from "blockly/javascript";
|
||||
import type { BlockDef } from "../toolbox";
|
||||
|
||||
Blockly.Blocks['console_log_action'] = {
|
||||
init(this: Blockly.Block) {
|
||||
this.appendValueInput('VALUE')
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
// .setCheck('String')
|
||||
.appendField('print');
|
||||
this.setInputsInline(false);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip('Print value to console');
|
||||
this.setHelpUrl('');
|
||||
this.setColour(150);
|
||||
export const consoleLogAction: BlockDef = {
|
||||
category: 'Actions',
|
||||
block: {
|
||||
init(this: Blockly.Block) {
|
||||
this.appendValueInput('VALUE')
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField('print');
|
||||
this.setInputsInline(false);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip('Print value to console');
|
||||
}
|
||||
},
|
||||
code(block, generator) {
|
||||
const value = generator.valueToCode(block, 'VALUE', Order.ATOMIC);
|
||||
return `console.log(${value});\n`;
|
||||
}
|
||||
};
|
||||
|
||||
javascriptGenerator.forBlock['console_log_action'] = function (block, generator) {
|
||||
const valueValue = generator.valueToCode(block, 'VALUE', Order.ATOMIC);
|
||||
return `console.log(${valueValue});\n`;
|
||||
};
|
||||
|
||||
export { };
|
||||
|
||||
Reference in New Issue
Block a user