Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71b2235
commit ba50bc9
Showing
4 changed files
with
64 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<xml id="toolbox" style="display: none"> | ||
<category name="Main"> | ||
<block type="forever"></block> | ||
<block type="procedures_defnoreturn"></block> | ||
<block type="math_number"></block> | ||
|
||
<block type="turn"> | ||
<value name="time"> | ||
<shadow type="math_number"> | ||
<field name="NUM">.2</field> | ||
</shadow> | ||
</value> | ||
</block> | ||
|
||
<block type="thrustfor"> | ||
<value name="time"> | ||
<shadow type="math_number"> | ||
<field name="NUM">.2</field> | ||
</shadow> | ||
</value> | ||
</block> | ||
</category> | ||
|
||
<category name="Names" custom="VARIABLE"></category> | ||
<category name="Scripts" custom="PROCEDURE"></category> | ||
</xml> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
var ace = require('brace'); | ||
require('brace/mode/scheme'); | ||
require('brace/theme/terminal'); | ||
|
||
interface Editor { | ||
getCode(): string; | ||
setListener(cb: ()=>void): void; | ||
} | ||
|
||
export class BlocklySL{ | ||
constructor(id: string){ | ||
if (!(<any>window).Blockly){ throw Error('Blockly not loaded!'); } | ||
createBlocklyToolbox(); | ||
this.workspace = (<any>window).Blockly.inject('editor', | ||
{toolbox: document.getElementById('toolbox')}); | ||
} | ||
workspace: any; | ||
getCode(){ | ||
return (<any>window).Blockly.ShipLang.workspaceToCode(this.workspace); | ||
} | ||
setListener(cb: ()=>void){ | ||
this.workspace.addChangeListener(cb); | ||
} | ||
} | ||
|
||
function createBlocklyToolbox(){ | ||
var toolboxXML = require("raw!./blocklySLtoolbox.xml"); | ||
var node = document.createElement('div'); | ||
node.innerHTML = toolboxXML; | ||
console.log(node); | ||
document.body.appendChild(node); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters