hicli/html: open mxc urls in new tab

This commit is contained in:
Tulir Asokan 2024-10-29 14:38:23 +02:00
parent ab97efbcc1
commit e2f0ba61ac

View file

@ -223,6 +223,7 @@ func writeURL(w *strings.Builder, addr []byte) {
} }
w.WriteString("<a") w.WriteString("<a")
writeAttribute(w, "class", "hicli-mxc-url") writeAttribute(w, "class", "hicli-mxc-url")
writeAttribute(w, "target", "_blank")
writeAttribute(w, "data-mxc", mxc.String()) writeAttribute(w, "data-mxc", mxc.String())
writeAttribute(w, "href", fmt.Sprintf(HTMLSanitizerImgSrcTemplate, mxc.Homeserver, mxc.FileID)) writeAttribute(w, "href", fmt.Sprintf(HTMLSanitizerImgSrcTemplate, mxc.Homeserver, mxc.FileID))
w.WriteByte('>') w.WriteByte('>')
@ -405,6 +406,7 @@ func writeA(w *strings.Builder, attr []html.Attribute) (mxc id.ContentURI) {
return return
} }
writeAttribute(w, "class", "hicli-mxc-url") writeAttribute(w, "class", "hicli-mxc-url")
writeAttribute(w, "target", "_blank")
writeAttribute(w, "data-mxc", mxc.String()) writeAttribute(w, "data-mxc", mxc.String())
href = fmt.Sprintf(HTMLSanitizerImgSrcTemplate, mxc.Homeserver, mxc.FileID) href = fmt.Sprintf(HTMLSanitizerImgSrcTemplate, mxc.Homeserver, mxc.FileID)
default: default: