API Reference

<vue-blocks-container />

<template>
  <div id="app">
    <vue-blocks-container
      ref="container"
      :blocks-content="blocks"
      :scene.sync="scene"
      class="container"
    />
  </div>
</template>

<script>
export default {
  data: function() {
    return {
      blocks: [
        {
          name: "test",
          title: "Test block",
          family: "Test",
          description: "Description text",
          fields: [
            {
              name: "in1",
              type: "event",
              attr: "input"
            },
            {
              name: "out1",
              type: "event",
              attr: "output"
            }
          ]
        }
      ],
      scene: {
        blocks: [
          {
            id: 1,
            x: 0,
            y: 0,
            name: "test",
            title: "Test block",
            values: {
              property: [
                {
                  name: "message",
                  type: "string"
                }
              ]
            }
          }
        ],
        links: [],
        container: {
          centerX: 0,
          centerY: 0,
          scale: 1
        }
      }
    };
  }
};
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

<vue-blocks-container /> Props

blocks-content

  • type: Array<Node> | undefined
  • default: []

Node:

declare type Node {
    name: string,
    title: string,
    family: string | undefined,
    description: string,
    fields: Array<NodeField>
}
1
2
3
4
5
6
7

NodeField:

declare type NodeField {
    name: string,
    type: TypeName,
    attr: AttributeType,
    other: any | undefined
}
1
2
3
4
5
6

scene

  • type: Scene | undefined
  • default:
{
    blocks: [],
    links: [],
    container: {}
}
1
2
3
4
5

Scene:

declare type Scene {
  blocks: Array<Block>,
  links: Array<BlockLinks>,
  container: {
   centerX: number
   centerY: number
   scale: number
  }
}
1
2
3
4
5
6
7
8
9

Block:

declare type Block {
    id: number,
    x: number,
    y: number,
    name: string,
    title: string,
    values: {
        customAttribute: [ // show "NodeField"
            name: NodeField // (without name and attr fields)
        ]
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
declare type BlockLinks {
  id: number, // ID
  originID: number, // Origin block ID
  originSlot: number, // Origin block slot number
  targetID: number, // Target block ID
  targetSlot: number // Target block slot number
}
1
2
3
4
5
6
7

options

  • type: Object | undefined

<vue-blocks-container /> Methods

addNewBlock(nodeName, x, y)

Add a new block of type nodeName at the coordinates (x, y)

  • nodeName: String
  • x: Integer
  • y: Integer
<!-- Add two 'test' blocks to the scene -->
<template>
  <div id="app">
    <vue-blocks-container
      ref="container"
      :blocks-content="..."
      :scene.sync="..."
      class="container"
    />
  </div>
</template>

<script>
export default {
  // ...
  mounted() {
    this.$refs.container.addNewBlock("test", 0, 0);
    this.$refs.container.addNewBlock("test", 100, 250);
  }
};
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

<vue-blocks-container /> Events

blockSelect → block

blockDeselect → block

blockDelete → block