Yuki Takei 2 лет назад
Родитель
Сommit
0c06fdd013

+ 3 - 3
apps/app/src/client/services/renderer/renderer.tsx

@@ -65,7 +65,7 @@ export const generateViewOptions = (
     drawio.remarkPlugin,
     mermaid.remarkPlugin,
     xsvToTable.remarkPlugin,
-    [attachment.remarkPlugin, { isSharedPage: config.isSharedPage }],
+    attachment.remarkPlugin,
     lsxGrowiDirective.remarkPlugin,
     refsGrowiDirective.remarkPlugin,
     [slides.remarkPlugin, { isEnabledMarp: config.isEnabledMarp }],
@@ -178,7 +178,7 @@ export const generateSimpleViewOptions = (
     drawio.remarkPlugin,
     mermaid.remarkPlugin,
     xsvToTable.remarkPlugin,
-    [attachment.remarkPlugin, { isSharedPage: config.isSharedPage }],
+    attachment.remarkPlugin,
     lsxGrowiDirective.remarkPlugin,
     refsGrowiDirective.remarkPlugin,
   );
@@ -259,7 +259,7 @@ export const generatePreviewOptions = (config: RendererConfig, pagePath: string)
     drawio.remarkPlugin,
     mermaid.remarkPlugin,
     xsvToTable.remarkPlugin,
-    [attachment.remarkPlugin, { isSharedPage: config.isSharedPage }],
+    attachment.remarkPlugin,
     lsxGrowiDirective.remarkPlugin,
     refsGrowiDirective.remarkPlugin,
     [slides.remarkPlugin, { isEnabledMarp: config.isEnabledMarp }],

+ 4 - 7
apps/app/src/components/ReactMarkdownComponents/RichAttachment.tsx

@@ -13,11 +13,10 @@ type RichAttachmentProps = {
   attachmentId: string,
   url: string,
   attachmentName: string,
-  isSharedPage: 'true' | 'false',
 }
 
 export const RichAttachment = React.memo((props: RichAttachmentProps) => {
-  const { attachmentId, attachmentName, isSharedPage } = props;
+  const { attachmentId, attachmentName } = props;
   const { t } = useTranslation();
   const { data: attachment, remove } = useSWRxAttachment(attachmentId);
   const { open: openDeleteAttachmentModal } = useDeleteAttachmentModal();
@@ -70,11 +69,9 @@ export const RichAttachment = React.memo((props: RichAttachmentProps) => {
               <a className="ml-2 attachment-download" href={downloadPathProxied}>
                 <i className="icon-cloud-download" />
               </a>
-              {isSharedPage === 'false' && (
-                <a className="ml-2 text-danger attachment-delete" onClick={onClickTrashButtonHandler}>
-                  <i className="icon-trash" />
-                </a>
-              )}
+              <a className="ml-2 text-danger attachment-delete" onClick={onClickTrashButtonHandler}>
+                <i className="icon-trash" />
+              </a>
             </div>
             <div className="d-flex align-items-center">
               <UserPicture user={creator} size="sm" />

+ 4 - 8
apps/app/src/services/renderer/remark-plugins/attachment.ts

@@ -5,7 +5,7 @@ import { Plugin } from 'unified';
 import { Node } from 'unist';
 import { visit } from 'unist-util-visit';
 
-const SUPPORTED_ATTRIBUTES = ['attachmentId', 'url', 'attachmentName', 'isSharedPage'];
+const SUPPORTED_ATTRIBUTES = ['attachmentId', 'url', 'attachmentName'];
 
 const isAttachmentLink = (url: string): boolean => {
   // https://regex101.com/r/9qZhiK/1
@@ -13,7 +13,7 @@ const isAttachmentLink = (url: string): boolean => {
   return attachmentUrlFormat.test(url);
 };
 
-const rewriteNode = (node: Node, isSharedPage?: boolean) => {
+const rewriteNode = (node: Node) => {
   const attachmentId = path.basename(node.url as string);
   const data = node.data ?? (node.data = {});
   data.hName = 'attachment';
@@ -21,20 +21,16 @@ const rewriteNode = (node: Node, isSharedPage?: boolean) => {
     attachmentId,
     url: node.url,
     attachmentName: (node.children as any)[0]?.value,
-    isSharedPage: isSharedPage ? 'true' : 'false',
   };
 };
 
-type AttachmentPluginParams = {
-  isSharedPage?: boolean,
-}
 
-export const remarkPlugin: Plugin<[AttachmentPluginParams]> = (options) => {
+export const remarkPlugin: Plugin = () => {
   return (tree) => {
     visit(tree, (node) => {
       if (node.type === 'link') {
         if (isAttachmentLink(node.url as string)) {
-          rewriteNode(node, options.isSharedPage);
+          rewriteNode(node);
         }
       }
     });