From ed9efba03995892b9915a92bfde182c29ba655d5 Mon Sep 17 00:00:00 2001 From: hjlarry Date: Fri, 30 Jan 2026 15:13:32 +0800 Subject: [PATCH] fix: variable of sync display in prompt editor --- web/app/components/base/prompt-editor/index.tsx | 6 ++++++ .../base/prompt-editor/plugins/update-block.tsx | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/web/app/components/base/prompt-editor/index.tsx b/web/app/components/base/prompt-editor/index.tsx index 35bdd138b5..d5212d5942 100644 --- a/web/app/components/base/prompt-editor/index.tsx +++ b/web/app/components/base/prompt-editor/index.tsx @@ -113,6 +113,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 diff --git a/web/app/components/base/prompt-editor/plugins/update-block.tsx b/web/app/components/base/prompt-editor/plugins/update-block.tsx index bf89a259af..f63352887c 100644 --- a/web/app/components/base/prompt-editor/plugins/update-block.tsx +++ b/web/app/components/base/prompt-editor/plugins/update-block.tsx @@ -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' @@ -21,6 +21,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() + }) + }) } })