11<script setup lang="ts">
2- import type { Edge , Node } from ' @vue-flow/core'
2+ import type { Edge , Node , NodeTypesObject } from ' @vue-flow/core'
33import { Canvas } from ' @repo/elements/canvas'
44import { Connection } from ' @repo/elements/connection'
55import { Controls } from ' @repo/elements/controls'
66import { Panel } from ' @repo/elements/panel'
77import { Button } from ' @repo/shadcn-vue/components/ui/button'
88import { nanoid } from ' nanoid'
9- import { ref } from ' vue'
9+ import { markRaw , ref } from ' vue'
10+ import CustomNode from ' ./custom-node.vue'
1011
1112const nodeIds = {
1213 start: nanoid (),
@@ -16,13 +17,27 @@ const nodeIds = {
1617const nodes = ref <Node []>([
1718 {
1819 id: nodeIds .start ,
19- position: { x: 50 , y: 50 },
20- data: { label: ' Node 1' },
20+ type: ' custom' ,
21+ position: { x: 80 , y: 80 },
22+ data: {
23+ label: ' start' ,
24+ description: ' test' ,
25+ content: ' test' ,
26+ footer: ' test' ,
27+ handles: { target: false , source: true },
28+ },
2129 },
2230 {
2331 id: nodeIds .process1 ,
24- position: { x: 50 , y: 250 },
25- data: { label: ' Node 2' },
32+ type: ' custom' ,
33+ position: { x: 320 , y: 260 },
34+ data: {
35+ label: ' process1' ,
36+ description: ' test' ,
37+ content: ' test' ,
38+ footer: ' test' ,
39+ handles: { target: true , source: true },
40+ },
2641 },
2742])
2843
@@ -33,11 +48,15 @@ const edges = ref<Edge[]>([
3348 target: nodeIds .process1 ,
3449 },
3550])
51+
52+ const nodeTypes: NodeTypesObject = {
53+ custom: markRaw (CustomNode ),
54+ }
3655 </script >
3756
3857<template >
3958 <div style =" height : 400px " >
40- <Canvas :nodes =" nodes" :edges =" edges" >
59+ <Canvas :nodes =" nodes" :edges =" edges" :node-types = " nodeTypes " >
4160 <template #connection-line =" connectionLineProps " >
4261 <Connection v-bind =" connectionLineProps" />
4362 </template >
0 commit comments