mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-28 13:22:39 +03:00
Added whitespace and newline support
This commit is contained in:
parent
81db05a3ac
commit
3522ee6ee1
@ -4,6 +4,8 @@ import {formatRelativeTime} from '../utils/helpers';
|
||||
function Comment(props) {
|
||||
const comment = props.comment;
|
||||
|
||||
const html = {__html: comment.html};
|
||||
|
||||
return (
|
||||
<div className="flex mb-4">
|
||||
<div className="mr-4">
|
||||
@ -18,7 +20,7 @@ function Comment(props) {
|
||||
</div>
|
||||
</div>
|
||||
<div className="mb-4 font-sans leading-normal dark:text-neutral-300">
|
||||
<p>{comment.html}</p>
|
||||
<p dangerouslySetInnerHTML={html} className="whitespace-pre-wrap"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -14,6 +14,13 @@ class Form extends React.Component {
|
||||
this.handleChange = this.handleChange.bind(this);
|
||||
}
|
||||
|
||||
getHTML() {
|
||||
const text = this.state.message;
|
||||
|
||||
// Convert newlines to <br> for now (until we add a real editor)
|
||||
return text.replace('\n', '<br>');
|
||||
}
|
||||
|
||||
async submitForm(event) {
|
||||
event.preventDefault();
|
||||
const message = this.state.message;
|
||||
@ -28,7 +35,7 @@ class Form extends React.Component {
|
||||
await this.context.onAction('addComment', {
|
||||
post_id: this.context.postId,
|
||||
status: 'published',
|
||||
html: message
|
||||
html: this.getHTML()
|
||||
});
|
||||
|
||||
// Clear message on success
|
||||
|
Loading…
Reference in New Issue
Block a user