From be60dae9f8d8355580fe065ef8aadd3f6fdcf3cd Mon Sep 17 00:00:00 2001 From: Camel Coder <69110542+camel-cdr@users.noreply.github.com> Date: Wed, 14 Jun 2023 12:00:13 +0000 Subject: [PATCH 1/5] Horizontally scrollable code blocks, instead of wrapping. This disables word wrapping for code generated from markdown, and instead enables a horizontal scroll bar. --- src/assets/css/main.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/assets/css/main.css b/src/assets/css/main.css index 1c45341d..3ff70e47 100644 --- a/src/assets/css/main.css +++ b/src/assets/css/main.css @@ -75,6 +75,11 @@ font-size: 1.2rem; } +.md-div pre { + white-space: pre; + overflow-x: auto; +} + .md-div table { border-collapse: collapse; width: 100%; From 520efdcadaab0eff3c50f78d1bbc9412c072d4fe Mon Sep 17 00:00:00 2001 From: Alec Armbruster Date: Wed, 14 Jun 2023 09:47:33 -0400 Subject: [PATCH 2/5] trim all username state input --- src/shared/components/home/login.tsx | 2 +- src/shared/components/home/setup.tsx | 2 +- src/shared/components/home/signup.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/shared/components/home/login.tsx b/src/shared/components/home/login.tsx index 87ef234e..94915542 100644 --- a/src/shared/components/home/login.tsx +++ b/src/shared/components/home/login.tsx @@ -195,7 +195,7 @@ export class Login extends Component { } handleLoginUsernameChange(i: Login, event: any) { - i.state.form.username_or_email = event.target.value; + i.state.form.username_or_email = event.target.value.trim(); i.setState(i.state); } diff --git a/src/shared/components/home/setup.tsx b/src/shared/components/home/setup.tsx index 581c1c56..14350a58 100644 --- a/src/shared/components/home/setup.tsx +++ b/src/shared/components/home/setup.tsx @@ -221,7 +221,7 @@ export class Setup extends Component { } handleRegisterUsernameChange(i: Setup, event: any) { - i.state.form.username = event.target.value; + i.state.form.username = event.target.value.trim(); i.setState(i.state); } diff --git a/src/shared/components/home/signup.tsx b/src/shared/components/home/signup.tsx index 3efeac62..16a3cc6d 100644 --- a/src/shared/components/home/signup.tsx +++ b/src/shared/components/home/signup.tsx @@ -496,7 +496,7 @@ export class Signup extends Component { } handleRegisterUsernameChange(i: Signup, event: any) { - i.state.form.username = event.target.value; + i.state.form.username = event.target.value.trim(); i.setState(i.state); } From 99f81f8d638d2976178ba71c66fa3ba069912b96 Mon Sep 17 00:00:00 2001 From: Alec Armbruster Date: Wed, 14 Jun 2023 10:03:00 -0400 Subject: [PATCH 3/5] adds missing tooltip --- src/shared/components/post/post-listing.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/shared/components/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx index f1f06c58..d5fc785c 100644 --- a/src/shared/components/post/post-listing.tsx +++ b/src/shared/components/post/post-listing.tsx @@ -835,6 +835,8 @@ export class PostListing extends Component { search: "", }} title={i18n.t("cross_post")} + data-tippy-content={i18n.t("cross_post")} + aria-label={i18n.t("cross_post")} > From d75e4365c4ff79568d2c4b38f208e6b2b5a549d5 Mon Sep 17 00:00:00 2001 From: Alec Armbruster Date: Wed, 14 Jun 2023 16:29:04 -0400 Subject: [PATCH 4/5] remove pictrsDeleteToast usage from PostForm, add delete image button, fix infinite loading bug if upload error occured --- src/shared/components/post/post-form.tsx | 45 +++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/src/shared/components/post/post-form.tsx b/src/shared/components/post/post-form.tsx index 3ce96bb0..cef8e294 100644 --- a/src/shared/components/post/post-form.tsx +++ b/src/shared/components/post/post-form.tsx @@ -25,7 +25,6 @@ import { isImage, myAuth, myAuthRequired, - pictrsDeleteToast, relTags, setupTippy, toast, @@ -73,6 +72,7 @@ interface PostFormState { suggestedPostsRes: RequestState; metadataRes: RequestState; imageLoading: boolean; + imageDeleteUrl: string; communitySearchLoading: boolean; communitySearchOptions: Choice[]; previewMode: boolean; @@ -86,6 +86,7 @@ export class PostForm extends Component { form: {}, loading: false, imageLoading: false, + imageDeleteUrl: "", communitySearchLoading: false, previewMode: false, communitySearchOptions: [], @@ -269,6 +270,17 @@ export class PostForm extends Component { {url && isImage(url) && ( )} + {this.state.imageDeleteUrl && ( + + )} {this.props.crossPosts && this.props.crossPosts.length > 0 && ( <>
@@ -553,7 +565,15 @@ export class PostForm extends Component { } handlePostUrlChange(i: PostForm, event: any) { - i.setState(s => ((s.form.url = event.target.value), s)); + const url = event.target.value; + + i.setState({ + form: { + url, + }, + imageDeleteUrl: "", + }); + i.fetchPageTitle(); } @@ -644,18 +664,35 @@ export class PostForm extends Component { if (res.state === "success") { if (res.data.msg === "ok") { i.state.form.url = res.data.url; - pictrsDeleteToast(file.name, res.data.delete_url as string); - i.setState({ imageLoading: false }); + i.setState({ + imageLoading: false, + imageDeleteUrl: res.data.delete_url as string, + }); } else { toast(JSON.stringify(res), "danger"); } } else if (res.state === "failed") { console.error(res.msg); toast(res.msg, "danger"); + i.setState({ imageLoading: false }); } }); } + handleImageDelete(i: PostForm) { + const { imageDeleteUrl } = i.state; + + fetch(imageDeleteUrl); + + i.setState({ + imageDeleteUrl: "", + imageLoading: false, + form: { + url: "", + }, + }); + } + handleCommunitySearch = debounce(async (text: string) => { const { selectedCommunityChoice } = this.props; this.setState({ communitySearchLoading: true }); From 44e45bb84da4651f1a775d909503d9e8f8b9627f Mon Sep 17 00:00:00 2001 From: Alec Armbruster Date: Wed, 14 Jun 2023 16:45:56 -0400 Subject: [PATCH 5/5] make button a tad smaller --- src/shared/components/post/post-form.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/components/post/post-form.tsx b/src/shared/components/post/post-form.tsx index cef8e294..4640922d 100644 --- a/src/shared/components/post/post-form.tsx +++ b/src/shared/components/post/post-form.tsx @@ -272,7 +272,7 @@ export class PostForm extends Component { )} {this.state.imageDeleteUrl && (