feat: undo/redo for workflow editor (#3927)
Co-authored-by: StyleZhang <jasonapring2015@outlook.com>
This commit is contained in:
parent
d0fe56a98e
commit
af9448e6f2
38 changed files with 2049 additions and 778 deletions
|
|
@ -13,8 +13,10 @@ import {
|
|||
generateNewNode,
|
||||
} from '../../utils'
|
||||
import {
|
||||
WorkflowHistoryEvent,
|
||||
useAvailableBlocks,
|
||||
useNodesReadOnly,
|
||||
useWorkflowHistory,
|
||||
} from '../../hooks'
|
||||
import { NODES_INITIAL_DATA } from '../../constants'
|
||||
import InsertBlock from './insert-block'
|
||||
|
|
@ -42,6 +44,7 @@ const AddBlock = ({
|
|||
const { nodesReadOnly } = useNodesReadOnly()
|
||||
const { availableNextBlocks } = useAvailableBlocks(BlockEnum.Start, true)
|
||||
const { availablePrevBlocks } = useAvailableBlocks(iterationNodeData.startNodeType, true)
|
||||
const { saveStateToHistory } = useWorkflowHistory()
|
||||
|
||||
const handleSelect = useCallback<OnSelectBlock>((type, toolDefaultValue) => {
|
||||
const {
|
||||
|
|
@ -78,7 +81,8 @@ const AddBlock = ({
|
|||
draft.push(newNode)
|
||||
})
|
||||
setNodes(newNodes)
|
||||
}, [store, t, iterationNodeId])
|
||||
saveStateToHistory(WorkflowHistoryEvent.NodeAdd)
|
||||
}, [store, t, iterationNodeId, saveStateToHistory])
|
||||
|
||||
const renderTriggerElement = useCallback((open: boolean) => {
|
||||
return (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue