Only render mxc images in markdown
This commit is contained in:
parent
0cf5aac591
commit
258afec391
1 changed files with 12 additions and 1 deletions
|
@ -76,11 +76,22 @@ function transformATag(tagName, attribs) {
|
|||
|
||||
function transformImgTag(tagName, attribs) {
|
||||
const { src } = attribs;
|
||||
if (src.startsWith('mxc://') === false) {
|
||||
return {
|
||||
tagName: 'a',
|
||||
attribs: {
|
||||
href: src,
|
||||
rel: 'noopener',
|
||||
target: '_blank',
|
||||
},
|
||||
text: attribs.alt || src,
|
||||
};
|
||||
}
|
||||
return {
|
||||
tagName,
|
||||
attribs: {
|
||||
...attribs,
|
||||
src: src.startsWith('mxc://') ? mx?.mxcUrlToHttp(src) : src,
|
||||
src: mx?.mxcUrlToHttp(src),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue