workflow底层UI库整合至项目,优化构建逻辑
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import {getContext} from 'svelte';
|
||||
import {useNodesData, useSvelteFlow} from '@xyflow/svelte';
|
||||
import type {TinyflowOptions} from '#types';
|
||||
|
||||
export const getCurrentNodeId = () => {
|
||||
return getContext<string>('svelteflow__node_id');
|
||||
};
|
||||
|
||||
export const getOptions = () => {
|
||||
return getContext<TinyflowOptions>('tinyflow_options');
|
||||
};
|
||||
|
||||
export const useCurrentNodeData = () => {
|
||||
const currentNodeId = getCurrentNodeId();
|
||||
return useNodesData<any>(currentNodeId);
|
||||
};
|
||||
|
||||
export const useUpdateNodeData = () => {
|
||||
const { updateNodeData } = useSvelteFlow();
|
||||
const currentNodeId = getCurrentNodeId();
|
||||
return {
|
||||
updateNodeData: (data: any) => {
|
||||
updateNodeData(currentNodeId, data);
|
||||
}
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user