mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-26 07:52:19 +00:00
fix: Fix undefined showing up in markdown (#970)
This commit is contained in:
parent
47daa9d143
commit
1ad36d2c1d
|
@ -416,18 +416,18 @@ export class MarkdownTextArea extends Component<
|
||||||
handleInsertLink(i: MarkdownTextArea, event: any) {
|
handleInsertLink(i: MarkdownTextArea, event: any) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
let textarea: any = document.getElementById(i.id);
|
const textarea: any = document.getElementById(i.id);
|
||||||
let start: number = textarea.selectionStart;
|
const start: number = textarea.selectionStart;
|
||||||
let end: number = textarea.selectionEnd;
|
const end: number = textarea.selectionEnd;
|
||||||
|
|
||||||
let content = i.state.content;
|
const content = i.state.content ?? "";
|
||||||
|
|
||||||
if (!i.state.content) {
|
if (!i.state.content) {
|
||||||
i.setState({ content: "" });
|
i.setState({ content: "" });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start !== end) {
|
if (start !== end) {
|
||||||
let selectedText = content?.substring(start, end);
|
const selectedText = content?.substring(start, end);
|
||||||
i.setState({
|
i.setState({
|
||||||
content: `${content?.substring(
|
content: `${content?.substring(
|
||||||
0,
|
0,
|
||||||
|
@ -457,16 +457,16 @@ export class MarkdownTextArea extends Component<
|
||||||
afterChars: string,
|
afterChars: string,
|
||||||
emptyChars = "___"
|
emptyChars = "___"
|
||||||
) {
|
) {
|
||||||
let content = this.state.content;
|
const content = this.state.content ?? "";
|
||||||
if (!this.state.content) {
|
if (!this.state.content) {
|
||||||
this.setState({ content: "" });
|
this.setState({ content: "" });
|
||||||
}
|
}
|
||||||
let textarea: any = document.getElementById(this.id);
|
const textarea: any = document.getElementById(this.id);
|
||||||
let start: number = textarea.selectionStart;
|
const start: number = textarea.selectionStart;
|
||||||
let end: number = textarea.selectionEnd;
|
const end: number = textarea.selectionEnd;
|
||||||
|
|
||||||
if (start !== end) {
|
if (start !== end) {
|
||||||
let selectedText = content?.substring(start, end);
|
const selectedText = content?.substring(start, end);
|
||||||
this.setState({
|
this.setState({
|
||||||
content: `${content?.substring(
|
content: `${content?.substring(
|
||||||
0,
|
0,
|
||||||
|
|
Loading…
Reference in a new issue