diff --git a/src/lib/components/lemmy/post/PostForm.svelte b/src/lib/components/lemmy/post/PostForm.svelte index aa920127..399d0de9 100644 --- a/src/lib/components/lemmy/post/PostForm.svelte +++ b/src/lib/components/lemmy/post/PostForm.svelte @@ -10,6 +10,7 @@ BookOpen, ArrowPath, Sparkles, + ChatBubbleBottomCenterText, } from 'svelte-hero-icons' import { profile } from '$lib/auth.js' import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte' @@ -20,6 +21,8 @@ import { Button } from 'mono-svelte' import Avatar from '$lib/components/ui/Avatar.svelte' import { t } from '$lib/translations' + import { slide } from 'svelte/transition' + import { feature } from '$lib/version' export let edit = false @@ -35,17 +38,21 @@ title: string body: string image: FileList | null + thumbnail: string | undefined url: string | undefined nsfw: boolean loading: boolean + alt_text: string | undefined } = { community: null, title: '', body: '', image: null, + thumbnail: undefined, url: undefined, nsfw: false, loading: false, + alt_text: undefined, } let saveDraft = edit ? false : true @@ -61,6 +68,8 @@ data.body = editingPost.body ?? '' data.title = editingPost.name data.nsfw = editingPost.nsfw + data.alt_text = editingPost.alt_text + data.thumbnail = editingPost.thumbnail_url } if (passedCommunity) { @@ -117,6 +126,8 @@ url: data.url || undefined, post_id: editingPost.id, nsfw: data.nsfw, + alt_text: data.alt_text, + custom_thumbnail: data.thumbnail, }) if (!post) throw new Error('Failed to edit post') @@ -125,16 +136,14 @@ dispatcher('submit', post.post_view) } else { - let image = data.image - ? await uploadImage(data.image[0], $profile.instance, $profile.jwt) - : undefined - data.url = image || data.url || undefined const post = await client().createPost({ community_id: data.community!.id, name: data.title, body: data.body, url: data.url, nsfw: data.nsfw, + custom_thumbnail: data.thumbnail, + alt_text: data.alt_text, }) if (!post) throw new Error('Failed to upload post') @@ -200,6 +209,8 @@ title: '', } + let addAltText = false + $: generation.generatable = canGenerateTitle(data.url) @@ -295,6 +306,14 @@ {$t('form.post.generateTitle')} {/if} + + {#if addAltText} +
+ +
+ {/if} + the background blur + {#if post.alt_text} + + {/if} {/if} {:else if (type == 'iframe' || type == 'video') && (view == 'cozy' || view == 'card') && post.url} diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json index 79a0c009..234d04b1 100644 --- a/src/lib/i18n/en.json +++ b/src/lib/i18n/en.json @@ -119,7 +119,8 @@ "body": "Body", "nsfw": "NSFW", "generateTitle": "Generate Title", - "uploadImage": "Upload Image" + "uploadImage": "Upload Image", + "altText": "Alt Text" }, "profile": { "displayName": "Display name", diff --git a/src/lib/version.ts b/src/lib/version.ts index 5862a33c..a08f2645 100644 --- a/src/lib/version.ts +++ b/src/lib/version.ts @@ -7,6 +7,8 @@ const FEATURES = { newTotp: '0.19.0', blockInstances: '0.19.0', hidePosts: '0.19.4', + altText: '0.19.4', + customThumbnail: '0.19.4', } type Feature = keyof typeof FEATURES