mention link
This commit is contained in:
parent
1923ed84d4
commit
22c8f71945
6 changed files with 161 additions and 3 deletions
|
@ -1,7 +1,8 @@
|
|||
import Vue from 'vue'
|
||||
import { unescape } from 'lodash'
|
||||
import { unescape, flattenDeep } from 'lodash'
|
||||
import { convertHtml, getTagName, processTextForEmoji, getAttrs } from 'src/services/mini_html_converter/mini_html_converter.service.js'
|
||||
import StillImage from 'src/components/still-image/still-image.vue'
|
||||
import MentionLink from 'src/components/mention_link/mention_link.vue'
|
||||
|
||||
import './rich_content.scss'
|
||||
|
||||
|
@ -22,6 +23,9 @@ export default Vue.component('RichContent', {
|
|||
const attrs = getAttrs(tag)
|
||||
return <StillImage {...{ attrs }} class="img"/>
|
||||
}
|
||||
const renderMention = (attrs, children) => {
|
||||
return <MentionLink url={attrs.href} content={flattenDeep(children).join('')} origattrs={attrs}/>
|
||||
}
|
||||
const structure = convertHtml(this.html)
|
||||
const processItem = (item) => {
|
||||
if (typeof item === 'string') {
|
||||
|
@ -45,8 +49,14 @@ export default Vue.component('RichContent', {
|
|||
if (Array.isArray(item)) {
|
||||
const [opener, children] = item
|
||||
const Tag = getTagName(opener)
|
||||
if (Tag === 'img') {
|
||||
return renderImage(opener)
|
||||
switch (Tag) {
|
||||
case 'img':
|
||||
return renderImage(opener)
|
||||
case 'a':
|
||||
const attrs = getAttrs(opener)
|
||||
if (attrs['class'] && attrs['class'].includes('mention')) {
|
||||
return renderMention(attrs, children)
|
||||
}
|
||||
}
|
||||
if (children !== undefined) {
|
||||
return <Tag {...{ attrs: getAttrs(opener) }}>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue