Skip to content

Commit

Permalink
adding comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ignatandrei committed May 2, 2024
1 parent bb3d8f5 commit 989b9d8
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
75 changes: 75 additions & 0 deletions src/blockly10/src/BlocklyReusable/BlocklyNewBlocks/meta/comment.ts
Original file line number Diff line number Diff line change
@@ -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 `<block type="comment">
<value name="TEXT">
<shadow type="text">
<field name="TEXT">Put here comments</field>
</shadow>
</value>
</block>
<block type="debugger">
<value name="TEXT">
<shadow type="text">
<field name="TEXT">my message for debug</field>
</shadow>
</value>
</block>
`
}
}
2 changes: 2 additions & 0 deletions src/blockly10/src/BlocklyReusable/allNewBlocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -70,6 +71,7 @@ export default class AllNewBlocks
new SwitchBlock(),
new SpecialCharBlock(),
new MoreOperators(),
new comment()
];
return this.nb;
}
Expand Down

0 comments on commit 989b9d8

Please sign in to comment.