diff --git a/client/ui/chat/ChatFragment.tsx b/client/ui/chat/ChatFragment.tsx index 0ab20df..4ee3fec 100644 --- a/client/ui/chat/ChatFragment.tsx +++ b/client/ui/chat/ChatFragment.tsx @@ -33,10 +33,17 @@ const markedInstance = new marked.Marked({ return `${text}` }, image({ text, href }) { - if (/uploaded_files\/[A-Za-z0-9]+$/.test(href)) - return `` + const type = /^(Video|File)=.*/.exec(text)?.[1] || 'Image' + + if (/uploaded_files\/[A-Za-z0-9]+$/.test(href)) { + return ({ + Image: ``, + Video: ``, + File: ``, + })?.[type] || `` + } return `` - } + }, } }) @@ -178,6 +185,8 @@ export default function ChatFragment({ target, showReturnButton, onReturnButtonC cachedFileNamesCount.current[name] = 1 if (type.startsWith('image/')) insertText(`![圖片](${name})`) + else if (type.startsWith('video/')) + insertText(`![Video=${name}](${name})`) else insertText(`![File=${name}](${name})`) }