Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Thomas G. Lopes
commited on
Commit
·
9129dc5
1
Parent(s):
1c8490e
fix auto resize on programmatic event
Browse files
src/lib/components/inference-playground/message.svelte
CHANGED
|
@@ -6,6 +6,7 @@
|
|
| 6 |
import { images } from "$lib/state/images.svelte";
|
| 7 |
import { PipelineTag, type ConversationMessage } from "$lib/types.js";
|
| 8 |
import { copyToClipboard } from "$lib/utils/copy.js";
|
|
|
|
| 9 |
import { FileUpload } from "melt/builders";
|
| 10 |
import { fade } from "svelte/transition";
|
| 11 |
import IconCopy from "~icons/carbon/copy";
|
|
@@ -14,7 +15,6 @@
|
|
| 14 |
import IconCustom from "../icon-custom.svelte";
|
| 15 |
import LocalToasts from "../local-toasts.svelte";
|
| 16 |
import ImgPreview from "./img-preview.svelte";
|
| 17 |
-
import { AsyncQueue } from "$lib/utils/queue.js";
|
| 18 |
|
| 19 |
type Props = {
|
| 20 |
conversation: ConversationClass;
|
|
|
|
| 6 |
import { images } from "$lib/state/images.svelte";
|
| 7 |
import { PipelineTag, type ConversationMessage } from "$lib/types.js";
|
| 8 |
import { copyToClipboard } from "$lib/utils/copy.js";
|
| 9 |
+
import { AsyncQueue } from "$lib/utils/queue.js";
|
| 10 |
import { FileUpload } from "melt/builders";
|
| 11 |
import { fade } from "svelte/transition";
|
| 12 |
import IconCopy from "~icons/carbon/copy";
|
|
|
|
| 15 |
import IconCustom from "../icon-custom.svelte";
|
| 16 |
import LocalToasts from "../local-toasts.svelte";
|
| 17 |
import ImgPreview from "./img-preview.svelte";
|
|
|
|
| 18 |
|
| 19 |
type Props = {
|
| 20 |
conversation: ConversationClass;
|
src/lib/spells/textarea-autosize.svelte.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
-
import { extract } from "./extract.svelte.js";
|
| 2 |
import { useResizeObserver, watch } from "runed";
|
| 3 |
import { onDestroy, tick } from "svelte";
|
| 4 |
import type { Attachment } from "svelte/attachments";
|
| 5 |
import { on } from "svelte/events";
|
|
|
|
| 6 |
|
| 7 |
export interface TextareaAutosizeOptions {
|
| 8 |
/** Function called when the textarea size changes. */
|
|
@@ -159,6 +159,20 @@ export class TextareaAutosize {
|
|
| 159 |
attachment: Attachment<HTMLTextAreaElement> = node => {
|
| 160 |
this.element = node;
|
| 161 |
this.input = node.value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
const removeListener = on(node, "input", _ => {
|
| 163 |
this.input = node.value;
|
| 164 |
});
|
|
|
|
|
|
|
| 1 |
import { useResizeObserver, watch } from "runed";
|
| 2 |
import { onDestroy, tick } from "svelte";
|
| 3 |
import type { Attachment } from "svelte/attachments";
|
| 4 |
import { on } from "svelte/events";
|
| 5 |
+
import { extract } from "./extract.svelte.js";
|
| 6 |
|
| 7 |
export interface TextareaAutosizeOptions {
|
| 8 |
/** Function called when the textarea size changes. */
|
|
|
|
| 159 |
attachment: Attachment<HTMLTextAreaElement> = node => {
|
| 160 |
this.element = node;
|
| 161 |
this.input = node.value;
|
| 162 |
+
|
| 163 |
+
// Detect programmatic changes
|
| 164 |
+
const desc = Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, "value")!;
|
| 165 |
+
Object.defineProperty(node, "value", {
|
| 166 |
+
get: desc.get,
|
| 167 |
+
set: v => {
|
| 168 |
+
const cleanup = $effect.root(() => {
|
| 169 |
+
this.input = v;
|
| 170 |
+
});
|
| 171 |
+
cleanup();
|
| 172 |
+
desc.set?.call(node, v);
|
| 173 |
+
},
|
| 174 |
+
});
|
| 175 |
+
|
| 176 |
const removeListener = on(node, "input", _ => {
|
| 177 |
this.input = node.value;
|
| 178 |
});
|