Skip to content

feat(core): add VueFlowProvider #1482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @vue-flow/core

## 1.43.1

### Patch Changes

- [#1833](https://github.com/bcakmakoglu/vue-flow/pull/1833) [`8eccc19`](https://github.com/bcakmakoglu/vue-flow/commit/8eccc19d9ffc7534bee6e085d2be6f5a7c8b857b) Thanks [@bcakmakoglu](https://github.com/bcakmakoglu)! - Add missing vue-flow\_\_container class to marker defs.

## 1.43.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue-flow/core",
"version": "1.43.0",
"version": "1.43.1",
"private": false,
"license": "MIT",
"author": "Burak Cakmakoglu<[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script lang="ts" setup>
import { inject } from 'vue'
import { useVueFlow } from '../../composables'
import { VueFlow } from '../../context'
import type { VueFlowProviderProps } from '../../types'
const props = defineProps<VueFlowProviderProps>()
const hasInjection = inject(VueFlow, null)
if (!hasInjection) {
// createVueFlow() or setupVueFlow()
useVueFlow({
nodes: props.initialNodes,
edges: props.initialEdges,
fitViewOnInit: props.fitViewOnInit,
})
}
</script>

<template>
<slot />
</template>
2 changes: 1 addition & 1 deletion packages/core/src/composables/useVueFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
* @public
* @returns a vue flow store instance
* @param idOrOpts - id of the store instance or options to create a new store instance
* @param idOrOpts - id of the store instance or options to pass to the store instance (options are deprecated!)

Check warning on line 22 in packages/core/src/composables/useVueFlow.ts

View workflow job for this annotation

GitHub Actions / build-and-test (ubuntu-latest, 20)

Expected @param names to be "id". Got "idOrOpts"
*/
export function useVueFlow(id?: string): VueFlowStore
export function useVueFlow(options?: FlowOptions): VueFlowStore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default {
</script>

<template>
<svg class="vue-flow__marker" aria-hidden="true">
<svg class="vue-flow__marker vue-flow__container" aria-hidden="true">
<defs>
<MarkerSymbols
v-for="marker of markers"
Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/types/flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,9 @@ export interface FlowSlots extends NodeSlots, EdgeSlots {
'zoom-pane': () => any
'default': () => any
}

export interface VueFlowProviderProps {
initialNodes?: Node[]
initialEdges?: Edge[]
fitViewOnInit?: boolean
}
Loading