Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import React, { FC } from 'react' import styled from 'styled-components' import { CommonProps } from 'client/types/component' const PageCommentBody = styled.div<Props>` padding: 8px 0; word-wrap: break-word; ` type Props = CommonProps & { comment: string } const CommentBody: FC<Props> = props => { const { comment, ...others } = props return ( <PageCommentBody {...others}> {comment.split(/(\r\n|\r|\n)/g).map((line, i) => ( <React.Fragment key={i}>{/(\r\n|\r|\n)/.test(line) ? <br /> : line}</React.Fragment> ))} </PageCommentBody> ) } export default CommentBody |