feat(core): add onError hook

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2023-03-23 15:58:30 +01:00
committed by Braks
parent 87249e5dde
commit 8c3f54ec28
22 changed files with 250 additions and 180 deletions
@@ -19,6 +19,7 @@ const {
getEdgeTypes,
elevateEdgesOnSelect,
dimensions,
emits,
} = $(useVueFlow())
const sourceNode = controlledComputed(
@@ -75,7 +76,7 @@ function getType(type?: string, template?: GraphEdge['template']) {
const slot = slots?.[`edge-${name}`]
if (!slot) {
warn(`Edge type "${type}" not found and no edge-slot detected. Using fallback type "default".`)
emits.error(new VueFlowError(ErrorCode.EDGE_TYPE_MISSING, edgeType))
return false
}
@@ -68,7 +68,7 @@ function getType(type?: string, template?: GraphNode['template']) {
const slot = slots?.[`node-${name}`]
if (!slot) {
warn(`Node type "${type}" not found and no node-slot detected. Using fallback type "default".`)
emits.error(new VueFlowError(ErrorCode.NODE_TYPE_MISSING, nodeType))
return false
}
@@ -287,7 +287,9 @@ function setDimensions() {
const { width, height } = getDimensions(viewportEl.value)
if (width === 0 || height === 0) warn('The Vue Flow parent container needs a width and a height to render the graph.')
if (width === 0 || height === 0) {
emits.error(new VueFlowError(ErrorCode.MISSING_VIEWPORT_DIMENSIONS))
}
dimensions.width = width || 500
dimensions.height = height || 500