diff --git a/package.json b/package.json index 14682e6a..c5120b44 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "photon-lemmy", - "version": "0.5.1", + "version": "0.5.2", "private": true, "scripts": { "dev": "vite dev", diff --git a/src/lib/components/lemmy/comment/CommentForm.svelte b/src/lib/components/lemmy/comment/CommentForm.svelte index 6162021f..6f60cf33 100644 --- a/src/lib/components/lemmy/comment/CommentForm.svelte +++ b/src/lib/components/lemmy/comment/CommentForm.svelte @@ -10,6 +10,7 @@ import { profile } from '$lib/auth.js' import { toast } from '$lib/components/ui/toasts/toasts.js' import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte' + import { placeholders } from '$lib/util.js' export let postId: number export let parentId: number | undefined = undefined @@ -68,7 +69,9 @@ {:else} diff --git a/src/lib/components/lemmy/post/PostForm.svelte b/src/lib/components/lemmy/post/PostForm.svelte index 7bdea11d..99765ff1 100644 --- a/src/lib/components/lemmy/post/PostForm.svelte +++ b/src/lib/components/lemmy/post/PostForm.svelte @@ -11,6 +11,7 @@ import { Check, Icon } from 'svelte-hero-icons' import { profile } from '$lib/auth.js' import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte' + import { placeholders } from '$lib/util.js' export let edit = false @@ -42,25 +43,6 @@ loading: false, } - const placeholders = [ - 'Is starting nuclear warfare illegal?', - 'A cool photo I took before the destruction of mankind!', - 'AITA for ending all contention and causing world peace?', - 'BREAKING NEWS: Police break into gun shop, find weapons', - 'How do I make sure my pet rock stays alive?', - 'My cat just invented a time machine, what do I do?', - 'Unpopular opinion: world peace and global happiness would be beneficial to humanity', - 'LPT: The smaller weights are easier to lift than the bigger weights in a gym', - 'javascript bad', - 'ELI5: What is 4 + 8?', - ] - - const placeholder = - placeholders[Math.floor(Math.random() * placeholders.length)] - - const placeholder2 = - placeholders[Math.floor(Math.random() * placeholders.length)] - let communities: Community[] = [] const dispatcher = createEventDispatcher<{ submit: PostView }>() @@ -96,6 +78,17 @@ return } if (!data.title || !$profile?.jwt) return + if (data.url && data.url != '') { + try { + new URL(data.url) + } catch (err) { + toast({ + content: 'Invalid URL', + type: 'warning', + }) + return + } + } data.loading = true @@ -193,17 +186,22 @@ /> {/if} - +
diff --git a/src/lib/components/markdown/MarkdownEditor.svelte b/src/lib/components/markdown/MarkdownEditor.svelte index 3aad36d8..817479eb 100644 --- a/src/lib/components/markdown/MarkdownEditor.svelte +++ b/src/lib/components/markdown/MarkdownEditor.svelte @@ -111,7 +111,9 @@ overflow-hidden" {:else}