// @flow import { CHANNEL_STAKED_LEVEL_VIDEO_COMMENTS, MISSING_THUMB_DEFAULT } from 'config'; import { platform } from 'util/platform'; import { formattedEmote, inlineEmote } from 'util/remark-emote'; import { formattedLinks, inlineLinks } from 'util/remark-lbry'; import { formattedTimestamp, inlineTimestamp } from 'util/remark-timestamp'; import { getThumbnailCdnUrl, getImageProxyUrl } from 'util/thumbnail'; import * as ICONS from 'constants/icons'; import * as React from 'react'; import Button from 'component/button'; import classnames from 'classnames'; import defaultSchema from 'hast-util-sanitize/lib/github.json'; import MarkdownLink from 'component/markdownLink'; import OptimizedImage from 'component/optimizedImage'; import reactRenderer from 'remark-react'; import remark from 'remark'; import remarkAttr from 'remark-attr'; import remarkBreaks from 'remark-breaks'; import remarkEmoji from 'remark-emoji'; import remarkFrontMatter from 'remark-frontmatter'; import remarkStrip from 'strip-markdown'; import ZoomableImage from 'component/zoomableImage'; const RE_EMOTE = /:\+1:|:-1:|:[\w-]+:/; function isEmote(title, src) { return title && RE_EMOTE.test(title) && src.includes('static.odycdn.com/emoticons'); } function isStakeEnoughForPreview(stakedLevel) { return !stakedLevel || stakedLevel >= CHANNEL_STAKED_LEVEL_VIDEO_COMMENTS; } type SimpleTextProps = { children?: React.Node, }; type SimpleLinkProps = { href?: string, title?: string, embed?: boolean, children?: React.Node, }; type ImageLinkProps = { src: string, title?: string, alt?: string, helpText?: string, }; type MarkdownProps = { strip?: boolean, content: ?string, simpleLinks?: boolean, noDataStore?: boolean, className?: string, parentCommentId?: string, isMarkdownPost?: boolean, disableTimestamps?: boolean, stakedLevel?: number, setUserMention?: (boolean) => void, hasMembership?: boolean, }; // **************************************************************************** // **************************************************************************** const SimpleText = (props: SimpleTextProps) => { return {props.children}; }; // **************************************************************************** // **************************************************************************** const SimpleLink = (props: SimpleLinkProps) => { const { title, children, href, embed } = props; if (!href) { return children || null; } if (!href.startsWith('lbry:/')) { return ( {children} ); } const [uri, search] = href.split('?'); const urlParams = new URLSearchParams(search); const embedParam = urlParams.get('embed'); if (embed || embedParam) { // Decode this since users might just copy it from the url bar const decodedUri = decodeURI(uri); return (
{decodedUri}