From 53fe1c90398f3d43bc3ba85d4a35951286a947ce Mon Sep 17 00:00:00 2001 From: hjlarry Date: Fri, 10 Apr 2026 10:20:49 +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 9e004ca19d..cceffd4af4 100644 --- a/web/app/components/base/prompt-editor/index.tsx +++ b/web/app/components/base/prompt-editor/index.tsx @@ -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 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 2d83573b1f..e67b027be7 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' @@ -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() + }) + }) } })