diff --git a/src/renderer/component/common/markdown-preview.jsx b/src/renderer/component/common/markdown-preview.jsx new file mode 100644 index 000000000..b00ae7025 --- /dev/null +++ b/src/renderer/component/common/markdown-preview.jsx @@ -0,0 +1,46 @@ +// @flow +import * as React from 'react'; +import remark from 'remark'; +import reactRenderer from 'remark-react'; +import remarkEmoji from 'remark-emoji'; +import ExternalLink from 'component/externalLink'; +import defaultSchema from 'hast-util-sanitize/lib/github.json'; + +// Use github sanitation schema +const schema = { ...defaultSchema }; + +// Extend sanitation schema to support lbry protocol +schema.protocols.href[3] = 'lbry'; + +type MarkdownProps = { + content: string, + promptLinks?: boolean, +}; + +const SimpleLink = ({ href, title, children }) => ( + + {children} + +); + +const MarkdownPreview = (props: MarkdownProps) => { + const { content, externalLinks, promptLinks } = props; + const remarkOptions = { + sanitize: schema, + remarkReactComponents: { + a: promptLinks ? ExternalLink : SimpleLink, + }, + }; + return ( +