Highlight self-mentions in messages
Signed-off-by: Nikola Forró <nforro@redhat.com>
This commit is contained in:
@@ -35,11 +35,18 @@ class Message {
|
|||||||
target: '_blank'
|
target: '_blank'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return addNewlines(linked);
|
const highlighted = this.highlightUsername(linked);
|
||||||
|
return addNewlines(highlighted);
|
||||||
}
|
}
|
||||||
userColor() {
|
userColor() {
|
||||||
return messageBubbleColorForString(this.author);
|
return messageBubbleColorForString(this.author);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
highlightUsername(message) {
|
||||||
|
const username = document.getElementById('self-message-author').value;
|
||||||
|
const pattern = new RegExp('@?' + username.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), 'gi');
|
||||||
|
return message.replace(pattern, '<span class="highlighted">$&</span>');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -624,6 +624,11 @@ h2 {
|
|||||||
border-radius: 15px;
|
border-radius: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.message-text .highlighted {
|
||||||
|
color: orange;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
.message-text code {
|
.message-text code {
|
||||||
background-color:darkslategrey;
|
background-color:darkslategrey;
|
||||||
padding: 3px;
|
padding: 3px;
|
||||||
|
|||||||
Reference in New Issue
Block a user