don't show ClaimLinks in file description

This commit is contained in:
Sean Yesmunt 2020-10-22 14:16:42 -04:00
parent ad88d8993d
commit 6659ef50ff
3 changed files with 20 additions and 7 deletions

View file

@ -24,7 +24,7 @@ type SimpleLinkProps = {
type MarkdownProps = {
strip?: boolean,
content: ?string,
promptLinks?: boolean,
simpleLinks?: boolean,
noDataStore?: boolean,
className?: string,
parentCommentId?: string,
@ -78,7 +78,7 @@ schema.attributes.a.push('embed');
const REPLACE_REGEX = /(<iframe\s+src=["'])(.*?(?=))(["']\s*><\/iframe>)/g;
const MarkdownPreview = (props: MarkdownProps) => {
const { content, strip, promptLinks, noDataStore, className, parentCommentId, isMarkdownPost } = props;
const { content, strip, simpleLinks, noDataStore, className, parentCommentId, isMarkdownPost } = props;
const strippedContent = content
? content.replace(REPLACE_REGEX, (iframeHtml, y, iframeSrc) => {
// Let the browser try to create an iframe to see if the markup is valid
@ -109,7 +109,7 @@ const MarkdownPreview = (props: MarkdownProps) => {
{...linkProps}
parentCommentId={parentCommentId}
isMarkdownPost={isMarkdownPost}
promptLinks={promptLinks}
simpleLinks={simpleLinks}
/>
),
// Workaraund of remarkOptions.Fragment

View file

@ -47,7 +47,7 @@ function FileDescription(props: Props) {
'media__info-text--fade': hasOverflow && !expanded,
})}
>
<MarkdownPreview className="markdown-preview--description" content={description} />
<MarkdownPreview className="markdown-preview--description" content={description} simpleLinks />
<ClaimTags uri={uri} type="large" />
</div>
{hasCalculatedOverflow && hasOverflow && (

View file

@ -15,10 +15,20 @@ type Props = {
openModal: (id: string, { uri: string }) => void,
parentCommentId?: string,
isMarkdownPost?: boolean,
simpleLinks?: boolean,
};
function MarkdownLink(props: Props) {
const { children, href, title, embed = false, openModal, parentCommentId, isMarkdownPost } = props;
const {
children,
href,
title,
embed = false,
openModal,
parentCommentId,
isMarkdownPost,
simpleLinks = false,
} = props;
const decodedUri = decodeURI(href);
if (!href) {
return children || null;
@ -33,7 +43,7 @@ function MarkdownLink(props: Props) {
// Return plain text if no valid url
// Return external link if protocol is http or https
// Return local link if protocol is lbry uri
if (protocol && protocol[0] === 'lbry:' && isURIValid(decodedUri)) {
if (!simpleLinks && protocol && protocol[0] === 'lbry:' && isURIValid(decodedUri)) {
const linkUrlObject = new URL(decodedUri);
const linkDomain = linkUrlObject.host;
const isKnownAppDomainLink = KNOWN_APP_DOMAINS.includes(linkDomain);
@ -59,7 +69,10 @@ function MarkdownLink(props: Props) {
{children}
</ClaimLink>
);
} else if (protocol && (protocol[0] === 'http:' || protocol[0] === 'https:' || protocol[0] === 'mailto:')) {
} else if (
simpleLinks ||
(protocol && (protocol[0] === 'http:' || protocol[0] === 'https:' || protocol[0] === 'mailto:'))
) {
element = (
<Button
button="link"