diff --git a/src/composables/useStore.ts b/src/composables/useStore.ts index 5ff4c036..4f9edbfb 100644 --- a/src/composables/useStore.ts +++ b/src/composables/useStore.ts @@ -1,6 +1,6 @@ import { getCurrentInstance } from 'vue' import { FlowExportObject, FlowOptions, FlowState, FlowStore } from '~/types' -import { useNewStore } from '~/store' +import { useFlowStore } from '~/store' import { StoreSymbol } from '~/context' import { onLoadToObject, initialState } from '~/utils' @@ -10,6 +10,7 @@ export const createStore = (options?: FlowOptions) => { let storedState = ref() const initial = initialState() const storageKey = options?.id ?? `vue-flow-${id++}` + delete options?.id const preloadedState = { ...initial, ...(options as FlowState), @@ -22,7 +23,7 @@ export const createStore = (options?: FlowOptions) => { preloadedState.transform = [storedState.value.position[0], storedState.value.position[1], storedState.value.zoom] } } - const store = useNewStore(storageKey, preloadedState) + const store = useFlowStore(storageKey, preloadedState) if (withStorage && storageKey === store.id) { const toObject = onLoadToObject(store.state) watch( diff --git a/src/composables/useVueFlow.ts b/src/composables/useVueFlow.ts index a9a1367b..3c738a5e 100644 --- a/src/composables/useVueFlow.ts +++ b/src/composables/useVueFlow.ts @@ -2,8 +2,7 @@ import useStore from './useStore' import useHooks from './useHooks' import { EmitFunc, FlowStore } from '~/types' -let key = 0 -export const initFlow = (emit: EmitFunc, id = `vue-flow-${key++}`): FlowStore => { +export const initFlow = (emit: EmitFunc, id?: string): FlowStore => { const store = useStore({ id }) useHooks(store, emit) return store diff --git a/src/store/index.ts b/src/store/index.ts index f1689b55..205c738c 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1 +1 @@ -export { default as useNewStore } from './store' +export { default as useFlowStore } from './store' diff --git a/src/utils/graph.ts b/src/utils/graph.ts index 0788bb7d..682b8aea 100644 --- a/src/utils/graph.ts +++ b/src/utils/graph.ts @@ -97,7 +97,7 @@ const connectionExists = (edge: Edge, elements: Elements) => { export const addEdge = (edgeParams: Edge | Connection, elements: Elements) => { if (!edgeParams.source || !edgeParams.target) { - console.log("Can't create edge. An edge needs a source and a target.") + console.warn("Can't create edge. An edge needs a source and a target.") return elements }