From 989b9d86f7a3a87b00bf9c7882d7af3861545875 Mon Sep 17 00:00:00 2001 From: Andrei Ignat Date: Thu, 2 May 2024 17:12:19 +0300 Subject: [PATCH] adding comments --- .../BlocklyNewBlocks/meta/comment.ts | 75 +++++++++++++++++++ .../src/BlocklyReusable/allNewBlocks.ts | 2 + 2 files changed, 77 insertions(+) create mode 100644 src/blockly10/src/BlocklyReusable/BlocklyNewBlocks/meta/comment.ts diff --git a/src/blockly10/src/BlocklyReusable/BlocklyNewBlocks/meta/comment.ts b/src/blockly10/src/BlocklyReusable/BlocklyNewBlocks/meta/comment.ts new file mode 100644 index 00000000..22195f72 --- /dev/null +++ b/src/blockly10/src/BlocklyReusable/BlocklyNewBlocks/meta/comment.ts @@ -0,0 +1,75 @@ +import * as Blockly from 'blockly/core'; +import { IBlocksSimple } from '../../blocksInterface'; + + + +export class comment implements IBlocksSimple { + addWrapper(interpreter: any, globalObject: any) { + + } + category: string= "meta"; + definitionBlocksSimple (blocks:any, javaScript:any):void { + const ORDER_ATOMIC = 0; + blocks['comment'] = { + init: function() { + this.appendValueInput("TEXT") + .setCheck(null) + .appendField("comment /* */") + .appendField(new Blockly.FieldLabelSerializable(""), "NAME"); + //this.setOutput(true, null); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + this.setTooltip(""); + this.setHelpUrl(""); + } + }; + + javaScript['comment'] = function(block: any) { + // Print statement. + var msg = javaScript.valueToCode(block, 'TEXT', + /*javaScript.*/ORDER_ATOMIC) || '\'\''; + var code= '/*\n' + msg+'\n*/;\n'; + return code; + }; + + blocks['debugger'] = { + init: function() { + this.appendValueInput("TEXT") + .setCheck(null) + .appendField("debugger") + .appendField(new Blockly.FieldLabelSerializable(""), "NAME"); + //this.setOutput(true, null); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + this.setTooltip(""); + this.setHelpUrl(""); + } + }; + + javaScript['debugger'] = function(block: any) { + // Print statement. + var msg = javaScript.valueToCode(block, 'TEXT', + /*javaScript.*/ORDER_ATOMIC) || '\'\''; + var code= 'startDebugger('+ msg+",'"+ block.id+"',this);\n"; + return code; + }; +} + +fieldXML() : string { + return ` + + + Put here comments + + + + + + + my message for debug + + + +` +} +} \ No newline at end of file diff --git a/src/blockly10/src/BlocklyReusable/allNewBlocks.ts b/src/blockly10/src/BlocklyReusable/allNewBlocks.ts index 0fe095f4..e47e9027 100644 --- a/src/blockly10/src/BlocklyReusable/allNewBlocks.ts +++ b/src/blockly10/src/BlocklyReusable/allNewBlocks.ts @@ -24,6 +24,7 @@ import container from "./BlocklyNewBlocks/meta/container"; import { SwitchBlock } from "./BlocklyNewBlocks/switch"; import { SpecialCharBlock } from "./BlocklyNewBlocks/specialChar"; import { MoreOperators } from "./BlocklyNewBlocks/moreOperators"; +import { comment } from "./BlocklyNewBlocks/meta/comment"; export default class AllNewBlocks { @@ -70,6 +71,7 @@ export default class AllNewBlocks new SwitchBlock(), new SpecialCharBlock(), new MoreOperators(), + new comment() ]; return this.nb; }