chore: lint
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { Background, ConnectionMode, Controls, MiniMap, VueFlow, useVueFlow } from '@braks/vue-flow'
|
import { Background, ConnectionMode, Controls, MiniMap, VueFlow, useVueFlow } from '@braks/vue-flow/src/index'
|
||||||
|
|
||||||
const { onConnect, nodes, edges, addEdges, addNodes } = useVueFlow({
|
const { onConnect, nodes, edges, addEdges, addNodes } = useVueFlow({
|
||||||
fitViewOnInit: true,
|
fitViewOnInit: true,
|
||||||
|
|||||||
@@ -14,9 +14,8 @@ import type {
|
|||||||
import {
|
import {
|
||||||
addEdgeToStore,
|
addEdgeToStore,
|
||||||
applyChanges,
|
applyChanges,
|
||||||
createGraphNodes,
|
|
||||||
connectionExists,
|
|
||||||
createAdditionChange,
|
createAdditionChange,
|
||||||
|
createGraphNodes,
|
||||||
createPositionChange,
|
createPositionChange,
|
||||||
createSelectionChange,
|
createSelectionChange,
|
||||||
getDimensions,
|
getDimensions,
|
||||||
@@ -230,9 +229,7 @@ export default (state: State, getters: ComputedGetters): Actions => {
|
|||||||
if (missingTarget) console.warn(`[vueflow]: Couldn't create edge for target id: ${edge.target}; edge id: ${edge.id}`)
|
if (missingTarget) console.warn(`[vueflow]: Couldn't create edge for target id: ${edge.target}; edge id: ${edge.id}`)
|
||||||
if (missingTarget || missingSource) return acc
|
if (missingTarget || missingSource) return acc
|
||||||
|
|
||||||
acc.push(
|
acc.push(createAdditionChange<GraphEdge>(shallowReactive(edge)))
|
||||||
createAdditionChange<GraphEdge>(shallowReactive(edge)),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return acc
|
return acc
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { clampPosition, isGraphEdge, isGraphNode } from './graph'
|
|||||||
import type {
|
import type {
|
||||||
CoordinateExtent,
|
CoordinateExtent,
|
||||||
Edge,
|
Edge,
|
||||||
|
EdgeAddChange,
|
||||||
EdgeChange,
|
EdgeChange,
|
||||||
EdgeSelectionChange,
|
EdgeSelectionChange,
|
||||||
ElementChange,
|
ElementChange,
|
||||||
@@ -11,11 +12,10 @@ import type {
|
|||||||
GraphEdge,
|
GraphEdge,
|
||||||
GraphNode,
|
GraphNode,
|
||||||
Node,
|
Node,
|
||||||
|
NodeAddChange,
|
||||||
NodeChange,
|
NodeChange,
|
||||||
NodePositionChange,
|
NodePositionChange,
|
||||||
NodeSelectionChange,
|
NodeSelectionChange,
|
||||||
NodeAddChange,
|
|
||||||
EdgeAddChange,
|
|
||||||
XYPosition,
|
XYPosition,
|
||||||
} from '~/types'
|
} from '~/types'
|
||||||
|
|
||||||
@@ -106,43 +106,43 @@ export const applyChanges = <
|
|||||||
return elements.push(item)
|
return elements.push(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
const i = elementIds.indexOf((<any>change).id)
|
const i = elementIds.indexOf((<any>change).id)
|
||||||
const el = elements[i]
|
const el = elements[i]
|
||||||
switch (change.type) {
|
switch (change.type) {
|
||||||
case 'select':
|
case 'select':
|
||||||
if (isGraphNode(el) || isGraphEdge(el)) el.selected = change.selected
|
if (isGraphNode(el) || isGraphEdge(el)) el.selected = change.selected
|
||||||
break
|
break
|
||||||
case 'position':
|
case 'position':
|
||||||
if (isGraphNode(el)) {
|
if (isGraphNode(el)) {
|
||||||
if (typeof change.position !== 'undefined') el.position = change.position
|
if (typeof change.position !== 'undefined') el.position = change.position
|
||||||
if (el.expandParent && el.parentNode) {
|
if (el.expandParent && el.parentNode) {
|
||||||
const parent = elements.find((parent) => parent.id === el.parentNode)
|
const parent = elements.find((parent) => parent.id === el.parentNode)
|
||||||
|
|
||||||
if (parent && isGraphNode(parent)) {
|
if (parent && isGraphNode(parent)) {
|
||||||
handleParentExpand(el, parent)
|
handleParentExpand(el, parent)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
break
|
||||||
break
|
case 'dimensions':
|
||||||
case 'dimensions':
|
if (isGraphNode(el)) {
|
||||||
if (isGraphNode(el)) {
|
if (typeof change.dimensions !== 'undefined') el.dimensions = change.dimensions
|
||||||
if (typeof change.dimensions !== 'undefined') el.dimensions = change.dimensions
|
if (el.expandParent && el.parentNode) {
|
||||||
if (el.expandParent && el.parentNode) {
|
const parent = elements.find((parent) => parent.id === el.parentNode)
|
||||||
const parent = elements.find((parent) => parent.id === el.parentNode)
|
|
||||||
|
|
||||||
if (parent && isGraphNode(parent)) {
|
if (parent && isGraphNode(parent)) {
|
||||||
handleParentExpand(el, parent)
|
handleParentExpand(el, parent)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
break
|
||||||
break
|
case 'remove':
|
||||||
case 'remove':
|
if (elementIds.includes(change.id)) {
|
||||||
if (elementIds.includes(change.id)) {
|
elements.splice(i, 1)
|
||||||
elements.splice(i, 1)
|
elementIds = elements.map((el) => el.id)
|
||||||
elementIds = elements.map((el) => el.id)
|
}
|
||||||
}
|
break
|
||||||
break
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user