port more updates
This commit is contained in:
+17
-2
@@ -4,7 +4,7 @@ import { useStore } from '$lib/store';
|
||||
* Hook for getting the current nodes from the store.
|
||||
*
|
||||
* @public
|
||||
* @returns store with an array of nodes
|
||||
* @returns reactive signal of the current edges
|
||||
*/
|
||||
export function useNodes() {
|
||||
const { nodes } = $derived(useStore());
|
||||
@@ -19,7 +19,7 @@ export function useNodes() {
|
||||
* Hook for getting the current edges from the store.
|
||||
*
|
||||
* @public
|
||||
* @returns store with an array of edges
|
||||
* @returns reactive signal of the current edges
|
||||
*/
|
||||
export function useEdges() {
|
||||
const { edges } = $derived(useStore());
|
||||
@@ -29,3 +29,18 @@ export function useEdges() {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook for getting the current viewport from the store.
|
||||
*
|
||||
* @public
|
||||
* @returns reactive signal of the current viewport
|
||||
*/
|
||||
export function useViewport() {
|
||||
const { viewport } = $derived(useStore());
|
||||
return {
|
||||
get current() {
|
||||
return viewport;
|
||||
}
|
||||
};
|
||||
}
|
||||
+1
-1
@@ -370,7 +370,7 @@ export function useSvelteFlow(): {
|
||||
|
||||
return Promise.resolve(true);
|
||||
},
|
||||
getViewport: () => store.viewport,
|
||||
getViewport: () => $state.snapshot(store.viewport),
|
||||
setCenter: async (x, y, options) => {
|
||||
const nextZoom = typeof options?.zoom !== 'undefined' ? options.zoom : store.maxZoom;
|
||||
const currentPanZoom = store.panZoom;
|
||||
+2
-3
@@ -1,4 +1,3 @@
|
||||
import { get } from 'svelte/store';
|
||||
import type { UpdateNodeInternals } from '@xyflow/system';
|
||||
|
||||
import { useStore } from '$lib/store';
|
||||
@@ -10,7 +9,7 @@ import { useStore } from '$lib/store';
|
||||
* @returns function for updating node internals
|
||||
*/
|
||||
export function useUpdateNodeInternals(): UpdateNodeInternals {
|
||||
const { domNode, updateNodeInternals } = useStore();
|
||||
const { domNode, updateNodeInternals } = $derived(useStore());
|
||||
|
||||
// @todo: do we want to add this to system?
|
||||
const updateInternals = (id: string | string[]) => {
|
||||
@@ -18,7 +17,7 @@ export function useUpdateNodeInternals(): UpdateNodeInternals {
|
||||
const updates = new Map();
|
||||
|
||||
updateIds.forEach((updateId) => {
|
||||
const nodeElement = get(domNode)?.querySelector(
|
||||
const nodeElement = domNode?.querySelector(
|
||||
`.svelte-flow__node[data-id="${updateId}"]`
|
||||
) as HTMLDivElement;
|
||||
|
||||
Reference in New Issue
Block a user