fix: regex to replace url to a clickable link in notifictiaons (#832)
* fix: wrap too long lines in notifications Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix: regex to replace url to a link in notification description text Signed-off-by: Stefan Dej <meteyou@gmail.com>
This commit is contained in:
1 parent
fd89ff7ba3
commit
d657db36d6
1 file changed
+16
-3
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<v-alert text :color="alertColor" border="left">
|
||||
<v-alert :class="`notification-menu-entry--priority-${entry.priority}`" text :color="alertColor" border="left">
|
||||
<v-row align="start">
|
||||
<v-col class="grow">
|
||||
<div class="notification-menu-entry__headline mb-1 text-subtitle-1">
|
||||
@@ -15,7 +15,9 @@
|
||||
<span :class="`${alertColor}--text`">{{ entry.title }}</span>
|
||||
</template>
|
||||
</div>
|
||||
<p class="text-body-2 mb-0 text--disabled font-weight-light" v-html="formatedText"></p>
|
||||
<p
|
||||
class="notification-menu-entry__description text-body-2 mb-0 text--disabled font-weight-light"
|
||||
v-html="formatedText"></p>
|
||||
</v-col>
|
||||
<v-col
|
||||
v-if="entry.priority !== 'critical'"
|
||||
@@ -117,7 +119,10 @@ export default class NotificationMenuEntry extends Mixins(BaseMixin) {
|
||||
declare readonly parentState: boolean
|
||||
|
||||
get formatedText() {
|
||||
return this.entry.description.replace(/\[([^\]]+)\]\(([^)]+)\)/, '<a href="$2" target="_blank">$1</a>')
|
||||
return this.entry.description.replace(
|
||||
/(\bhttps?:\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/gim,
|
||||
'<a href="$1" target="_blank" class="' + this.alertColor + '--text">$1</a>'
|
||||
)
|
||||
}
|
||||
|
||||
get alertColor() {
|
||||
@@ -153,4 +158,12 @@ export default class NotificationMenuEntry extends Mixins(BaseMixin) {
|
||||
.notification-menu-entry__headline {
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.notification-menu-entry__description {
|
||||
max-width: 292px;
|
||||
}
|
||||
|
||||
.notification-menu-entry--priority-critical .notification-menu-entry__description {
|
||||
max-width: 336px;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user