diff --git a/bun.lockb b/bun.lockb index d6aabcda..760cbde8 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 3015a15d..5cb9be83 100644 --- a/package.json +++ b/package.json @@ -18,10 +18,12 @@ "autoprefixer": "^10.4.16", "jsdom": "^22.1.0", "lemmy-js-client": "latest", + "linkify-it": "^5.0.0", "markdown-it": "^14.1.0", "markdown-it-container": "^3.0.0", "markdown-it-sub": "^1.0.0", "markdown-it-sup": "^1.0.0", + "marked-linkify-it": "^3.1.10", "mono-svelte": "^1.5.14", "nprogress": "^0.2.0", "postcss": "^8.4.30", @@ -30,6 +32,7 @@ "svelte-check": "^3.0.1", "svelte-hero-icons": "^5.0.0", "svelte-infinite-scroll": "^2.0.1", + "svelte-markdown": "^0.4.1", "sveltekit-i18n": "^2.4.2", "tailwindcss": "^3.3.3", "tslib": "^2.4.1", diff --git a/src/lib/components/lemmy/post/helpers.ts b/src/lib/components/lemmy/post/helpers.ts index 110ef830..c35d7f40 100644 --- a/src/lib/components/lemmy/post/helpers.ts +++ b/src/lib/components/lemmy/post/helpers.ts @@ -79,9 +79,9 @@ export const mediaType = (url?: string, view: View = 'cozy'): MediaType => { return 'none' } -export const iframeType = (post: Post): IframeType => { - if (isVideo(post.url)) return 'video' - if (isYoutubeLink(post.url)) return 'youtube' +export const iframeType = (url: string): IframeType => { + if (isVideo(url)) return 'video' + if (isYoutubeLink(url)) return 'youtube' return 'none' } diff --git a/src/lib/components/lemmy/post/media/PostIframe.svelte b/src/lib/components/lemmy/post/media/PostIframe.svelte index 9cd710a6..00fb948a 100644 --- a/src/lib/components/lemmy/post/media/PostIframe.svelte +++ b/src/lib/components/lemmy/post/media/PostIframe.svelte @@ -41,6 +41,7 @@ export let thumbnail: string | undefined = undefined export let url: string export let opened = !$userSettings.embeds.clickToView + export let autoplay: boolean = $userSettings.embeds.clickToView const urlToEmbed = (inputUrl: string) => { if (type == 'video') { @@ -52,11 +53,10 @@ const videoID = youtubeVideoID(inputUrl) - if ($userSettings.embeds.clickToView) - url.searchParams.set('autoplay', '1') + if (autoplay) url.searchParams.set('autoplay', '1') return `https://${youtubeDomain( - $userSettings.embeds.youtube, + $userSettings.embeds.youtube )}/embed/${videoID}?${url.searchParams.toString()}` } @@ -64,7 +64,7 @@ } const typeData = ( - type: IframeType, + type: IframeType ): { icon: IconSource text: string @@ -102,11 +102,7 @@ {#if opened} {#if type == 'video'} -