mirror of https://github.com/MaxLeiter/Drift
client: improve rendered post styling; length is 100% if uneditable
parent
5b71fc6b27
commit
844ccded3c
@ -1,15 +1,8 @@
|
|||||||
import { memo } from "react"
|
import { memo } from "react"
|
||||||
import ReactMarkdown from "react-markdown"
|
import ReactMarkdownPreview from "./react-markdown-preview"
|
||||||
import remarkGfm from "remark-gfm"
|
|
||||||
// @ts-ignore because of no types in remark-a11y-emoji
|
|
||||||
import a11yEmoji from '@fec/remark-a11y-emoji';
|
|
||||||
import styles from './preview.module.css'
|
|
||||||
|
|
||||||
const MarkdownPreview = ({ content, height }: { content?: string, height?: number | string }) => {
|
const MarkdownPreview = ({ content = '', height = 500 }: { content?: string, height?: number | string }) => {
|
||||||
{/* remarkGfm is github flavored markdown support, a11yEmoji wraps emojis in accessible spans for screen readers */ }
|
return (<ReactMarkdownPreview height={height} content={content} />)
|
||||||
return (<div style={{ height }}><ReactMarkdown className={styles.markdownPreview} remarkPlugins={[remarkGfm, a11yEmoji]} >
|
|
||||||
{content || ""}
|
|
||||||
</ReactMarkdown></div>)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default memo(MarkdownPreview)
|
export default memo(MarkdownPreview)
|
||||||
|
|||||||
@ -0,0 +1,19 @@
|
|||||||
|
import ReactMarkdown from "react-markdown"
|
||||||
|
import remarkGfm from "remark-gfm"
|
||||||
|
|
||||||
|
// @ts-ignore because of no types in remark-a11y-emoji
|
||||||
|
import a11yEmoji from '@fec/remark-a11y-emoji';
|
||||||
|
import styles from './preview.module.css'
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
content: string | undefined
|
||||||
|
height: number | string
|
||||||
|
}
|
||||||
|
|
||||||
|
const ReactMarkdownPreview = ({ content, height }: Props) => {
|
||||||
|
return (<div style={{ height }}><ReactMarkdown className={styles.markdownPreview} remarkPlugins={[remarkGfm, a11yEmoji]} >
|
||||||
|
{content || ""}
|
||||||
|
</ReactMarkdown></div>)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ReactMarkdownPreview
|
||||||
Loading…
Reference in New Issue