quickly bootstrap Blockly instances in node and browser
create-blockly makes it easy to create Blockly instances in both node and the browser (using browserify).
In the browser, Blockly will always be installed in the most flexible and isolated way, using the Blockly's resizable iframe method.
First, make sure you have
on your machine.
Create a new directory with create-blockly installed:
mkdir MyProjectcd MyProjectnpm install create-blockly
Create "browser.js" that instantiates Blockly:
var createBlockly = require"create-blockly";var Blockly = createBlockly// This is where the iframed resizable Blockly will be embedded.container: documentgetElementById"my-editor"// Make the default set of blocks available, with English translations.// (you can choose other translations like "create-blockly/Msg/zh_tw")extensions:require"create-blockly/Blocks"require"create-blockly/Msg/en"// This is the toolbox that defines which blocks are visible.//toolbox: documentgetElementById"my-toolbox";
<!-- This is where the iframed resizable Blockly will be embedded. --><!-- This is the toolbox that defines which blocks are visible. --><!-- -->
Install helpers for the server:
npm install express enchilada
Create the "server.js" to serve the demo:
var express = require"express";var enchilada = require"enchilada";var app = express;appuseexpresslogger;appuseenchilada__dirname;appuseexpressstatic__dirname;applisten1337;console.log"Running demo on localhost:1337"
Run the server and open localhost:1337 in your browser:
$ node server.jsRunning demo on localhost:1337
Just make a pull request :)