From ce795a2a7d200faa40c2d4f2ebf0d0c69e1f6e63 Mon Sep 17 00:00:00 2001 From: boojack Date: Sun, 27 Nov 2022 09:01:19 +0800 Subject: [PATCH] chore: show content image (#602) --- web/src/components/Memo.tsx | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/web/src/components/Memo.tsx b/web/src/components/Memo.tsx index a604d1e3..e24ec9fd 100644 --- a/web/src/components/Memo.tsx +++ b/web/src/components/Memo.tsx @@ -139,24 +139,9 @@ const Memo: React.FC = (props: Props) => { } } } else if (targetEl.tagName === "IMG") { - const currImgUrl = targetEl.getAttribute("src"); - - if (currImgUrl) { - // use regex to get all image urls from memo content - const imageUrls = - memo.content.match(/!\[.*?\]\((.*?)\)/g)?.map( - (item) => - `/o/get/image?url=${ - item - .match(/\((.*?)\)/g) - ?.slice(-1)[0] - .slice(1, -1) ?? "" - }` - ) ?? []; - showPreviewImageDialog( - imageUrls, - imageUrls.findIndex((item) => item === currImgUrl) - ); + const imgUrl = targetEl.getAttribute("src"); + if (imgUrl) { + showPreviewImageDialog([imgUrl], 0); } } };