Skip to content
Snippets Groups Projects
Unverified Commit 60949b55 authored by Gabriel Engel's avatar Gabriel Engel
Browse files

Added Hex Color Preview Setting

parent aaf0959e
No related branches found
No related tags found
No related merge requests found
......@@ -3,9 +3,9 @@
# @param {Object} message - The message object
###
class ColorsClient
class HexColorPreview
constructor: (message) ->
if _.trim message.html
if _.trim(message.html) and RocketChat.settings.get 'HexColorPreview_Enabled'
msg = message.html
msg = msg.replace /(?:^|\s|\n)(#[A-Fa-f0-9]{3}([A-Fa-f0-9]{3})?)\b/g, (match, completeColor) ->
......@@ -14,4 +14,4 @@ class ColorsClient
message.html = msg
return message
RocketChat.callbacks.add 'renderMessage', ColorsClient, RocketChat.callbacks.priority.MEDIUM
RocketChat.callbacks.add 'renderMessage', HexColorPreview, RocketChat.callbacks.priority.MEDIUM
......@@ -10,7 +10,7 @@ Package.onUse(function(api) {
'coffeescript',
'rocketchat:lib'
]);
api.addFiles('client.coffee', 'client');
api.addFiles('style.css', 'client');
api.addFiles('client.coffee', ['client']);
api.addFiles('style.css', ['client']);
api.addFiles('settings.js', ['server']);
});
RocketChat.settings.add('HexColorPreview_Enabled', true, {
type: 'boolean',
i18nLabel: 'Enabled',
group: 'Message',
section: 'Hex Color Preview',
public: true
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment