feat(core): add onError hook
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -11,19 +11,19 @@ export default function useNode<Data = ElementData, CustomEvents extends Record<
|
||||
const nodeId = id ?? inject(NodeId, '')
|
||||
const nodeEl = inject(NodeRef, null)
|
||||
|
||||
const { findNode, getEdges } = useVueFlow()
|
||||
const { findNode, getEdges, emits } = useVueFlow()
|
||||
|
||||
const node = findNode<Data, CustomEvents>(nodeId)
|
||||
|
||||
if (!node) {
|
||||
throw new VueFlowError(`Node with id ${nodeId} not found!`, 'useNode')
|
||||
emits.error(new VueFlowError(ErrorCode.NODE_NOT_FOUND, nodeId))
|
||||
}
|
||||
|
||||
return {
|
||||
id: nodeId,
|
||||
nodeEl,
|
||||
node,
|
||||
parentNode: computed(() => (node.parentNode ? findNode(node.parentNode) : undefined)),
|
||||
connectedEdges: computed(() => getConnectedEdges([node], getEdges.value)),
|
||||
parentNode: computed(() => (node!.parentNode ? findNode(node!.parentNode) : undefined)),
|
||||
connectedEdges: computed(() => getConnectedEdges([node!], getEdges.value)),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user