Sfoglia il codice sorgente

Revert "use value key for attachmentName"

This reverts commit 761c3b92c61dda9841e55c95eaaccf9f115d5022.
reiji-h 1 anno fa
parent
commit
8af4a61df2

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

@@ -5,6 +5,17 @@ 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 => {
@@ -21,7 +32,7 @@ const rewriteNode = (node: Link) => {
   data.hProperties = {
   data.hProperties = {
     attachmentId,
     attachmentId,
     url: node.url,
     url: node.url,
-    attachmentName: 'value' in node.children[0] ? node.children[0].value : '',
+    attachmentName: node.children[0] ?? '',
   };
   };
 };
 };