feat: Redesign the format bar / textarea into a single bordered area with divider
This commit is contained in:
parent
ebba5bdd80
commit
f9f4caf260
1 changed files with 115 additions and 91 deletions
|
@ -1,4 +1,5 @@
|
||||||
import autosize from "autosize";
|
import autosize from "autosize";
|
||||||
|
import classNames from "classnames";
|
||||||
import { NoOptionI18nKeys } from "i18next";
|
import { NoOptionI18nKeys } from "i18next";
|
||||||
import { Component, linkEvent } from "inferno";
|
import { Component, linkEvent } from "inferno";
|
||||||
import { Language } from "lemmy-js-client";
|
import { Language } from "lemmy-js-client";
|
||||||
|
@ -143,7 +144,19 @@ export class MarkdownTextArea extends Component<
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<div className="form-group row">
|
<div className="form-group row">
|
||||||
<div className="col-sm-12 d-flex flex-wrap">
|
<div className="col-12">
|
||||||
|
<div
|
||||||
|
className="rounded bg-white"
|
||||||
|
style={{
|
||||||
|
border: "1px solid var(--bs-border-color)",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="d-flex flex-wrap"
|
||||||
|
style={{
|
||||||
|
"border-bottom": "1px solid var(--bs-border-color)",
|
||||||
|
}}
|
||||||
|
>
|
||||||
{this.getFormatButton("bold", this.handleInsertBold)}
|
{this.getFormatButton("bold", this.handleInsertBold)}
|
||||||
{this.getFormatButton("italic", this.handleInsertItalic)}
|
{this.getFormatButton("italic", this.handleInsertItalic)}
|
||||||
{this.getFormatButton("link", this.handleInsertLink)}
|
{this.getFormatButton("link", this.handleInsertLink)}
|
||||||
|
@ -172,7 +185,9 @@ export class MarkdownTextArea extends Component<
|
||||||
name="file"
|
name="file"
|
||||||
className="d-none"
|
className="d-none"
|
||||||
multiple
|
multiple
|
||||||
disabled={!UserService.Instance.myUserInfo || this.isDisabled}
|
disabled={
|
||||||
|
!UserService.Instance.myUserInfo || this.isDisabled
|
||||||
|
}
|
||||||
onChange={linkEvent(this, this.handleImageUpload)}
|
onChange={linkEvent(this, this.handleImageUpload)}
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
|
@ -185,7 +200,10 @@ export class MarkdownTextArea extends Component<
|
||||||
{this.getFormatButton("list", this.handleInsertList)}
|
{this.getFormatButton("list", this.handleInsertList)}
|
||||||
{this.getFormatButton("code", this.handleInsertCode)}
|
{this.getFormatButton("code", this.handleInsertCode)}
|
||||||
{this.getFormatButton("subscript", this.handleInsertSubscript)}
|
{this.getFormatButton("subscript", this.handleInsertSubscript)}
|
||||||
{this.getFormatButton("superscript", this.handleInsertSuperscript)}
|
{this.getFormatButton(
|
||||||
|
"superscript",
|
||||||
|
this.handleInsertSuperscript
|
||||||
|
)}
|
||||||
{this.getFormatButton("spoiler", this.handleInsertSpoiler)}
|
{this.getFormatButton("spoiler", this.handleInsertSpoiler)}
|
||||||
<a
|
<a
|
||||||
href={markdownHelpUrl}
|
href={markdownHelpUrl}
|
||||||
|
@ -197,10 +215,12 @@ export class MarkdownTextArea extends Component<
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-sm-12 mt-2">
|
<div>
|
||||||
<textarea
|
<textarea
|
||||||
id={this.id}
|
id={this.id}
|
||||||
className={`form-control ${this.state.previewMode && "d-none"}`}
|
className={classNames("form-control border-0", {
|
||||||
|
"d-none": this.state.previewMode,
|
||||||
|
})}
|
||||||
value={this.state.content}
|
value={this.state.content}
|
||||||
onInput={linkEvent(this, this.handleContentChange)}
|
onInput={linkEvent(this, this.handleContentChange)}
|
||||||
onPaste={linkEvent(this, this.handleImageUploadPaste)}
|
onPaste={linkEvent(this, this.handleImageUploadPaste)}
|
||||||
|
@ -208,7 +228,9 @@ export class MarkdownTextArea extends Component<
|
||||||
required
|
required
|
||||||
disabled={this.isDisabled}
|
disabled={this.isDisabled}
|
||||||
rows={2}
|
rows={2}
|
||||||
maxLength={this.props.maxLength ?? markdownFieldCharacterLimit}
|
maxLength={
|
||||||
|
this.props.maxLength ?? markdownFieldCharacterLimit
|
||||||
|
}
|
||||||
placeholder={this.props.placeholder}
|
placeholder={this.props.placeholder}
|
||||||
/>
|
/>
|
||||||
{this.state.previewMode && this.state.content && (
|
{this.state.previewMode && this.state.content && (
|
||||||
|
@ -235,8 +257,10 @@ export class MarkdownTextArea extends Component<
|
||||||
<label className="sr-only" htmlFor={this.id}>
|
<label className="sr-only" htmlFor={this.id}>
|
||||||
{i18n.t("body")}
|
{i18n.t("body")}
|
||||||
</label>
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="col-sm-12 d-flex align-items-center flex-wrap mt-2">
|
<div className="col-12 d-flex align-items-center flex-wrap mt-2">
|
||||||
{this.props.showLanguage && (
|
{this.props.showLanguage && (
|
||||||
<LanguageSelect
|
<LanguageSelect
|
||||||
iconVersion
|
iconVersion
|
||||||
|
|
Loading…
Reference in a new issue