refactor(svelte): cleanup useSvelteFlow, add functions (#3474)

* chore(svelte) removed nodes, edges from useSvelteFlow

* feat(svelte) added deleteElements to useSvelteFlow

* fix(svelte) parent div gets resized correctly, got rid of getBoundingClient Rect

* feat(svelte) added screenToFlowCoordinate

* feat(svelte) added flowToScreenCoordinate to useSvelteFlow

* chore(svelte) removed project from useSvelteFlow

* Delete examples/svelte/src/routes/add-node-on-drop/+server.ts

---------

Co-authored-by: Moritz Klack <info@moritzklack.com>
This commit is contained in:
peterkogo
2023-10-05 18:53:57 +02:00
committed by GitHub
co-authored by Moritz Klack
parent 86516d3ddd
commit cdf1c4c3a6
5 changed files with 235 additions and 18 deletions
@@ -71,13 +71,14 @@
export { className as class };
let domNode: HTMLDivElement;
let clientWidth: number;
let clientHeight: number;
const store = hasContext(key) ? useStore() : createStoreContext();
onMount(() => {
const { width, height } = domNode.getBoundingClientRect();
store.width.set(width);
store.height.set(height);
store.width.set(clientWidth);
store.height.set(clientHeight);
store.domNode.set(domNode);
store.syncNodeStores(nodes);
@@ -141,6 +142,8 @@
<div
bind:this={domNode}
bind:clientWidth
bind:clientHeight
{style}
class={cc(['svelte-flow', className])}
data-testid="svelte-flow__wrapper"