From: sunaurus Date: Sat, 1 Jul 2023 16:46:42 +0000 (+0300) Subject: Fix quotedText bugs in markdown editor X-Git-Url: http://these/git/%22https:/image.com/%7B%60%24%7BghostArchiveUrl%7D/static/%7BpictrsAvatarThumbnail%28community.icon%29%7D?a=commitdiff_plain;h=47cbe3e0022c5a13216ac7bcaf9dadddb2647e46;p=lemmy-ui.git Fix quotedText bugs in markdown editor --- diff --git a/src/shared/components/common/markdown-textarea.tsx b/src/shared/components/common/markdown-textarea.tsx index 5623ace..5912537 100644 --- a/src/shared/components/common/markdown-textarea.tsx +++ b/src/shared/components/common/markdown-textarea.tsx @@ -702,18 +702,20 @@ export class MarkdownTextArea extends Component< quoteInsert() { const textarea: any = document.getElementById(this.id); const selectedText = window.getSelection()?.toString(); - const { content } = this.state; + let { content } = this.state; if (selectedText) { const quotedText = selectedText .split("\n") .map(t => `> ${t}`) .join("\n") + "\n\n"; + if (!content) { - this.setState({ content: "" }); + content = ""; } else { - this.setState({ content: `${content}\n` }); + content = `${content}\n\n`; } + this.setState({ content: `${content}${quotedText}`, });