Add markdown preview to support request composer

Summary:
Adds a side-by-side markdown preview to the support form.
No time spent on UI because it makes sense to do it all together.

There also seems to be a problem with state updates not propagating when values are changed, so currently it never gets updated.

Reviewed By: passy

Differential Revision: D18638025

fbshipit-source-id: c4a49286434c7e2e85d532aef3a36924e02a4467
This commit is contained in:
John Knox
2019-11-22 06:22:31 -08:00
committed by Facebook Github Bot
parent 33a63c9c5b
commit d7cfefb2bd

View File

@@ -69,33 +69,22 @@ class LinkReference extends PureComponent<{href: string}> {
} }
} }
export class Markdown extends PureComponent<{ export function Markdown(props: {source: string}) {
source: string; return (
}> { <ReactMarkdown
containerRef: RefObject<HTMLDivElement> = React.createRef(); source={props.source}
renderers={{
componentDidMount() { heading: Heading,
ReactDOM.render( listItem: ListItem,
<ReactMarkdown paragraph: Row,
source={this.props.source} strong: Strong,
renderers={{ emphasis: Emphasis,
heading: Heading, inlineCode: Code,
listItem: ListItem, code: CodeBlock,
paragraph: Row, blockquote: Quote,
strong: Strong, link: LinkReference,
emphasis: Emphasis, linkReference: LinkReference,
inlineCode: Code, }}
code: CodeBlock, />
blockquote: Quote, );
link: LinkReference,
linkReference: LinkReference,
}}
/>,
this.containerRef.current,
);
}
render() {
return <div ref={this.containerRef}></div>;
}
} }