Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mo4islona/node-blockly
Blockly for Node.js and Browser via CommonJS module
https://github.com/mo4islona/node-blockly
blockly browser commonjs nodejs
Last synced: about 20 hours ago
JSON representation
Blockly for Node.js and Browser via CommonJS module
- Host: GitHub
- URL: https://github.com/mo4islona/node-blockly
- Owner: mo4islona
- Created: 2015-06-18T11:43:07.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T19:23:14.000Z (almost 2 years ago)
- Last Synced: 2024-11-09T07:15:11.464Z (9 days ago)
- Topics: blockly, browser, commonjs, nodejs
- Language: JavaScript
- Homepage:
- Size: 6.53 MB
- Stars: 135
- Watchers: 5
- Forks: 81
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Blockly for Node.js and Browser via CommonJS module
![Build](https://travis-ci.org/mo4islona/node-blockly.svg?branch=master)
Supports `JavaScript`, `PHP`, `Dart`, `Lua` and `Python` generators.
[Live demo](http://mo4islona.github.io/blockly/) with async locales
## Install
```
yarn add node-blockly
```
## Usage
**Node.js**All generators
```js
var Blockly = require('node-blockly');
```
Or you may use standalone generators to decrease memory usage
```js
var Blockly = require('node-blockly/lua');
```**Browser**
All generators
```js
var Blockly = require('node-blockly/browser');
```## Example
**Node.js**
```js
var Blockly = require('node-blockly');var xmlText = `
blockly
Hello Node.js!
`;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```js
var blockly;blockly = 'Hello Node.js!';
```**Browser**
[Live demo](http://mo4islona.github.io/blockly/) ([source](https://github.com/mo4islona/mo4islona.github.io/blob/master/blockly/index.js))
## Internationalization
```js
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](https://github.com/mo4islona/mo4islona.github.io/blob/master/blockly/index.js#L6)