feat: Allow node/edge template per element

* Allow templates to be overwritten per element with template option
This commit is contained in:
Braks
2022-04-10 17:40:27 +02:00
parent 367c7fdf40
commit 88f808711a
9 changed files with 126 additions and 23 deletions

View File

@@ -266,6 +266,44 @@ const elements = ref([
You can find a more advanced example <router-link to="/examples/custom-node/">here</router-link>.
:::
### Node Template
You can also set a template per node, which will overwrite the node-type component but will retain
the type otherwise.
```vue:no-line-numbers
<script setup>
import { markRaw } from 'vue'
import CustomNode from './CustomNode.vue'
import CustomNode from './OverwriteCustomNode.vue'
import SpecialNode from './SpecialNode.vue'
const nodeTypes = {
custom: markRaw(CustomNode),
special: markRaw(SpecialNode),
}
const elements = ref([
{
id: '1',
label: 'Node 1',
type: 'custom',
template: markRaw(OverwriteCustomNode),
},
{
id: '1',
label: 'Node 1',
type: 'special',
}
])
</script>
<template>
<div style="height: 300px">
<VueFlow v-model="elements" :node-types="nodeTypes" />
</div>
</template>
```
### Custom Node Props
Your custom nodes are wrapped so that the basic functions like dragging or selecting work.