feat: undo/redo for workflow editor (#3927)

Co-authored-by: StyleZhang <jasonapring2015@outlook.com>
This commit is contained in:
Pascal M 2024-06-26 08:37:12 +02:00 committed by GitHub
commit af9448e6f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
38 changed files with 2049 additions and 778 deletions

View file

@ -13,6 +13,7 @@ import { ListPlugin } from '@lexical/react/LexicalListPlugin'
import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary'
import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin'
import { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin'
import { useWorkflowHistoryStore } from '../../workflow-history-store'
import LinkEditorPlugin from './plugins/link-editor-plugin'
import FormatDetectorPlugin from './plugins/format-detector-plugin'
// import TreeView from '@/app/components/base/prompt-editor/plugins/tree-view'
@ -32,12 +33,16 @@ const Editor = ({
onChange?.(editorState)
}, [onChange])
const { setShortcutsEnabled } = useWorkflowHistoryStore()
return (
<div className='relative'>
<RichTextPlugin
contentEditable={
<div>
<ContentEditable
onFocus={() => setShortcutsEnabled(false)}
onBlur={() => setShortcutsEnabled(true)}
spellCheck={false}
className='w-full h-full outline-none caret-primary-600'
placeholder={placeholder}