move handleEdgeSelection into store, fix hooks
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import { getContext, type Snippet } from 'svelte';
|
||||
|
||||
import { EdgeLabelRenderer } from '$lib/components/EdgeLabelRenderer';
|
||||
import { useHandleEdgeSelect } from '$lib/hooks/useHandleEdgeSelect';
|
||||
import { useStore } from '$lib/store';
|
||||
|
||||
let {
|
||||
style,
|
||||
@@ -16,7 +16,7 @@
|
||||
children?: Snippet;
|
||||
} = $props();
|
||||
|
||||
const handleEdgeSelect = useHandleEdgeSelect();
|
||||
const store = useStore();
|
||||
|
||||
const id = getContext<string>('svelteflow__edge_id');
|
||||
</script>
|
||||
@@ -30,7 +30,7 @@
|
||||
tabindex="-1"
|
||||
onkeyup={() => {}}
|
||||
onclick={() => {
|
||||
if (id) handleEdgeSelect(id);
|
||||
if (id) store.handleEdgeSelection(id);
|
||||
}}
|
||||
>
|
||||
{@render children?.()}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
import { getMarkerId } from '@xyflow/system';
|
||||
|
||||
import { BezierEdgeInternal } from '$lib/components/edges';
|
||||
import { useHandleEdgeSelect } from '$lib/hooks/useHandleEdgeSelect';
|
||||
|
||||
import type { EdgeLayouted, Edge, EdgeEvents } from '$lib/types';
|
||||
import type { SvelteFlowStore } from '$lib/store/types';
|
||||
@@ -61,13 +60,11 @@
|
||||
markerEnd ? `url('#${getMarkerId(markerEnd, store.flowId)}')` : undefined
|
||||
);
|
||||
|
||||
const handleEdgeSelect = useHandleEdgeSelect();
|
||||
|
||||
function onclick(event: MouseEvent | TouchEvent) {
|
||||
const edge = store.edgeLookup.get(id);
|
||||
|
||||
if (edge) {
|
||||
handleEdgeSelect(id);
|
||||
store.handleEdgeSelection(id);
|
||||
onedgeclick?.({ event, edge });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user