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-colors/client.coffee

17 lines
631 B

###
# Colors is a named function that will process Colors
# @param {Object} message - The message object
###
class ColorsClient
constructor: (message) ->
if _.trim message.html
msg = message.html
msg = msg.replace /(?:^|\s|\n)(#[A-Fa-f0-9]{3}([A-Fa-f0-9]{3})?)\b/g, (match, completeColor) ->
return match.replace completeColor, "<div class=\"message-color\"><div class=\"message-color-sample\" style=\"background-color:#{completeColor}\"></div>#{completeColor.toUpperCase()}</div>"
message.html = msg
return message
RocketChat.callbacks.add 'renderMessage', ColorsClient, RocketChat.callbacks.priority.MEDIUM