mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-12-28 22:01:27 +00:00
Merge pull request #1732 from sunaurus/undefined_quote
Fix markdown editor quote bugs
This commit is contained in:
commit
efccabe1ad
1 changed files with 5 additions and 3 deletions
|
@ -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}`,
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue