2018-05-02 00:05:36 +00:00
|
|
|
<div class={computedClass} ref:node>
|
|
|
|
{@html massagedContent}
|
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-04-14 17:47:53 +00:00
|
|
|
display: none;
|
2018-02-04 18:35:24 +00:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-04-14 17:47:53 +00:00
|
|
|
.status-content.shown {
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
|
2018-02-04 18:35:24 +00:00
|
|
|
: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-10 22:30:09 +00:00
|
|
|
:global(.status-content .invisible) {
|
|
|
|
/* copied from Mastodon */
|
|
|
|
font-size: 0;
|
|
|
|
line-height: 0;
|
|
|
|
display: inline-block;
|
|
|
|
width: 0;
|
|
|
|
height: 0;
|
|
|
|
position: absolute;
|
|
|
|
}
|
|
|
|
|
2018-02-04 18:35:24 +00:00
|
|
|
</style>
|
|
|
|
<script>
|
|
|
|
import { mark, stop } from '../../_utils/marks'
|
|
|
|
import { store } from '../../_store/store'
|
2018-04-14 17:47:53 +00:00
|
|
|
import { classname } from '../../_utils/classname'
|
2018-08-23 21:47:33 +00:00
|
|
|
import { massageUserText } from '../../_utils/massageUserText'
|
2018-02-04 18:35:24 +00:00
|
|
|
|
|
|
|
export default {
|
2018-04-20 04:38:01 +00:00
|
|
|
oncreate () {
|
2018-02-04 18:35:24 +00:00
|
|
|
this.hydrateContent()
|
|
|
|
},
|
|
|
|
store: () => store,
|
|
|
|
computed: {
|
2018-05-02 00:05:36 +00:00
|
|
|
computedClass: ({ isStatusInOwnThread, isStatusInNotification, shown }) => {
|
2018-04-14 17:47:53 +00:00
|
|
|
return classname(
|
|
|
|
'status-content',
|
|
|
|
isStatusInOwnThread && 'status-in-own-thread',
|
|
|
|
isStatusInNotification && 'status-in-notification',
|
|
|
|
shown && 'shown'
|
|
|
|
)
|
|
|
|
},
|
2018-08-19 18:31:02 +00:00
|
|
|
content: ({ originalStatus }) => (originalStatus.content || ''),
|
2018-05-02 00:05:36 +00:00
|
|
|
emojis: ({ originalStatus }) => originalStatus.emojis,
|
2018-08-23 21:47:33 +00:00
|
|
|
massagedContent: ({ content, emojis, $autoplayGifs }) => massageUserText(content, emojis, $autoplayGifs)
|
2018-02-04 18:35:24 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2018-04-20 04:38:01 +00:00
|
|
|
hydrateContent () {
|
2018-02-04 18:35:24 +00:00
|
|
|
if (!this.refs.node) {
|
|
|
|
return
|
|
|
|
}
|
2018-04-14 17:08:43 +00:00
|
|
|
mark('hydrateContent')
|
2018-03-15 17:05:49 +00:00
|
|
|
let node = this.refs.node
|
2018-04-19 16:37:05 +00:00
|
|
|
let { originalStatus, uuid } = this.get()
|
2018-02-10 21:57:04 +00:00
|
|
|
let count = 0
|
2018-04-14 17:08:43 +00:00
|
|
|
let anchors = node.getElementsByTagName('A')
|
|
|
|
let mentions = originalStatus.mentions
|
|
|
|
let tags = originalStatus.tags
|
|
|
|
for (let i = 0, len = anchors.length; i < len; i++) {
|
|
|
|
let anchor = anchors[i]
|
|
|
|
let href = anchor.getAttribute('href')
|
|
|
|
if (tags && anchor.classList.contains('hashtag')) {
|
|
|
|
for (let j = 0, jLen = tags.length; j < jLen; j++) {
|
|
|
|
let tag = tags[j]
|
|
|
|
if (href.endsWith(`/tags/${tag.name}`)) {
|
|
|
|
anchor.setAttribute('href', `/tags/${tag.name}`)
|
|
|
|
anchor.setAttribute('focus-key', `status-content-link-${uuid}-${++count}`)
|
|
|
|
anchor.removeAttribute('target')
|
|
|
|
anchor.removeAttribute('rel')
|
2018-02-04 18:35:24 +00:00
|
|
|
}
|
|
|
|
}
|
2018-04-14 17:08:43 +00:00
|
|
|
} else if (mentions && anchor.classList.contains('mention')) {
|
|
|
|
for (let j = 0, jLen = mentions.length; j < jLen; j++) {
|
|
|
|
let mention = mentions[j]
|
|
|
|
if (href === mention.url) {
|
|
|
|
anchor.setAttribute('href', `/accounts/${mention.id}`)
|
|
|
|
anchor.setAttribute('title', `@${mention.acct}`)
|
|
|
|
anchor.setAttribute('focus-key', `status-content-link-${uuid}-${++count}`)
|
|
|
|
anchor.removeAttribute('target')
|
|
|
|
anchor.removeAttribute('rel')
|
2018-02-04 18:35:24 +00:00
|
|
|
}
|
|
|
|
}
|
2018-04-14 17:08:43 +00:00
|
|
|
} else if (anchor.getAttribute('rel') === 'nofollow noopener') {
|
|
|
|
anchor.setAttribute('title', href)
|
2018-02-04 18:35:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
stop('hydrateContent')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-04-28 01:19:37 +00:00
|
|
|
</script>
|