mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
feat: view all images of a memo (#393)
* feat: view all images of a memo * fix: function arguments * refactor: unified image preview * refactor: image preview for resource dialog Co-authored-by: XQ <qiaobingxue1998@163.com>
This commit is contained in:
@ -161,9 +161,15 @@ const Memo: React.FC<Props> = (props: Props) => {
|
||||
}
|
||||
}
|
||||
} else if (targetEl.tagName === "IMG") {
|
||||
const imgUrl = targetEl.getAttribute("src");
|
||||
if (imgUrl) {
|
||||
showPreviewImageDialog(imgUrl);
|
||||
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) => item.match(/\((.*?)\)/)?.[1] ?? "") ?? [];
|
||||
showPreviewImageDialog(
|
||||
imageUrls,
|
||||
imageUrls.findIndex((item) => item === currImgUrl)
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user