feat(core): add dom attributes option for nodes (#1861)
feat: Possibility to customize nodes HTML attributes
This commit is contained in:
@@ -61,6 +61,7 @@ const NodeWrapper = defineComponent({
|
|||||||
elementsSelectable,
|
elementsSelectable,
|
||||||
nodesConnectable,
|
nodesConnectable,
|
||||||
nodesFocusable,
|
nodesFocusable,
|
||||||
|
nodesAttrs,
|
||||||
hooks,
|
hooks,
|
||||||
} = useVueFlow()
|
} = useVueFlow()
|
||||||
|
|
||||||
@@ -286,6 +287,8 @@ const NodeWrapper = defineComponent({
|
|||||||
'role': isFocusable.value ? 'button' : undefined,
|
'role': isFocusable.value ? 'button' : undefined,
|
||||||
'aria-describedby': disableKeyboardA11y.value ? undefined : `${ARIA_NODE_DESC_KEY}-${vueFlowId}`,
|
'aria-describedby': disableKeyboardA11y.value ? undefined : `${ARIA_NODE_DESC_KEY}-${vueFlowId}`,
|
||||||
'aria-label': node.ariaLabel,
|
'aria-label': node.ariaLabel,
|
||||||
|
...nodesAttrs?.value,
|
||||||
|
...node.attrs,
|
||||||
'onMouseenter': onMouseEnter,
|
'onMouseenter': onMouseEnter,
|
||||||
'onMousemove': onMouseMove,
|
'onMousemove': onMouseMove,
|
||||||
'onMouseleave': onMouseLeave,
|
'onMouseleave': onMouseLeave,
|
||||||
|
|||||||
@@ -114,6 +114,8 @@ export function useState(): State {
|
|||||||
|
|
||||||
disableKeyboardA11y: false,
|
disableKeyboardA11y: false,
|
||||||
ariaLiveMessage: '',
|
ariaLiveMessage: '',
|
||||||
|
|
||||||
|
nodesAttrs: {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -229,6 +229,8 @@ export interface FlowProps {
|
|||||||
autoPanOnConnect?: boolean
|
autoPanOnConnect?: boolean
|
||||||
autoPanOnNodeDrag?: boolean
|
autoPanOnNodeDrag?: boolean
|
||||||
autoPanSpeed?: number
|
autoPanSpeed?: number
|
||||||
|
|
||||||
|
nodesAttrs?: Record<string, any>
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ export interface Node<Data = ElementData, CustomEvents extends Record<string, Cu
|
|||||||
events?: Partial<NodeEventsHandler<CustomEvents>>
|
events?: Partial<NodeEventsHandler<CustomEvents>>
|
||||||
zIndex?: number
|
zIndex?: number
|
||||||
ariaLabel?: string
|
ariaLabel?: string
|
||||||
|
attrs?: Record<string, any>
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GraphNode<
|
export interface GraphNode<
|
||||||
|
|||||||
Reference in New Issue
Block a user