From 156b3123366b86ff4b14bf8850850c344a211dbb Mon Sep 17 00:00:00 2001 From: Braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Sun, 8 Aug 2021 20:33:55 +0200 Subject: [PATCH] update: button edge example to remove edge on click --- examples/EdgeWithButton/ButtonEdge.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/examples/EdgeWithButton/ButtonEdge.tsx b/examples/EdgeWithButton/ButtonEdge.tsx index fb00387d..2b89663f 100644 --- a/examples/EdgeWithButton/ButtonEdge.tsx +++ b/examples/EdgeWithButton/ButtonEdge.tsx @@ -1,13 +1,20 @@ -import { computed, defineComponent } from 'vue'; -import { getBezierPath, getEdgeCenter, getMarkerEnd } from '../../src'; +import { computed, defineComponent, inject } from 'vue'; +import { getBezierPath, getEdgeCenter, getMarkerEnd, RevueFlowStore } from '../../src'; import { DefaultEdgeProps } from '../../src/components/Edges/utils'; +import { RevueFlowHooks } from '../../src/hooks/RevueFlowHooks'; export default defineComponent({ props: { ...DefaultEdgeProps }, setup(props) { + const store = inject('store')!; + const hooks = inject('hooks')!; const onEdgeClick = (evt: Event, id: string) => { + const edge = store.edges.find((edge) => edge.id === id); + if (edge) { + hooks.elementsRemove.trigger([edge]); + } evt.stopPropagation(); alert(`remove ${id}`); };