Catch and redirect clicks on inline mentions
This commit is contained in:
parent
db16d94c0b
commit
fd1b8ee0e8
1 changed files with 9 additions and 3 deletions
|
@ -270,9 +270,15 @@ export default class PostComponent extends Vue {
|
|||
|
||||
mounted() {
|
||||
const mentions = this.$refs.postContent.getElementsByClassName("mention")
|
||||
for (const mention of Array.from(mentions)) {
|
||||
mention.setAttribute("target", "_blank")
|
||||
mention.setAttribute("rel", "noreferrer")
|
||||
for (const mentionElement of Array.from(mentions)) {
|
||||
mentionElement.addEventListener("click", (event: Event) => {
|
||||
event.preventDefault()
|
||||
const mention = this.post.mentions
|
||||
.find((mention) => mention.url === mentionElement.getAttribute("href"))
|
||||
if (mention) {
|
||||
this.$router.push({ name: "profile", params: { profileId: mention.id } })
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue