Spaces:
Running
Running
make sure the input resize
Browse files
src/lib/components/chat/ChatInput.svelte
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<script lang="ts">
|
2 |
import { browser } from "$app/environment";
|
3 |
-
import { createEventDispatcher, onMount } from "svelte";
|
4 |
|
5 |
import HoverTooltip from "$lib/components/HoverTooltip.svelte";
|
6 |
import IconInternet from "$lib/components/icons/IconInternet.svelte";
|
@@ -76,7 +76,7 @@
|
|
76 |
textareaElement.parentElement.style.height = `${newHeight}px`;
|
77 |
}
|
78 |
|
79 |
-
function handleKeydown(event: KeyboardEvent) {
|
80 |
if (event.key === "Enter" && !event.shiftKey && !isCompositionOn) {
|
81 |
event.preventDefault();
|
82 |
if (isVirtualKeyboard()) {
|
@@ -88,6 +88,8 @@
|
|
88 |
} else {
|
89 |
if (value.trim() !== "") {
|
90 |
dispatch("submit");
|
|
|
|
|
91 |
}
|
92 |
}
|
93 |
}
|
@@ -121,7 +123,7 @@
|
|
121 |
) satisfies ToolFront[];
|
122 |
</script>
|
123 |
|
124 |
-
<div class="min-h-full flex-1
|
125 |
<div class="relative w-full min-w-0">
|
126 |
<textarea
|
127 |
enterkeyhint={!isVirtualKeyboard() ? "enter" : "send"}
|
|
|
1 |
<script lang="ts">
|
2 |
import { browser } from "$app/environment";
|
3 |
+
import { createEventDispatcher, onMount, tick } from "svelte";
|
4 |
|
5 |
import HoverTooltip from "$lib/components/HoverTooltip.svelte";
|
6 |
import IconInternet from "$lib/components/icons/IconInternet.svelte";
|
|
|
76 |
textareaElement.parentElement.style.height = `${newHeight}px`;
|
77 |
}
|
78 |
|
79 |
+
async function handleKeydown(event: KeyboardEvent) {
|
80 |
if (event.key === "Enter" && !event.shiftKey && !isCompositionOn) {
|
81 |
event.preventDefault();
|
82 |
if (isVirtualKeyboard()) {
|
|
|
88 |
} else {
|
89 |
if (value.trim() !== "") {
|
90 |
dispatch("submit");
|
91 |
+
await tick();
|
92 |
+
adjustTextareaHeight();
|
93 |
}
|
94 |
}
|
95 |
}
|
|
|
123 |
) satisfies ToolFront[];
|
124 |
</script>
|
125 |
|
126 |
+
<div class="min-h-full flex-1" on:paste>
|
127 |
<div class="relative w-full min-w-0">
|
128 |
<textarea
|
129 |
enterkeyhint={!isVirtualKeyboard() ? "enter" : "send"}
|