Skip to content
Snippets Groups Projects
Commit 792cf18b authored by Johann's avatar Johann
Browse files

Add formatter for highlight words

parent d102b926
No related branches found
No related tags found
No related merge requests found
......@@ -138,3 +138,4 @@ rocketchat:assets
rocketchat:integrations
rocketchat:message-attachments
rocketchat:api
rocketchat:highlight-words
......@@ -121,6 +121,7 @@ reactive-dict@1.1.3
reactive-var@1.0.6
reload@1.1.4
retry@1.0.4
rocketchat:highlight-words@0.0.1
rocketchat:api@0.0.1
rocketchat:assets@0.0.1
rocketchat:authorization@0.0.1
......
###
# 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("(#{highlight})", 'gmi'), '<span class="highlight-text">$1</span>')
message.html = msg
return message
RocketChat.callbacks.add 'renderMessage', HighlightWordsClient
\ No newline at end of file
Package.describe({
name: 'rocketchat:highlight-words',
version: '0.0.1',
// Brief, one-line summary of the package.
summary: '',
// URL to the Git repository containing the source code for this package.
git: '',
// By default, Meteor will default to using README.md for documentation.
// To avoid submitting documentation, set this field to null.
documentation: ''
});
Package.onUse(function(api) {
api.versionsFrom('1.2.1');
api.use([
'coffeescript',
'rocketchat:lib'
]);
api.addFiles('client.coffee', 'client');
});
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