feat: sub-graph to use dynamic node generation

This commit is contained in:
zhsama
2026-01-13 22:28:30 +08:00
parent f57d2ef31f
commit 96ec176b83
16 changed files with 351 additions and 134 deletions

View File

@ -17,7 +17,7 @@ import {
} from '../utils'
import { useWorkflowHistoryStore } from '../workflow-history-store'
export const useShortcuts = (): void => {
export const useShortcuts = (enabled = true): void => {
const {
handleNodesCopy,
handleNodesPaste,
@ -66,13 +66,17 @@ export const useShortcuts = (): void => {
}
const shouldHandleShortcut = useCallback((e: KeyboardEvent) => {
if (!enabled)
return false
return !isEventTargetInputArea(e.target as HTMLElement)
}, [])
}, [enabled])
const shouldHandleCopy = useCallback(() => {
if (!enabled)
return false
const selection = document.getSelection()
return !selection || selection.isCollapsed
}, [])
}, [enabled])
useKeyPress(['delete', 'backspace'], (e) => {
if (shouldHandleShortcut(e)) {
@ -282,6 +286,8 @@ export const useShortcuts = (): void => {
// Listen for zen toggle event from /zen command
useEffect(() => {
if (!enabled)
return
const handleZenToggle = () => {
handleToggleMaximizeCanvas()
}
@ -290,5 +296,5 @@ export const useShortcuts = (): void => {
return () => {
window.removeEventListener(ZEN_TOGGLE_EVENT, handleZenToggle)
}
}, [handleToggleMaximizeCanvas])
}, [enabled, handleToggleMaximizeCanvas])
}

View File

@ -498,13 +498,9 @@ export const useNodesReadOnly = () => {
const isRestoring = useStore(s => s.isRestoring)
const getNodesReadOnly = useCallback((): boolean => {
const {
workflowRunningData,
historyWorkflowData,
isRestoring,
} = workflowStore.getState()
const state = workflowStore.getState()
return !!(workflowRunningData?.result.status === WorkflowRunningStatus.Running || historyWorkflowData || isRestoring)
return !!(state.workflowRunningData?.result.status === WorkflowRunningStatus.Running || state.historyWorkflowData || state.isRestoring)
}, [workflowStore])
return {