Skip to content

Blockly for Node.js and Browser via CommonJS module

Notifications You must be signed in to change notification settings

eyz/node-blockly

This branch is 1 commit ahead of, 26 commits behind mo4islona/node-blockly:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

3dd2524 · Aug 27, 2018

History

85 Commits
May 24, 2018
May 24, 2018
Oct 14, 2017
Jul 21, 2017
Jun 24, 2015
Jul 20, 2017
Oct 25, 2016
Jul 21, 2017
Oct 18, 2017
Mar 14, 2018
Oct 18, 2017
Oct 25, 2016
Oct 14, 2017
Oct 25, 2016
Oct 25, 2016
Oct 25, 2016
Aug 27, 2018
Oct 25, 2016
Oct 25, 2016
Nov 7, 2017

Repository files navigation

Blockly for Node.js and Browser via CommonJS module

Build

Supports JavaScript, PHP, Dart, Lua and Python generators.

Live demo with async locales

Install

yarn add node-blockly

Usage

Node.js

All generators

var Blockly = require('node-blockly');

Or you may use standalone generators to decrease memory usage

var Blockly = require('node-blockly/lua');

Browser

All generators

var Blockly = require('node-blockly/browser');

Example

Node.js

var Blockly = require('node-blockly');

var xmlText = `<xml xmlns="http://www.w3.org/1999/xhtml">
        <block type="variables_set">
            <field name="VAR">blockly</field>
            <value name="VALUE">
                <block type="text">
                    <field name="TEXT">Hello Node.js!</field>
                </block>
            </value>
        </block>
    </xml>`;

try {
    var xml = Blockly.Xml.textToDom(xmlText);
}
catch (e) {
    console.log(e);
    return
}

var workspace = new Blockly.Workspace();
Blockly.Xml.domToWorkspace(xml, workspace);
var code = Blockly.JavaScript.workspaceToCode(workspace);

console.log(code)  

Compiled result

var blockly; 

blockly = 'Hello Node.js!';

Browser

Live demo (source)

Internationalization

import Blockly from 'node-blockly/browser';
import De from 'node-blockly/lib/i18n/de';
Blockly.setLocale(De)

Dynamic imports also works but Blockly doesn't re-render workspace. You must re-render it manually after locale loaded

About

Blockly for Node.js and Browser via CommonJS module

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%