fix: variable of sync display in prompt editor

This commit is contained in:
hjlarry 2026-04-10 10:20:49 +08:00
parent 9c7a2196ed
commit 53fe1c9039
2 changed files with 13 additions and 1 deletions

View File

@ -86,6 +86,12 @@ const ValueSyncPlugin: FC<{ value?: string }> = ({ value }) => {
const editorState = editor.parseEditorState(textToEditorState(incomingValue))
editor.setEditorState(editorState)
editor.update(() => {
$getRoot().getAllTextNodes().forEach((node) => {
if (node instanceof CustomTextNode)
node.markDirty()
})
})
}, [editor, value])
return null

View File

@ -1,5 +1,5 @@
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'
import { $insertNodes } from 'lexical'
import { $getRoot, $insertNodes } from 'lexical'
import { useEventEmitterContextContext } from '@/context/event-emitter'
import { textToEditorState } from '../utils'
import { CustomTextNode } from './custom-text/node'
@ -20,6 +20,12 @@ const UpdateBlock = ({
if (v.type === PROMPT_EDITOR_UPDATE_VALUE_BY_EVENT_EMITTER && v.instanceId === instanceId) {
const editorState = editor.parseEditorState(textToEditorState(v.payload))
editor.setEditorState(editorState)
editor.update(() => {
$getRoot().getAllTextNodes().forEach((node) => {
if (node instanceof CustomTextNode)
node.markDirty()
})
})
}
})