Parcourir la source

Revert "use value key for attachmentName"

This reverts commit 761c3b92c61dda9841e55c95eaaccf9f115d5022.
reiji-h il y a 1 an
Parent
commit
8af4a61df2
1 fichiers modifiés avec 12 ajouts et 1 suppressions
  1. 12 1
      apps/app/src/services/renderer/remark-plugins/attachment.ts

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