Просмотр исходного кода

Merge pull request #7572 from weseek/feat/86710-119498-pdf-preview

feat: Be able to preview PDFs
Yuki Takei 3 лет назад
Родитель
Сommit
3e66b47698

+ 1 - 1
packages/app/src/components/ReactMarkdownComponents/Attachment.tsx

@@ -46,7 +46,7 @@ export const Attachment: React.FC<{
           </div>
           <div className='col-10'>
             <div>
-              <a className='' href={attachment.downloadPathProxied}>{attachment.originalName}</a>
+              <a target="_blank" rel="noopener noreferrer" href={attachment.filePathProxied}>{attachment.originalName}</a>
               <span className='ml-2'>
                 <a className="attachment-download" href={attachment.downloadPathProxied}>
                   <i className="icon-cloud-download" />

+ 0 - 17
packages/app/src/components/ReactMarkdownComponents/NextLink.tsx

@@ -22,10 +22,6 @@ const isExternalLink = (href: string, siteUrl: string | undefined): boolean => {
   }
 };
 
-const isAttached = (href: string): boolean => {
-  return href.startsWith('/attachment/');
-};
-
 type Props = Omit<LinkProps, 'href'> & {
   children: React.ReactNode,
   href?: string,
@@ -63,19 +59,6 @@ export const NextLink = (props: Props): JSX.Element => {
     );
   }
 
-  // when href is an attachment file
-  if (isAttached(href)) {
-    const dlhref = href.replace('/attachment/', '/download/');
-    return (
-      <span>
-        <a href={href} className={className} target="_blank" rel="noopener noreferrer" {...dataAttributes}>
-          {children}
-        </a>&nbsp;
-        <a href={dlhref} className="attachment-download"><i className='icon-cloud-download'></i></a>
-      </span>
-    );
-  }
-
   return (
     <Link {...rest} href={href} prefetch={false} legacyBehavior>
       <a href={href} className={className} {...dataAttributes}>{children}</a>