update: button edge example to remove edge on click

This commit is contained in:
Braks
2021-08-08 20:33:55 +02:00
parent 74a2a3d8c3
commit 156b312336

View File

@@ -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<RevueFlowStore>('store')!;
const hooks = inject<RevueFlowHooks>('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}`);
};