diff --git a/Components/ChatAttachments.svelte b/Components/ChatAttachments.svelte index 37ff63f..30f83a9 100644 --- a/Components/ChatAttachments.svelte +++ b/Components/ChatAttachments.svelte @@ -2,12 +2,17 @@ import type { Attachment } from "Conversations/Attachment"; import { setElementIcon } from "Helpers/ElementHelper"; import { setIcon } from "obsidian"; + import { tick } from "svelte"; export let attachments: Attachment[] = []; let removeAttachmentButtons: (HTMLButtonElement | null)[] = []; let attachmentElements: (HTMLDivElement | null)[] = []; let selectedElement: HTMLDivElement | null = null; + let contentDiv: HTMLDivElement; + let height = 0; + + $: attachments, updateHeight(); $: if (removeAttachmentButtons.length > 0) { removeAttachmentButtons.forEach((button) => { @@ -17,6 +22,14 @@ }); } + function updateHeight() { + tick().then(() => { + if (contentDiv) { + height = contentDiv.scrollHeight; + } + }); + } + function removeAttachment(attachment: Attachment) { attachments = attachments.filter((a) => a !== attachment); } @@ -37,41 +50,48 @@ } -