mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-25 22:01:13 +00:00
Merge pull request #193 from LemmyNet/markup_bug
Fixing markup not throwing onContentChange. Fixes #182
This commit is contained in:
commit
19e5e6b5c9
1 changed files with 12 additions and 3 deletions
|
@ -343,6 +343,7 @@ export class MarkdownTextArea extends Component<
|
|||
content = content ? `${content}\n${imageMarkdown}` : imageMarkdown;
|
||||
i.state.content = content;
|
||||
i.state.imageLoading = false;
|
||||
i.contentChange();
|
||||
i.setState(i.state);
|
||||
let textarea: any = document.getElementById(i.id);
|
||||
autosize.update(textarea);
|
||||
|
@ -364,12 +365,16 @@ export class MarkdownTextArea extends Component<
|
|||
});
|
||||
}
|
||||
|
||||
contentChange() {
|
||||
if (this.props.onContentChange) {
|
||||
this.props.onContentChange(this.state.content);
|
||||
}
|
||||
}
|
||||
|
||||
handleContentChange(i: MarkdownTextArea, event: any) {
|
||||
i.state.content = event.target.value;
|
||||
i.contentChange();
|
||||
i.setState(i.state);
|
||||
if (i.props.onContentChange) {
|
||||
i.props.onContentChange(i.state.content);
|
||||
}
|
||||
}
|
||||
|
||||
handlePreviewToggle(i: MarkdownTextArea, event: any) {
|
||||
|
@ -412,6 +417,7 @@ export class MarkdownTextArea extends Component<
|
|||
textarea.focus();
|
||||
setTimeout(() => (textarea.selectionEnd -= 1), 10);
|
||||
}
|
||||
i.contentChange();
|
||||
i.setState(i.state);
|
||||
}
|
||||
|
||||
|
@ -446,6 +452,7 @@ export class MarkdownTextArea extends Component<
|
|||
} else {
|
||||
this.state.content += `${beforeChars}${emptyChars}${afterChars}`;
|
||||
}
|
||||
this.contentChange();
|
||||
this.setState(this.state);
|
||||
setTimeout(() => {
|
||||
autosize.update(textarea);
|
||||
|
@ -509,6 +516,7 @@ export class MarkdownTextArea extends Component<
|
|||
setTimeout(() => {
|
||||
autosize.update(textarea);
|
||||
}, 10);
|
||||
this.contentChange();
|
||||
this.setState(this.state);
|
||||
}
|
||||
|
||||
|
@ -534,6 +542,7 @@ export class MarkdownTextArea extends Component<
|
|||
this.state.content += "\n";
|
||||
}
|
||||
this.state.content += quotedText;
|
||||
this.contentChange();
|
||||
this.setState(this.state);
|
||||
// Not sure why this needs a delay
|
||||
setTimeout(() => autosize.update(textarea), 10);
|
||||
|
|
Loading…
Reference in a new issue