From 755df4dbba1bd7bbf697ebf407fe4ebeba646bc4 Mon Sep 17 00:00:00 2001 From: Timothy Carambat Date: Mon, 19 Feb 2024 10:32:53 -0800 Subject: [PATCH] auto highlight slash command on typing (#743) --- .../ChatWindow/ChatContainer/PromptInput/index.jsx | 1 - .../components/ChatWindow/ChatContainer/index.jsx | 1 - .../ChatContainer/PromptInput/index.jsx | 14 +++++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/embed/src/components/ChatWindow/ChatContainer/PromptInput/index.jsx b/embed/src/components/ChatWindow/ChatContainer/PromptInput/index.jsx index 5231b0f5..feddbc0d 100644 --- a/embed/src/components/ChatWindow/ChatContainer/PromptInput/index.jsx +++ b/embed/src/components/ChatWindow/ChatContainer/PromptInput/index.jsx @@ -2,7 +2,6 @@ import { CircleNotch, PaperPlaneRight } from "@phosphor-icons/react"; import React, { useState, useRef } from "react"; export default function PromptInput({ - setttings, message, submit, onChange, diff --git a/embed/src/components/ChatWindow/ChatContainer/index.jsx b/embed/src/components/ChatWindow/ChatContainer/index.jsx index 9c1ffa36..505142de 100644 --- a/embed/src/components/ChatWindow/ChatContainer/index.jsx +++ b/embed/src/components/ChatWindow/ChatContainer/index.jsx @@ -79,7 +79,6 @@ export default function ChatContainer({
{ + const input = e.target.value; + if (input === "/") setShowSlashCommand(true); + if (showSlashCommand) setShowSlashCommand(false); + return; + }; + const captureEnter = (event) => { if (event.keyCode == 13) { if (!event.shiftKey) { @@ -42,6 +50,7 @@ export default function PromptInput({ : "1px"; }; + const watchForSlash = debounce(checkForSlash, 300); return (
{ + onChange(e); + watchForSlash(e); + }} required={true} disabled={inputDisabled} onFocus={() => setFocused(true)}