Add formatter for highlight words

pull/2236/head
Johann 9 years ago
parent d102b926f0
commit 792cf18b4b
  1. 1
      .meteor/packages
  2. 1
      .meteor/versions
  3. 25
      packages/rocketchat-highlight-words/client.coffee
  4. 22
      packages/rocketchat-highlight-words/package.js

@ -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

@ -0,0 +1,25 @@
###
# 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

@ -0,0 +1,22 @@
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');
});
Loading…
Cancel
Save