|
|
@ -36,6 +36,10 @@ export default Vue.component('RichContent', {
|
|
|
|
required: true,
|
|
|
|
required: true,
|
|
|
|
type: String
|
|
|
|
type: String
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
attentions: {
|
|
|
|
|
|
|
|
required: false,
|
|
|
|
|
|
|
|
default: () => []
|
|
|
|
|
|
|
|
},
|
|
|
|
// Emoji object, as in status.emojis, note the "s" at the end...
|
|
|
|
// Emoji object, as in status.emojis, note the "s" at the end...
|
|
|
|
emoji: {
|
|
|
|
emoji: {
|
|
|
|
required: true,
|
|
|
|
required: true,
|
|
|
@ -91,8 +95,12 @@ export default Vue.component('RichContent', {
|
|
|
|
</a>
|
|
|
|
</a>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const renderMention = (attrs, children, encounteredText) => {
|
|
|
|
const renderMention = (attrs, children) => {
|
|
|
|
const linkData = getLinkData(attrs, children, mentionIndex++)
|
|
|
|
const linkData = getLinkData(attrs, children, mentionIndex++)
|
|
|
|
|
|
|
|
linkData.notifying = this.attentions.some(a => a.statusnet_profile_url === linkData.url)
|
|
|
|
|
|
|
|
if (!linkData.notifying) {
|
|
|
|
|
|
|
|
encounteredText = true
|
|
|
|
|
|
|
|
}
|
|
|
|
writtenMentions.push(linkData)
|
|
|
|
writtenMentions.push(linkData)
|
|
|
|
if (!encounteredText) {
|
|
|
|
if (!encounteredText) {
|
|
|
|
firstMentions.push(linkData)
|
|
|
|
firstMentions.push(linkData)
|
|
|
@ -121,14 +129,13 @@ export default Vue.component('RichContent', {
|
|
|
|
if (emptyText) {
|
|
|
|
if (emptyText) {
|
|
|
|
return encounteredText ? item : item.trim()
|
|
|
|
return encounteredText ? item : item.trim()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let unescapedItem = unescape(item)
|
|
|
|
|
|
|
|
if (!encounteredText) {
|
|
|
|
if (!encounteredText) {
|
|
|
|
unescapedItem = unescapedItem.trimStart()
|
|
|
|
item = item.trimStart()
|
|
|
|
encounteredText = true
|
|
|
|
encounteredText = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (item.includes(':')) {
|
|
|
|
if (item.includes(':')) {
|
|
|
|
unescapedItem = ['', processTextForEmoji(
|
|
|
|
item = ['', processTextForEmoji(
|
|
|
|
unescapedItem,
|
|
|
|
item,
|
|
|
|
this.emoji,
|
|
|
|
this.emoji,
|
|
|
|
({ shortcode, url }) => {
|
|
|
|
({ shortcode, url }) => {
|
|
|
|
return <StillImage
|
|
|
|
return <StillImage
|
|
|
@ -140,7 +147,7 @@ export default Vue.component('RichContent', {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)]
|
|
|
|
)]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return unescapedItem
|
|
|
|
return item
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Handle tag nodes
|
|
|
|
// Handle tag nodes
|
|
|
@ -149,7 +156,7 @@ export default Vue.component('RichContent', {
|
|
|
|
const Tag = getTagName(opener)
|
|
|
|
const Tag = getTagName(opener)
|
|
|
|
const attrs = getAttrs(opener)
|
|
|
|
const attrs = getAttrs(opener)
|
|
|
|
switch (Tag) {
|
|
|
|
switch (Tag) {
|
|
|
|
case 'span': // replace images with StillImage
|
|
|
|
case 'span': // Replace last mentions class with mentionsline
|
|
|
|
if (attrs['class'] && attrs['class'].includes('lastMentions')) {
|
|
|
|
if (attrs['class'] && attrs['class'].includes('lastMentions')) {
|
|
|
|
if (firstMentions.length > 1 && lastMentions.length > 1) {
|
|
|
|
if (firstMentions.length > 1 && lastMentions.length > 1) {
|
|
|
|
break
|
|
|
|
break
|
|
|
@ -189,7 +196,7 @@ export default Vue.component('RichContent', {
|
|
|
|
const emptyText = item.trim() === ''
|
|
|
|
const emptyText = item.trim() === ''
|
|
|
|
if (emptyText) return item
|
|
|
|
if (emptyText) return item
|
|
|
|
if (!encounteredTextReverse) encounteredTextReverse = true
|
|
|
|
if (!encounteredTextReverse) encounteredTextReverse = true
|
|
|
|
return item
|
|
|
|
return unescape(item)
|
|
|
|
} else if (Array.isArray(item)) {
|
|
|
|
} else if (Array.isArray(item)) {
|
|
|
|
// Handle tag nodes
|
|
|
|
// Handle tag nodes
|
|
|
|
const [opener, children] = item
|
|
|
|
const [opener, children] = item
|
|
|
@ -203,9 +210,7 @@ export default Vue.component('RichContent', {
|
|
|
|
return renderHashtag(attrs, children, encounteredTextReverse)
|
|
|
|
return renderHashtag(attrs, children, encounteredTextReverse)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
attrs.target = '_blank'
|
|
|
|
attrs.target = '_blank'
|
|
|
|
html.includes('freenode') && console.log('PASS1', children)
|
|
|
|
|
|
|
|
const newChildren = [...children].reverse().map(processItemReverse).reverse()
|
|
|
|
const newChildren = [...children].reverse().map(processItemReverse).reverse()
|
|
|
|
html.includes('freenode') && console.log('PASS1b', newChildren)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return <a {...{ attrs }}>
|
|
|
|
return <a {...{ attrs }}>
|
|
|
|
{ newChildren }
|
|
|
|
{ newChildren }
|
|
|
|