fix: adjust height automatically, close #294, close #272

This commit is contained in:
Xylight committed 2024-09-06 17:12:37 -07:00
1 parent 190b28a331
commit b78145a4f5
2 files changed
+13 -2

No files matched your search

@@ -368,7 +368,17 @@
{/if}
<div class="flex flex-row gap-2 flex-wrap">
{#if data.url === undefined}
<Button on:click={() => (data.url = '')} size="lg">
<Button
on:click={async () => {
data.url = ''
try {
const url = new URL(await navigator.clipboard.readText())
data.url = url.toString()
} catch (e) {}
}}
size="lg"
>
<Icon src={Link} size="16" micro />
{$t('form.post.addUrl')}
</Button>
@@ -88,6 +88,8 @@
textArea.style.height = 'auto' // Reset height to auto to calculate new height
textArea.style.height = `${textArea.scrollHeight}px` // Set height to the scrollHeight
}
$: if (textArea && !previewing) adjustHeight()
</script>
{#if uploadingImage && images}
@@ -122,7 +124,6 @@ overflow-hidden transition-colors {$$props.class}"
{#if previewing}
<div
class="px-3 py-2.5 overflow-auto text-sm resize-y bg-white dark:bg-zinc-950"
style="height: {rows * 2}em"
>
<Markdown source={beforePreview(value)} />
</div>