Przeglądaj źródła

use value key for attachmentName

reiji-h 1 rok temu
rodzic
commit
1e55f4cf11

+ 1 - 12
apps/app/src/services/renderer/remark-plugins/attachment.ts

@@ -5,17 +5,6 @@ import type { Link } from 'mdast';
 import type { Plugin } from 'unified';
 import type { Plugin } from 'unified';
 import { visit } from 'unist-util-visit';
 import { visit } from 'unist-util-visit';
 
 
-declare module 'mdast' {
-  interface LinkData {
-    hName?: string,
-    hProperties?: {
-      attachmentId?: string,
-      url?: string,
-      attachmentName?: PhrasingContent,
-    }
-  }
-}
-
 const SUPPORTED_ATTRIBUTES = ['attachmentId', 'url', 'attachmentName'];
 const SUPPORTED_ATTRIBUTES = ['attachmentId', 'url', 'attachmentName'];
 
 
 const isAttachmentLink = (url: string): boolean => {
 const isAttachmentLink = (url: string): boolean => {
@@ -32,7 +21,7 @@ const rewriteNode = (node: Link) => {
   data.hProperties = {
   data.hProperties = {
     attachmentId,
     attachmentId,
     url: node.url,
     url: node.url,
-    attachmentName: node.children[0] ?? '',
+    attachmentName: 'value' in node.children[0] ? node.children[0].value : '',
   };
   };
 };
 };