feat: can support choose current node var

This commit is contained in:
Joel
2025-06-25 16:05:57 +08:00
parent a4f4fea0a5
commit 4631575c12
3 changed files with 47 additions and 25 deletions

View File

@ -63,6 +63,15 @@ export const useWorkflow = () => {
workflowStore.setState({ panelWidth: width })
}, [workflowStore])
const getNodeById = useCallback((nodeId: string) => {
const {
getNodes,
} = store.getState()
const nodes = getNodes()
const currentNode = nodes.find(node => node.id === nodeId)
return currentNode
}, [store])
const getTreeLeafNodes = useCallback((nodeId: string) => {
const {
getNodes,
@ -445,6 +454,7 @@ export const useWorkflow = () => {
return {
setPanelWidth,
getNodeById,
getTreeLeafNodes,
getBeforeNodesInSameBranch,
getBeforeNodesInSameBranchIncludeParent,