This commit is contained in:
Timothy Jaeryang Baek
2025-07-03 21:28:09 +04:00
parent d2485bbf09
commit 75096c24ac
3 changed files with 21 additions and 17 deletions
+9 -9
View File
@@ -287,15 +287,6 @@
}}>{$i18n.t('All')}</button }}>{$i18n.t('All')}</button
> >
<button
class="min-w-fit p-1.5 {selectedType === 'filter'
? ''
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition"
on:click={() => {
selectedType = 'filter';
}}>{$i18n.t('Filter')}</button
>
<button <button
class="min-w-fit p-1.5 {selectedType === 'pipe' class="min-w-fit p-1.5 {selectedType === 'pipe'
? '' ? ''
@@ -305,6 +296,15 @@
}}>{$i18n.t('Pipe')}</button }}>{$i18n.t('Pipe')}</button
> >
<button
class="min-w-fit p-1.5 {selectedType === 'filter'
? ''
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition"
on:click={() => {
selectedType = 'filter';
}}>{$i18n.t('Filter')}</button
>
<button <button
class="min-w-fit p-1.5 {selectedType === 'action' class="min-w-fit p-1.5 {selectedType === 'action'
? '' ? ''
@@ -175,17 +175,16 @@
if (words.length > 0) { if (words.length > 0) {
const word = words.at(0); const word = words.at(0);
const fullPrompt = prompt;
prompt = prompt.substring(0, word?.endIndex + 1);
await tick(); await tick();
chatInputElement.scrollTop = chatInputElement.scrollHeight; if (!($settings?.richTextInput ?? true)) {
chatInputElement.setSelectionRange(word.startIndex, word.endIndex + 1);
chatInputElement.focus();
prompt = fullPrompt; // This is a workaround to ensure the cursor is placed correctly
await tick(); // after the text is inserted, especially for multiline inputs.
chatInputElement.setSelectionRange(word.startIndex, word.endIndex + 1);
chatInputElement.setSelectionRange(word?.startIndex, word.endIndex + 1); }
} else { } else {
chatInputElement.scrollTop = chatInputElement.scrollHeight; chatInputElement.scrollTop = chatInputElement.scrollHeight;
} }
@@ -123,6 +123,11 @@
if (dispatch) { if (dispatch) {
const tr = state.tr.setSelection(TextSelection.create(doc, template.from, template.to)); const tr = state.tr.setSelection(TextSelection.create(doc, template.from, template.to));
dispatch(tr); dispatch(tr);
// Scroll to the selected template
dispatch(
tr.scrollIntoView().setMeta('preventScroll', true) // Prevent default scrolling behavior
);
} }
return true; return true;
} }