refactor(vue-flow,viewpane)!: remove FlowInstance type
This commit is contained in:
@@ -1,16 +1,12 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { Connection, Edge, Elements, FlowInstance } from '@braks/vue-flow'
|
import type { Connection, Edge, Elements } from '@braks/vue-flow'
|
||||||
import { Background, VueFlow, addEdge } from '@braks/vue-flow'
|
import { Background, VueFlow, addEdge } from '@braks/vue-flow'
|
||||||
|
import { ref } from 'vue'
|
||||||
import initialElements from './elements'
|
import initialElements from './elements'
|
||||||
import { PathFindingEdge, PerfectArrow } from '~/index'
|
import { PathFindingEdge, PerfectArrow } from '~/index'
|
||||||
|
|
||||||
const elements = ref<Elements>(initialElements)
|
const elements = ref<Elements>(initialElements)
|
||||||
const rfInstance = ref<FlowInstance | null>(null)
|
|
||||||
const onConnect = (params: Edge | Connection) => (elements.value = addEdge(params, elements.value))
|
const onConnect = (params: Edge | Connection) => (elements.value = addEdge(params, elements.value))
|
||||||
const onLoad = (flowInstance: FlowInstance) => {
|
|
||||||
flowInstance.fitView({ padding: 1 })
|
|
||||||
rfInstance.value = flowInstance
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -18,9 +14,9 @@ const onLoad = (flowInstance: FlowInstance) => {
|
|||||||
<VueFlow
|
<VueFlow
|
||||||
v-model="elements"
|
v-model="elements"
|
||||||
:default-edge-options="{ type: 'perfectArrow' }"
|
:default-edge-options="{ type: 'perfectArrow' }"
|
||||||
|
:fit-view-on-init="true"
|
||||||
class="vue-flow-basic-example"
|
class="vue-flow-basic-example"
|
||||||
@connect="onConnect"
|
@connect="onConnect"
|
||||||
@pane-ready="onLoad"
|
|
||||||
>
|
>
|
||||||
<template #edge-pathFinding="props">
|
<template #edge-pathFinding="props">
|
||||||
<PathFindingEdge v-bind="props" />
|
<PathFindingEdge v-bind="props" />
|
||||||
|
|||||||
@@ -1,21 +1,17 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { Connection, Edge, Elements, FlowInstance } from '@braks/vue-flow'
|
import type { Connection, Edge, Elements } from '@braks/vue-flow'
|
||||||
import { Background, Controls, MiniMap, VueFlow, addEdge } from '@braks/vue-flow'
|
import { Background, Controls, MiniMap, VueFlow, addEdge } from '@braks/vue-flow'
|
||||||
|
import { ref } from 'vue'
|
||||||
import { ResizeRotateNode } from '../src'
|
import { ResizeRotateNode } from '../src'
|
||||||
import initialElements from './elements'
|
import initialElements from './elements'
|
||||||
|
|
||||||
const elements = ref<Elements>(initialElements)
|
const elements = ref<Elements>(initialElements)
|
||||||
const rfInstance = ref<FlowInstance | null>(null)
|
|
||||||
const onConnect = (params: Edge | Connection) => (elements.value = addEdge(params, elements.value))
|
const onConnect = (params: Edge | Connection) => (elements.value = addEdge(params, elements.value))
|
||||||
const onLoad = (flowInstance: FlowInstance) => {
|
|
||||||
flowInstance.fitView({ padding: 1 })
|
|
||||||
rfInstance.value = flowInstance
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div style="height: 100%">
|
<div style="height: 100%">
|
||||||
<VueFlow v-model="elements" class="vue-flow-basic-example" @connect="onConnect" @pane-ready="onLoad">
|
<VueFlow v-model="elements" class="vue-flow-basic-example" :fit-view-on-init="true" @connect="onConnect">
|
||||||
<template #node-resize-rotate="props">
|
<template #node-resize-rotate="props">
|
||||||
<ResizeRotateNode v-bind="props" />
|
<ResizeRotateNode v-bind="props" />
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -85,9 +85,6 @@ export interface FlowExportObject {
|
|||||||
zoom: number
|
zoom: number
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @deprecated will be removed soon, only remains for backwards compatability */
|
|
||||||
export type FlowInstance = VueFlowStore
|
|
||||||
|
|
||||||
export interface FlowProps {
|
export interface FlowProps {
|
||||||
id?: string
|
id?: string
|
||||||
modelValue?: Elements
|
modelValue?: Elements
|
||||||
|
|||||||
Reference in New Issue
Block a user