2018-02-04 20:10:02 +00:00
|
|
|
<div
|
2018-02-04 20:49:42 +00:00
|
|
|
class="status-content {{isStatusInOwnThread ? 'status-in-own-thread' : ''}} {{isStatusInNotification ? 'status-in-notification' : ''}}"
|
2018-02-04 20:10:02 +00:00
|
|
|
ref:node
|
|
|
|
>
|
|
|
|
{{{emojifiedContent}}}
|
2018-02-04 18:35:24 +00:00
|
|
|
</div>
|
|
|
|
<style>
|
|
|
|
.status-content {
|
|
|
|
margin: 10px 10px 10px 5px;
|
2018-02-10 04:07:48 +00:00
|
|
|
grid-area: content;
|
2018-02-04 18:35:24 +00:00
|
|
|
word-wrap: break-word;
|
|
|
|
overflow: hidden;
|
|
|
|
white-space: pre-wrap;
|
|
|
|
font-size: 0.9em;
|
|
|
|
}
|
|
|
|
|
2018-02-04 20:10:02 +00:00
|
|
|
.status-content.status-in-own-thread {
|
2018-02-04 18:35:24 +00:00
|
|
|
font-size: 1.3em;
|
|
|
|
margin: 20px 10px 20px 5px;
|
|
|
|
}
|
|
|
|
|
|
|
|
:global(.status-content .status-emoji) {
|
|
|
|
width: 20px;
|
|
|
|
height: 20px;
|
|
|
|
margin: -3px 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
:global(.status-content p) {
|
|
|
|
margin: 0 0 20px;
|
|
|
|
}
|
|
|
|
|
|
|
|
:global(.status-content p:first-child) {
|
|
|
|
margin: 0 0 20px;
|
|
|
|
}
|
|
|
|
|
|
|
|
:global(.status-content p:last-child) {
|
|
|
|
margin: 0;
|
|
|
|
}
|
2018-02-04 20:49:42 +00:00
|
|
|
|
|
|
|
.status-content.status-in-notification {
|
|
|
|
color: var(--very-deemphasized-text-color);
|
|
|
|
}
|
|
|
|
:global(.status-content.status-in-notification a, .status-content.status-in-notification a:hover) {
|
|
|
|
color: var(--very-deemphasized-link-color);
|
|
|
|
}
|
|
|
|
|
2018-02-04 18:35:24 +00:00
|
|
|
</style>
|
|
|
|
<script>
|
|
|
|
import { replaceAll } from '../../_utils/strings'
|
|
|
|
import { mark, stop } from '../../_utils/marks'
|
|
|
|
import { store } from '../../_store/store'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
oncreate() {
|
|
|
|
this.hydrateContent()
|
|
|
|
},
|
|
|
|
store: () => store,
|
|
|
|
computed: {
|
|
|
|
emojifiedContent: (status, $autoplayGifs) => {
|
|
|
|
let content = status.content
|
|
|
|
if (status.emojis && status.emojis.length) {
|
|
|
|
for (let emoji of status.emojis) {
|
|
|
|
let { shortcode, url, static_url } = emoji
|
|
|
|
let urlToUse = $autoplayGifs ? url : static_url
|
|
|
|
let shortcodeWithColons = `:${shortcode}:`
|
|
|
|
content = replaceAll(
|
|
|
|
content,
|
|
|
|
shortcodeWithColons,
|
|
|
|
`<img class="status-emoji" draggable="false" src="${urlToUse}"
|
|
|
|
alt="${shortcodeWithColons}" title="${shortcodeWithColons}" />`
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return content
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
hydrateContent() {
|
|
|
|
if (!this.refs.node) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
let status = this.get('status')
|
|
|
|
mark('hydrateContent')
|
|
|
|
if (status.tags && status.tags.length) {
|
|
|
|
let anchorTags = Array.from(this.refs.node.querySelectorAll(
|
|
|
|
'a[class~=hashtag][href^=http]'))
|
|
|
|
for (let tag of status.tags) {
|
|
|
|
for (let anchorTag of anchorTags) {
|
|
|
|
if (anchorTag.getAttribute('href').endsWith(`/tags/${tag.name}`)) {
|
|
|
|
anchorTag.setAttribute('href', `/tags/${tag.name}`)
|
|
|
|
anchorTag.removeAttribute('target')
|
|
|
|
anchorTag.removeAttribute('rel')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (status.mentions && status.mentions.length) {
|
|
|
|
let anchorTags = Array.from(this.refs.node.querySelectorAll(
|
|
|
|
'a[class~=mention][href^=http]'))
|
|
|
|
for (let mention of status.mentions) {
|
|
|
|
for (let anchorTag of anchorTags) {
|
|
|
|
if (anchorTag.getAttribute('href') === mention.url) {
|
|
|
|
anchorTag.setAttribute('href', `/accounts/${mention.id}`)
|
|
|
|
anchorTag.removeAttribute('target')
|
|
|
|
anchorTag.removeAttribute('rel')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stop('hydrateContent')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|