fix(canvas): avoid post-launch editor rehydrate when auto-send is enabled
This commit is contained in:
parent
2469024a76
commit
c6c6c3f7bb
@ -1664,27 +1664,29 @@ export function CanvasChatPanel({ chatId, initialMessages = [], onClose, onOpenF
|
||||
});
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
const editableDiv = textareaRef.current as HTMLDivElement | null;
|
||||
if (editableDiv) {
|
||||
editableDiv.innerHTML = "";
|
||||
if (normalizedPrompt) {
|
||||
editableDiv.appendChild(document.createTextNode(normalizedPrompt));
|
||||
const selection = window.getSelection();
|
||||
if (selection) {
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(editableDiv);
|
||||
range.collapse(false);
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
if (!parsed.autoSend) {
|
||||
setTimeout(() => {
|
||||
const editableDiv = textareaRef.current as HTMLDivElement | null;
|
||||
if (editableDiv) {
|
||||
editableDiv.innerHTML = "";
|
||||
if (normalizedPrompt) {
|
||||
editableDiv.appendChild(document.createTextNode(normalizedPrompt));
|
||||
const selection = window.getSelection();
|
||||
if (selection) {
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(editableDiv);
|
||||
range.collapse(false);
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
normalizedAttachments.forEach((attachment, index) => {
|
||||
insertImageTagInEditor(attachment.url, attachment.name, index);
|
||||
});
|
||||
}, 50);
|
||||
normalizedAttachments.forEach((attachment, index) => {
|
||||
insertImageTagInEditor(attachment.url, attachment.name, index);
|
||||
});
|
||||
}, 50);
|
||||
}
|
||||
|
||||
if (parsed.autoSend) {
|
||||
pendingLaunchRef.current = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user