sandro-timia commited on
Commit
fb6241c
·
1 Parent(s): 48678a2

Third push

Browse files
Files changed (2) hide show
  1. index.html +4 -50
  2. index.js +15 -0
index.html CHANGED
@@ -3,58 +3,12 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Simple Rete.js Flow</title>
7
- <style>
8
- html, body {
9
- margin: 0;
10
- height: 100%;
11
- overflow: hidden;
12
- }
13
- #rete {
14
- width: 100%;
15
- height: 100%;
16
- background: #f5f5f5;
17
- }
18
- </style>
19
  </head>
20
  <body>
21
- <div id="rete"></div>
22
- <script src="https://cdn.jsdelivr.net/npm/rete@1.4.5/build/rete.min.js"></script>
23
- <script src="https://cdn.jsdelivr.net/npm/rete-area-plugin@0.2.1/build/rete-area-plugin.min.js"></script>
24
- <script src="https://cdn.jsdelivr.net/npm/rete-connection-plugin@0.9.0/build/rete-connection-plugin.min.js"></script>
25
- <script src="https://cdn.jsdelivr.net/npm/rete-vue-render-plugin@0.4.0/build/rete-vue-render-plugin.min.js"></script>
26
- <script src="https://cdn.jsdelivr.net/npm/rete-context-menu-plugin@0.4.7/build/rete-context-menu-plugin.min.js"></script>
27
 
28
- <script>
29
- (async () => {
30
- const container = document.getElementById('rete');
31
- const editor = new Rete.NodeEditor('simple@0.1.0', container);
32
-
33
- editor.use(ConnectionPlugin.default);
34
- editor.use(VueRenderPlugin.default);
35
- editor.use(ContextMenuPlugin.default);
36
- editor.use(AreaPlugin.default);
37
-
38
- const component = new Rete.Component('Number');
39
- component.builder = (node) => {
40
- node.addInput(new Rete.Input('num', 'Number', Rete.sockets.number));
41
- node.addControl(new Rete.Control('preview', component.editor.nodes.get(node.id)));
42
- };
43
-
44
- editor.register(component);
45
- editor.on('connectioncreate connectionremove nodecreate noderemove', () => {
46
- console.log('Flow Updated');
47
- });
48
-
49
- editor.fromJSON({
50
- id: 'demo@0.1.0',
51
- nodes: {}
52
- });
53
-
54
- editor.view.resize();
55
- AreaPlugin.zoomAt(editor);
56
- editor.trigger('process');
57
- })();
58
- </script>
59
  </body>
60
  </html>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Rete.js Flow Editor</title>
 
 
 
 
 
 
 
 
 
 
 
 
7
  </head>
8
  <body>
9
+ <div id="rete" style="height: 500px; width: 100%;"></div>
 
 
 
 
 
10
 
11
+ <!-- Include your JavaScript file -->
12
+ <script src="index.js" defer></script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  </body>
14
  </html>
index.js ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // index.js or app.js
2
+
3
+ document.addEventListener('DOMContentLoaded', function () {
4
+ const container = document.querySelector('#rete');
5
+ const editor = new Rete.NodeEditor('demo@0.1.0', container);
6
+
7
+ // Simple component example
8
+ const component = new Rete.Component('demo');
9
+ editor.register(component);
10
+
11
+ editor.view.resize();
12
+ window.addEventListener('resize', () => editor.view.resize());
13
+
14
+ editor.trigger('process');
15
+ });