From 8fcde4bdd08280b2565a39bbb005bf49686c7295 Mon Sep 17 00:00:00 2001 From: Alec Armbruster <alectrocute@gmail.com> Date: Fri, 16 Jun 2023 19:14:35 -0400 Subject: [PATCH] more cleanup --- src/shared/components/common/html-tags.tsx | 1 + .../components/common/markdown-textarea.tsx | 98 ++++++++++--------- src/shared/components/common/moment-time.tsx | 6 +- 3 files changed, 54 insertions(+), 51 deletions(-) diff --git a/src/shared/components/common/html-tags.tsx b/src/shared/components/common/html-tags.tsx index 387cd04..f32b0fc 100644 --- a/src/shared/components/common/html-tags.tsx +++ b/src/shared/components/common/html-tags.tsx @@ -4,6 +4,7 @@ import { Helmet } from "inferno-helmet"; import { httpExternalPath } from "../../env"; import { i18n } from "../../i18next"; import { md } from "../../utils"; + interface HtmlTagsProps { title: string; path: string; diff --git a/src/shared/components/common/markdown-textarea.tsx b/src/shared/components/common/markdown-textarea.tsx index 36f6283..55e7361 100644 --- a/src/shared/components/common/markdown-textarea.tsx +++ b/src/shared/components/common/markdown-textarea.tsx @@ -184,53 +184,6 @@ export class MarkdownTextArea extends Component< </div> <div className="row"> <div className="col-sm-12 d-flex flex-wrap"> - {this.props.buttonTitle && ( - <button - type="submit" - className="btn btn-sm btn-secondary mr-2" - disabled={this.isDisabled} - > - {this.state.loading ? ( - <Spinner /> - ) : ( - <span>{this.props.buttonTitle}</span> - )} - </button> - )} - {this.props.replyType && ( - <button - type="button" - className="btn btn-sm btn-secondary mr-2" - onClick={linkEvent(this, this.handleReplyCancel)} - > - {i18n.t("cancel")} - </button> - )} - {this.state.content && ( - <button - className={`btn btn-sm btn-secondary mr-2 ${ - this.state.previewMode && "active" - }`} - onClick={linkEvent(this, this.handlePreviewToggle)} - > - {this.state.previewMode ? i18n.t("edit") : i18n.t("preview")} - </button> - )} - {/* A flex expander */} - <div className="flex-grow-1"></div> - - {this.props.showLanguage && ( - <LanguageSelect - iconVersion - allLanguages={this.props.allLanguages} - selectedLanguageIds={ - languageId ? Array.of(languageId) : undefined - } - siteLanguages={this.props.siteLanguages} - onChange={this.handleLanguageChange} - disabled={this.isDisabled} - /> - )} {this.getFormatButton("bold", this.handleInsertBold)} {this.getFormatButton("italic", this.handleInsertItalic)} {this.getFormatButton("link", this.handleInsertLink)} @@ -283,6 +236,57 @@ export class MarkdownTextArea extends Component< <Icon icon="help-circle" classes="icon-inline" /> </a> </div> + + <div className="col-sm-12 d-flex align-items-center flex-wrap"> + {this.props.showLanguage && ( + <LanguageSelect + iconVersion + allLanguages={this.props.allLanguages} + selectedLanguageIds={ + languageId ? Array.of(languageId) : undefined + } + siteLanguages={this.props.siteLanguages} + onChange={this.handleLanguageChange} + disabled={this.isDisabled} + /> + )} + + {/* A flex expander */} + <div className="flex-grow-1"></div> + + {this.props.buttonTitle && ( + <button + type="submit" + className="btn btn-sm btn-secondary mr-2" + disabled={this.isDisabled} + > + {this.state.loading ? ( + <Spinner /> + ) : ( + <span>{this.props.buttonTitle}</span> + )} + </button> + )} + {this.props.replyType && ( + <button + type="button" + className="btn btn-sm btn-secondary mr-2" + onClick={linkEvent(this, this.handleReplyCancel)} + > + {i18n.t("cancel")} + </button> + )} + {this.state.content && ( + <button + className={`btn btn-sm btn-secondary mr-2 ${ + this.state.previewMode && "active" + }`} + onClick={linkEvent(this, this.handlePreviewToggle)} + > + {this.state.previewMode ? i18n.t("edit") : i18n.t("preview")} + </button> + )} + </div> </div> </form> ); diff --git a/src/shared/components/common/moment-time.tsx b/src/shared/components/common/moment-time.tsx index 10714f5..30c1682 100644 --- a/src/shared/components/common/moment-time.tsx +++ b/src/shared/components/common/moment-time.tsx @@ -1,7 +1,7 @@ import { Component } from "inferno"; import moment from "moment"; import { i18n } from "../../i18next"; -import { capitalizeFirstLetter, getLanguages } from "../../utils"; +import { capitalizeFirstLetter } from "../../utils"; import { Icon } from "./icon"; interface MomentTimeProps { @@ -15,9 +15,7 @@ export class MomentTime extends Component<MomentTimeProps, any> { constructor(props: any, context: any) { super(props, context); - const lang = getLanguages(); - - moment.locale(lang); + moment.locale([...i18n.languages]); } createdAndModifiedTimes() { -- 2.44.1