From 39494439d359fa058079c9325efdff244a7e7890 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 23 Aug 2021 20:57:21 +0300 Subject: [PATCH] very minimalist hashtaglink implementation, also you can middle-click mentions now. --- src/components/hashtag_link/hashtag_link.js | 36 +++++++++++++++++++ src/components/hashtag_link/hashtag_link.scss | 6 ++++ src/components/hashtag_link/hashtag_link.vue | 19 ++++++++++ src/components/mention_link/mention_link.vue | 5 +-- src/components/rich_content/rich_content.jsx | 13 +++---- .../specs/components/rich_content.spec.js | 8 ++--- 6 files changed, 75 insertions(+), 12 deletions(-) create mode 100644 src/components/hashtag_link/hashtag_link.js create mode 100644 src/components/hashtag_link/hashtag_link.scss create mode 100644 src/components/hashtag_link/hashtag_link.vue diff --git a/src/components/hashtag_link/hashtag_link.js b/src/components/hashtag_link/hashtag_link.js new file mode 100644 index 00000000..a2433c2a --- /dev/null +++ b/src/components/hashtag_link/hashtag_link.js @@ -0,0 +1,36 @@ +import { extractTagFromUrl } from 'src/services/matcher/matcher.service.js' + +const HashtagLink = { + name: 'HashtagLink', + props: { + url: { + required: true, + type: String + }, + content: { + required: true, + type: String + }, + tag: { + required: false, + type: String, + default: '' + } + }, + methods: { + onClick () { + const tag = this.tag || extractTagFromUrl(this.url) + if (tag) { + const link = this.generateTagLink(tag) + this.$router.push(link) + } else { + window.open(this.url, '_blank') + } + }, + generateTagLink (tag) { + return `/tag/${tag}` + } + } +} + +export default HashtagLink diff --git a/src/components/hashtag_link/hashtag_link.scss b/src/components/hashtag_link/hashtag_link.scss new file mode 100644 index 00000000..78e8fb99 --- /dev/null +++ b/src/components/hashtag_link/hashtag_link.scss @@ -0,0 +1,6 @@ +.HashtagLink { + position: relative; + white-space: normal; + display: inline-block; + color: var(--link); +} diff --git a/src/components/hashtag_link/hashtag_link.vue b/src/components/hashtag_link/hashtag_link.vue new file mode 100644 index 00000000..918ed26b --- /dev/null +++ b/src/components/hashtag_link/hashtag_link.vue @@ -0,0 +1,19 @@ + + +