refacto: change avec description is handled with new lines
This commit is contained in:
parent
b389200017
commit
861ecf0db1
@ -1,3 +1,4 @@
|
||||
<!-- eslint-disable vue/no-v-html -->
|
||||
<template>
|
||||
<div class="header">
|
||||
<img class="background" :src="imageUrl">
|
||||
@ -15,7 +16,7 @@
|
||||
</a>
|
||||
<br><br>
|
||||
<p>
|
||||
<small>{{ strippedDescription }}</small>
|
||||
<small v-html="strippedDescription" />
|
||||
</p>
|
||||
</div>
|
||||
<NcAppNavigationNew v-if="!isSubscribed"
|
||||
@ -34,6 +35,7 @@
|
||||
import { NcAppNavigationNew, NcAvatar } from '@nextcloud/vue'
|
||||
import Plus from 'vue-material-design-icons/Plus.vue'
|
||||
import axios from '@nextcloud/axios'
|
||||
import { cleanHtml } from '../../utils/text.js'
|
||||
import { decodeUrl } from '../../utils/url.js'
|
||||
import { generateUrl } from '@nextcloud/router'
|
||||
import { showError } from '@nextcloud/dialogs'
|
||||
@ -75,9 +77,7 @@ export default {
|
||||
return this.$store.state.subscriptions.subscriptions.includes(this.url)
|
||||
},
|
||||
strippedDescription() {
|
||||
const pre = document.createElement('pre')
|
||||
pre.innerHTML = this.description
|
||||
return pre.textContent || pre.innerText || ''
|
||||
return cleanHtml(this.description)
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
|
@ -32,6 +32,7 @@
|
||||
import { NcAvatar, NcButton } from '@nextcloud/vue'
|
||||
import Download from 'vue-material-design-icons/Download.vue'
|
||||
import OpenInNew from 'vue-material-design-icons/OpenInNew.vue'
|
||||
import { cleanHtml } from '../../utils/text.js'
|
||||
import { humanFileSize } from '../../utils/size.js'
|
||||
|
||||
export default {
|
||||
@ -77,10 +78,7 @@ export default {
|
||||
return humanFileSize(this.size)
|
||||
},
|
||||
strippedDescription() {
|
||||
const pre = document.createElement('pre')
|
||||
pre.innerHTML = this.description
|
||||
const strippedDescription = pre.textContent || pre.innerText || ''
|
||||
return strippedDescription.replace(/\n/g, '<br>')
|
||||
return cleanHtml(this.description)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
6
src/utils/text.js
Normal file
6
src/utils/text.js
Normal file
@ -0,0 +1,6 @@
|
||||
export const cleanHtml = (text) => {
|
||||
const pre = document.createElement('pre')
|
||||
pre.innerHTML = text.replace(/<br\s*\/?>/mg, '\n')
|
||||
const strippedText = pre.textContent || pre.innerText || ''
|
||||
return strippedText.replace(/\n/mg, '<br>')
|
||||
}
|
Loading…
Reference in New Issue
Block a user