diff options
| author | Henry Jameson <me@hjkos.com> | 2021-06-10 12:08:31 +0300 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2021-06-10 12:29:58 +0300 |
| commit | aec867b30036fd039113e4197ca98566447efec6 (patch) | |
| tree | 556505243aff6bd951ef8115726f1dc2e03bfda7 /src/components/status_body | |
| parent | 566964992a394f1d0462557f70e284f2493d82bf (diff) | |
Moved greentext to RichContent, improved how first mentions are
restored, now shows mentions not uh, mention in post body
Diffstat (limited to 'src/components/status_body')
| -rw-r--r-- | src/components/status_body/status_body.js | 60 | ||||
| -rw-r--r-- | src/components/status_body/status_body.vue | 20 |
2 files changed, 21 insertions, 59 deletions
diff --git a/src/components/status_body/status_body.js b/src/components/status_body/status_body.js index 3c092ac7..dbabd208 100644 --- a/src/components/status_body/status_body.js +++ b/src/components/status_body/status_body.js @@ -1,8 +1,6 @@ import fileType from 'src/services/file_type/file_type.service' -import RichContent from 'src/components/rich_content/rich_content.jsx' +import RichContent, { getHeadTailLinks } from 'src/components/rich_content/rich_content.jsx' import MentionsLine from 'src/components/mentions_line/mentions_line.vue' -import { processHtml } from 'src/services/tiny_post_html_processor/tiny_post_html_processor.service.js' -import { extractTagFromUrl } from 'src/services/matcher/matcher.service.js' import { mapGetters } from 'vuex' import { library } from '@fortawesome/fontawesome-svg-core' import { @@ -28,7 +26,10 @@ const StatusContent = { 'focused', 'noHeading', 'fullContent', - 'singleLine' + 'singleLine', + // if this was computed at upper level it can be passed here, otherwise + // it will be in this component + 'headTailLinks' ], data () { return { @@ -72,44 +73,18 @@ const StatusContent = { showingMore () { return (this.mightHideBecauseTall && this.showingTall) || (this.mightHideBecauseSubject && this.expandingSubject) }, - postBodyHtml () { - const html = this.status.raw_html - - if (this.mergedConfig.greentext) { - try { - if (html.includes('>')) { - // This checks if post has '>' at the beginning, excluding mentions so that @mention >impying works - return processHtml(html, (string) => { - if (string.includes('>') && - string - .replace(/<[^>]+?>/gi, '') // remove all tags - .replace(/@\w+/gi, '') // remove mentions (even failed ones) - .trim() - .startsWith('>')) { - return `<span class='greentext'>${string}</span>` - } else { - return string - } - }) - } else { - return html - } - } catch (e) { - console.error('Failed to process status html', e) - return html - } - } else { - return html - } - }, attachmentTypes () { return this.status.attachments.map(file => fileType.fileType(file.mimetype)) }, mentionsOwnLine () { return this.mergedConfig.mentionsOwnLine }, + headTailLinksComputed () { + if (this.headTailLinks) return this.headTailLinks + return getHeadTailLinks(this.status.raw_html) + }, mentions () { - return this.status.attentions + return this.headTailLinksComputed.firstMentions }, ...mapGetters(['mergedConfig']) }, @@ -124,21 +99,6 @@ const StatusContent = { }) }, methods: { - linkClicked (event) { - const target = event.target.closest('.status-content a') - if (target) { - if (target.rel.match(/(?:^|\s)tag(?:$|\s)/) || target.className.match(/hashtag/)) { - // Extract tag name from dataset or link url - const tag = target.dataset.tag || extractTagFromUrl(target.href) - if (tag) { - const link = this.generateTagLink(tag) - this.$router.push(link) - return - } - } - window.open(target.href, '_blank') - } - }, toggleShowMore () { if (this.mightHideBecauseTall) { this.showingTall = !this.showingTall diff --git a/src/components/status_body/status_body.vue b/src/components/status_body/status_body.vue index fae2d594..ff919211 100644 --- a/src/components/status_body/status_body.vue +++ b/src/components/status_body/status_body.vue @@ -10,7 +10,6 @@ class="media-body summary" :html="status.summary_raw_html" :emoji="status.emojis" - @click.prevent="linkClicked" /> <button v-if="longSubject && showingLongSubject" @@ -43,19 +42,22 @@ class="text-wrapper" v-if="!hideSubjectStatus && !(singleLine && status.summary_html)" > - <MentionsLine - v-if="!mentionsOwnLine" - :attentions="status.attentions" - class="mentions-line" - /> <RichContent :class="{ '-single-line': singleLine }" class="text media-body" - :html="postBodyHtml" + :html="status.raw_html" :emoji="status.emojis" :handle-links="true" - @click.prevent="linkClicked" - /> + :greentext="mergedConfig.greentext" + > + <template v-slot:prefix> + <MentionsLine + v-if="!mentionsOwnLine" + :mentions="mentions" + class="mentions-line" + /> + </template> + </RichContent> </span> <button |
