The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/packages/rocketchat-highlight-words/client.coffee

25 lines
789 B

###
# Hilights is a named function that will process Highlights
# @param {Object} message - The message object
###
class HighlightWordsClient
constructor: (message) ->
msg = message
if not _.isString message
if _.trim message.html
msg = message.html
else
return message
to_highlight = Meteor.user()?.settings?.preferences?['highlights']
_.forEach to_highlight, (highlight) ->
if not _.isBlank(highlight)
msg = msg.replace(new RegExp("(^|\\b|[\\s\\n\\r\\t.,،'\\\"\\+!?:-])(#{s.escapeRegExp(highlight)})($|\\b|[\\s\\n\\r\\t.,،'\\\"\\+!?:-])(?![^<]*>|[^<>]*<\\/)", 'gmi'), '$1<span class="highlight-text">$2</span>$3')
message.html = msg
return message
RocketChat.callbacks.add 'renderMessage', HighlightWordsClient