-
-
Notifications
You must be signed in to change notification settings - Fork 749
/
drawflow-element.js
48 lines (39 loc) · 1.07 KB
/
drawflow-element.js
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
import { css, LitElement, html } from 'lit-element';
import { style } from '../dist/drawflow.style';
import '../dist/drawflow.min';
class DrawflowElement extends LitElement {
static get styles() {
return [
style,
css`
#drawflow {
display: block;
position: relative;
width: 100%;
height: 800px;
}
`
];
}
render() {
return html`
<div id="drawflow"></div>
`;
}
firstUpdated() {
const container = this.shadowRoot?.getElementById('drawflow');
const editor = new Drawflow(container);
editor.reroute = true;
editor.reroute_fix_curvature = true;
editor.start();
const data = {
name: ''
};
editor.addNode('foo', 1, 1, 100, 200, 'foo', data, 'Foo');
editor.addNode('bar', 1, 1, 400, 100, 'bar', data, 'Bar A');
editor.addNode('bar', 1, 1, 400, 300, 'bar', data, 'Bar B');
editor.addConnection(1, 2, "output_1", "input_1");
editor.addConnection(1, 3, "output_1", "input_1");
}
}
customElements.define("drawflow-element", DrawflowElement);