Skip to content

Commit 989b9d8

Browse files
committed
adding comments
1 parent bb3d8f5 commit 989b9d8

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import * as Blockly from 'blockly/core';
2+
import { IBlocksSimple } from '../../blocksInterface';
3+
4+
5+
6+
export class comment implements IBlocksSimple {
7+
addWrapper(interpreter: any, globalObject: any) {
8+
9+
}
10+
category: string= "meta";
11+
definitionBlocksSimple (blocks:any, javaScript:any):void {
12+
const ORDER_ATOMIC = 0;
13+
blocks['comment'] = {
14+
init: function() {
15+
this.appendValueInput("TEXT")
16+
.setCheck(null)
17+
.appendField("comment /* */")
18+
.appendField(new Blockly.FieldLabelSerializable(""), "NAME");
19+
//this.setOutput(true, null);
20+
this.setPreviousStatement(true, null);
21+
this.setNextStatement(true, null);
22+
this.setTooltip("");
23+
this.setHelpUrl("");
24+
}
25+
};
26+
27+
javaScript['comment'] = function(block: any) {
28+
// Print statement.
29+
var msg = javaScript.valueToCode(block, 'TEXT',
30+
/*javaScript.*/ORDER_ATOMIC) || '\'\'';
31+
var code= '/*\n' + msg+'\n*/;\n';
32+
return code;
33+
};
34+
35+
blocks['debugger'] = {
36+
init: function() {
37+
this.appendValueInput("TEXT")
38+
.setCheck(null)
39+
.appendField("debugger")
40+
.appendField(new Blockly.FieldLabelSerializable(""), "NAME");
41+
//this.setOutput(true, null);
42+
this.setPreviousStatement(true, null);
43+
this.setNextStatement(true, null);
44+
this.setTooltip("");
45+
this.setHelpUrl("");
46+
}
47+
};
48+
49+
javaScript['debugger'] = function(block: any) {
50+
// Print statement.
51+
var msg = javaScript.valueToCode(block, 'TEXT',
52+
/*javaScript.*/ORDER_ATOMIC) || '\'\'';
53+
var code= 'startDebugger('+ msg+",'"+ block.id+"',this);\n";
54+
return code;
55+
};
56+
}
57+
58+
fieldXML() : string {
59+
return `<block type="comment">
60+
<value name="TEXT">
61+
<shadow type="text">
62+
<field name="TEXT">Put here comments</field>
63+
</shadow>
64+
</value>
65+
</block>
66+
<block type="debugger">
67+
<value name="TEXT">
68+
<shadow type="text">
69+
<field name="TEXT">my message for debug</field>
70+
</shadow>
71+
</value>
72+
</block>
73+
`
74+
}
75+
}

src/blockly10/src/BlocklyReusable/allNewBlocks.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import container from "./BlocklyNewBlocks/meta/container";
2424
import { SwitchBlock } from "./BlocklyNewBlocks/switch";
2525
import { SpecialCharBlock } from "./BlocklyNewBlocks/specialChar";
2626
import { MoreOperators } from "./BlocklyNewBlocks/moreOperators";
27+
import { comment } from "./BlocklyNewBlocks/meta/comment";
2728

2829
export default class AllNewBlocks
2930
{
@@ -70,6 +71,7 @@ export default class AllNewBlocks
7071
new SwitchBlock(),
7172
new SpecialCharBlock(),
7273
new MoreOperators(),
74+
new comment()
7375
];
7476
return this.nb;
7577
}

0 commit comments

Comments
 (0)