feat: Add default edge options
This commit is contained in:
@@ -226,6 +226,7 @@ export default (state: State, getters: ComputedGetters): Actions => {
|
||||
|
||||
return {
|
||||
...parseEdge(edge, {
|
||||
...state.defaultEdgeOptions,
|
||||
...getters.getEdge.value(edge.id),
|
||||
}),
|
||||
sourceNode,
|
||||
@@ -263,6 +264,7 @@ export default (state: State, getters: ComputedGetters): Actions => {
|
||||
console.warn(`couldn't create edge for target id: ${edge.target}; edge id: ${edge.id}`)
|
||||
|
||||
state.edges.push({
|
||||
...state.defaultEdgeOptions,
|
||||
...edge,
|
||||
sourceNode,
|
||||
targetNode,
|
||||
|
||||
@@ -99,6 +99,12 @@ export default (opts?: FlowOptions): State => {
|
||||
|
||||
applyDefault: true,
|
||||
|
||||
fitViewOnInit: false,
|
||||
noDragClassName: undefined,
|
||||
noWheelClassName: undefined,
|
||||
noPanClassName: undefined,
|
||||
defaultEdgeOptions: undefined,
|
||||
|
||||
vueFlowVersion: typeof __VUE_FLOW_VERSION__ !== 'undefined' ? __VUE_FLOW_VERSION__ : '-',
|
||||
}
|
||||
|
||||
|
||||
+7
-1
@@ -2,7 +2,7 @@ import { ComputedRef, CSSProperties, ToRefs } from 'vue'
|
||||
import { Dimensions, Elements, FlowElements, FlowInstance, FlowOptions, Rect, SnapGrid, Transform, XYPosition } from './flow'
|
||||
import { EdgeComponent, NodeComponent, DefaultNodeTypes, DefaultEdgeTypes } from './components'
|
||||
import { Connection, ConnectionLineType, ConnectionMode } from './connection'
|
||||
import { Edge, GraphEdge } from './edge'
|
||||
import { DefaultEdgeOptions, Edge, GraphEdge } from './edge'
|
||||
import { GraphNode, CoordinateExtent, Node } from './node'
|
||||
import { D3Selection, D3Zoom, D3ZoomHandler, KeyCode, PanOnScrollMode } from './zoom'
|
||||
import { FlowHooks, FlowHooksOn } from './hooks'
|
||||
@@ -71,6 +71,12 @@ export interface State<N = any, E = N> extends Omit<FlowOptions<N, E>, 'id' | 'm
|
||||
initialized: boolean
|
||||
applyDefault: boolean
|
||||
|
||||
fitViewOnInit?: boolean
|
||||
noDragClassName?: string
|
||||
noWheelClassName?: string
|
||||
noPanClassName?: string
|
||||
defaultEdgeOptions?: DefaultEdgeOptions
|
||||
|
||||
vueFlowVersion: string
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user