Only render mxc images in markdown

This commit is contained in:
Ajay Bura 2022-08-11 17:20:55 +05:30
parent 0cf5aac591
commit 258afec391

View file

@ -76,11 +76,22 @@ function transformATag(tagName, attribs) {
function transformImgTag(tagName, attribs) { function transformImgTag(tagName, attribs) {
const { src } = attribs; const { src } = attribs;
if (src.startsWith('mxc://') === false) {
return {
tagName: 'a',
attribs: {
href: src,
rel: 'noopener',
target: '_blank',
},
text: attribs.alt || src,
};
}
return { return {
tagName, tagName,
attribs: { attribs: {
...attribs, ...attribs,
src: src.startsWith('mxc://') ? mx?.mxcUrlToHttp(src) : src, src: mx?.mxcUrlToHttp(src),
}, },
}; };
} }