Update slash command UX in chat UI of desktop app to match web app

Make commands in popup menu on typing slash in chat input selectable
This commit is contained in:
Debanjum Singh Solanky
2024-06-02 17:01:55 +05:30
parent 7828bd6f2e
commit 8cdab5f31a

View File

@@ -576,6 +576,16 @@
} }
} }
function fillCommandInPrompt(command) {
let chatTooltip = document.getElementById("chat-tooltip");
chatTooltip.style.display = "none";
let chatInput = document.getElementById("chat-input");
chatInput.value = "/" + command + " ";
chatInput.classList.add("option-enabled");
chatInput.focus();
}
function onChatInput() { function onChatInput() {
let chatInput = document.getElementById("chat-input"); let chatInput = document.getElementById("chat-input");
chatInput.value = chatInput.value.trimStart(); chatInput.value = chatInput.value.trimStart();
@@ -591,7 +601,7 @@
const command = chatInput.value.split(" ")[0].substring(1); const command = chatInput.value.split(" ")[0].substring(1);
for (let key in chatOptions) { for (let key in chatOptions) {
if (!!!command || key.startsWith(command)) { if (!!!command || key.startsWith(command)) {
helpText += "<b>/" + key + "</b>: " + chatOptions[key] + "<br>"; helpText += `<div class="helpoption" onclick="fillCommandInPrompt('${key}')"><b>/${key}</b>: ${chatOptions[key]}</div>`;
} }
} }
chatTooltip.innerHTML = helpText; chatTooltip.innerHTML = helpText;
@@ -1853,6 +1863,9 @@
text-align: left; text-align: left;
font-size: medium; font-size: medium;
} }
div#chat-tooltip:hover {
cursor: pointer;
}
svg.new-convo-button { svg.new-convo-button {
width: 20px; width: 20px;