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;
|
|
|
|
}
|
|
|
|
|
2019-07-21 22:31:05 +00:00
|
|
|
:global(.status-content li) {
|
|
|
|
font-size: 1.3em;
|
|
|
|
}
|
|
|
|
|
|
|
|
:global(
|
|
|
|
.status-content p,
|
|
|
|
.status-content blockquote,
|
|
|
|
.status-content ul,
|
|
|
|
.status-content ol) {
|
2018-02-04 18:35:24 +00:00
|
|
|
margin: 0 0 20px;
|
|
|
|
}
|
|
|
|
|
2019-07-21 22:31:05 +00:00
|
|
|
:global(
|
|
|
|
.status-content p:first-child,
|
|
|
|
.status-content blockquote:first-child,
|
|
|
|
.status-content ul:first-child,
|
|
|
|
.status-content ol:first-child) {
|
2018-02-04 18:35:24 +00:00
|
|
|
margin: 0 0 20px;
|
|
|
|
}
|
|
|
|
|
2019-07-21 22:31:05 +00:00
|
|
|
:global(
|
|
|
|
.status-content p:last-child,
|
|
|
|
.status-content blockquote:last-child,
|
|
|
|
.status-content ul:last-child,
|
|
|
|
.status-content ol:last-child) {
|
2018-02-04 18:35:24 +00:00
|
|
|
margin: 0;
|
|
|
|
}
|
2018-02-04 20:49:42 +00:00
|
|
|
|
2019-07-21 22:31:05 +00:00
|
|
|
:global(.status-content blockquote) {
|
|
|
|
padding-left: 1.5rem;
|
|
|
|
border-left: 5px solid var(--body-bg);
|
|
|
|
color: var(--very-deemphasized-text-color);
|
|
|
|
font-style: italic;
|
|
|
|
}
|
|
|
|
|
|
|
|
:global(.status-content ul, .status-content ol) {
|
|
|
|
padding-left: 2rem;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-01-26 21:50:45 +00:00
|
|
|
:global(.underline-links .status-content a) {
|
|
|
|
text-decoration: underline;
|
|
|
|
}
|
|
|
|
|
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'
|
2019-08-11 18:09:51 +00:00
|
|
|
import { urlIsCrossOrigin } from '../../_utils/urlIsCrossOrigin'
|
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 || ''),
|
2019-05-26 23:01:14 +00:00
|
|
|
massagedContent: ({ content, originalStatusEmojis, $autoplayGifs }) => (
|
|
|
|
massageUserText(content, originalStatusEmojis, $autoplayGifs)
|
|
|
|
)
|
2018-02-04 18:35:24 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2018-04-20 04:38:01 +00:00
|
|
|
hydrateContent () {
|
2018-04-14 17:08:43 +00:00
|
|
|
mark('hydrateContent')
|
2019-08-03 20:49:37 +00:00
|
|
|
const node = this.refs.node
|
|
|
|
const { originalStatus, uuid } = this.get()
|
|
|
|
const { mentions, tags } = originalStatus
|
2018-02-10 21:57:04 +00:00
|
|
|
let count = 0
|
2019-08-03 20:49:37 +00:00
|
|
|
const anchors = Array.from(node.getElementsByTagName('A'))
|
2019-01-14 01:11:27 +00:00
|
|
|
|
2019-08-03 20:49:37 +00:00
|
|
|
for (const anchor of anchors) {
|
2019-01-14 01:11:27 +00:00
|
|
|
// hydrate hashtag
|
2018-04-14 17:08:43 +00:00
|
|
|
if (tags && anchor.classList.contains('hashtag')) {
|
2019-08-03 20:49:37 +00:00
|
|
|
for (const tag of tags) {
|
2019-01-14 01:11:27 +00:00
|
|
|
if (anchor.getAttribute('href').endsWith(`/tags/${tag.name}`)) {
|
2018-04-14 17:08:43 +00:00
|
|
|
anchor.setAttribute('href', `/tags/${tag.name}`)
|
2019-02-23 20:32:00 +00:00
|
|
|
anchor.setAttribute('id', `status-content-link-${uuid}-${++count}`)
|
2018-04-14 17:08:43 +00:00
|
|
|
anchor.removeAttribute('target')
|
|
|
|
anchor.removeAttribute('rel')
|
2018-02-04 18:35:24 +00:00
|
|
|
}
|
|
|
|
}
|
2019-01-14 01:11:27 +00:00
|
|
|
// hydrate mention
|
2018-04-14 17:08:43 +00:00
|
|
|
} else if (mentions && anchor.classList.contains('mention')) {
|
2019-08-03 20:49:37 +00:00
|
|
|
for (const mention of mentions) {
|
2019-01-14 01:11:27 +00:00
|
|
|
if (anchor.getAttribute('href') === mention.url) {
|
2018-04-14 17:08:43 +00:00
|
|
|
anchor.setAttribute('href', `/accounts/${mention.id}`)
|
|
|
|
anchor.setAttribute('title', `@${mention.acct}`)
|
2019-02-23 20:32:00 +00:00
|
|
|
anchor.setAttribute('id', `status-content-link-${uuid}-${++count}`)
|
2018-04-14 17:08:43 +00:00
|
|
|
anchor.removeAttribute('target')
|
|
|
|
anchor.removeAttribute('rel')
|
2018-02-04 18:35:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-01-14 01:11:27 +00:00
|
|
|
// hydrate external links
|
2019-08-03 20:49:37 +00:00
|
|
|
const href = anchor.getAttribute('href')
|
2019-08-11 18:09:51 +00:00
|
|
|
if (urlIsCrossOrigin(href)) {
|
2019-01-14 01:11:27 +00:00
|
|
|
anchor.setAttribute('title', href)
|
2019-01-14 00:05:41 +00:00
|
|
|
anchor.setAttribute('target', '_blank')
|
2019-01-14 01:11:27 +00:00
|
|
|
anchor.setAttribute('rel', 'nofollow noopener')
|
2019-01-14 00:05:41 +00:00
|
|
|
}
|
2018-02-04 18:35:24 +00:00
|
|
|
}
|
|
|
|
stop('hydrateContent')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-04-28 01:19:37 +00:00
|
|
|
</script>
|