aboutsummaryrefslogtreecommitdiff
path: root/src/components/rich_content
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2021-08-23 20:57:21 +0300
committerHenry Jameson <me@hjkos.com>2021-08-23 20:57:21 +0300
commit39494439d359fa058079c9325efdff244a7e7890 (patch)
treebbb70feea5018844645ffc3635a0cd5c1316f65e /src/components/rich_content
parentc3576211cbbf9ada109c0869dcf4e4fc7b3ef925 (diff)
very minimalist hashtaglink implementation, also you can middle-click
mentions now.
Diffstat (limited to 'src/components/rich_content')
-rw-r--r--src/components/rich_content/rich_content.jsx13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/components/rich_content/rich_content.jsx b/src/components/rich_content/rich_content.jsx
index d98947df..f52b0370 100644
--- a/src/components/rich_content/rich_content.jsx
+++ b/src/components/rich_content/rich_content.jsx
@@ -5,6 +5,7 @@ import { convertHtmlToTree } from 'src/services/html_converter/html_tree_convert
import { convertHtmlToLines } from 'src/services/html_converter/html_line_converter.service.js'
import StillImage from 'src/components/still-image/still-image.vue'
import MentionsLine, { MENTIONS_LIMIT } from 'src/components/mentions_line/mentions_line.vue'
+import HashtagLink from 'src/components/hashtag_link/hashtag_link.vue'
import './rich_content.scss'
@@ -83,13 +84,10 @@ export default Vue.component('RichContent', {
const renderHashtag = (attrs, children, encounteredTextReverse) => {
const linkData = getLinkData(attrs, children, tagsIndex++)
writtenTags.push(linkData)
- attrs.target = '_blank'
if (!encounteredTextReverse) {
lastTags.push(linkData)
}
- return <a {...{ attrs }}>
- { children.map(processItem) }
- </a>
+ return <HashtagLink {...{ props: linkData }}/>
}
const renderMention = (attrs, children) => {
@@ -211,7 +209,10 @@ export default Vue.component('RichContent', {
if (!this.handleLinks) break
const attrs = getAttrs(opener)
// should only be this
- if (attrs['class'] && attrs['class'].includes('hashtag')) {
+ if (
+ (attrs['class'] && attrs['class'].includes('hashtag')) || // Pleroma style
+ (attrs['rel'] === 'tag') // Mastodon style
+ ) {
return renderHashtag(attrs, children, encounteredTextReverse)
} else {
attrs.target = '_blank'
@@ -275,7 +276,7 @@ const getLinkData = (attrs, children, index) => {
return {
index,
url: attrs.href,
- hashtag: attrs['data-tag'],
+ tag: attrs['data-tag'],
content: flattenDeep(children).join(''),
textContent
}