From 1ad36d2c1d28d9131245be20b48957fd47016a34 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Sun, 26 Mar 2023 22:10:08 -0400 Subject: [PATCH] fix: Fix undefined showing up in markdown (#970) --- .../components/common/markdown-textarea.tsx | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/shared/components/common/markdown-textarea.tsx b/src/shared/components/common/markdown-textarea.tsx index b2eabe2..001779e 100644 --- a/src/shared/components/common/markdown-textarea.tsx +++ b/src/shared/components/common/markdown-textarea.tsx @@ -416,18 +416,18 @@ export class MarkdownTextArea extends Component< handleInsertLink(i: MarkdownTextArea, event: any) { event.preventDefault(); - let textarea: any = document.getElementById(i.id); - let start: number = textarea.selectionStart; - let end: number = textarea.selectionEnd; + const textarea: any = document.getElementById(i.id); + const start: number = textarea.selectionStart; + const end: number = textarea.selectionEnd; - let content = i.state.content; + const content = i.state.content ?? ""; if (!i.state.content) { i.setState({ content: "" }); } if (start !== end) { - let selectedText = content?.substring(start, end); + const selectedText = content?.substring(start, end); i.setState({ content: `${content?.substring( 0, @@ -457,16 +457,16 @@ export class MarkdownTextArea extends Component< afterChars: string, emptyChars = "___" ) { - let content = this.state.content; + const content = this.state.content ?? ""; if (!this.state.content) { this.setState({ content: "" }); } - let textarea: any = document.getElementById(this.id); - let start: number = textarea.selectionStart; - let end: number = textarea.selectionEnd; + const textarea: any = document.getElementById(this.id); + const start: number = textarea.selectionStart; + const end: number = textarea.selectionEnd; if (start !== end) { - let selectedText = content?.substring(start, end); + const selectedText = content?.substring(start, end); this.setState({ content: `${content?.substring( 0, -- 2.44.1