/
demo.html
63 lines (52 loc) · 1.57 KB
/
demo.html
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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="data:;base64,=" />
<meta name="viewport" content="width=device-width" />
<title>flow-view example</title>
<link rel="stylesheet" href="../../style.css" />
</head>
<body>
<main>
<h1>flow-view</h1>
<h2>custom node example</h2>
<p>Click on a node to edit it. Node contain a <code>textarea</code>.</p>
<div class="container"></div>
</main>
<script type="module">
// import { FlowView } from 'https://unpkg.com/flow-view';
import { FlowView } from "../../index.js"
import { FlowViewNodeInfo } from "./info.js"
const flowView = new FlowView(document.querySelector(".container"))
flowView.addNodeClass("info", FlowViewNodeInfo)
flowView.onChange(({ action, data }) => {
console.info(action, data)
})
flowView.nodeTextToType((text) => {
if (text.indexOf("\n") >= 0) return "info"
if (text.indexOf(" ") >= 0) return "info"
})
flowView.loadGraph({
nodes: [
{
type: "info",
text: "This content is\neditable",
outputs: [{ id: "out" }],
x: 100,
y: 150
},
{
text: "click me to edit",
outputs: [{ id: "out" }],
x: 150,
y: 400
}
]
})
</script>
<footer>
Source code <a href="https://github.com/fibo/flow-view/blob/main/examples/custom-node/demo.html">here</a>.
</footer>
</body>
</html>