Skip to content

Commit 9b0ad89

Browse files
committed
chore(core): cleanup
1 parent 537af0d commit 9b0ad89

File tree

3 files changed

+29
-15
lines changed

3 files changed

+29
-15
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<script lang="ts" setup>
2+
import { inject } from 'vue'
3+
import { useVueFlow } from '../../composables'
4+
import { VueFlow } from '../../context'
5+
import type { VueFlowProviderProps } from '../../types'
6+
7+
const props = defineProps<VueFlowProviderProps>()
8+
9+
const hasInjection = inject(VueFlow, null)
10+
11+
if (!hasInjection) {
12+
// createVueFlow() or setupVueFlow()
13+
useVueFlow({
14+
nodes: props.initialNodes,
15+
edges: props.initialEdges,
16+
fitViewOnInit: props.fitViewOnInit,
17+
})
18+
}
19+
</script>
20+
21+
<template>
22+
<slot />
23+
</template>

packages/core/src/context/VueFlowProvider.vue

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/core/src/types/flow.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,3 +331,9 @@ export interface FlowSlots extends NodeSlots, EdgeSlots {
331331
'zoom-pane': () => any
332332
'default': () => any
333333
}
334+
335+
export interface VueFlowProviderProps {
336+
initialNodes?: Node[]
337+
initialEdges?: Edge[]
338+
fitViewOnInit?: boolean
339+
}

0 commit comments

Comments
 (0)