implement onSelectionChanged

This commit is contained in:
peterkogo
2025-04-30 20:32:06 +02:00
parent adb13e261d
commit 47f9118296
13 changed files with 108 additions and 11 deletions
+2
View File
@@ -0,0 +1,2 @@
export const ssr = false;
export const prerender = false;
@@ -1,11 +1,21 @@
<script lang="ts">
import { Handle, Position, type BuiltInNode, type NodeProps } from '@xyflow/svelte';
import {
Handle,
Position,
useSelectionChanged,
type BuiltInNode,
type NodeProps
} from '@xyflow/svelte';
let {
data = { label: 'Node' },
positionAbsoluteX = 0,
positionAbsoluteY = 0
}: NodeProps<BuiltInNode> = $props();
useSelectionChanged(({ nodes, edges }) => {
console.log('on selection changed via hook', { nodes, edges });
});
</script>
<div class="custom">
@@ -216,6 +216,10 @@
connectionMode={ConnectionMode.Strict}
attributionPosition={'top-center'}
deleteKey={['Backspace', 'd']}
onselectionchanged={({ nodes, edges }) => {
console.log('on selection changed via prop', { nodes, edges });
}}
selectNodesOnDrag
>
<Controls orientation="horizontal" {fitViewOptions}>
{#snippet before()}
@@ -240,7 +244,6 @@
}}>left-right</button
>
</Panel>
<InitTracker />
</SvelteFlow>
+2 -1
View File
@@ -4,7 +4,8 @@ import { defineConfig } from 'vite';
export default defineConfig({
plugins: [sveltekit()],
build: {
sourcemap: true
sourcemap: true,
minify: false
},
server: {
fs: {