All Projects → Gregwar → Blocks.js

Gregwar / Blocks.js

Licence: mit
JavaScript dataflow graph editor

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Blocks.js

Vue Blocks
Vue2 dataflow graph editor
Stars: ✭ 201 (+21.82%)
Mutual labels:  graph, dataflow, editor
Vue Dataflow Editor
Vue 2 dataflow graph editor
Stars: ✭ 73 (-55.76%)
Mutual labels:  graph, dataflow, editor
Litegraph.js
A graph node engine and editor written in Javascript similar to PD or UDK Blueprints, comes with its own editor in HTML5 Canvas2D. The engine can run client side or server side using Node. It allows to export graphs as JSONs to be included in applications independently.
Stars: ✭ 2,735 (+1557.58%)
Mutual labels:  graph, editor
Hyperfiddle
a Hypermedia Function
Stars: ✭ 422 (+155.76%)
Mutual labels:  graph, dataflow
The Graph
SVG custom elements for FBP graph editing and visualization. Used in noflo/noflo-ui
Stars: ✭ 896 (+443.03%)
Mutual labels:  graph, editor
Baklavajs
Graph / node editor in the browser using VueJS
Stars: ✭ 157 (-4.85%)
Mutual labels:  graph, editor
Diagram
☊ Tool for making node graphs. Inspired by dependency graph. Used mainly for automation services 📈
Stars: ✭ 510 (+209.09%)
Mutual labels:  graph, editor
Shenzhen Go
Experimental visual Go environment
Stars: ✭ 450 (+172.73%)
Mutual labels:  graph, dataflow
Shadoweditor
Cross-platform 3D scene editor based on three.js, golang and mongodb for desktop and web. https://tengge1.github.io/ShadowEditor-examples/
Stars: ✭ 1,060 (+542.42%)
Mutual labels:  scene, editor
Pyflowgraph
Python Module for displaying flowgraphs using Pyside or PyQt.
Stars: ✭ 61 (-63.03%)
Mutual labels:  graph, dataflow
Leaderboardx
A tool for building graphs quickly
Stars: ✭ 13 (-92.12%)
Mutual labels:  graph, editor
Rusty Editor
Scene editor for rg3d engine
Stars: ✭ 139 (-15.76%)
Mutual labels:  scene, editor
Xnode
Unity Node Editor: Lets you view and edit node graphs inside Unity
Stars: ✭ 2,077 (+1158.79%)
Mutual labels:  graph, editor
Diagram Maker
A library to display an interactive editor for any graph-like data.
Stars: ✭ 2,086 (+1164.24%)
Mutual labels:  graph, editor
Smarteditor2
Javascript WYSIWYG HTML editor
Stars: ✭ 162 (-1.82%)
Mutual labels:  editor
Report Designer
🚀 打印设计、可视化、大屏、编辑器、设计器、数据分析、报表设计、组件化、表单设计、h5页面、调查问卷、pdf生成、流程图、试卷、SVG、图形元素、物联网
Stars: ✭ 160 (-3.03%)
Mutual labels:  editor
Hgp Sl
Hierarchical Graph Pooling with Structure Learning
Stars: ✭ 159 (-3.64%)
Mutual labels:  graph
Editor
Android simple text editor
Stars: ✭ 165 (+0%)
Mutual labels:  editor
Animatedgraph
Animated Graph which you can include in your application to show information in more attractive way
Stars: ✭ 162 (-1.82%)
Mutual labels:  graph
Pervane
Plain text file based note taking and knowledge base building tool, markdown editor, simple browser IDE.
Stars: ✭ 159 (-3.64%)
Mutual labels:  editor

blocks.js

blocks

JavaScript dataflow graph editor

blocks.js is a JavaScript visual editor for editing dataflow graph, it can be used to edit processes graphs.

Note that this is just a flexible front-end editor, there is no back-end here.

You can try a live demo.

Overview

blocks.js is feeded using blocks specifications, using meta informations explaining its fields, name and behaviour.

It allow the user to edit the blocks scene.

Then, thanks for instance to the export(), method, you can get back the edited scene. When you load the blocks, you can also load back a scene.

Using blocks.js

Downloading

If you want to use it, you'll have to fetch the code, either by cloning this repository, or by downloading it.

Requirements

blocks.js uses:

All these requirements are included in this repository. This is why the third party libraries will look like this:

<!-- Third party libraries -->
<script type="text/javascript" src="build/jquery.js"></script>
<script type="text/javascript" src="build/jquery.json.min.js"></script>
<script type="text/javascript" src="build/jquery.mousewheel.min.js"></script>
<script type="text/javascript" src="build/jquery.svg.min.js"></script>
<script type="text/javascript" src="build/jquery.formserialize.min.js"></script>
<script type="text/javascript" src="build/jquery.fancybox.min.js"></script> 
<link rel="stylesheet" type="text/css" href="build/fancybox/jquery.fancybox.css" />

Then, you'll have to load blocks.js and blocks.css:

<!-- blocks.js -->
<script type="text/javascript" src="build/blocks.js"></script> 
<link rel="stylesheet" type="text/css" href="build/blocks.css" />

Running it

Here is a simple example:

// Instanciate Blocks
var blocks = new Blocks();

// Registering a simple block, with an input
// and an output
blocks.register({
    name: "Test",
    fields: [
        {
            name: "Input",
            attrs: "input"
        },
        {
            name: "Output",
            attrs: "output"
        }
    ]
});

// Running blocks on the div with the name "blocks"
blocks.run("#blocks");

Have a look at simple.html.

Blocks

The blocks is an object containing:

  • name: the name of the block
  • family: the block family, this will be used to put it in the right blocks menu sub-section
  • module: the block module, act like a namespace and avoid name collisions
  • description: a description of what the block does, to help the user
  • size: the size of the block, can be ̀small, normal or a certain number of pixels
  • class: additionals CSS classes that will be added to the block
  • fields: an array listing of the block fields, see below

Fields

A field can be an input, output and/or an editable parameter of the block. It is an object containing:

  • name: the name of the field, should not contain special chars
  • label: the label of the field, which will be printed in the blocks title, can contain special characters
  • attrs: a string containg field attributes, can contain input, output and/or editable. For instance: "editable input"
  • type: the field type. See typing.
  • defaultValue: the default value of the field, that will be used if it's editable
  • hide: do not display the editable field in the block information
  • hideLabel: do not display the editable field label in the block information
  • card: the cardinality of the input/output. This can be a string like "0-3" or and array like [0,3], it represents the minimum and the maximum edges that can be connected to the I/O.
  • dimension: the number of connection on the same field can depend on another field value, size, or be fixed to a static number. See variadic I/Os

Do not hesitate to have a look at the repository demo, in the `demo/̀ directory.

Scene

The scene is an easy-to-parse object containing:

Scene blocks

All scene block is represented with:

  • id: its numeric ID
  • x and y, the position of the block in the scene
  • type: the block type name
  • module: the block type module name
  • values: an array containing the values of all its editable fields

Scene edges

A scene edge is represented with:

  • id: its numeric ID
  • block1: the ID of the block where the edge starts
  • connector1: the connector of the block where the edge starts
  • block2: the ID of the block where the edge ends
  • connector2: the connector of the block where the edge ends

Scene connectors

A connector is an array containing 2 or 3 elements:

  • A string, input or output, explaining if the connector is outgoing of the block or entering in it
  • The name of the block field, in lower case
  • Optionally, the index for variadic fields

Typing

Each field can be typed. Basic types (string, choice, longtext, bool, int) are rendered as form inputs, all other unknown types are rendered as a simple text input. (Note: for choice type, you can define choices adding a ̀choices entry in the block field).

If the type ends with [], it is considered as an array, the Add & Remove buttons will be added when editing.

By default, the different types are not compatibles, and thus can't be linked together. You can however tell blocks.js that some types are compatible using:

// Tells blocks.js that string and number are compatible and can be linked
blocks.types.addCompatibility('string', 'number');

// Tells blocks.js that an image can be converted to a string, however, the
// string can't be converted to an image
blocks.types.addCompatibilityOneWay('image', 'string');

Variadic I/Os

Some I/Os can be variadic, think of a block that would output the n first users of a database, you could define it this way:

blocks.register({
    name: "TopUsers",
    description: "Outputs the n first users of the database",
    fields: [
        {
            name: "n",
            type: "int",
            hide: true,
            defaultValue: 3,
            attrs: "editable"
        },
        {
	    name: "users",
            label: "User #",
            dimension: "n",
            attrs: "output"
        }
    ]
});

Here, the number of outputed users will be editable, using the n editable field. Note that the # will be replaced by the number of the output.

Example

Here is an example that uses blocks.js:

Contributing & hacking

The development takes places in the src/ directory. There is a Makefile using uglifyjs command line to create the build.

You can use index-dev.html to test blocks.js using its sources, and index.html to try it in build mode.

The build/ directory of this repository will not be updated on every commit, but must contain a recent snapshot of the repository.

License

blocks.js is under MIT license. Have a look at the LICENSE file for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].