refac: tab text variable select

This commit is contained in:
Timothy J. Baek
2024-10-19 00:23:59 -07:00
parent 0107a70343
commit 6c0d3ce736
3 changed files with 87 additions and 38 deletions

View File

@@ -110,21 +110,17 @@
prompt = text;
const chatInputContainerElement = document.getElementById('chat-input-container');
const chatInputElement = document.getElementById('chat-input');
await tick();
chatInputElement.style.height = '';
chatInputElement.style.height = Math.min(chatInputElement.scrollHeight, 200) + 'px';
if (chatInputContainerElement) {
chatInputContainerElement.style.height = '';
chatInputContainerElement.style.height =
Math.min(chatInputContainerElement.scrollHeight, 200) + 'px';
chatInputElement?.focus();
await tick();
const words = findWordIndices(prompt);
if (words.length > 0) {
const word = words.at(0);
chatInputElement.setSelectionRange(word?.startIndex, word.endIndex + 1);
chatInputElement?.focus();
}
};
</script>