修复润色按钮无法感知输入
- 用 React 状态同步编辑器当前文本 - 让按钮禁用态随用户输入即时更新
This commit is contained in:
+3
-3
@@ -763,6 +763,7 @@ function ResourceReferenceEditor({
|
||||
references: initialDraft?.references ?? [],
|
||||
content: [],
|
||||
});
|
||||
const [draftText, setDraftText] = useState(initialDraft?.text ?? '');
|
||||
const reminderDisabledRef = useRef(reminderDisabled);
|
||||
reminderDisabledRef.current = reminderDisabled;
|
||||
|
||||
@@ -1007,9 +1008,7 @@ function ResourceReferenceEditor({
|
||||
aria-label="AI 润色"
|
||||
title="AI 润色"
|
||||
aria-busy={polishing}
|
||||
disabled={
|
||||
disabled || polishing || liveDraftRef.current.text.trim() === ''
|
||||
}
|
||||
disabled={disabled || polishing || draftText.trim() === ''}
|
||||
onMouseDown={(event) => event.preventDefault()}
|
||||
onClick={() => void polishPrompt()}
|
||||
>
|
||||
@@ -1215,6 +1214,7 @@ function ResourceReferenceEditor({
|
||||
onChange={(editorState) => {
|
||||
const nextDraft = readResourceReferenceDraft(editorState);
|
||||
liveDraftRef.current = nextDraft;
|
||||
setDraftText(nextDraft.text);
|
||||
if (skipInitialDraftChangeRef.current) {
|
||||
skipInitialDraftChangeRef.current = false;
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user