mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
feat(frontend): links and emails in messages (#3377)
* feat(frontend): Transform links and mails in transaction messages into clickable links and mailto links. * feat(frontend): Lint fix
This commit is contained in:
parent
b69d2273ae
commit
ba91f8d6fe
@ -2,21 +2,34 @@
|
||||
<div class="decayinformation-startblock">
|
||||
<div class="my-4">
|
||||
<div class="fw-bold pb-2">{{ $t('form.memo') }}</div>
|
||||
<div>{{ memo }}</div>
|
||||
<div v-html="displayData" />
|
||||
</div>
|
||||
<div class="mt-3 mb-3 text-center">
|
||||
<b>{{ $t('decay.before_startblock_transaction') }}</b>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: 'DecayInformationStartBlock',
|
||||
props: {
|
||||
memo: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
memo: String,
|
||||
})
|
||||
|
||||
const formatLinks = (text) => {
|
||||
// URL regex pattern
|
||||
const urlPattern = /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim
|
||||
// Email regex pattern
|
||||
const emailPattern = /(\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b)/g
|
||||
|
||||
// Replace URLs with clickable links
|
||||
text = text.replace(urlPattern, '<a href="$1" target="_blank">$1</a>')
|
||||
|
||||
// Replace email addresses with mailto links
|
||||
text = text.replace(emailPattern, '<a href="mailto:$1">$1</a>')
|
||||
|
||||
return text
|
||||
}
|
||||
|
||||
const displayData = computed(() => formatLinks(props.memo))
|
||||
</script>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<div class="decayinformation-long px-1">
|
||||
<div class="word-break mb-5 mt-lg-3">
|
||||
<div class="fw-bold pb-2">{{ $t('form.memo') }}</div>
|
||||
<div class="">{{ memo }}</div>
|
||||
<div @click.stop v-html="displayData" />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<IBiDropletHalf class="me-2" />
|
||||
@ -73,6 +73,7 @@
|
||||
</template>
|
||||
<script>
|
||||
import DurationRow from '@/components/TransactionRows/DurationRow'
|
||||
import { computed } from 'vue'
|
||||
|
||||
export default {
|
||||
name: 'DecayInformationLong',
|
||||
@ -89,5 +90,27 @@ export default {
|
||||
type: Object,
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
displayData() {
|
||||
return this.formatLinks(this.memo)
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
formatLinks(text) {
|
||||
const urlPattern = /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim
|
||||
const emailPattern = /(\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b)/g
|
||||
|
||||
// Replace URLs with clickable links
|
||||
text = text.replace(
|
||||
urlPattern,
|
||||
'<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>',
|
||||
)
|
||||
|
||||
// Replace email addresses with mailto links
|
||||
text = text.replace(emailPattern, '<a href="mailto:$1">$1</a>')
|
||||
|
||||
return text
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<div class="text-end">{{ $t('form.memo') }}</div>
|
||||
</BCol>
|
||||
<BCol cols="7">
|
||||
<div class="gdd-transaction-list-message">{{ memo }}</div>
|
||||
<div class="gdd-transaction-list-message" v-html="displayData" />
|
||||
</BCol>
|
||||
</BRow>
|
||||
</div>
|
||||
@ -19,5 +19,27 @@ export default {
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
displayData() {
|
||||
return this.formatLinks(this.memo)
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
formatLinks(text) {
|
||||
const urlPattern = /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim
|
||||
const emailPattern = /(\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b)/g
|
||||
|
||||
// Replace URLs with clickable links
|
||||
text = text.replace(
|
||||
urlPattern,
|
||||
'<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>',
|
||||
)
|
||||
|
||||
// Replace email addresses with mailto links
|
||||
text = text.replace(emailPattern, '<a href="mailto:$1">$1</a>')
|
||||
|
||||
return text
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user