mirror of
https://github.com/usememos/memos.git
synced 2025-01-04 12:35:14 +03:00
chore: show content image (#602)
This commit is contained in:
parent
045819c312
commit
ce795a2a7d
@ -139,24 +139,9 @@ const Memo: React.FC<Props> = (props: Props) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (targetEl.tagName === "IMG") {
|
} else if (targetEl.tagName === "IMG") {
|
||||||
const currImgUrl = targetEl.getAttribute("src");
|
const imgUrl = targetEl.getAttribute("src");
|
||||||
|
if (imgUrl) {
|
||||||
if (currImgUrl) {
|
showPreviewImageDialog([imgUrl], 0);
|
||||||
// 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)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user