fix: Fix undefined showing up in markdown (#970)

This commit is contained in:
SleeplessOne1917 2023-03-26 22:10:08 -04:00 committed by GitHub
parent 47daa9d143
commit 1ad36d2c1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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,