From 0f3af1d9d79452e837206878a671406d989883f3 Mon Sep 17 00:00:00 2001 From: Henry Fontanier Date: Tue, 3 Oct 2023 18:00:15 +0200 Subject: [PATCH 1/2] enh: make inputbar scrollable --- .../assistant/conversation/InputBar.tsx | 94 +++++++++++-------- 1 file changed, 56 insertions(+), 38 deletions(-) diff --git a/front/components/assistant/conversation/InputBar.tsx b/front/components/assistant/conversation/InputBar.tsx index ced676e5d8c3..4c21efe0abe1 100644 --- a/front/components/assistant/conversation/InputBar.tsx +++ b/front/components/assistant/conversation/InputBar.tsx @@ -374,7 +374,7 @@ export function AssistantInputBar({
{ + const element = inputRef.current; + if (element) { + element.scrollTop = element.scrollHeight; + } + }, 0); } + + // Move the cursor to the end of the paste. + const newRange = document.createRange(); + newRange.setStart(node, offset + text.length); + newRange.setEnd(node, offset + text.length); + selection.removeAllRanges(); + selection.addRange(newRange); }} onKeyDown={(e) => { // We prevent the content editable from creating italics, bold and underline. @@ -687,38 +698,45 @@ export function AssistantInputBar({ }} >
-
-
- { - // We construct the HTML for an AgentMention and inject it in the content - // editable with an extra space after it. - const mentionNode = getAgentMentionNode(c); - const contentEditable = - document.getElementById("dust-input-bar"); - if (contentEditable && mentionNode) { - // Add mentionNode as last childe of contentEditable. - contentEditable.appendChild(mentionNode); - const afterTextNode = document.createTextNode(" "); - contentEditable.appendChild(afterTextNode); - contentEditable.focus(); - moveCursorToEnd(contentEditable); - } - }} - assistants={activeAgents} - showBuilderButtons={true} - /> +
+
+
+ { + // We construct the HTML for an AgentMention and inject it in the content + // editable with an extra space after it. + const mentionNode = getAgentMentionNode(c); + const contentEditable = + document.getElementById("dust-input-bar"); + if (contentEditable && mentionNode) { + // Add mentionNode as last childe of contentEditable. + contentEditable.appendChild(mentionNode); + const afterTextNode = document.createTextNode(" "); + contentEditable.appendChild(afterTextNode); + contentEditable.focus(); + moveCursorToEnd(contentEditable); + } + }} + assistants={activeAgents} + showBuilderButtons={true} + /> + + { + void handleSubmit(); + }} + /> +
- { - void handleSubmit(); - }} - />
From be10beb4c6879f0ccede919d9657bedf72b6905c Mon Sep 17 00:00:00 2001 From: Henry Fontanier Date: Tue, 3 Oct 2023 18:31:20 +0200 Subject: [PATCH 2/2] no scrollbar --- front/components/assistant/conversation/InputBar.tsx | 8 ++++++-- front/package-lock.json | 6 ++++++ front/package.json | 1 + front/tailwind.config.js | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/front/components/assistant/conversation/InputBar.tsx b/front/components/assistant/conversation/InputBar.tsx index 4c21efe0abe1..5bb91f88d792 100644 --- a/front/components/assistant/conversation/InputBar.tsx +++ b/front/components/assistant/conversation/InputBar.tsx @@ -393,8 +393,12 @@ export function AssistantInputBar({ Ask a question