Skip to content

Commit 5ef8980

Browse files
author
ColinTree
committed
0.1.1: Supported methods with return value
1 parent 50a6d84 commit 5ef8980

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,17 @@ e.g.
3535
```markdown
3636
# test
3737

38+
---
39+
3840
{% Ai2Method %}{"name":"MethodName", "componentName":"compName1", "arg":["arg1","arg2"]}{% endAi2Method %}
3941

42+
{% Ai2Method %}{"name":"MethodName", "arg":["arg1","arg2"], "output":true}{% endAi2Method %}
43+
4044
{% Ai2Event %}{"name":"EventName", "componentName":"compName2", "arg":["arg1","arg2"]}{% endAi2Event %}
4145

4246
{% Ai2Property %}{"name":"PropertyName", "componentName":"compName3", "getter":true}{% endAi2Property %}
4347

44-
{% Ai2Property %}{"name":"PropertyName", "componentName":"compName4", "getter":false}{% endAi2Property %}
48+
{% Ai2Property %}{"name":"PropertyName", "getter":false}{% endAi2Property %}
4549
```
4650

4751
will be converted into:

assets/plugin.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ require(['gitbook', 'jQuery'], function(gitbook, $) {
2727

2828
var name = block['name'];
2929
var arg = block['arg'] || [];
30+
var output = block['output']===true;
3031
var divId = 'method_'+name;
3132

3233
$(this).attr('id', divId).show();
@@ -38,15 +39,19 @@ require(['gitbook', 'jQuery'], function(gitbook, $) {
3839
this.appendValueInput('NAME').setAlign(Blockly.ALIGN_RIGHT).appendField(arg[i]);
3940
}
4041
this.setInputsInline(false);
41-
this.setPreviousStatement(true, null);
42-
this.setNextStatement(true, null);
42+
if (output) {
43+
this.setOutput(true, null);
44+
} else {
45+
this.setPreviousStatement(true, null);
46+
this.setNextStatement(true, null);
47+
}
4348
this.setColour(COLOUR_METHOD);
4449
this.setTooltip('');
4550
this.setHelpUrl('');
4651
}
4752
};
4853

49-
newBlockAndWorkspace(divId);
54+
newBlockAndWorkspace(divId).moveBy(output?8:0, 0);
5055
});
5156

5257
// EVENT

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@
4545
"type": "git",
4646
"url": "git+https://github.com/ColinTree/gitbook-plugin-ai2-blocks.git"
4747
},
48-
"version": "0.0.3"
48+
"version": "0.1.1"
4949
}

0 commit comments

Comments
 (0)