proper collapse
This commit is contained in:
parent
26a2232e18
commit
8780e0191e
2 changed files with 19 additions and 3 deletions
|
|
@ -86,6 +86,12 @@ export default {
|
||||||
required: false,
|
required: false,
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
|
},
|
||||||
|
// Collapse newlines
|
||||||
|
collapse: {
|
||||||
|
required: false,
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// NEVER EVER TOUCH DATA INSIDE RENDER
|
// NEVER EVER TOUCH DATA INSIDE RENDER
|
||||||
|
|
@ -281,11 +287,20 @@ export default {
|
||||||
|
|
||||||
const pass1 = convertHtmlToTree(html).map(processItem)
|
const pass1 = convertHtmlToTree(html).map(processItem)
|
||||||
const pass2 = [...pass1].reverse().map(processItemReverse).reverse()
|
const pass2 = [...pass1].reverse().map(processItemReverse).reverse()
|
||||||
|
|
||||||
// DO NOT USE SLOTS they cause a re-render feedback loop here.
|
// DO NOT USE SLOTS they cause a re-render feedback loop here.
|
||||||
// slots updated -> rerender -> emit -> update up the tree -> rerender -> ...
|
// slots updated -> rerender -> emit -> update up the tree -> rerender -> ...
|
||||||
// at least until vue3?
|
// at least until vue3?
|
||||||
const result = <span class={['RichContent', this.faint ? '-faint' : '']}>
|
const result =
|
||||||
{ pass2 }
|
<span class={['RichContent', this.faint ? '-faint' : '']}>
|
||||||
|
{
|
||||||
|
this.collapse
|
||||||
|
? pass2.map(x => {
|
||||||
|
if (!Array.isArray(x)) return x.replace(/\n/g, ' ')
|
||||||
|
return x.map(y => y.type === 'br' ? ' ' : y)
|
||||||
|
})
|
||||||
|
: pass2
|
||||||
|
}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
const event = {
|
const event = {
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,8 @@
|
||||||
v-if="!hideSubjectStatus && !(singleLine && status.summary_raw_html)"
|
v-if="!hideSubjectStatus && !(singleLine && status.summary_raw_html)"
|
||||||
:class="{ '-single-line': singleLine }"
|
:class="{ '-single-line': singleLine }"
|
||||||
class="text media-body"
|
class="text media-body"
|
||||||
:html="collapse ? collapsedStatus : status.raw_html"
|
:html="status.raw_html"
|
||||||
|
:collapse="collapse"
|
||||||
:emoji="status.emojis"
|
:emoji="status.emojis"
|
||||||
:handle-links="true"
|
:handle-links="true"
|
||||||
:faint="compact"
|
:faint="compact"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue